You can use the NumPy library to convert the Symengine matrix to a NumPy array, which can then be saved to a file using the NumPy's save
function.
import numpy as np
from symengine import Matrix
# create a Symengine matrix
M = Matrix([[1, 2], [3, 4]])
# convert the matrix to a NumPy array
N = np.array(M.tolist())
# save the NumPy array to a file
np.save('matrix.npy', N)
To load the saved matrix from the file, you can use the NumPy's load
function:
# load the saved matrix from the file
N = np.load('matrix.npy')
# convert the NumPy array back to a Symengine matrix
M = Matrix(N)
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2021-12-27 11:00:00 +0000
Seen: 7 times
Last updated: Jun 13 '21
How can I set up Gunicorn with a Django Project?
Looking for a Python Module that finds Tags for a Text describing its Content
Need a Function in Python to remove entries less than 2 digits from an Array
How can I convert a Document in Python?
How can I program a Loop in Python?
How can I enable Python Code Highlighting in Askbot?