Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Intel Community
- Software
- Software Development SDKs and Libraries
- Intel® oneAPI Math Kernel Library
- Problem creating sparse matrix handle coordinate 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

marcsolal

Beginner

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

01-10-2017
02:29 PM

64 Views

Problem creating sparse matrix handle coordinate format

I have a problem creating a sparse matrix handle in coordinate format. I have a problem to make this function work in my code. I made a very simple example. I define a 10x10 identity matrix. My rows and column index array are defined by rows*=cols =i+1; i=0 to 9. I get a return code for the function SPARSE_STATUS_NOT_INITIALIZED which means the handle is empty or the arrays are empty. The handle is empty because I am trying to create it and the arrays are not. I tried zero base and one base and double and complex value matrices. The results are the same*

Am I missing something or is this a bug?

#include <iostream> using namespace std; #include "mkl.h" int main() { MKL_INT nRows=10; MKL_INT* rows=new MKL_INT[nRows]; MKL_INT* cols=new MKL_INT [nRows]; // MKL_Complex16* permutData=new MKL_Complex16[nRows]; double *permutData=new double[nRows]; for (int i=0;i<nRows;i++){ rows=i+1; cols=i+1; permutData=1.0; //permutData.real=1.0; //permutData.imag=0.0; } sparse_matrix_t *MATRIX; // sparse_status_t ok=mkl_sparse_z_create_coo (MATRIX,SPARSE_INDEX_BASE_ONE,nRows,nRows, nRows, rows,cols,permutData); sparse_status_t ok=mkl_sparse_d_create_coo (MATRIX,SPARSE_INDEX_BASE_ONE,nRows,nRows, nRows, rows,cols,permutData); if (ok==SPARSE_STATUS_SUCCESS){ cout<<"Matrix done\n"; cout.flush(); } else{ cout<<"Problem in handle creation"; cout.flush(); } return 0; }

Thanks a lot,

Marc

Link Copied

3 Replies

Alexander_K_Intel2

Employee

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

01-10-2017
05:09 PM

64 Views

HI,

I am currently cannot check this fact but seem problem in this line:

` ` `sparse_matrix_t *MATRIX;` |

Looks like you initialize pointer which set to NULL but have not initialize sparse_matrix_t variable. Could you rewrite code by following way:

`18` |
` ` `sparse_matrix_t MATRIX;` |

`19` |

`20` |
` ` `sparse_status_t ok=mkl_sparse_d_create_coo (&MATRIX,SPARSE_INDEX_BASE_ONE,nRows,nRows, nRows, rows,cols,permutData);` |

In any case i will check issue later

Thanks,

Alex

Zhen_Z_Intel

Employee

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

01-10-2017
10:20 PM

64 Views

Dear customer,

Alex is right. Your program probably get error "SPARSE_STATUS_NOT_INITIALIZED" which represents a null pointer of matrix. You could also refer to %MKLROOT%\examples\examples_core_c\spblasc\source\sparse_csrmv.c to see how this example create handle for matrix in CSR format. It has similar usage with function for COO.

Best regards,

Fiona

marcsolal

Beginner

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

01-11-2017
08:34 AM

64 Views

I misunderstood how to use this. I was thinking the pointer was allocated and given a value in the function. I modified according to your suggestions. I think this issue is solved.

Thanks a lot,

Marc

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

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