mardi 8 janvier 2019

matrix vector product with banded matrix using cblas

I want to implement the following matrix-vector-product:

float B[]=  {5,1,2,0,0,0,
             4,4,1,3,0,0,
             0,5,3,2,2,0,
             0,0,1,1,1,2,
             0,0,0,1,2,2,
             0,0,0,0,1,1}; //column major

float v[]={1,2,1,1,2,1};
float w[6]={0};

int m=6; int n=6; int ku=1; kl=2; 
int ldb = 6;
cblas_sgbmv(CblasColMajor, CblasNoTrans, m, n, kl, ku, 1.0, B, ldb,v,1, 1.0,w, 1);

enter image description here

  • In the matrix B, I have one sup-diagonal and two supdiagonals
  • I saved the matrix B in CblasColMajor

My code does not give the result I want. I think I choose the wrong leading dimension. But how do I have to set it in the case of a banded matrix? I thought the leading dimension is relating to the original stored matrix.

Aucun commentaire:

Enregistrer un commentaire