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


> I was thinking of adding two routines to GSL, to increment a single element
> of a matrix or vector by some amount, since I'm always doing things like:
>
> gsl_vector_set(v, i, gsl_vector_get(v, i) + x);
>
> which I think is ugly and annoying....

Agreed.  This has often bugged me.

> Or also is there another solution to this problem that I don't know about?

How about using

INLINE_DECL double * gsl_vector_ptr (gsl_vector * v, const size_t i);

to say *gsl_vector_ptr(v, i) += x ?  Never knew about this until I
just went fishing for it.

- Rhys


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