This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: offset gsl_vectors and matrices
- From: Brian Gough <bjg at network-theory dot co dot uk>
- To: "J.Underwood" <J dot Underwood at open dot ac dot uk>
- Cc: "'gsl-discuss at sources dot redhat dot com'" <gsl-discuss at sources dot redhat dot com>
- Date: Wed, 9 Jul 2003 19:41:14 +0100
- Subject: Re: offset gsl_vectors and matrices
- References: <F08F052A3BC28440ADA76024D19A95940347FC73@atlantis.open.ac.uk>
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