FastCholesky.cholinv
— Methodcholinv(input)
Calculate the inverse of the input matrix input
using Cholesky factorization. This function is an alias for inv(fastcholesky(input))
.
julia> A = [4.0 2.0; 2.0 5.0];
julia> A_inv = cholinv(A);
julia> A_inv ≈ inv(A)
true
FastCholesky.cholinv_logdet
— Methodcholinv_logdet(input)
Calculate the inverse and the natural logarithm of the determinant of the input matrix input
simultaneously using Cholesky factorization.
julia> A = [4.0 2.0; 2.0 5.0];
julia> A_inv, logdet_A = cholinv_logdet(A);
julia> isapprox(A_inv * A, I)
true
julia> isapprox(logdet_A, log(det(A)))
true
FastCholesky.chollogdet
— Methodchollogdet(input)
Calculate the log-determinant of the input matrix input
using Cholesky factorization. This function is an alias for logdet(fastcholesky(input))
.
julia> A = [4.0 2.0; 2.0 5.0];
julia> logdet_A = chollogdet(A);
julia> isapprox(logdet_A, log(det(A)))
true
FastCholesky.cholsqrt
— Methodcholsqrt(input)
Calculate the square root of the input matrix input
using Cholesky factorization. This function is an alias for fastcholesky(input).L
.
julia> A = [4.0 2.0; 2.0 5.0];
julia> A_sqrt = cholsqrt(A);
julia> isapprox(A_sqrt * A_sqrt', A)
true
FastCholesky.fastcholesky!
— Functionfastcholesky!(input)
Calculate the Cholesky factorization of the input matrix input
in-place. This function is an in-place version of fastcholesky
, and it does not check the positive-definiteness of the input matrix or throw errors. You can use LinearAlgebra.issuccess
to check if the result is a proper Cholesky factorization.
This function does not verify the positive-definiteness of the input matrix and does not throw errors. Ensure that the input matrix is appropriate for Cholesky factorization before using this function.
julia> C = fastcholesky!([ 1.0 0.5; 0.5 1.0 ]);
julia> C.L * C.L' ≈ [ 1.0 0.5; 0.5 1.0 ]
true
FastCholesky.fastcholesky
— Methodfastcholesky(input)
Calculate the Cholesky factorization of the input matrix input
. This function provides a more efficient implementation for certain input matrices compared to the standard LinearAlgebra.cholesky
function. By default, it falls back to using LinearAlgebra.cholesky(PositiveFactorizations.Positive, input)
, which means it does not require the input matrix to be perfectly symmetric.
This function assumes that the input matrix is nearly positive definite, and it will attempt to make the smallest possible adjustments to the matrix to ensure it becomes positive definite. Note that the magnitude of these adjustments may not necessarily be small, so it's important to use this function only when you expect the input matrix to be nearly positive definite.
julia> C = fastcholesky([ 1.0 0.5; 0.5 1.0 ]);
julia> C.L * C.L' ≈ [ 1.0 0.5; 0.5 1.0 ]
true