quantax.optimizer.lsmr#

quantax.optimizer.lsmr(rtol: float = 0.0001, atol: float = 0.0, maxiter: int = 500) → Callable[[...], Array]#

Obtain the least-square solver for the linear equation \(Ax=b\) solved by the LSMR method lineax.LSMR.

LSMR is applied to the pure least-square problem \(\min_x \|Ax - b\|^2\) without a diagonal shift. The solution is regularized by early stopping instead: the Krylov space is built from \(b\), so the iteration only explores the dominant singular directions that \(b\) excites and never amplifies the small, noise-dominated directions before the residual tolerance is reached. Working on \(A\) directly rather than \(A^† A\) keeps the effective condition number squared smaller, which is numerically more stable than lstsq_shift_cg, especially in single precision. This solver gives the same solution regardless of whether the problem is over- or under-determined.

Parameters:
  • rtol –

    The relative tolerance for terminating the LSMR iteration, default to 1e-4.

    Warning

    For single-precision inputs the internal residual estimate of LSMR is optimistic: the true relative residual \(\|Ax-b\| / \|b\|\) is typically about two orders of magnitude larger than rtol at termination. Choose rtol accordingly, or verify the residual with one extra matrix-vector product after solving.

  • atol – The absolute tolerance for terminating the LSMR iteration, default to 0.

  • maxiter – The maximum number of LSMR iterations, default to 500.

Returns:

A solver function with two arguments A and b and one output x as the solution of \(A x = b\).