
Ublas : 
Subject: [ublas] compressed_matrix to CSR triplets
From: Rishi Amrit (rishiamrit_at_[hidden])
Date: 20120124 18:19:36
Hi,
I need to pass compressed_matrix objects to external function in the
standard CSR triplet format.
The external function takes the three inputs as pointers; for eg:
function foo(int* row_ptr, int* col_ind, double* val)
After extremely strenuous searching, I found the following post:
http://boost.2283326.n4.nabble.com/compressedrowstoragetd2710072.html
This suggests the availability of the following methods:
index1_data() // aka row_ptr (pointer to the start of row k)
index2_data() // aka col_idx (column indices)
value_data() // values corresponding to col_idx
Now just to make sure I get this right, for a matrix:
compressed_matrix<double> M, I can do
M.complete_index1_data();
int* row_ptr = &M.index1_data()[0];
int* col_idx = &M.index2_data()[0];
double* val = &M.value_data()[0];
foo(row_ptr, col_ind, val);
This implementation assumes that the pointers to the start of rows,
column indices and value are all stored contiguous in memory (and
hence extracting the pointers to the first element would work).
I have a doubt about this. Can anyone correct me please ?
Thanks,
Best,
R.