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
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gsl

Reply via email to