1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Numpy基本操作メモ

1
Last updated at Posted at 2018-07-29

Numpy基本操作メモ

基本的な操作メモ.


import numpy as np
data = [[1,2,4],[2,1,2]]
d1 = np.array(data)
ndim = d1.ndim              #次元数チェック
nsiz = d1.shape             #サイズ(matlabでのsize())
d2 = np.zeros([2,3])        #2行3列ゼロ行列    
d3 = np.eye(3,3)            #3行単位行列
d4 = np.arange(6)           #0-7までの連続数字
d5 = d4.reshape((2,3))      #2行3列の行列に直す
d1 = d1.T                   #d1を転置し,3行2列に
d6 = np.dot(d1,d5)          #d1とd5の行列積

線形代数

Numpyで逆行列を求めてみる.


import numpy as np
from numpy.linalg import inv
data = [[1,2],[2,3]]
d1 = np.array(data)
d8 = inv(d1)                #逆行列算出
d9 = np.dot(d1,d8)          #行列積

d9の結果は以下の様になる.
image.png

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?