0

I have a sparse matrix saved in a mat file. I want to process it in C++ but my library expects the sparse matrix to be represented as three vectors: colIdx (vector of indices of nonzero columns), rowIdx (vector of indices of nonzero rows), and val (vector of values).

How should I go about this? Are there any built-in commands doing similar operations?

1 Answer 1

3

find is what you are looking for

[rowIdx colIdx val] = find( myHugeSparseMatrix );
Sign up to request clarification or add additional context in comments.

3 Comments

I get an error (Out of memory). Any ideas on what to do?
@user111691 bummer :( you might need to process your matrix in blocks. One block at a time.
@user111691 check mathworks.com/help/matlab/import_export/… Read in part of your data, then export the [rowIdx colIdx val] of Shai's find

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.