scipy.io.
hb_write#
- scipy.io.hb_write(path_or_open_file, m, hb_info=None)[source]#
寫入 HB 格式檔案。
- 參數:
- path_or_open_file路徑型或檔案型
如果是一個檔案型物件,則直接使用。否則,會在寫入前開啟。
- m稀疏陣列或矩陣
要寫入的稀疏陣列
- hb_infoHBInfo
包含寫入的元數據
- 回傳:
- 無
說明
目前尚不支援完整的 Harwell-Boeing 格式。支援的功能有
組裝好的、非對稱的實數矩陣
指標/索引的整數
浮點數值的指數格式,以及整數格式
範例
我們可以讀取和寫入 harwell-boeing 格式檔案
>>> from scipy.io import hb_read, hb_write >>> from scipy.sparse import csr_array, eye >>> data = csr_array(eye(3)) # create a sparse array >>> hb_write("data.hb", data) # write a hb file >>> print(hb_read("data.hb", spmatrix=False)) # read a hb file <Compressed Sparse Column sparse array of dtype 'float64' with 3 stored elements and shape (3, 3)> Coords Values (0, 0) 1.0 (1, 1) 1.0 (2, 2) 1.0