pymatrix (GitHUb) is a lightweight library for basic linear algebra operations.
Here is an example, for a linear system as follows:
It can be solved like:
from pymatrix import *
A = matrix([
[ 3.0, 2.0, -1.0],
[ 2.0, -2.0, 4.0],
[-1.0, .5, -1.0],
])
b = Matrix.FromString('''
1
-2
0
''')
print(A.inverse()*b)
There are some differences ways to instantiate a matrix. The matrix elements are iterable and indexable. A few dozens of matrix operations and functions are available. It’s written for both Python 2 and 3.
By the way, recently there is a PEP 465 about dedicated @ matrix operattor, you might want to check that out.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.