LU decomposition

Download Report

Transcript LU decomposition

LU decomposition
日期:2014/9/30
助教:汪柏岑
授課老師:徐國錦 教授
LU 分解
• Doolittle’s method
• Crout’s method
• Choleski’s method
Doolittle’s method
library(Matrix)
B=matrix(c(1,2,0,1))
mm <- matrix(c(4,-1,-1,0,-1,4,0,-1,-1,0,4,-1,0,-1,-1,4),nrow=4)
lum <- lu(mm)
elu <- expand(lum)
y=solve(elu$L)%*%B
x=solve(elu$U)%*%y
elu$L
elu$U
Choleski’s method
Exercise
4X4 矩陣
A=matrix(c(4,-1,-1,0,-1,4,0,-1,-1,0,4,-1,0,-1,-1,4),4,4) #定義A
矩陣
b=matrix(c(1,2,0,1),4,1) #定義b矩陣
U=chol(A) #使用Choleski's method 算出U
L=t(chol(A)) #求U之轉置矩陣L
y=solve(L)%*%b #求y矩陣
L的反矩陣
矩陣相乘
x=solve(U)%*%y #求x矩陣
A=LU  Ax=b  Lux=b  Ly=b  Ux=y