[M-5] _factorsym() -- Factor a symmetric nonnegative-definite matrix
real scalar _factorsym(real matrix A[, real scalar tol])
_factorsym(A) factors a symmetric nonnegative-definite matrix A to a
lower triangular matrix and overwrites A with the solution. Returned is
the rank of A. For a matrix with dimension n and rank r < n, the
resulting matrix has n - r rows with zeros. The optional argument tol is
the tolerance used to determine whether the matrix is nonnegative
definite. The default is tol = sum(abs(diagonal(A)))*epsilon(16).
The decomposition G of a symmetric nonnegative-definite matrix A is
A = GG'
where G is lower triangular.
A generalized inverse (G-inverse) can be computed from the factored
matrix G by typing
: G = A
: rank = _factorsym(G)
: Ai = I(n)
: rank = _solvelower(G,Ai)
: Ai = Ai'Ai
You can compare this G-inverse Ai with that computed from invsym().
A: n x n
tol: 1 x 1 (optional)
A: n x n
result: 1 x 1
_factorsym(A) uses the elements from the lower triangle of A without
checking whether A is symmetric.
_factorsym() is built-in.