madupite.writePETScBinary#
- madupite.writePETScBinary(matrix, filename, info_file=False)#
Write a numpy/scipy matrix as petsc binary sparse format to file https://petsc.org/release/manualpages/Mat/MatLoad/#notes.
If you are working with a 3-dimensional array to represent the transition probabilities you must reshape it before writing it to file. If the array P[i,j,k] represents the transition probability from state i to state k given input j, you can reshape it as follows:
1stdim, 2nddim, 3rddim = P.shape P = P.reshape(1stdim * 2nddim, 3rddim)
Parameters#
- matrixnumpy/scipy matrix (2-dimensional)
any matrix type that allows calling scipy.sparse.csr_array(matrix)
- filenamestring
output filename
- info_filebool, optional
write empty info file for PETSc versions that throw a warning if it does not exist, by default False