Cholesky decomposition; Cholesky 分解
Cholesky分解並回傳下三角矩陣
只有正定矩陣才可作Cholesky分解並回傳下三角矩陣
Example Code
- import numpy as np
- from numpy import linalg as LA
- import math
- martixA = [[ 5, 3, -1],[ 3, 3, 1], [ -1, 1, 6]]
- print('eigen values of martixA = ')
- print(martixA)
- LMatrix = LA.cholesky(martixA)
- print('\n Lower triangular Matrix = \n', LMatrix)
- print('\n transfer conjugate matrix of Lower triangular Matrix = \n', LMatrix.T.conj())
- print('\n LL^-T = ', np.dot(LMatrix, LMatrix.T.conj()))
Note and Comments
- import numpy as np: 讀入numpy函式庫並命名為np
- from numpy import linalg as LA: 讀取numpy函式庫的線性代數函式庫並命名為LA
- LA.cholesky(martixA): cholesky分解martixA並傳回下三角矩陣(lower triangular matrix)只有正定矩陣才可作Cholesky分解
- LMatrix.T.conj(): 傳回LMatrix的共軛轉置矩陣
result