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

CSC to CSR Sparse Matrix Conversion Problem

h88433
Beginner
1,049 Views

Hello, I am having difficulty converting a column format matrix to row format using mkl_dcsrcsc(). I have checked the matrix many times over and can't find anything wrong with the definition of the data, still I get an incorrect result. Using data from the example C program, converters_c.c the answer I recieve is correct.

The data for converters_c.c, NNZ=8, N=4


double acsc[] = {5,9,8,2,3,1,6,4};
LONG aj[] = {0,1,0,1,2,3,2,3};
LONG ai[] = {0,2,4,6,8};

The data in my matrix, NNZ=13, N=5

double acsc[] = {1,-2,-4,-1,5,8,4,2,-3,6,7,4,-5};
LONG aj[] = {0,1,3,0,1,4,2,3,0,2,3,2,4};
LONG ai[] = {0,3,6,8,11,13};

where job = {1 0 0 2 NNZ 1}; in both cases, LONG = _int64, 0 based indexing.

Additionally, the 4'th element in job[] is (2), which is not explained in the manual as far as I can tell (it is described as 'locat' in the example program), and job[5]=1 is the values that fill all output arrays, not job[5]=0 as the manual states on page 450 of the mklman.

Just interested to see if anyone can help explain the problem, perhaps I have overlooked something.

Thanks, john

0 Kudos
6 Replies
Gennady_F_Intel
Moderator
1,049 Views
John,
- looking at these arrays, it's pretty difficult to say what's wrong with conversion.what was your results?
- It should be noted that there is the documentation issueregarding description of job(6) for themkl_dcsrcsc function.
Accordingly documentation

If job(6)=0, all output arrays acsr, ja, and ia are filled in for the output storage.

If job(6)0, only arrays ja, ia are filled in for the output storage.

but actually should be

For conversion to the CSR format:

If job(6)=0, only arrays ja, ia are filled in for the output storage.

If job(6) != 0, all output arrays acsr, ja, and ia are filled in for the output storage.

and the same for conversion to the CSC format.

--Gennady

0 Kudos
h88433
Beginner
1,049 Views
Hi Gennady,

Thanks again for the reply. The matrix I am testing actually came as a test matrix from the mkl documentation. I dont remember exacly where, I think it was in the Pardiso section. The matrix is unsymmetric,

n= 5, nnz = 13

1 -1 0 -3 0
-2 5 0 0 0
0 0 4 6 4
-4 0 2 7 0
0 8 0 0 -5


The control settings I used were,

job[0]=1
job[1]=job[2]=0
job[6]=1

The Column (CSC) format input is:

acsc[] = {1, -2, -4, -1, 5, 8, 4, 2, -3, 6, 7, 4, -5};
ja1[] = {0, 3, 6, 8, 11, 13};
ia1[] = {0, 1, 3, 0, 1, 4, 2, 3, 0, 2, 3, 2, 4};


The output from mkl_dcsrcsc() is,

ia:
0 3 4 8 11 12

ja:
0 1 3 1 0 2 3 4 0 2 3 4 0

acsr:
1 -1 -3 5 0 4 6 4 -4 2 7 -5 0,

and info is NOT equal to zero.

When I run my code, i get (1 based index output),

ia:
1 4 6 9 12 14

ja:
1 2 4 1 2 3 4 5 1 3 4 2 5

acsr:
1 -1 -3 -2 5 4 6 4 -4 2 7 8 -5

which is correct !

PS: I think I agree with Jennifer Scott at from the Rutherford-Appleton lab in England where in an article I read some time ago (i dont have a copy), she said that conversion from/to these formats "Is not a trivial task". I am never so arrogant as to assume I am always right, but this does not look correct. On a large matrix n~400,000, the conversion in my opinion happens much too fast.

If you have time, try the matrix yourself ! Perhaps you see something I dont.

john
0 Kudos
Gennady_F_Intel
Moderator
1,049 Views
john,
yea, it's require some time to investigate the probelm.
Please let me time - i will check the results and let you know the results.
--Gennady
0 Kudos
h88433
Beginner
1,049 Views
Hi Gennady, thanks very much for agreeing to look into the matter. For the time being I have a solution so there is no urgency on my part.
john
0 Kudos
Gennady_F_Intel
Moderator
1,049 Views
Hi john,

we 've checked it - this is the error.this issue has been submitted to our internal development tracking database for further investigation, we will inform you once a new update becomes available.

Here is a bug tracking number for your reference: DPD200092652.
Regards, Gennady

0 Kudos
h88433
Beginner
1,049 Views
Hi Gennady, thanks !
0 Kudos
Reply