- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I am quite a newbie in using the Sparse BLAS and I am trying to convert a sparse matrix in csr in to the csc format. The dns 2 csr conversion works. This is my code for the conversion:
A:
+0.8401877 +0.3943829 +0.0000000 +0.0000000
+0.7830992 +0.7984400 +0.0000000 +0.0000000
+0.0000000 +0.0000000 +0.0000000 +0.0000000
+0.0000000 +0.0000000 +0.0000000 +0.0000000
Acsr :
+0.8401877 +0.3943829 +0.7830992 +0.7984400
columns :
0 1 0 1
rowIndex
0 2 4 4 4
Acsc:
+0.0000000 +0.0000000 +0.0000000 +0.0000000
rows:
0 1 0 1
rowIndex:
0 2 4 2 2
regards,
Cem
I am quite a newbie in using the Sparse BLAS and I am trying to convert a sparse matrix in csr in to the csc format. The dns 2 csr conversion works. This is my code for the conversion:
[cpp]This is the output of the conversion operations:
double* A = (double*) malloc( sizeof(double) * m * n );
// A is filled with data. see below ...
double* Acsr = (double*) malloc( sizeof(double) * m_s * n_s );
double* Acsc = (double*) malloc( sizeof(double) * m_s * n_s );
int* columns_csr = (int*) malloc( sizeof(int) * m_s * n_s);
int* rowIndex_csr = (int*) malloc( sizeof(int) * m + 1 );
int* rows_csc = (int*) malloc( sizeof(int) * m_s * n_s);
int* rowIndex_csc = (int*) malloc( sizeof(int) * m + 1 );
int job_csr[6] = {0, 0, 0, 2, m_s * n_s, 3};
mkl_ddnscsr( job_csr, &m, &n, A, &m, Acsr, columns_csr, rowIndex_csr, &info );
int job_csc[6] = {0, 0, 0, 0, 0, 0};
mkl_dcsrcsc(job_csc, &m,Acsr, columns_csr, rowIndex_csr, Acsc, rows_csc, rowIndex_csc, &info);
[/cpp]
A:
+0.8401877 +0.3943829 +0.0000000 +0.0000000
+0.7830992 +0.7984400 +0.0000000 +0.0000000
+0.0000000 +0.0000000 +0.0000000 +0.0000000
+0.0000000 +0.0000000 +0.0000000 +0.0000000
Acsr :
+0.8401877 +0.3943829 +0.7830992 +0.7984400
columns :
0 1 0 1
rowIndex
0 2 4 4 4
Acsc:
+0.0000000 +0.0000000 +0.0000000 +0.0000000
rows:
0 1 0 1
rowIndex:
0 2 4 2 2
regards,
Cem
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Cem,
please try to use
int job_csc[6] = {0,0,0,0,0, 1 };
According to the description of mkl_dcsrcsc
For conversion to the CSC format:
If job(6)=0, all output arrays acsc, ja1, and ia1 are filled in for the output storage.
If job(6)0, only arrays ja1, ia1 are filled in for the output storage.
--Gennady
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - Gennady Fedorov (Intel)
Hi Cem,
please try to use
int job_csc[6] = {0,0,0,0,0, 1 };
According to the description of mkl_dcsrcsc
For conversion to the CSC format:
If job(6)=0, all output arrays acsc, ja1, and ia1 are filled in for the output storage.
If job(6)0, only arrays ja1, ia1 are filled in for the output storage.
--Gennady
Okay that works,
But having the matrix A :
0 2 0 4
0 6 0 8
0 10 0 12
0 14 0 16
0 18 0 20
m = 5;
n = 4;
k = 10
but still I have problems with the conversion: If
[cpp]int job_csr[6] = {0, 0, 0, 2, k, 3};
mkl_ddnscsr( job_csr, &m, &n, A, &m, Acsr, columns_csr, rowIndex_csr, &info );
int job_csc[6] = {0, 0, 0, 0, 0, 1};
mkl_dcsrcsc(job_csc, &m, Acsr, columns_csr, rowIndex_csr, Acsc, rows_csc, rowIndex_csc, &info);[/cpp]
then the output is :
Acsr :
2 4 6 8 12 14 16 18 0 1
columns:
1 3 0 2 1 3 0 2 0 1
rowIndex:
0 2 4 6 8 0
Acsc:
6 16 2 12 8 18 4 14 0 0
colums:
1 3 0 2 1 3 0 2 0 0
rowIndex:
0 2 4 6 8 6
Something is wrong cause the last element of rowIndex is 0, yet it must be the number of elements + 1 according to the documentation. Also, some elements in Acsr and Acsc are 0 which does not make sense.
If change the order of m and n:
[cpp]mkl_ddnscsr( job_csr, &n, &m, A, &m, Acsr, columns_csr, rowIndex_csr, &info );[/cpp]
I get the following output:
Acsr:
2 4 6 8 10 12 14 16 18 20
Columns :
1 3 0 2 4 1 3 0 2 4
Indexrows:
0 2 5 7 10 0
Acsc:
6 16 2 12 8 18 4 14 10 20
Rows:
1 3 0 2 1 3 0 2 1 3
Indexrows:
0 2 4 6 8 10
This output seems to be more promising, however I doubt the correctness of this solution as I had to change the property of the matrix (m,n) in order to get this output and still indexrows of acsr is not correct.
What did I do wrong ?
Cem
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page