pymoto.solvers.SolverDenseLDL

class pymoto.solvers.SolverDenseLDL(*args, hermitian=None, **kwargs)

Solver for Hermitian or symmetric matrices using an LDL factorization. Unlike SolverDenseCholesky, it is able to factorize (some, not all) indefinite matrices, as well as symmetric complex (thus non-Hermitian) matrices.

Requires scipy>=1.7

__init__(*args, hermitian=None, **kwargs)

Initialize the solver

Parameters:

A (matrix, optional) – Optionally provide a matrix, which is used in :method:`update` right away.

Methods

__init__(*args[, hermitian])

Initialize the solver

residual(A, x, b[, trans])

Calculates the (relative) residual of the linear system of equations

solve(rhs[, x0, trans])

Solves the linear system of equations \(\mathbf{A} \mathbf{x} = \mathbf{b}\) by forward and backward substitution of \(\mathbf{x} = \mathbf{L}^{-\text{H}}\mathbf{D}^{-1}\mathbf{L}^{-1}\mathbf{b}\) in the Hermitian case or as \(\mathbf{x} = \mathbf{L}^{-\text{T}}\mathbf{D}^{-1}\mathbf{L}^{-1}\mathbf{b}\) in the symmetric case.

update(A)

Factorize the matrix as \(\mathbf{A}=\mathbf{L}\mathbf{D}\mathbf{L}^{\text{H}}\) in case it is Hermitian, or as \(\mathbf{A}=\mathbf{L}\mathbf{D}\mathbf{L}^{\text{T}}\) if it is symmetric.

Attributes

defined

update(A)

Factorize the matrix as \(\mathbf{A}=\mathbf{L}\mathbf{D}\mathbf{L}^{\text{H}}\) in case it is Hermitian, or as \(\mathbf{A}=\mathbf{L}\mathbf{D}\mathbf{L}^{\text{T}}\) if it is symmetric. In the case matrix \(\mathbf{A}\) is real-valued, there is no difference between the two. The matrix \(\mathbf{L}\) is lower triangular and \(\mathbf{D}\) is a diagonal matrix.

solve(rhs, x0=None, trans='N')

Solves the linear system of equations \(\mathbf{A} \mathbf{x} = \mathbf{b}\) by forward and backward substitution of \(\mathbf{x} = \mathbf{L}^{-\text{H}}\mathbf{D}^{-1}\mathbf{L}^{-1}\mathbf{b}\) in the Hermitian case or as \(\mathbf{x} = \mathbf{L}^{-\text{T}}\mathbf{D}^{-1}\mathbf{L}^{-1}\mathbf{b}\) in the symmetric case.

The adjoint system of equations \(\mathbf{A}^\text{H} \mathbf{x} = \mathbf{b}\) is solved by forward and backward substitution of \(\mathbf{x} = \mathbf{L}^{-\text{H}}\mathbf{D}^{-\text{H}}\mathbf{L}^{-1}\mathbf{b}\) in the Hermitian case or as \(\mathbf{x} = \mathbf{L}^{-\text{H}}\mathbf{D}^{-\text{H}}\mathbf{L}^{-*}\mathbf{b}\) in the symmetric case.

The right-hand-side \(\mathbf{b}\) can be of size (N) or (N, K), where N is the size of matrix \(\mathbf{A}\) and K is the number of right-hand sides.

defined = True
static residual(A, x, b, trans='N')

Calculates the (relative) residual of the linear system of equations

The residual is calculated as \(r = \frac{\left| \mathbf{A} \mathbf{x} - \mathbf{b} \right|}{\left| \mathbf{b} \right|}\)

Parameters:
  • A – The matrix

  • x – Solution vector

  • b – Right-hand side

  • trans (optional) – Matrix tranformation (N is normal, T is transposed, H is hermitian transposed)

Returns:

Residual value