Template Class ConjugateGradient

Inheritance Relationships

Base Type

Class Documentation

template<class Matrix, class Preconditioner>
class ConjugateGradient : public NetworKit::LinearSolver<Matrix>

Implementation of Conjugate Gradient.

Public Functions

inline ConjugateGradient(double tolerance = 1e-5)
inline virtual void setup(const Matrix &matrix) override

Sets the solver up for the specified matrix.

Parameters:

matrix

inline virtual void setupConnected(const Matrix &matrix) override

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

Parameters:

matrix

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

Solves the linear system \(Ax = b\) using the conjugate gradient method with a given preconditioner and with initial value \((0, \dots, 0)^T\). We the return the solution \(x\). The solution \(x\) fulfils \(\frac{\Vert Ax - b\Vert}{\Vert b \Vert} \leq relative\_residual\) if the algorithm has converged.

Obviously, A needs to have the same number of rows as b and status.residual must be nonnegative. You may also request that the algorithm does not run for more than status.max_iters iterations.

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 override

Solves the linear systems in parallel.

Parameters:
  • rhs

  • results

  • maxConvergenceTime

  • maxIterations

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())

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