partitioned LU factorization
待续
1.算法来源
Toledo, S. 1997. Locality of Reference in LU Decomposition with Partial Pivoting. SIAM J. Matrix Anal. Appl. 18, 4 (Oct. 1997),1065-1081.
https://sci-hub.wf/10.1137/s0895479896297744
论文中原始算法:
2.LAPACK dgetrf()
LAPACK 中 dgetrf() API介绍:
http://www.netlib.org/lapack/explorehtml/dd/d9a/group__double_g_ecomputational_ga0019443faea08275ca60a734d0593e60.html#ga0019443faea08275ca60a734d0593e60
subroutine dgetrf ( integer M,
integer N,
double precision, dimension( lda, * ) A,
integer LDA,
integer, dimension( * ) IPIV,
integer INFO
)
API的返回值有些难以理解,可参考此描述:
即返回值也覆盖在A里,L对角线元素都是1,所以返回的A中也就不体现L的对角线元素。
另外还有P矩阵(permutation/pivot matrix),可能是体现在IPIV?待验证。
3.使用scipy进行LU分解实例
直接使用scipy官网中的例子:scipy.linalg.lu
import numpy as np
from scipy.linalg import lu
A = np.array([[2, 5, 8, 7], [5, 2, 2, 8], [7, 5, 6, 6], [5, 4, 4, 8]])
p, l, u = lu(A)
#p
array([[0., 1., 0., 0.],
[0., 0., 0., 1.],
[1., 0., 0., 0.],
[0., 0., 1., 0.]])
#l
array([[ 1. , 0. , 0. , 0. ],
[ 0.28571429, 1. , 0. , 0. ],
[ 0.71428571, 0.12 , 1. , 0. ],
[ 0.71428571, -0.44 , -0.46153846, 1. ]])
#u
array([[ 7. , 5. , 6. , 6. ],
[ 0. , 3.57142857, 6.28571429, 5.28571429],
[ 0. , 0. , -1.04 , 3.08 ],
[ 0. , 0. , 0. , 7.46153846]])
参考文献
[1] LOCALITY OF REFERENCE IN LU DECOMPOSITION WITH PARTIAL PIVOTING
[2]http://www.netlib.org/lapack/explorehtml/dd/d9a/group__double_g_ecomputational_ga0019443faea08275ca60a734d0593e60.html#ga0019443faea08275ca60a734d0593e60
[3] https://docs.scipy.org/doc/scipy/reference/reference/generated/scipy.linalg.lu.html#scipy.linalg.lu