pymoto.solvers.SolverDenseQR
- class pymoto.solvers.SolverDenseQR(A=None)
Solver for dense (square) matrices using a QR decomposition
- __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 using the QR factorization.
update(A)Factorize the matrix as \(\mathbf{A}=\mathbf{Q}\mathbf{R}\), where \(\mathbf{Q}\) is orthogonal (\(\mathbf{Q}^\text{H}=\mathbf{Q}^{-1}\)) and \(\mathbf{R}\) is upper triangular.
Attributes
- update(A)
Factorize the matrix as \(\mathbf{A}=\mathbf{Q}\mathbf{R}\), where \(\mathbf{Q}\) is orthogonal (\(\mathbf{Q}^\text{H}=\mathbf{Q}^{-1}\)) and \(\mathbf{R}\) is upper triangular.
- solve(rhs, x0=None, trans='N')
Solves the linear system of equations using the QR factorization.
trans
Equation
Solution of \(x\)
N
\(A x = b\)
\(R^{-1} Q^H b\)
T
\(A^T x = b\)
\(Q^* R^{-T} b\)
H
\(A^H x = b\)
\(Q R^{-H} b\)
The right-hand-side \(\mathbf{b}\) can be of size
(N)or(N, K), whereNis the size of matrix \(\mathbf{A}\) andKis 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