scipy.io.
mminfo#
- scipy.io.mminfo(source)[源代码]#
从 Matrix Market 文件类“source”返回大小和存储参数。
- 参数:
- source字符串或文件类对象
Matrix Market 文件名(扩展名为 .mtx)或已打开的文件类对象
- 返回:
- rowsint
矩阵的行数。
- colsint
矩阵的列数。
- entriesint
稀疏矩阵的非零条目数,或稠密矩阵的行数*列数。
- formatstr
‘coordinate’ 或 ‘array’。
- fieldstr
‘real’、‘complex’、‘pattern’ 或 ‘integer’。
- symmetrystr
‘general’、‘symmetric’、‘skew-symmetric’ 或 ‘hermitian’。
注意
1.12.0 版本中更改:C++ 实现。
示例
>>> 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')