sparse matrix dense matrix multiplication question

sparse matrix dense matrix multiplication question

Dear all,

I am trying to do a sparse matrix - dense matrix multiplication operation, however the below code does not give me what I want,
I use the sparse matrix that is used in the intel manual and examples and a dense matrix of
1 5
1 4
1 3
1 2
1 1
I guess my representation is correct in the code, however there is still sth wrong since I can not find the right answer. Could you please help me?

Best regards,
Umut

My code

#include

#include "mkl_types.h"
#include "mkl_spblas.h"

int main()
{
MKL_INT M = 5;
double values[] = {1.0, -1.0, -3.0, -2.0, 5.0, 4.0, 6.0, 4.0, -4.0, 2.0, 7.0, 8.0, -5.0};
MKL_INT columns[] = {0, 1, 3, 0, 1, 2, 3, 4, 0, 2, 3, 1, 4};
MKL_INT rowIndex[] = {0, 3, 5, 8, 11, 13};
MKL_INT pntrb[] = {0, 3, 5, 8, 11};
MKL_INT pntre[] = {3, 5, 8, 11, 13;
MKL_INT N = 2;
double b[] = {1.0, 5.0, 1.0, 4.0, 1.0, 3.0, 1.0, 2.0, 1.0,1.0};
double c[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,0.0};
char transa = 'N';
double alpha = 1.0;
double beta = 0.0;
char matdescra[6] = {'G','U','N','C',' ',' '};
mkl_dcsrmm(&transa, &M, &N, &M, &alpha, matdescra, values, columns, pntrb, pntre, b, &N, &beta, c, &N);
// can not get the right result however.
for (int j = 0; j < M*N; j++) {
std::cout << c[j] << std::endl;
}
return 0;
}

1 条帖子 / 0 全新
如需更全面地了解编译器优化,请参阅优化注意事项