2x2行列の2x2行列を作成しました。
a = matrix([[matrix([[ 1, 2], [ 3, 4]]),
matrix([[ 5, 6], [ 7, 8]])],
[matrix([[ 9, 10], [11, 12]]),
matrix([[13, 14], [15, 16]])]])
数値(タイプa*3
など)で乗算すると、次のエラーが発生します。
TypeError: unsupported operand parent(s) for '*':
'Full MatrixSpace of 2 by 2 dense matrices over Integer Ring' and
'Full MatrixSpace of 2 by 2 dense matrices over Integer Ring'
Full MatrixSpace of 2 by 2 dense matrices over Integer Ring
は部分行列(parent(a[0,0])
)の親であり、問題なく乗算できるため、これは奇妙に見えます。
sage: a[0,0]*a[0,0]
[ 7 10]
[15 22]
次のコマンドのいずれかが正常に機能します。
sage: a[0,0]*3
sage: a[0,0]*a[0,0]
sage: a[0,0]*a
sage: a*a
sage: a[0,0]*3*a
sage: diagonal_matrix([3]*2)*a # I don't want do this every time!
しかし、これらはしません:
sage: a*3 #TypeError
sage: a[0,0]*a*3 #TypeError
だからここに質問があります:
- 2x2行列の乗算がサポートされていないと言われるのはなぜですか?
- 行列をスカラーで乗算すると、なぜこの乗算が表示されるのですか?
diagonal_matrix
チートなしで行列をスカラーで乗算できますか?