help-gsl
[Top][All Lists]
Advanced

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

Re: [Help-gsl] Question about Vector Views


From: Srikant
Subject: Re: [Help-gsl] Question about Vector Views
Date: Wed, 23 Jun 2010 07:41:33 -0700 (PDT)

Hi,
Thanks for your reply. I am using the Visual Studio 2010 build of GSL 1.14 that 
was made available by Brian Gladman (See: 
http://gladman.plushost.co.uk/oldsite/computing/gnu_scientific_library.php). I 
checked that GSL 1.14 (in linux) itself is working as expected. So, I am 
guessing that either the build provided by Brian is broken or some setting in 
VS 2010 at my end is broken. 
I will get in touch with Brian to get this sorted out. Thanks for our help.
Srikant

--- On Wed, 6/23/10, Xuebin Wu <address@hidden> wrote:

From: Xuebin Wu <address@hidden>
Subject: Re: [Help-gsl] Question about Vector Views
To: "Srikant" <address@hidden>
Cc: address@hidden
Date: Wednesday, June 23, 2010, 1:56 AM

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









reply via email to

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