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: Stephan Petzchen
Subject: Re: [Help-gsl] Why is Negative Stride in GSL not allowed?
Date: Mon, 19 Nov 2012 11:06:00 +0100

Thanks for your answer.

I think my understanding of negative stride is as follows and probably
matching with yours:


BLAS Specification: http://www.netlib.org/blas/blast-forum/
Chapter 2.5.3: Dense and Banded BLAS

INCX != 0
i = 1,....N
for INCX >0: X(1 + (i-1) * INCX)
for INCX <0: X(1 + (n-i) * abs(INCX))

so for example:

X: {1.0  2.0  3.0  4.0  5.0  6.0  7.0  8.0  9.0  10.0}
n =  elements to be processed = 4
INCX = -2
i = 2

X(1 + (4-2) * abs(-2)) = X(6) = 6.0



But when I look up the ATLAS source for example for computing: the sum
\alpha + x^T y for the vectors x and y
the negative stride is not considered here. DO I oversee here something?


ATLAS source: ATL_dsdot.c

double ATL_dsdot(const int N, const float *X, const int incX,
                 const float *Y, const int incY)
{
   int i;
   double dot = 0.0;
   for (i=N; i; i--, X += incX, Y += incY) dot += (double)(*X) * (double)
(*Y);
   return(dot);
}


best stephan


On Mon, Nov 19, 2012 at 10:51 AM, Michael Lehn <address@hidden>wrote:

> >
> > 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)
>
> So maybe you stumbled over the same misunderstanding I once had?
>
>
> Cheers,
>
> Michael
>
>
> >
> > Beside this, the BLAS spec. allows for negative stride.
> >
> >
> > Thanks in advance.
> >
> > best,
> > Stephan Petzchen
> >
> >
>
>
>
>


-- 

Gesius GmbH
Beim Strohhause 31
20097 Hamburg, Germany
Tel.    +49 (40) 6094673-10
Mobil +49 (172) 1977014
Fax   +49 (40) 6094673-99
email: address@hidden <address@hidden>
www.gesius.de <http://gesius.de>

gesius. engineering excellence

Sitz der Gesellschaft/Registered office: Hamburg

Handelsregister/Commercial register:  HRB 117558

Geschäftsführung/executive board: Stephan Petzchen

---
This communication contains confidential information. If you are not the
intended recipient please return this email to the sender and delete it
from your records.
Diese Nachricht enthält vertrauliche Informationen. Sollten Sie nicht der
beabsichtigte Empfänger dieser E-mail sein, senden Sie bitte diese an den
Absender zurück und löschen Sie die E-mail aus Ihrem System.


reply via email to

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