以下是我们遇到问题的sympy
代码。我们试图在正交矩阵上使用简单代数。
from sympy import *
from sympy.abc import a, l
E = MatrixSymbol('E', l, l)
aE = a * E
with assuming(Q.orthogonal(E)):
print(refine(E.T * E))
print(refine(aE.T * aE))
第一条印刷线成功完成并给出了#34; I"正如我们所料。另一方面,最后的print语句终止于:
"属性错误:'符号'对象没有属性' T'"错误。
整个错误消息显示为:
/Users/wakita/anaconda3/envs/pyqtgl/bin/python "/Users/wakita/Dropbox (smartnova)/work/pysandbox/testsympy/aE.py"
Traceback (most recent call last):
File "/Users/wakita/Dropbox (smartnova)/work/pysandbox/testsympy/aE.py", line 9, in <module>
print(refine(aE.T * aE))
File "/Users/wakita/anaconda3/envs/pyqtgl/lib/python3.5/site-packages/sympy/assumptions/refine.py", line 29, in refine
args = [refine(arg, assumptions) for arg in expr.args]
File "/Users/wakita/anaconda3/envs/pyqtgl/lib/python3.5/site-packages/sympy/assumptions/refine.py", line 29, in <listcomp>
args = [refine(arg, assumptions) for arg in expr.args]
File "/Users/wakita/anaconda3/envs/pyqtgl/lib/python3.5/site-packages/sympy/assumptions/refine.py", line 29, in refine
args = [refine(arg, assumptions) for arg in expr.args]
File "/Users/wakita/anaconda3/envs/pyqtgl/lib/python3.5/site-packages/sympy/assumptions/refine.py", line 29, in <listcomp>
args = [refine(arg, assumptions) for arg in expr.args]
File "/Users/wakita/anaconda3/envs/pyqtgl/lib/python3.5/site-packages/sympy/assumptions/refine.py", line 40, in refine
new_expr = handler(expr, assumptions)
File "/Users/wakita/anaconda3/envs/pyqtgl/lib/python3.5/site-packages/sympy/matrices/expressions/matmul.py", line 265, in refine_MatMul
if arg == last.T and ask(Q.orthogonal(arg), assumptions):
AttributeError: 'Symbol' object has no attribute 'T'