# Why does the matlab command **chol(A)** slower than **chol(A,'lower')** for a large sparse SPD matrix?

For a SPD matrix A, there exists Cholesky factorization $$A=LL^T$$ or $$A=R^TR$$, where L, R are a lower and upper triangular matrix, respectively.

Also in matlab, there has a command R = chol(A) which produces $$A=R^TR$$. and another command L = chol(A,'lower') which produces $$A=LL^T$$. But when I implement these two commands with a same large sparse SPD matrix A, L = chol(A,'lower') is faster than R = chol(A) so mysterious. why this happens? Thanks.

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


I have run the example 3 times and the numerical results are as follows which indeed demonstrates that the above words what I said (my cpu is 8GB memory and 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.

• It's clearly something about the implementation of the sparse Cholesky factorization in MATLAB. MATLAB uses Tim Davis's CHOLMOD for this factorization. You could test CHOLMOD to see if it has the same issue and investigate the code to understand the particular issue. In any case it's a matter of implementation and not really appropriate for this group. – Brian Borchers Nov 6 '19 at 2:36
• Get it. Thanks for your reply. I understand it now. – sunshine Nov 6 '19 at 4:14