I need to get raw pointer from cusp library matrix format. For example:
cusp::coo_matrix<int,double,cusp::device_memory> A(3,3,4);
A.values[0] = 1;
A.row_indices[0] = 0;
A.column_indices[0]= 1;
A.values[1] = 2;
A.row_indices[1] = 1;
A.column_indices[1]= 0;
A.values[2] = 3;
A.row_indices[2] = 1;
A.column_indices[2]= 1;
A.values[3] = 4;
A.row_indices[3] = 2;
A.column_indices[3]= 2;
How can I get the raw pointer to row_indices, column_indices and values arrays? I need to pass them to my kernels and I'd like to avoid unnecesary data copying if possible.
There are multiple ways to accomplish this. For example, if the you wish to start with the raw device data representation instead of the cusp data representation, you could use the methodology in the cusp views functionality.
If you have cusp data already, and you want to convert to raw data representation, we can use the fact that cusp is built on top of thrust. Here's a fully worked example: