Unexpected result with cblas_dgemv

前端 未结 1 1250
鱼传尺愫
鱼传尺愫 2021-01-13 16:40

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

相关标签:
1条回答
  • 2021-01-13 17:25

    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);
    
    0 讨论(0)
提交回复
热议问题