At Thu, 29 Jun 2006 15:56:03 -0700 (PDT), Brian Austin wrote: > I would really like to loop over vector views of a const gsl_matrix. > Something like this: > > void foo( const gsl_matrix *A ){ > gsl_vector_const_view a; > for( i=0; i<A->size1; i++ ){ > a = gsl_matrix_const_row( A, i ); > //some operations that read elements of a.vector > } > }//end foo > > The compiler seems to dislike this because a is const. I don't want a to > be const, just the data that a points to. Can anyone suggest a way to do > this?
Hello, In C it is only possible to assign to const objects when they are initialised. Try moving the view inside the loop like this, void foo( const gsl_matrix *A ){ for( i=0; i<A->size1; i++ ){ gsl_vector_const_view a = gsl_matrix_const_row( A, i ); //some operations that read elements of a.vector } }//end foo -- best regards, Brian Gough Network Theory Ltd, Publishing the GSL Manual - http://www.network-theory.co.uk/gsl/manual/ _______________________________________________ Help-gsl mailing list Help-gsl@gnu.org http://lists.gnu.org/mailman/listinfo/help-gsl