Class SUNLinSolWrapper

Inheritance Relationships

Derived Types

Class Documentation

class amici::SUNLinSolWrapper

A RAII wrapper for SUNLinearSolver structs.

For details on member functions see documentation in sunlinsol/sundials_linearsolver.h.

Subclassed by amici::SUNLinSolBand, amici::SUNLinSolDense, amici::SUNLinSolKLU, amici::SUNLinSolPCG, amici::SUNLinSolSPBCGS, amici::SUNLinSolSPFGMR, amici::SUNLinSolSPGMR, amici::SUNLinSolSPTFQMR

Public Functions

SUNLinSolWrapper() = default
SUNLinSolWrapper(SUNLinearSolver linsol)

Wrap existing SUNLinearSolver.

Parameters
  • linsol:

~SUNLinSolWrapper()
SUNLinSolWrapper(const SUNLinSolWrapper &other) = delete

Copy constructor.

Parameters
  • other:

SUNLinSolWrapper(SUNLinSolWrapper &&other) noexcept

Move constructor.

Parameters
  • other:

SUNLinSolWrapper &operator=(const SUNLinSolWrapper &other) = delete

Copy assignment.

Return

Parameters
  • other:

SUNLinSolWrapper &operator=(SUNLinSolWrapper &&other) noexcept

Move assignment.

Return

Parameters
  • other:

SUNLinearSolver get() const

Returns the wrapped SUNLinSol.

Return

SUNLinearSolver

SUNLinearSolver_Type getType() const

Returns an identifier for the linear solver type.

Return

void setup(SUNMatrix A) const

Performs any linear solver setup needed, based on an updated system matrix A.

Parameters
  • A:

void setup(const SUNMatrixWrapper &A) const

Performs any linear solver setup needed, based on an updated system matrix A.

Parameters
  • A:

int Solve(SUNMatrix A, N_Vector x, N_Vector b, realtype tol) const

Solves a linear system A*x = b.

Return

error flag

Parameters
  • A:

  • x: A template for cloning vectors needed within the solver.

  • b:

  • tol: Tolerance (weighted 2-norm), iterative solvers only

long int getLastFlag() const

Returns the last error flag encountered within the linear solver.

Return

error flag

int space(long int *lenrwLS, long int *leniwLS) const

Returns the integer and real workspace sizes for the linear solver.

Return

workspace size

Parameters
  • lenrwLS: output argument for size of real workspace

  • leniwLS: output argument for size of integer workspace

SUNMatrix getMatrix() const

Get the matrix A (matrix solvers only).

Return

A

Protected Functions

int initialize()

Performs linear solver initialization (assumes that all solver-specific options have been set).

Return

error code

Protected Attributes

SUNLinearSolver solver_ = {nullptr}

Wrapped solver