2

Python プログラムで使用する必要がある大規模な matlab 疎行列 (matlab 7.3) を格納するデータ ファイルがあります。h5py を使用してこの疎行列を読み込み、疎行列に関連付けられた 3 つのデータ構造があることを確認しました。

疎行列の名前が M で、3 つのデータ構造が M['data']、M['ir']、M['jc'] であるとします。最初は、M['ir'] と M['jc'] はゼロ以外の項目の行インデックスと列インデックスを格納すると思っていましたが、M['jc'] の行番号より大きい値がいくつか存在することがわかりました。疎行列。3つのデータ構造にどのような種類の情報が格納されているか説明できますか?

4

1 に答える 1

2

irご想像のとおり、空でない行の行インデックスです。column-index の場合はやや複雑ですが、Mathworks mex-Function のドキュメントに完全に記載されています。

http://www.mathworks.de/de/help/matlab/apiref/mxsetir.htmlから貼り付け:

If the jth column of the sparse mxArray has any nonzero elements:

jc[j] is the index in ir, pr, and pi (if it exists) of the first nonzero element in the jth column.
jc[j+1]-1 is the index of the last nonzero element in the jth column.
For the jth column of the sparse matrix, jc[j] is the total number of nonzero elements in all preceding columns.
The number of nonzero elements in the jth column of the sparse mxArray is:

jc[j+1] - jc[j];

のドキュメントも確認してくださいmxSetIr。matlab にもアクセスできると仮定すると、ドキュメントからリンクされている mex の例を確認する必要があります。

于 2013-10-07T07:31:56.940 に答える