将稀疏矩阵另存为行,列和值向量 [英] Save sparse matrix as row, column, and value vectors
本文介绍了将稀疏矩阵另存为行,列和值向量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在mat
文件中保存了一个稀疏矩阵.我想用C ++处理它,但我的库希望将稀疏矩阵表示为三个向量:colIdx
(非零列索引的向量),rowIdx
(非零行索引的向量)和val
(值向量).
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?
推荐答案
[rowIdx colIdx val] = find( myHugeSparseMatrix );
这篇关于将稀疏矩阵另存为行,列和值向量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文