healpix_resample.psf.conjugate_gradient#

healpix_resample.psf.conjugate_gradient(A_mv, b, x0=None, max_iter=200, tol=1e-06, verbose=True, weight=None, preconditioner=None)[source]#

Solve A x = b with Conjugate Gradient, using only matvec A_mv(v).

preconditioner, if given, is the inverse of a positive diagonal (K,) (e.g. of A itself: Jacobi). A diagonal is self-adjoint in the weighted inner product as well, so the preconditioned iteration keeps the weighted Conjugate Gradient’s guarantees; it stops on the same weighted residual tol * |b|. Without it, the iteration is the plain one, unchanged. No autograd (uses torch.no_grad).

A_mv (as built by least_squares_cg() for PSFResampler) is self-adjoint and positive-definite with respect to the weighted inner product <u, v>_w = sum(u * v * weight) on the HEALPix-cell space (weight = per-cell column-weight Dx used to normalize M), not with respect to the plain Euclidean inner product. Pass weight so CG’s own dot products use the inner product the operator is actually SPD in — with weight=None (Euclidean), CG’s classical convergence guarantees do not formally apply to this operator, even though it often still behaves reasonably in practice.

Returns:

x – solution info: dict with residual norms history, iterations