conjugate_gradient.py 🚧¢

Source: LION/classical_algorithms/conjugate_gradient.py

Warning

This file has not yet received a complete narrative and docstring audit. Its public source-level API is listed automatically below.

Conjugate gradient solver

conjugate_gradient(matmul_closure: Callable[[torch.Tensor], torch.Tensor], d: torch.Tensor, x0: torch.Tensor, max_iter: int, tol: float) torch.Tensor

Conjugate gradient solver.

Parameters β€”β€”β€”- matmul_closure : Callable[[torch.Tensor], torch.Tensor] A function that performs the matrix-vector multiplication. d : torch.Tensor The right-hand side vector. x0 : torch.Tensor The initial guess for the solution. max_iter : int Maximum number of iterations. tol : float Tolerance for convergence.

Returns β€”β€”- torch.Tensor The approximate solution vector.