Re: [Help-gsl] Vector and matrix views

2005-12-08 Thread Dimitris Papavasiliou
Brian Gough wrote: You need -ansi -pedantic there, otherwise the GNU extensions aren't completely disabled -- non-constant initialisers aren't part of C89. See http://www.network-theory.co.uk/docs/gccintro/gccintro_27.html and http://www.network-theory.co.uk/docs/gccintro/gccintro_28.html for d

Re: [Help-gsl] Vector and matrix views

2005-12-08 Thread Brian Gough
Dimitris Papavasiliou writes: > I've included the -ansi switch to gcc to make sure it won't > work just because of some GNU extension. You need -ansi -pedantic there, otherwise the GNU extensions aren't completely disabled -- non-constant initialisers aren't part of C89. See http://www.networ

Re: [Help-gsl] Vector and matrix views

2005-12-08 Thread Dimitris Papavasiliou
Brian Gough wrote: In C a const object has to be initialised in a single step (because you can't modify it afterwards). And initialisers can only contain constants, not expressions. So to create a const object whose members depend on other variables you have to go through an indirection -- cre

Re: [Help-gsl] Vector and matrix views

2005-12-08 Thread Brian Gough
James Bergstra writes: > The same trick works for matrix types. Matrices have two sizes instead of > one, > and the 'stride' between columns on the same row is always assumed to be 1, > but > other than that, the things are analogous. For some reason, a matrix stride > (from row to row) i

Re: [Help-gsl] Vector and matrix views

2005-12-08 Thread Brian Gough
Dimitris Papavasiliou writes: > Would something like this work > > + > gsl_vector v; /* a struct, not a pointer */ > > v = gsl_vector_view_from_array(array, n).vector; > + > > I know this looks ugly too but hidden behind a macro it would be ok. > Would this work correctly?

Re: [Help-gsl] Vector and matrix views

2005-12-07 Thread James Bergstra
Hi Dimitris, I agree with you completely that there should be a better way. In the meantime, remember that C has no private and public members :) A gsl_vector struct has three important fields: v.data( pointer to data[0] ) v.stride ( gsl_vector_at(v,i) refers to v.data[i * v.stride]

[Help-gsl] Vector and matrix views

2005-12-07 Thread Dimitris Papavasiliou
Hi all, I need to quickly and efficiently create a gsl vector/matrix from a C array but doing something like + gsl_vector_view v_view; gsl_vector *v; v_view = gsl_vector_view_from_array(array, n); v = &v_view.vector; + tends to get tedious and bloat functions where many vectors are