This is the mail archive of the gsl-discuss@sources.redhat.com 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: offset gsl_vectors and matrices


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


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