Hello all, I have been using OpenBLAS for the past month in the spectrum of my CS studies.
(Disclaimer: I'm not well acquainted with the world of BLAS and such)
I am trying to compare my implementation of the product of a tridiagonal matrix (stocked in General Band format) with a vector, with OpenBLAS's cblas_dgbmv.
The vector I build with the OpenBLAS implementation has bad values and I am trying to figure out what I am doing wrong.
Here are bits of the code I'm using (nothing really incredible) :
/* building the square tridiagonal vector, leaving some
* extra space in case it is needed (see LU factoring) */
double *getA(int n) {
double *A;
int i;
A = (double *)malloc(n*4*sizeof(double));
A[0] = 0;
for (i=1; i<n; i++) A[i] = -1; // upper
for (i=0; i<n; i++) A[n+i] = 2; // diag
for (i=0; i<n-1; i++) A[n+n+i] = -1; // lower
A[n+n+n-1] = 0; // end
for (i=0; i<n; i++) A[n+n+n+i] = 0; // extra ( I have tried without of course )
return A;
}
/* building a simple vector */
double *v = (double *)malloc(n*sizeof(double));
for (i=0; i<n; i++)
v[i] = i;
/* calculating the matrix-vector product with dgbmv (Y := alpha*A*X+beta*Y) */
double *w = (double *)malloc(n*sizeof(double));
cblas_dgbmv(CblasColMajor, CblasNoTrans,
n, n, /* size */
1, 1, /* kl, ku */
1., A, n, /* alpha, A, lda */
v, 1, /* X, incX */
0., w, 1 /* beta, Y, incY */
);
I invariably get results like
w = (1, 0, -1, -1, 9.63428e-322, 0)
though it should be something along the lines of
w = (-1, 0, 0, 0, 0, 6)
When looking through OpenBLAS sources I can't find %gb*.S implementation files like for %gemm*.S and such functions, so I really don't know how to go about finding out what I'm doing wrong.
Anyway if someone has some clue about what's going on, I'd love to hear about it :)
Thanks in advance,
-trosh