pub struct SolverRegistry { /* private fields */ }Expand description
Registry for solver backends
Implementations§
Source§impl SolverRegistry
impl SolverRegistry
pub fn new() -> Self
pub fn register(&mut self, factory: Box<dyn LinearSolverFactory>)
pub fn get(&self, name: &str) -> Option<&dyn LinearSolverFactory>
pub fn list(&self) -> Vec<String>
Sourcepub fn list_sorted(&self) -> Vec<String>
pub fn list_sorted(&self) -> Vec<String>
Registered solver names, sorted (deterministic).
pub fn create(&self, name: &str) -> Option<Box<dyn LinearSolver>>
Sourcepub fn validate_selection(
&self,
name: &str,
matrix: &SparseMatrix,
) -> Result<SolverCapabilities, SolverError>
pub fn validate_selection( &self, name: &str, matrix: &SparseMatrix, ) -> Result<SolverCapabilities, SolverError>
Validate that the named backend can legally handle matrix, returning
its capabilities on success. Performs no factorization.
§Errors
SolverError::Unsupportedif the name is unknown or the matrix class is incompatible with the backend.SolverError::InvalidInputfor an empty matrix.
Sourcepub fn select(
&self,
matrix: &SparseMatrix,
selection: &SolverSelection,
) -> Result<SolverSelectionInfo, SolverError>
pub fn select( &self, matrix: &SparseMatrix, selection: &SolverSelection, ) -> Result<SolverSelectionInfo, SolverError>
Decide which backend would be used, without constructing or factorizing anything. Answers “which solver, and why?”.
§Errors
Returns an error for an unknown explicit name, an incompatible matrix
class, an empty matrix, or (for Auto) when no suitable backend exists.
Sourcepub fn auto_select_info(
&self,
matrix: &SparseMatrix,
) -> Result<SolverSelectionInfo, SolverError>
pub fn auto_select_info( &self, matrix: &SparseMatrix, ) -> Result<SolverSelectionInfo, SolverError>
The auto-selection policy, exposed as a decision (name + reason).
Policy (conservative; never selects a solver that cannot handle the detected matrix class):
n <= 500→dense(general, any class).- symmetric with a positive diagonal (necessary condition for SPD) and
within skyline’s size limit →
skyline_ldlt(it verifies definiteness at factorization). - otherwise →
sparse_lu(general; handles symmetric or not).
Auto never selects cg/iccg. Unlike explicit selection, auto does not
hard-reject on max_size: it treats the limit as a preference and still
returns the only class-legal backend for very large systems.
cg/iccg are never auto-selected: their SPD requirement cannot be
established reliably from the matrix alone.
Sourcepub fn create_selected(
&self,
matrix: &SparseMatrix,
selection: &SolverSelection,
) -> Result<Box<dyn LinearSolver>, SolverError>
pub fn create_selected( &self, matrix: &SparseMatrix, selection: &SolverSelection, ) -> Result<Box<dyn LinearSolver>, SolverError>
Construct a solver for selection, after capability validation.
Explicit selections are authoritative: if the requested backend cannot
legally handle the matrix (or is unknown / uncreatable), an error is
returned and no other backend is substituted. Auto may pick any
backend that can handle the matrix class.
The solver is returned unfactored — the caller calls
LinearSolver::factor then LinearSolver::solve.
Sourcepub fn auto_select(
&self,
matrix: &SparseMatrix,
) -> Option<Box<dyn LinearSolver>>
pub fn auto_select( &self, matrix: &SparseMatrix, ) -> Option<Box<dyn LinearSolver>>
Backwards-compatible automatic selection: returns the chosen solver, or
None if none is registered. Prefer Self::select /
Self::create_selected for new code.