offset gsl_vectors and matrices
Brian Gough
bjg@network-theory.co.uk
Wed Jul 9 18:41:00 GMT 2003
J.Underwood writes:
> I'm fairly new to GSL, but have been pondering the best way to have offset
> vectors (and matrices) i.e. vectors (and matrices) whose index doesn't run
> from 0..n-1. This of course is trivial using standard C arrays, one simply
> offsets a pointer. However offsetting the data pointer within a gsl_vector
> is not a good plan, since then the functions which check for an index being
> in range (eg. gsl_vector_set etc) will be scuppered. One option would be to
> extend the definition of the gsl_vector to include an "offset" variable.
> Another is to define ones own pointer to the gsl_vector data pointer and
> offset that, but that negates using the gsl functions, and also means one
> needs to either use the stride from that vector or make (hairy) assumptions
> about how the vector is located in memory. This becomes very hairy with
> matrices. Any ideas/comments/pointers/suggestions welcome.
We have standardised on 0-based indices. It is the natural way in C,
and removes any need to consider offsets.
On the client side there is always the possibility of defining a macro.
--
Brian
More information about the Gsl-discuss
mailing list