I have a question regarding cblas_dgemv. I am trying to understand how it works. And what I am possibly doing wrong. I have an array Matrix and then I try to read that matri
The issue is on the lda
. From the reference we get that
lda: The size of the first dimension of matrix A
The CblasRowMajor
and CblasColMajor
describe the memory storage sequence of a two dimensional matrix.
The CblasRowMajor
storage of a matrix A(nrow,ncol)
means that first are stored the ncol
values of the first row of matrix A
, then the ncol
values of second row of A
and so on.
The CblasColMajor
storage of a matrix A(nrow,ncol)
means that first are stored the nrow
values of the first column of matrix A
, then the nrow
values of second column of A
and so on.
So in CblasRowMajor
storage the LDA (first dimension of matrix A) is the ncol
while in CblasColMajor
the nrow
.
In your example you just have to change lda
of the second cblas_dgemv
cblas_dgemv(CblasColMajor, CblasNoTrans, Nrows, NCols, alpha, A, Nrows, x, 1, beta, y, 1);