help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] why is gsl_vector_const_view const?


From: Brian Austin
Subject: Re: [Help-gsl] why is gsl_vector_const_view const?
Date: Mon, 3 Jul 2006 12:45:08 -0700 (PDT)

Wow, I wouldn't have guessed that it was possible to declare inside a loop like that. It works though. Thanks a lot.
-Brian

On Mon, 3 Jul 2006, Brian Gough wrote:

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/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]