问题
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:
find is what you are looking for
[rowIdx colIdx val] = find( myHugeSparseMatrix );
来源:https://stackoverflow.com/questions/32177489/save-sparse-matrix-as-row-column-and-value-vectors