I am trying to convert a dense matrix to sparse using the cusparseSdense2csr API, the dense matrix is as follows :
[ 0 1 0 3 0
0 6 0 8 0
0 11 0 13 0
0 16 0 18 0 ]
The expected resultant sparse matrix should be :
csrValA = {1,3,6,8,11,13,16,18}
csrRowPtrA = {0,2,4,6,8}
csrColIndA = {1,3,1,3,1,3,1,3}
But the output I get is
csrValA = {8,16,1,13,6,18,3,11}
csrRowPtrA = {0,2,4,6,8}
csrColIndA = {2,4,0,3,1,4,0,2}
Why is this happening ? whats the reason behind ?