Question

within a matlab code of mine, I have to deal with the Cholesky factorization of a certain given matrix. I am generally calling chol(A,'lower') to generate the lower triangular factor.

Now, checking my code with the profiler, it is evident that function chol is really time consuming, especially if the size of the input matrix becomes large.

Therefore, I would like to know, if there is any valuable alternative to the built-in chol function.

I have been thinking of the LAPACK library, and namely of spptrf function. Is it available in MATLAB or not?

Any hint or support are more than welcome.

EDIT

Just as an example, the profiler retrieves this information:

enter image description here

where Coh_u has size (1395*1395). It has, also, to be remarked that chol is called 4000 times, since I need the cholesky factor for 4000 different configurations.

Was it helpful?

Solution

I'm not sure what version of matlab you are using, but I found this discussion, which suggests in older versions that Cholesky Factorization was very slow as you're describing.

One of the answers there says to use the CHOLMOD package or SuiteSparse, which has a chol2 function that is supposed to be faster.

OTHER TIPS

Can you confirm if the correct expression for Coh_u is as under

a) Coh_u = exp(-a.*sqrt((f(ii)/Uhub).^2 + (0.12/Lc).^2)).*(df.*psd(ii,1));

or

b) Coh_u = exp(-a.*dist*sqrt((f(ii)/Uhub).^2 + (0.12/Lc).^2)).*(df.*psd(ii,1));

The difference in a) and b) is that in b) dist has been added which is the distance between two matrices Y an Z such that

dist = pdist2([Y(:) Z(:)],[Y(:) Z(:)]);

But it leads into the "Matrix not positive definite" error with the chol() function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top