pymoto.solvers.SolverSparseLU
- class pymoto.solvers.SolverSparseLU(A=None)
Solver for sparse (square) matrices using an LU decomposition.
Internally, scipy uses the SuperLU library, which is relatively slow. It may be sped up using the Python package
scikit-umfpack, which scipy` is able to use, but must be installed by the user.References
- __init__(A=None)
Initialize the solver
- Parameters:
A (matrix, optional) – Optionally provide a matrix, which is used in :method:`update` right away.
Methods
__init__([A])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{U}^{-1}\mathbf{L}^{-1}\mathbf{b}\).
update(A)Factorize the matrix as \(\mathbf{A}=\mathbf{L}\mathbf{U}\), where \(\mathbf{L}\) is a lower triangular matrix and \(\mathbf{U}\) is upper triangular.
Attributes
- update(A)
Factorize the matrix as \(\mathbf{A}=\mathbf{L}\mathbf{U}\), where \(\mathbf{L}\) is a lower triangular matrix and \(\mathbf{U}\) is upper triangular.
- 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{U}^{-1}\mathbf{L}^{-1}\mathbf{b}\).
Adjoint system solves the linear system of equations \(\mathbf{A}^\text{H}\mathbf{x} = \mathbf{b}\) by forward and backward substitution of \(\mathbf{x} = \mathbf{L}^{-\text{H}}\mathbf{U}^{-\text{H}}\mathbf{b}\)
- 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