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]

Re: gsl_vector_subvector


Thanks. I will correct that to v->offset.

The GSL convention is to return pointers for objects allocated on the
heap (in the style of malloc/free). The functions which return an
object on the stack are intended for temporary views. This allows a
stylistic distinction to be made within a function between views
defined in the local scope and vectors passed as arguments (pointers).

E. Robert Tisdale writes:
 > There is a documentation error for
 >
 >     gsl_vector gsl_vector_subvector(gsl_vector* v,
 >       size_t i, size_t n);
 >  It says
 >
 >     v'(i) = v-->data[(offset + i)*v->stride]


 > It seems strange that the GSL would define a function
 >
 >     gsl_vector gsl_vector_subvector(gsl_vector* v,
 >       size_t i, size_t n);
 >  which returns a gsl_vector object for subvectors and a function
 >
 >     gsl_vector* gsl_vector_alloc(size_t n);
 >  which returns a pointer to a gsl_vector for vectors.  Does anybody
 > know why?
 >  If gsl_vector_subvector returned a pointer to a gsl_vector object,
 > it might be practical to implement reference counting.
 >
 >

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