numeric::factorCholesky
-- Cholesky factorization of a matrixnumeric::factorCholesky
(A, ..)
returns a
Cholesky factorization A=LL^H of a positive definite
Hermitean matrix A.
numeric::factorCholesky
(A, Symmetric, ..)
returns a Cholesky factorization A=LL^T of a symmetric
matrix A.
numeric::factorCholesky(A <, Symmetric> <, Symbolic>
<, NoCheck>)
A |
- | a square matrix of domain type DOM_ARRAY or of category Cat::Matrix |
Symmetric |
- | makes numeric::factorCholesky compute a
symmetric factorization A=LL^T rather than a Hermitean
factorization A=LL^H |
Symbolic |
- | prevents numeric::factorCholesky from
using floating point arithmetic |
NoCheck |
- | prevents numeric::factorCholesky from
checking that the matrix is Hermitean and positive definite |
The lower triangular Cholesky factor L is returned as a
matrix of domain type DOM_ARRAY
. Its components are real or
complex floats, unless the option Symbolic is
used. Without the option NoCheck an error is
returned, if the matrix is not Hermitean or not positive definite.
Without the option Symbolic the function is
sensitive to the environment variable DIGITS
, which determines the
numerical working precision.
linalg::factorCholesky
,
numeric::factorLU
,
numeric::factorQR
PI
,
sqrt(2)
, exp(-1)
etc. are accepted.numeric::factorCholesky
is normalized such that its
diagonal elements are real and positive.numeric::factorCholesky
checks that the matrix
A is Hermitean and positive definite. The option NoCheck may be used to suppress these checks. It must be
used when the matrix contains symbolic objects. Elements in the upper
triangular part of the matrix will never be touched by the
algorithm!This option is dangerous! It returns a result for matrices that are not Hermitean or not positive definite (i.e., no Cholesky factorization exists)!
We consider the matrix
>> A := array(1..2, 1..2, [[1, I] , [-I, PI]]):
We compute a numerical factorization
>> numeric::factorCholesky(A)
+- -+ | 1.0, 0 | | | | - 1.0 I, 1.46341814 | +- -+
and a symbolic factorization:
>> L := numeric::factorCholesky(A, Symbolic, NoCheck)
+- -+ | 1, 0 | | | | 1/2 | | - I, (PI - 1) | +- -+
For further processing the Cholesky factor (of domain
type DOM_ARRAY
) is converted
to an element of the matrix domain Dom::Matrix()
:
>> L := Dom::Matrix()(L):
Now the overloaded arithmetical operators
+
, *
, ^
etc. can be used for
further computations:
>> L*linalg::transpose(map(L, conjugate))
+- -+ | 1, I | | | | - I, PI | +- -+
>> delete A, L:
The following matrix is not positive definite:
>> A := array(1..2, 1..2, [[-2, sqrt(2)], [sqrt(2), 1]]):
>> numeric::factorCholesky(A)
Error: matrix is not positive definite within working precision\ [numeric::factorCholesky]
However, a symmetric factorization with a complex Cholesky factor does exist:
>> numeric::factorCholesky(A, Symmetric)
+- -+ | 1.414213562 I, 0 | | | | - 1.0 I, 1.414213562 | +- -+
>> delete A:
The option NoCheck should be used, when the matrix contains symbolic objects:
>> assume(x > 0): assume(z > 0):
>> A := array(1..2, 1..2, [[x, conjugate(y)], [y, z]]):
>> numeric::factorCholesky(A, Symbolic, NoCheck)
+- -+ | 1/2 | | x , 0 | | | | / 2 \1/2 | | y | abs(y) | | | ----, | z - ------- | | | 1/2 \ x / | | x | +- -+
Note that with NoCheck it is
assumed that the matrix is Hermitean and positive definite! All upper
triangular entries ignored. The following result implicitly assumes
u=conjugate(y)
:
>> A := array(1..2, 1..2, [[x, u], [y, z]]):
>> numeric::factorCholesky(A, Symbolic, NoCheck)
+- -+ | 1/2 | | x , 0 | | | | / 2 \1/2 | | y | abs(y) | | | ----, | z - ------- | | | 1/2 \ x / | | x | +- -+
>> delete A:
DOM_ARRAY
.