Template Class LinearSolver

Inheritance Relationships

Derived Types

Class Documentation

template<class Matrix>
class LinearSolver

Abstract base class for solvers that solve linear systems.

Subclassed by NetworKit::ConjugateGradient< Matrix, Preconditioner >, NetworKit::Lamg< Matrix >

Public Functions

inline LinearSolver(const double tolerance)

Construct an abstract solver with the given tolerance. The relative residual ||Ax-b||/||b|| should be less than or equal to tolerance after the solver finished.

Parameters:

tolerance

virtual ~LinearSolver() = default
virtual void setup(const Matrix &matrix) = 0

Sets the solver up for the specified matrix.

Parameters:

matrix

virtual void setup(const Graph &graph)

Sets the solver up for the Laplacian matrix of the graph specified.

Parameters:

graph

virtual void setupConnected(const Matrix &matrix) = 0

Sets the solver up for the specified matrix where the underlying graph has to be connected.

Parameters:

matrix

virtual void setupConnected(const Graph &graph)

Sets the solver up for the Laplacian matrix of the graph specified. The graph has to be connected.

Parameters:

graph

virtual SolverStatus solve(const Vector &rhs, Vector &result, count maxConvergenceTime = 5 * 60 * 1000, count maxIterations = std::numeric_limits<count>::max()) const = 0

Abstract solve function that computes result for the given right-hand side rhs and the matrix that has been setup in setup.

Parameters:
  • rhs

  • result

  • maxConvergenceTime

  • maxIterations

Returns:

A SolverStatus object which provides some statistics like the final absolute residual.

virtual std::vector<SolverStatus> parallelSolve(const std::vector<Vector> &rhs, std::vector<Vector> &results, count maxConvergenceTime = 5 * 60 * 1000, count maxIterations = std::numeric_limits<count>::max()) const

Abstract parallel solve function that computes the results for the matrix currently setup and the right-hand sides rhs. The maximum spent time for each system can be specified by maxConvergenceTime and the maximum number of iterations can be set by maxIterations.

Note

If the solver does not support parallelism during solves, this function falls back to solving the systems sequentially.

Parameters:
  • rhs

  • results

  • maxConvergenceTime

  • maxIterations

Returns:

A vector of SolverStatus objects for each right hand side.

template<typename RHSLoader, typename ResultProcessor>
inline void parallelSolve(const RHSLoader &rhsLoader, const ResultProcessor &resultProcessor, std::pair<count, count> rhsSize, count maxConvergenceTime = 5 * 60 * 1000, count maxIterations = std::numeric_limits<count>::max()) const

Abstract parallel solve function that computes and processes results using resultProcessor for the matrix currently setup and the right-hand sides (size of rhsSize) provided by rhsLoader. The maximum spent time for each system can be specified by maxConvergenceTime and the maximum number of iterations can be set by maxIterations.

Note

If the solver does not support parallelism during solves, this function falls back to solving the systems sequentially.

Parameters:
  • rhsLoader

  • resultProcessor

  • rhsSize

  • maxConvergenceTime

  • maxIterations

Protected Attributes

double tolerance