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


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。