from scipy import *
a = matrix([[1, 2], [3, 4]])
b = matrix([[3, 4], [5, 6]])
a
tsurukame.py
# -*- coding: utf-8 -*- # tsurukame.py from scipy import * from scipy import linalg a = matrix([[1, 1], # 鶴, 亀 の頭 [2, 4]]) # 鶴, 亀 の足 b = matrix([[10], # 頭は 10 個 [26]]) # 足は 26 本 x = linalg.solve(a, b) print u"鶴は %d 羽, 亀は %d 匹" % (x[0], x[1])
>>> from scipy import * >>> from scipy.linalg import solve >>> a = matrix([[1,2],[1,-1]]) >>> b = matrix([[1],[4]]) >>> solve(a,b) array([[ 3.], [-1.]])