Unexpected result with cblas_dgemv

时光毁灭记忆、已成空白 提交于 2019-12-01 18:42:32

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);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!