Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6998 Discussions

## mkl_ddnscsr problem

Beginner
372 Views
```[cpp]#include
#include
using namespace std;

void 	mkl_ddnscsr_test() {
const size_t nNon0s =  6 ;
MKL_INT job[8] ;
job[0] = 0;			// ge->csr
job[1] = 0;			// ge is 0-based
job[2] = 1;			// csr is 1-based
job[3] = 2;			// general matrix
job[4] = nNon0s;	// general matrix
job[5] = 1;			// all csr arrays are generated

MKL_INT info;
MKL_INT nRows = 5 ;
MKL_INT nCols = 5 ;
MKL_INT lda	  = 5;

double values[ nNon0s  ] ;
MKL_INT columns[ nNon0s ] ;
MKL_INT rowIndex[ 5 + 1 ] ;

double pdata[25];
for ( size_t i = 0; i != 25 ; ++i )
pdata = 0L;
for ( size_t i = 0; i != nRows ; ++i )
pdata[i + 5*i] = double(i+1);
pdata[ 2 + 5*3 ] = 3.14L;
mkl_ddnscsr(
job,
&nRows, &nCols,
pdata, &lda,
values,
columns,
rowIndex,
&info );
if ( info != 0 )
throw;
cout << "values :" << endl;
for ( size_t i = 0; i !=nNon0s; ++i )
cout << values << endl;
cout << "rowIdx :" << endl;
for ( size_t i = 0; i != ( nRows + 1 ); ++i )
cout << rowIndex << endl;
cout << "columns :" << endl;
for ( size_t i = 0; i !=nNon0s; ++i )
cout << columns << endl;

}

int main(){
cout << "mkl_ddnscsr_test()" << endl;
mkl_ddnscsr_test();
return 1;
}[/cpp]```
Hi,
The follwing code shows a problem with the above function to convert between a (column-major) general matrix and a csr (3 variation).
It is a 5x5 matrix, with all diagonal elements being the corresponding incremental (1-based) row and the element
(2,3) being 3.14.
The result I get is for the rowIndex vector seems wrong since:
it should be:
1
2
3
5
6
7
and is, instead :
1
2
3
4
6
7

i.e. 4 shoulld be 5, snce the 5th element in values corresponds to the beginning of the 4th row.
TIA
Petros
ps: using msvc10, win7, mkl10.2.4.032

UPDATE: by setting job[1]=1 I get the right order. Apparently mkl assumes that the dense matrix is 1-based ??
This is rather confusing !
2 Replies
Moderator
372 Views
Petros, please check this problem with the latest 10.3 update8 (Evaluation Version valid for 30 days). Since version 10.2 we have fixed several similar issues.