学習環境
- Surface
- Windows 10 Pro (OS)
- Nebo(Windows アプリ)
- iPad
- MyScript Nebo - MyScript(iPad アプリ(iOS))
- 参考書籍
ラング線形代数学(上) (ちくま学現文庫)(S.ラング (著)、芹沢 正三 (翻訳)、筑摩書房)の3章(行列)、1(行列空間)、練習問題8の解答を求めてみる。
コード
#!/usr/bin/env python3
from unittest import TestCase, main
from sympy import symbols, Matrix
print('8.')
a = Matrix([[1, -1],
[2, 2]])
b = Matrix([[-1, 1],
[0, -3]])
class MyTestCase(TestCase):
def test1(self):
self.assertEqual((a + b).T,
Matrix([[0, 2], [0, -1]]))
def test2(self):
self.assertEqual(a.T + b.T,
Matrix([[0, 2],
[0, -1]]))
if __name__ == '__main__':
main()
入出力結果(Zsh、PowerShell、Terminal、Jupyter(IPython))
% ./sample8.py -v
8.
test1 (__main__.MyTestCase) ... ok
test2 (__main__.MyTestCase) ... ok
----------------------------------------------------------------------
Ran 2 tests in 0.001s
OK
%
0 コメント:
コメントを投稿