Showing results for

- Intel Community
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library & Intel® Math Kernel Library
- access to sub-matrices in CSR format

- 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
##

SupposeYis saved in sparse CSR formatby defining its values, columns and rowIndex vectors. Is that possible have access to its sub-matrices?

Vahid_Jalili

Beginner

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

04-12-2011
05:56 AM

34 Views

access to sub-matrices in CSR format

Hello all,

For example:

| 1 -1 0 -3 0 |

| -1 5 0 0 0 |

Y = | 0 0 4 6 4 |

| -3 0 6 7 0 |

| 0 0 4 0 -5 |

values[13] = {1.0, -1.0, -3.0, -1.0, 5.0, 4.0, 6.0, 4.0, -3.0, 6.0, 7.0, 4.0, -5.0};

columns[13] = {0, 1, 3, 0, 1, 2, 3, 4, 0, 2, 3, 2, 4};

rowIndex[6] = {0, 3, 5, 8, 11, 13};

Can I have access to sub-matrices of Y , e.g. [-3 0 // 0 0 // 6 4] or [0 0 4 // -3 0 6// 0 0 4] ?

Thanks for your help,

4 Replies

Highlighted
##

Hi there,

You could write code to unpack and access it I suppose, but if you're asking whether there is an easyway to access it or have MKL functions act upon it (as there is in LAPACK by specifying the first element and an appropriate leading dimension parameter as the stride) then I believe the answer is no.

Todd

Todd_R_Intel

Employee

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

04-12-2011
10:06 PM

34 Views

You could write code to unpack and access it I suppose, but if you're asking whether there is an easyway to access it or have MKL functions act upon it (as there is in LAPACK by specifying the first element and an appropriate leading dimension parameter as the stride) then I believe the answer is no.

Todd

Highlighted
##

The Intel MKL supports twovariations of thecompressed sparse row (CSR) format. The first variation proposed in the NISTSparse BLAS is specified by four arrays: the `values`, `columns`, `pointerB`, and `pointerE`. And the second variation is specified by three arrays:values, columns and rowIndex as you described above.Some MKLSparse BLAS routines can only works with the three arraysvarition of the CSR, all other routines can work with the both variations.

Compared to the classical three arrays variation of CSR mentioned by you, the NIST variation with four arraysallows working with submatrices. You just need to define`pointerB` and `pointerE arraysproperly`. You don't need to form additional the values and columns arrays since all sparse representations of submatrices can use only one copy of these arrays.

Hope it helps

All the best

Sergey

Sergey_K_Intel1

Employee

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

04-13-2011
03:51 AM

34 Views

Compared to the classical three arrays variation of CSR mentioned by you, the NIST variation with four arraysallows working with submatrices. You just need to define

Hope it helps

All the best

Sergey

Highlighted
##

But, still I cannot set these pointers correctly to extract submatrices, e.g. [0 0 4 // -3 0 6// 0 0 4] ?

Vahid_Jalili

Beginner

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

04-13-2011
06:50 AM

34 Views

Hello Sergey,

Thanks for your reply,

I am aware of pointerB and poiterE vectors used for CSR format:

For matrix Y they are as following:

pointerB* = {0, 3, 5, 8, 11};*

pointerE* = {3, 5, 8, 11, 13};*

I want to use these submatix in**mkl_scsrmv**

mkl_ccsrmv(&transa, &m, &k, α, matdescra, values, columns, pointerB, pointerE, sol_vec, β, rhs_vec);

If m and k should be dimensions of the original matrix (i.e. 5x5) or they should be dimensions of the submatrix (e.g 3x3)?

Thanks for your help.

--Vahid

Highlighted
##

Sergey_K_Intel1

Employee

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

04-14-2011
12:33 AM

34 Views

Your submatrix can be defined as follows:

int pointerB[3]={2, 3, 5} , pointerE[3]={3,3,8};

Here is a code example where submatrix is multiplied by vector {3,4, 5) with the help of mkl_dcsrmv

int main() {

//*******************************************************************************

// Declaration and initialization of parameters for sparse representation of

// the matrix A in the compressed sparse row format:

//*******************************************************************************

#define M 5

#define NNZ 13

#define MN

double values[NNZ] = {1.0, -1.0, -3.0, -1.0, 5.0, 4.0, 6.0, 4.0, -3.0, 6.0, 7.0, 4.0, -5.0};

int columns[NNZ] = {0, 1, 3, 0, 1, 2, 3, 4, 0, 2, 3, 2, 4};

int rowIndex[M+1] = {0, 3, 5, 8, 11, 13};

double sol_vec

double rhs_vec

double alpha=1.0, beta=0.0;

int pointerB[3]={2, 3, 5} , pointerE[3]={3,3,8};

char transa;

char matdescra[6];

int i, ishift, mn=3;

transa = 'n';

matdescra[0] = 'g';

matdescra[3] = 'c';

ishift=pointerB[0];

mkl_dcsrmv(&transa, &mn, &mn, α, matdescra,&values[ishift], &columns[ishift], pointerB, pointerE, sol_vec, β, rhs_vec);

for (i = 0; i < mn; i++) {

printf("%7.1f\n", rhs_vec*); };}As concerns as m and k, I'd recommend to use dimensions of the submatrix. All the bestSergey*

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