当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python SciPy io.hb_write用法及代码示例


本文简要介绍 python 语言中 scipy.io.hb_write 的用法。

用法:

scipy.io.hb_write(path_or_open_file, m, hb_info=None)#

写入HB-format 文件。

参数

path_or_open_file path-like 或 file-like

如果是 file-like 对象,则按原样使用。否则,它会在写入之前打开。

m sparse-matrix

要写的稀疏矩阵

hb_info HBInfo

包含 meta-data 用于写入

返回

None

注意

目前不支持完整的Harwell-Boeing 格式。支持的函数有:

  • assembled, non-symmetric, real matrices

  • integer for pointer/indices

  • exponential format for float values, and int format

例子

我们可以读写harwell-boeing格式文件:

>>> from scipy.io import hb_read, hb_write
>>> from scipy.sparse import csr_matrix, eye
>>> data = csr_matrix(eye(3))  # create a sparse matrix
>>> hb_write("data.hb", data)  # write a hb file
>>> print(hb_read("data.hb"))  # read a hb file
  (0, 0)    1.0
  (1, 1)    1.0
  (2, 2)    1.0

相关用法


注:本文由纯净天空筛选整理自scipy.org大神的英文原创作品 scipy.io.hb_write。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。