- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page