quantax.optimizer.lsmr#

quantax.optimizer.lsmr(rtol: float = 0.1, atol: float = 0.0, maxiter: int = 500, dtype: str | type[Any] | dtype | SupportsDType | None = None) → 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_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 0.1. It is divided by the number of samples \(n\), i.e. the number of rows of \(A\), before being passed to lineax.LSMR, so the effective tolerance \(\mathrm{rtol}/n\) tightens as the sample size grows. As the solution is regularized by early stopping, rtol also controls the strength of the regularization.

    Warning

    In single precision the internal residual estimate of LSMR is optimistic: the true relative residual \(\|Ax-b\| / \|b\|\) is typically about two orders of magnitude larger than the effective tolerance \(\mathrm{rtol}/n\) 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. Like rtol, it is divided by the number of samples \(n\).

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

  • dtype – The precision used internally in the LSMR iteration. By default (None) the dtype of the inputs is kept. Complex inputs use the complex counterpart, e.g. complex64 for float32. Pass dtype=jnp.float64 for a more accurate solution at a higher cost.

Returns:

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