ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
inv.m
Go to the documentation of this file.
1%> \brief
2%> Generate and return the inverse of a positive-definite matrix
3%> whose Lower-triangular Cholesky factorization is given as input.<br>
4%>
5%> \param[in] cholow : The input square matrix representing the lower-triangular
6%> Cholesky factorization whose inverse must be computed.<br>
7%>
8%> \return
9%> ``invmat`` : The output square positive-definite matrix, representing the inverse of
10%> the matrix whose lower-triangular Cholesky factorization is given as input.<br>
11%>
12%> \interface{inv}
13%> \code{.m}
14%>
15%> invmat = pm.matrix.inv(cholow);
16%>
17%> \endcode
18%>
19%> \see
20%> See *Matrix Inversion Using Cholesky Decomposition*, Aravindh Krishnamoorthy, Deepak Menon, (arXiv:1111.4144).<br>
21%>
22%> \example{inv}
23%> \include{lineno} example/matrix/inv/main.m
24%> \output{inv}
25%> \include{lineno} example/matrix/inv/main.out.m
26%>
27%> \final{inv}
28%>
29%> This function builds upon the work of Aravindh Krishnamoorthy (2024).
30%> [Matrix Inversion using Cholesky Decomposition](https://www.mathworks.com/matlabcentral/fileexchange/41957-matrix-inversion-using-cholow-decomposition),
31%> MATLAB Central File Exchange.<br>
32%>
33%> \author
34%> \JoshuaOsborne, May 21 2024, 12:06 AM, University of Texas at Arlington<br>
35%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
36%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute for Computational Engineering and Sciences (ICES), UT Austin<br>
37function invmat = inv(cholow)
38 %%%%
39 %%%% Initializations.
40 %%%%
41 ndim = size(cholow, 1);
42 invmat = zeros(ndim, ndim);
43 %%%%
44 %%%% Construct the auxillary diagonal matrix ``auxdia = 1 / rii``.
45 %%%%
46 auxdia = inv(diag(diag(cholow)));
47 %%%%
48 %%%% Compute the inverse.
49 %%%%
50 for j = ndim : -1 : 1
51 for i = j : -1 : 1
52 invmat(i, j) = auxdia(i, j) - cholow(i + 1 : end, i)' * invmat(i + 1 : end, j);
53 invmat(i, j) = invmat(i, j) / cholow(i, i);
54 %%%%
55 %%%% Write out the symmetric element.
56 %%%%
57 invmat(j, i) = conj(invmat(i, j));
58 end
59 end
60end
function inv(in cholow)
Generate and return the inverse of a positive-definite matrix whose Lower-triangular Cholesky factori...