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