Hi all,
This is my first message. I hope someone can help me here. I have a sparse float vector (about 3M non-zero elements; dense vector would be about 200M elements) and I want to copy a series of values (about 200K) from this vector to a dense vector. How do I do this most efficiently?
Thanks!
Michiel
Naive pseudo code:
void gather_from_sparse(const float * xVal,
const int * xInd,
const int nnz,
const int dense_size,
const int nr_desired_vals,
const int * desired_indices,
float * output)
{
float * dense = new float[dense_size];
for (int i = 0; i < nnz; ++i)
dense[xInd[i]] = xVal[i];
for (int j = 0; j < nr_desired_vals; ++j)
output[j] = dense[desired_indices[j]];
delete dense;
}
Some things that might make it easier:
- xInd and desired_indices will always be sorted in ascending order
- desired_indices is always a subset of xInd