import numpy as np
# numpy.ndarray 타입의 객체를 생성
     A = np.array([
     [1, 2, 3],
     [4, 5, 6]
     ])
     B = np.array([
     [1, 2],
     [3, 4],
     [5, 6]
     ])
     print(A)
     print(B)
     print(A.shape) # 2x3 행렬
     print(B.shape) # 3x2 행렬
(2, 3)
(3, 2)
     nrows, ncols = B.shape
     print(nrows, 'x', ncols)
3 x 2
     # slicing: 특정 행, 특정 열의 원소들을 추출하는 방법
     # list[row][column], ndarray[row, column]
     print(A[0, 0])
     print(B[1, 1])
1
4
     print(A[0:2, 0:3])
     print(A[0, :]) # index 0번 row의 원소들로 이루어진 array
     print(A[:, 0]) # index 0번 column의 원소들로 이루어진 array
     print(B[1, 0:2])
     print(B[:, 0:2])
[[1 2 3]
[4 5 6]]
[1 2 3] # index 0번 row의 원소들로 이루어진 array
[1, 4] # index 0번 column의 원소들로 이루어진 array
[3 4]
[[1 2]
[3 4]
[5 6]]
     # 항등 행렬(Identity Matrix)
     identity_matrix = np.identity(3, dtype=int)
     print(identity_matrix)
[[1. 0. 0.]
[0. 1. 0.]
[0. 0. 1.]]
     # 전치 행렬(Transpose Matrix)
     print(A.transpose())
     
[[1 4]
[2 5]
[3 6]]
     
     # 행렬 곱셈 : dot함수
     print(A.dot(B))
     print(B.dot(A))
[[22 28]
[49 64]]
[[ 9 12 15]
[19 26 33]
[29 40 51]]