0
0

「sympyのArray()」を調べた。

Last updated at Posted at 2023-11-29

・Arrayで、diffができましたが、invができませんでした。

sympyで

from sympy import *

var('x',real=True)
M=Matrix([[2*x,3*x],[4*x,5*x]])
print("#",M       ,type(M))
print("#",M.diff())
print("#",M.inv() )
print()
A=Array ([[2*x,3*x],[4*x,5*x]])
print("#",A       ,type(A))
print("#",A.diff())
print("#",A.inv() )
# Matrix([[2*x, 3*x], [4*x, 5*x]]) <class 'sympy.matrices.dense.MutableDenseMatrix'>
# Matrix([[2, 3], [4, 5]])
# Matrix([[-5/(2*x), 3/(2*x)], [2/x, -1/x]])

# [[2*x, 3*x], [4*x, 5*x]] <class 'sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray'>
# [[2, 3], [4, 5]]
# AttributeError: 'ImmutableDenseNDimArray' object has no attribute 'inv'

DOC

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0