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


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

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

用法:

scipy.io.hb_read(path_or_open_file)#

讀取HB-format 文件。

參數

path_or_open_file path-like 或 file-like

如果是 file-like 對象,則按原樣使用。否則,它會在閱讀之前打開。

返回

data scipy.sparse.csc_matrix 實例

從 HB 文件中讀取的數據作為稀疏矩陣。

注意

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