當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python SciPy io.mminfo用法及代碼示例

本文簡要介紹 python 語言中 scipy.io.mminfo 的用法。

用法:

scipy.io.mminfo(source)#

從 Matrix Market file-like ‘source’ 返回大小和存儲參數。

參數

source str 或 file-like

Matrix Market 文件名(擴展名 .mtx)或打開 file-like 對象

返回

rows int

矩陣行數。

cols int

矩陣列數。

entries int

稀疏矩陣的非零條目數或稠密矩陣的行*列數。

format str

‘coordinate’ 或‘array’。

field str

‘real’, ‘complex’, ‘pattern’或‘integer’。

symmetry str

‘general’, ‘symmetric’、“skew-symmetric”或‘hermitian’。

注意

例子

>>> from io import StringIO
>>> from scipy.io import mminfo
>>> text = '''%%MatrixMarket matrix coordinate real general
...  5 5 7
...  2 3 1.0
...  3 4 2.0
...  3 5 3.0
...  4 1 4.0
...  4 2 5.0
...  4 3 6.0
...  4 4 7.0
... '''

mminfo(source) 返回源文件的行數、列數、格式、字段類型和對稱屬性。

>>> mminfo(StringIO(text))
(5, 5, 7, 'coordinate', 'real', 'general')

相關用法


注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.io.mminfo。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。