对于 SPD 矩阵A,存在Cholesky 分解 或,其中L、R分别是下三角矩阵和上三角矩阵。
同样在matlab中,有一个命令R = chol(A)产生。另一个命令L = chol(A,'lower')产生。但是当我用相同的大稀疏 SPD 矩阵A来实现这两个命令时,L = chol(A,'lower')比R = chol(A)快得多,所以很神秘。为什么会这样?谢谢。
clc;clear;
n =400;
A = gallery('poisson',n);
tic
R = chol(A);% generate the triangular matrix such that A = R'*R
toc
tic
L = chol(A,'lower');% generate the lower matrix such that A = L*L'
toc
我已经运行了这个例子3次,数值结果如下,确实证明了我所说的上面的话(我的cpu是8GB内存和matlab 2018b):
Elapsed time is 12.089711 seconds.
Elapsed time is 8.467380 seconds.
Elapsed time is 10.372768 seconds.
Elapsed time is 8.131158 seconds.
Elapsed time is 10.027861 seconds.
Elapsed time is 8.105706 seconds.