- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi. Can anyone provide me with a minimum working example for mkl_ddnscsr? I have tried this so far
[cpp]#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 != 0) {
printf( "column = %i, A = %f\n", Aj, Acsr );
}
}
for (int i=0; i< m+1; i++) {
printf("Ai[%i] = %i\n", i, Ai);
}
return 0;
}[/cpp]
But it returns these results
[bash]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
[/bash]
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You have obtained the CSR representation of AT rather than of A. The reason is that your array A, being a native 2-D array in C, is arranged in row-major order. The library routine expects column-major order, which is the order used for 2-D arrays in Fortran.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
also you can have a look at the mkl_ddnscsr example from the mkl's package: "mkl_install_dir\examples\spblasc\source\ dconverters.c"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey great. Thanks a lot guys. I have it working now. Both suggestions were very helpful. Now I can try to so some science. Thank you very much :-)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page