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 Gough
Subject: Re: [Help-gsl] why is gsl_vector_const_view const?
Date: Mon, 03 Jul 2006 11:13:21 +0100
User-agent: Wanderlust/2.14.0 (Africa) Emacs/21.3 Mule/5.0 (SAKAKI)

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]