SymmetricMatrixBasedSolver

class probnum.linalg.SymmetricMatrixBasedSolver(A, b, A0=None, Ainv0=None, x0=None)[source]

Bases: probnum.linalg.MatrixBasedSolver

Symmetric matrix-based probabilistic linear solver.

Implements the solve iteration of the symmetric matrix-based probabilistic linear solver described in [1] and [2].

Parameters:
  • A (array-like or LinearOperator or RandomVariable, shape=(n,n)) – The square matrix or linear operator of the linear system.
  • b (array_like, shape=(n,) or (n, nrhs)) – Right-hand side vector or matrix in \(A x = b\).
  • A0 (array-like or LinearOperator or RandomVariable, shape=(n, n), optional) – A square matrix, linear operator or random variable representing the prior belief over the linear operator \(A\). If an array or linear operator is given, a prior distribution is chosen automatically.
  • Ainv0 (array-like or LinearOperator or RandomVariable, shape=(n,n), optional) – A square matrix, linear operator or random variable representing the prior belief over the inverse \(H=A^{-1}\). This can be viewed as taking the form of a pre-conditioner. If an array or linear operator is given, a prior distribution is chosen automatically.
  • x0 (array-like, or RandomVariable, shape=(n,) or (n, nrhs)) – Optional. Prior belief for the solution of the linear system. Will be ignored if Ainv0 is given.
Returns:

  • A (RandomVariable) – Posterior belief over the linear operator.
  • Ainv (RandomVariable) – Posterior belief over the inverse linear operator.
  • x (RandomVariable) – Posterior belief over the solution of the linear system.
  • info (dict) – Information about convergence and the solution.

References

[1]Wenger, J. and Hennig, P., Probabilistic Linear Solvers for Machine Learning, 2020
[2]Hennig, P., Probabilistic Interpretation of Linear Solvers, SIAM Journal on Optimization, 2015, 25, 234-260

See also

NoisySymmetricMatrixBasedSolver
Class implementing the noisy symmetric probabilistic linear solver.

Methods Summary

has_converged(iter, maxiter[, resid, atol, rtol]) Check convergence of a linear solver.
solve([callback, maxiter, atol, rtol, …]) Solve the linear system \(Ax=b\).

Methods Documentation

has_converged(iter, maxiter, resid=None, atol=None, rtol=None)[source]

Check convergence of a linear solver.

Evaluates a set of convergence criteria based on its input arguments to decide whether the iteration has converged.

Parameters:
  • iter (int) – Current iteration of solver.
  • maxiter (int) – Maximum number of iterations
  • resid (array-like) – Residual vector \(\lVert r_i \rVert = \lVert Ax_i - b \rVert\) of the current iteration.
  • atol (float) – Absolute residual tolerance. Stops if \(\min(\lVert r_i \rVert, \sqrt{\operatorname{tr}(\operatorname{Cov}(x))}) \leq \text{atol}\).
  • rtol (float) – Relative residual tolerance. Stops if \(\min(\lVert r_i \rVert, \sqrt{\operatorname{tr}(\operatorname{Cov}(x))}) \leq \text{rtol} \lVert b \rVert\).
Returns:

  • has_converged (bool) – True if the method has converged.
  • convergence_criterion (str) – Convergence criterion which caused termination.

solve(callback=None, maxiter=None, atol=None, rtol=None, calibration=None)[source]

Solve the linear system \(Ax=b\).

Parameters:
  • callback (function, optional) – User-supplied function called after each iteration of the linear solver. It is called as callback(xk, Ak, Ainvk, sk, yk, alphak, resid) and can be used to return quantities from the iteration. Note that depending on the function supplied, this can slow down the solver.
  • maxiter (int) – Maximum number of iterations
  • atol (float) – Absolute residual tolerance. Stops if \(\min(\lVert r_i \rVert, \sqrt{\operatorname{tr}(\operatorname{Cov}(x))}) \leq \text{atol}\).
  • rtol (float) – Relative residual tolerance. Stops if \(\min(\lVert r_i \rVert, \sqrt{\operatorname{tr}(\operatorname{Cov}(x))}) \leq \text{rtol} \lVert b \rVert\).
  • calibration (str or float, default=False) –

    If supplied calibrates the output via the given procedure or uncertainty scale. Available calibration procedures / choices are

    No calibration None
    Provided scale float
    Most recent Rayleigh quotient adhoc
    Running (weighted) mean weightedmean
    GP regression for kernel matrices gpkern
Returns:

  • x (RandomVariable, shape=(n,) or (n, nrhs)) – Approximate solution \(x\) to the linear system. Shape of the return matches the shape of b.
  • A (RandomVariable, shape=(n,n)) – Posterior belief over the linear operator.calibrate
  • Ainv (RandomVariable, shape=(n,n)) – Posterior belief over the linear operator inverse \(H=A^{-1}\).
  • info (dict) – Information on convergence of the solver.