Utilities#

pytential.solve.gmres(op: Callable[[ArrayOrContainerT], ArrayOrContainerT], rhs: ArrayOrContainerT, restart: Optional[int] = None, tol: Optional[float] = None, x0: Optional[ArrayOrContainerT] = None, inner_product: Optional[Callable[[ArrayOrContainerT, ArrayOrContainerT], float]] = None, maxiter: Optional[int] = None, hard_failure: Optional[bool] = None, no_progress_factor: Optional[float] = None, stall_iterations: Optional[int] = None, callback: Optional[Callable[[ArrayOrContainerT], None]] = None, progress: bool = False, require_monotonicity: bool = True) GMRESResult[source]#

Solve a linear system \(Ax = b\) using GMRES with restarts.

Parameters:
  • op – a callable to evaluate \(A(x)\).

  • rhs – the right hand side \(b\).

  • restart – the maximum number of iteration after which GMRES algorithm needs to be restarted

  • tol – the required decrease in residual norm (relative to the rhs).

  • x0 – an initial guess for the iteration (a zero array is used by default).

  • inner_product – a callable with an interface compatible with numpy.vdot() that returns a host scalar.

  • maxiter – the maximum number of iterations permitted.

  • hard_failure – if True, raise GMRESError in case of failure.

  • stall_iterations – number of iterations with residual decrease below no_progress_factor indicates stall. Set to 0 to disable stall detection.

Returns:

a GMRESResult.

class pytential.solve.GMRESResult(solution: ArrayContainer, residual_norms: Sequence[float], iteration_count: int, success: bool, state: str)[source]#
solution#
residual_norms#
iteration_count#
success#

A bool indicating whether the iteration succeeded.

state#

A description of the outcome.

exception pytential.solve.GMRESError[source]#
class pytential.solve.ResidualPrinter(inner_product=<function structured_vdot>)[source]#