[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] Question about Vector Views
From: |
Xuebin Wu |
Subject: |
Re: [Help-gsl] Question about Vector Views |
Date: |
Wed, 23 Jun 2010 01:56:11 -0400 |
Hi,
I have to say your understanding is correct and your code don't have
problem..
Here is my output:
0
1
2
gsl: ../vector/vector_source.c:29: ERROR: index out of range
Default GSL error handler invoked.
Is this your whole code?
Problem maybe somewhere else.
On Wed, Jun 23, 2010 at 12:59 AM, Srikant <address@hidden> wrote:
> Hi,
>
> Consider the following code:
>
> size_t rows = 10;
>
> gsl_vector *v = gsl_vector_calloc(10);
> for(size_t row=0;row<rows;row++)
> {
> gsl_vector_set(v,row,row);
> }
>
> gsl_vector_view v_test = gsl_vector_subvector(v,0,3);
>
> std::cout << gsl_vector_get(&v_test.vector,0) << std::endl;
> std::cout << gsl_vector_get(&v_test.vector,1) << std::endl;
> std::cout << gsl_vector_get(&v_test.vector,2) << std::endl;
> std::cout << gsl_vector_get(&v_test.vector,3) << std::endl;
>
> I was under the impression until now that GSL performs range checking on
> vector views as well and hence the last line should be an error. But, my
> test program suggests otherwise. The output of the above code is:
>
> 0
> 1
> 2
> 3
>
> whereas I was expecting it to be
>
> 0
> 1
> 2
>
> Is this a bug or is vector view expecting as it is supposed to?
>
> Thanks,
> Srikant
>
>
>
>
> _______________________________________________
> Help-gsl mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-gsl
>