help-gsl
[Top][All Lists]
Advanced

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

Re: [Help-gsl] Why is Negative Stride in GSL not allowed?


From: Michael Lehn
Subject: Re: [Help-gsl] Why is Negative Stride in GSL not allowed?
Date: Mon, 19 Nov 2012 11:09:56 +0100

Am 19.11.2012 um 10:51 schrieb Michael Lehn <address@hidden>:

>> 
>> I am working on testcases for the GSL BLAS and CBLAS functionality and my
>> testdata also includes negative stride for vectors.
>> 
>> Is there a specific reason why the GSL implementation does not allow
>> negative stride (ATLAS also does not consider this, MKL does)?
> 
> ATLAS also allows negative strides.  Otherwise it would not pass the BLAS
> test suite.
> 
> When I countered negative strides in BLAS I was confused by its meaning: In
> my expectation having a vector of length n, data pointer X and a stride
> of -1 then it would have references elements
> 
> *X, *(X-1), *(X-2), ..., *(X-n+1)
> 
> However, in BLAS a negative stride just means that one has to traverse the 
> elements
> in reverse order, i.e.
> 
> *(X+n-1), *(X+n-2), ..., *(X+1), *X
> 
> But the elements that are actually referenced are the same you would have for
> stride 1=abs(-1), i.e.
> 
> *X, *(X+1), *(X+2), ..., *(X+n-1)

Long story short: if you have a vector with stride incX then the i-th element 
is always stored in

*(X + abs(incX)*i)


reply via email to

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