Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
10 Views

mkl_?csrmultcsr and symmetric matrices

Hi, I am using mkl_dcsrmultcsr to compute an A'A matrix product. (A is nonsymmetric). This matrix is then fed into the direct sparse solver (DSS) routines.
Of course, I know that A'A will produce a sparse symmetric matrix, but I cannot find any way to convert the output of this function into a symmetric CSR format, rather than a non-symmetric CSR format.
Is there a way to do this conversion without manually going in and removing entries from the values,cols,rowIndex arrays?
I think callingdss_define_structure withMKL_DSS_NON_SYMMETRIC option should speed things up due to memory re-use.
Thanks!
Oliver
0 Kudos
3 Replies
Highlighted
10 Views

Hi Oliver,
Of course, you can solve your matrix as unsymmetrical, but it would be definitelyslower to factorize it in comparison with the code for symmetrical matrices. Anyway, this way is simple and should work for you.
As for me, I don't know any routines that can help you (I mean special unsym->sym converters etc.). The only way here is to manually convert arrays - however, it doesn't seem hard, something like this:
ja_cnt=0;
ia_new[0]=1;
for(i=1;i
ia_cnt=0;
for(j=ia[i-1];j<ia;j++) {
if (ja[j-1]>=i) {
ja_new[ja_cnt]=ja[j-1];
a_new[ja_cnt]=a[j-1];
ja_cnt++;
ia_cnt++;
}
}
ia_new=ia_new[i-1]+ia_cnt;
}
Moreover, you can just overwrite old ja and a arrays, not allocating ja_new and a_new.
Regards,
Konstantin
0 Kudos
Highlighted
Beginner
10 Views

This can be a silly solution, but for special cases like your case, maybe and maybe it would be worth to write your own function since you will need to allocate memory for the whole matrix and then convert it to the symmetric form. Thus some unnecessary memory has been allocated. The elements in CSR format are sorted in the row index array so accessing each element can be quite fast. As far as I know, if you implement an efficient code the time complexity will be much smaller than O(n3) for sparse matrix product, however it will depend of number of non-zeros.

D.
0 Kudos
Highlighted
10 Views

I believe unsym->sym conversion like this will be negligible if Oliver wants to factorize the matrix further with use of DSS/PARDISO - I mean time consumption. And additional memory consuption can be easily avoided by overwriting existing JA/A of unsymmtrical matrix by symmetical one (as I've already mentioned above).
Regards,
Konstantin
0 Kudos