quantax.optimizer.auto_shift_eig#

quantax.optimizer.auto_shift_eig(rshift: float | None = None, ashift: float = 1e-06, dtype: str | type[Any] | dtype | SupportsDType | None = <class 'jax.numpy.float64'>) → Callable[[...], Array]#

Obtain the least-square minimum-norm solver for the linear equation \(Ax=b\) using diagonal shift. It automatically chooses between \(x = (A^† A)^{-1} A^† b\) and \(x = A^† (A A^†)^{-1} b\), which respectively correspond to SR and MinSR.

Given \(M = A^† A\) or \(M = A A^†\) of dimension \(n\), the diagonal shift modifies it to \(M' = M + \epsilon I\) for stable inversion, with \(\epsilon = \mathrm{Tr}(M) \times \mathrm{rshift} / \sqrt{n} + \mathrm{ashift}\).

Parameters:
  • rshift – The relative diagonal shift. Default to be \(10^{-12}\) for double precision and \(10^{-6}\) for single precision.

  • ashift – The absolute diagonal shift, default to 1e-6.

  • dtype – The dtype used internally in the solver, default to float64. Complex inputs use the complex counterpart, e.g. complex128 for float64. None keeps the dtype of the inputs.

Returns:

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