기본 콘텐츠로 건너뛰기

라벨이 triu인 게시물 표시

[matplotlib]quiver()함수

[Linear Algebra] 삼각 행렬(Triangular matrix)

삼각 행렬(Triangular matrix) 식 1과 같이 삼각 행렬은 대각요소를 기준으로 그 요소들을 포함하여 윗 부분 또는 아래 부분의 요소들이 0이 아닌 값으로 구성된 행렬입니다. 0이 아닌 값들이 아랫 부분을 구성하는 경우는 하삼각 행렬(lower triangular matrix), 반대의 경우는 상삼각 행렬(upper triangular matrix)이 됩니다. \begin{align}\text{하삼각행렬}:\; \begin{bmatrix}{\color{red}a_{11}} & 0 & 0\\ a_{21} & {\color{red}a_{22}} & 0\\a_{31} & a_{32} & {\color{red}a_{33}}\end{bmatrix}\\ \text{상삼각행렬}:\; \begin{bmatrix}{\color{red}a_{11}} & a_{12} & a_{13}\\0& {\color{red}a_{22}} & a_{23}\\0 & 0 & {\color{red}a_{33}}\end{bmatrix} \end{align} (식 1) 하삼각행렬(lower triangular matrix) 대각 요소들을 기준으로 그 위 부분이 모두 0인 행렬 np.tril(x, k=0) 함수 사용. 이 함수의 인수 x는 배열 객체이며 k는 행렬의 대각요소들의 위치를 지정합니다. k의 기본값 0은 인덱스[0,0]을 기준으로하는 대각요소들을 의미합니다. 상삼각 행렬(upper triangular matrix) 대각 요소들을 기준으로 그 아래 부분이 모두 0인 행렬. np.triu(x, k=0) 함수 사용. np.random.seed(2) x=np.random.randint(1, 10, 9).reshape((3,3)) print(x) [[9 9 7] [3 9 8] [3 2 6]] print(np.triu(x)) [[9 9 7] [0 9 8] [0...