Showing results for

- Intel Community
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
- mkl_?csrmultcsr and symmetric matrices

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Highlighted
##

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.

laniik

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-28-2011
01:15 AM

10 Views

mkl_?csrmultcsr and symmetric matrices

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

3 Replies

Highlighted
##

Hi Oliver,

Konstantin_A_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-28-2011
02:02 AM

10 Views

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

Highlighted
##

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(n^{3}) for sparse matrix product, however it will depend of number of non-zeros.

D.

Danesh_Daroui

Beginner

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-28-2011
09:48 AM

10 Views

D.

Highlighted
##

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).

Konstantin_A_Intel

Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-09-2011
09:50 PM

10 Views

Regards,

Konstantin

For more complete information about compiler optimizations, see our Optimization Notice.