Numpy & Scipy - 1.2 Convenient Functions of Matrix
 Numpy & Scipy - 1.2 Convenient Functions of Matrix 
 eye / identity
- np.eye : band에 1을 채워 넣는 함수이다.
[[0. 1. 0.] [0. 0. 1.]]
- np.identity : identity matrix 를 만들어주는 함수이다.
[[1. 0. 0.] [0. 1. 0.] [0. 0. 1.]]
 
tri
- np.tri : lower triangular matrix 를 만들어주는 함수이다. nonzero entry = 1
- k $\ge$ band id 의 모든 밴드에 1을 채워넣고 나머지는 0을 채워 넣는다.
0.00, 0.00, 0.00 1.00, 0.00, 0.00 1.00, 1.00, 0.00 1.00, 1.00, 1.00
 
zeros / ones / full
- np.zeros : (row x column) matrix 를 전부 0으로 채우는 함수
0.00, 0.00, 0.00 0.00, 0.00, 0.00
- np.ones : (row x column) matrix 를 전부 1으로 채우는 함수
1.00, 1.00, 1.00 1.00, 1.00, 1.00
- np.full : (row x column) matrix 를 전부 지정된 value 로 채우는 함수
( 1.00+0.00j), ( 1.00+0.00j), ( 1.00+0.00j) ( 1.00+0.00j), ( 1.00+0.00j), ( 1.00+0.00j) ( 1.00+0.00j), ( 1.00+0.00j), ( 1.00+0.00j)
 
random.rand
- np.random.rand : (row x column) matrix 에 random 값을 채워넣는 함수
- 단, real matrix 이고 np.float64 데이터 타입만 허용된다.
0.7852, 0.7524, 0.8531, 0.0095, 0.9326 0.8960, 0.6175, 0.6236, 0.5146, 0.4580 0.4606, 0.6550, 0.0049, 0.1367, 0.3998 0.3829, 0.7723, 0.0422, 0.0209, 0.1061 0.1148, 0.0447, 0.1126, 0.7619, 0.9044 0.4618, 0.1164, 0.1075, 0.7190, 0.7792 0.1036, 0.8590, 0.8889, 0.7100, 0.9618 0.6096, 0.9913, 0.7568, 0.6786, 0.5567
- 물론 random.rand 를 가지고 complex matrix 로 표현이 가능하다.
Example 1
np.random.rand 를 사용하여 실수부분은 0이고 허수부분이 0i ~ 1i 인 3x3 matrix 만들기
( 0.00+0.33j) , ( 0.00+0.41j) , ( 0.00+0.52j) ( 0.00+0.11j) , ( 0.00+0.16j) , ( 0.00+0.45j) ( 0.00+0.92j) , ( 0.00+0.93j) , ( 0.00+0.81j)
 This post is licensed under  CC BY 4.0  by the author.
 
 
