This is the mail archive of the gsl-discuss@sourceware.org mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: increment a single element of matrix/vector


The functions gsl_vector_inc and gsl_matrix_inc are now in the git repository to accomplish this

On 01/27/2014 08:06 PM, Patrick Alken wrote:
On 01/27/2014 07:14 PM, Rhys Ulerich wrote:
*gsl_vector_ptr(v, i) += x
Of course, make sure warnings about expressions without side effects
are turned on.  Otherwise it may be a long debugging session before
you discover a

     gsl_vector_ptr(v, i) += x

mistake for integer-like types.

- Rhys

Nice find - unfortunately since it returns a pointer to the element, you
need to do:

*(gsl_vector_ptr(v, i)) += x;

This could lead to trouble so its probably better to have a function
which does range checking, etc. I'll think a little more on a good way
to do this.

Thanks,
Patrick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]