LinearSolver
- class cubie.integrators.matrix_free_solvers.LinearSolver(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], n: int, **kwargs)[source]
Bases:
MatrixFreeSolverFactory for linear solver device functions.
Implements steepest-descent or minimal-residual iterations for solving linear systems without forming Jacobian matrices.
- Parameters:
precision (PrecisionDType) – Numerical precision for computations.
n (int) – Length of residual and search-direction vectors.
**kwargs – Forwarded to
LinearSolverConfigand the norm factory. Includes prefixed tolerance parameters (krylov_atol,krylov_rtol).
See also
LinearSolverConfigConfiguration container for this factory.
MatrixFreeSolverParent class providing norm and tolerance management.
NewtonKrylovNewton–Krylov solver that owns a
LinearSolver.
- __init__(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], n: int, **kwargs) None[source]
Initialize LinearSolver with parameters.
- Parameters:
precision (PrecisionDType) – Numerical precision for computations.
n (int) – Length of residual and search-direction vectors.
**kwargs – Optional parameters passed to LinearSolverConfig. See LinearSolverConfig for available parameters. Tolerance parameters (krylov_atol, krylov_rtol) are passed to the norm factory. None values are ignored.
- build() LinearSolverCache[source]
Compile linear solver device function.
- Returns:
Container with compiled linear_solver device function.
- Return type:
- Raises:
ValueError – If operator_apply is None when build() is called.
- property settings_dict: Dict[str, Any]
Return linear solver configuration as dictionary.
Combines config settings with tolerance arrays from norm factory.
- Returns:
Configuration dictionary including krylov_atol and krylov_rtol from the norm factory.
- Return type:
- class cubie.integrators.matrix_free_solvers.LinearSolverConfig(precision: type[float16] | type[float32] | type[float64] | dtype[float16] | dtype[float32] | dtype[float64], instance_label: str = '', prefixed_attributes: Set[str] = NOTHING, n: int = 0, max_iters: int = 100, norm_device_function: Callable | None = None, operator_apply: Callable | None = None, preconditioner: Callable | None = None, linear_correction_type: str = 'minimal_residual', preconditioned_vec_location: str = 'local', temp_location: str = 'local', use_cached_auxiliaries: bool = False)[source]
Bases:
MatrixFreeSolverConfigConfiguration for LinearSolver compilation.
- precision
Numerical precision for computations.
- Type:
PrecisionDType
- norm_device_function
Compiled norm function for convergence checks.
- Type:
Optional[Callable]
- operator_apply
Device function applying operator F @ v.
- Type:
Optional[Callable]
- preconditioner
Device function for approximate inverse preconditioner.
- Type:
Optional[Callable]
- preconditioned_vec_location
Memory location for preconditioned_vec buffer (‘local’ or ‘shared’).
- Type:
Notes
Tolerance arrays (krylov_atol, krylov_rtol) are managed by the solver’s norm factory and accessed via LinearSolver.krylov_atol/krylov_rtol properties.