Hi. Can anyone provide me with a minimum working example for mkl_ddnscsr? I have tried this so far
#include <stdio.h> #include <stdlib.h> #include <mkl.h> int main(int argc, char *argv[]) { MKL_INT info; MKL_INT m = 3; //Number of rows of A MKL_INT n = 4; //Number of columns of A MKL_INT nnz = 6; //Number of non zero elements MKL_INT job[6] = {0,0,1,2,nnz,1}; double *Acsr = (double *) calloc(nnz, sizeof(double) ); MKL_INT *Aj = (MKL_INT *) calloc(nnz, sizeof(MKL_INT) ); MKL_INT *Ai = (MKL_INT *) calloc(m+1, sizeof(MKL_INT) ); double A[3][4] = {{1.,3.,0.,0.},{0.,0.,4.,0.},{2.,5.,0.,6.}}; mkl_ddnscsr ( job, &m, &n, A[0], &m, Acsr, Aj, Ai, &info); for (int i=0; i< nnz; i++) { if (Acsr[i] != 0) { printf( "column = %i, A = %fn", Aj[i], Acsr[i] ); } } for (int i=0; i< m+1; i++) { printf("Ai[%i] = %in", i, Ai[i]); } return 0; }
But it returns these results
column = 1, A = 1.000000 column = 2, A = 3.000000 column = 4, A = 4.000000 column = 1, A = 4.000000 column = 3, A = 2.000000 column = 4, A = 5.000000 Ai[0] = 1 Ai[1] = 3 Ai[2] = 4 Ai[3] = 7
If I play with the value for the lda I can almost get the correct result, however I believe this is as the manual suggests. I am on using Ubuntu 12.04 and Composer 2013.3.163 if that makes difference.
Thanks
Chris