[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [Help-gsl] Question about Vector Views

**From**: |
Srikant |

**Subject**: |
[Help-gsl] Question about Vector Views |

**Date**: |
Tue, 22 Jun 2010 21:59:28 -0700 (PDT) |

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] Question about Vector Views**,
*Srikant* **<=**