__Title__

**[M-5] _factorsym()** -- Factor a symmetric nonnegative-definite matrix

__Syntax__

*real scalar* **_factorsym(***real matrix A*[**,** *real scalar tol*]**)**

__Description__

**_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)**.

__Remarks__

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**

**: mreldif(A,A*Ai*A)**

You can compare this G-inverse **Ai** with that computed from **invsym()**.

__Conformability__

**_factorsym(***A***)**
*input:*
*A*: *n x n*
*tol*: *1 x 1* (optional)
*output:*
*A*: *n x n*
*result*: *1 x 1*

__Diagnostics__

**_factorsym(***A***)** uses the elements from the lower triangle of *A* without
checking whether *A* is symmetric.

__Source code__

**_factorsym()** is built-in.