Save sparse matrix as row, column, and value vectors

[亡魂溺海] 提交于 2019-12-25 06:38:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!