CG_solver Class Reference

#include <CG_solver.h>

Public Member Functions

 CG_solver ()
 
 ~CG_solver ()
 
int init (int N, scalar tol, int max_num_iterations)
 
int solve (SparseMatrixFixedPattern *A, scalar *x, scalar *b)
 
int solve (SparseMatrixFixedPattern *A, scalar *x, scalar *b, int num_iterations)
 

Private Member Functions

scalar conjugate_gradient_residual (SparseMatrixFixedPattern *A, scalar *x, scalar *b)
 
scalar residual2 ()
 
void parallel_vector_add_self (scalar *v1, scalar a, scalar *v2)
 
void parallel_vector_add (scalar *v1, scalar a, scalar *v2)
 
scalar parallel_apply_preconditioner ()
 
void zero (scalar *v)
 
scalar dot (scalar *a, scalar *b)
 

Private Attributes

int N
 The number of unknowns. More...
 
scalar tol
 The convergence tolerance threshold. More...
 
int max_num_iterations
 Maximum number of iterations before giving up. More...
 
scalarinv_M
 The preconditioner matrix (inverse of the diagonal) More...
 
scalard
 Vector needed for use by conjugate gradient solver. More...
 
scalarr
 Vector needed for use by conjugate gradient solver. More...
 
scalarq
 Vector needed for use by conjugate gradient solver. More...
 
scalars
 Vector needed for use by conjugate gradient solver. More...
 

Constructor & Destructor Documentation

◆ CG_solver()

CG_solver::CG_solver ( )

◆ ~CG_solver()

CG_solver::~CG_solver ( )

Member Function Documentation

◆ conjugate_gradient_residual()

scalar CG_solver::conjugate_gradient_residual ( SparseMatrixFixedPattern A,
scalar x,
scalar b 
)
private

Referenced by solve().

◆ dot()

scalar CG_solver::dot ( scalar a,
scalar b 
)
private

Returns the dot product of vectors a and b, of length N

Referenced by solve().

◆ init()

int CG_solver::init ( int  N,
scalar  tol,
int  max_num_iterations 
)

Referenced by Blob::init().

◆ parallel_apply_preconditioner()

scalar CG_solver::parallel_apply_preconditioner ( )
private

Referenced by solve().

◆ parallel_vector_add()

void CG_solver::parallel_vector_add ( scalar v1,
scalar  a,
scalar v2 
)
private

Referenced by solve().

◆ parallel_vector_add_self()

void CG_solver::parallel_vector_add_self ( scalar v1,
scalar  a,
scalar v2 
)
private

Referenced by solve().

◆ residual2()

scalar CG_solver::residual2 ( )
private

Referenced by solve().

◆ solve() [1/2]

int CG_solver::solve ( SparseMatrixFixedPattern A,
scalar x,
scalar b 
)

Referenced by Blob::solve_poisson().

◆ solve() [2/2]

int CG_solver::solve ( SparseMatrixFixedPattern A,
scalar x,
scalar b,
int  num_iterations 
)

◆ zero()

void CG_solver::zero ( scalar v)
private

Referenced by init().

Field Documentation

◆ d

scalar* CG_solver::d
private

Vector needed for use by conjugate gradient solver.

Referenced by CG_solver(), conjugate_gradient_residual(), init(), solve(), and ~CG_solver().

◆ inv_M

scalar* CG_solver::inv_M
private

The preconditioner matrix (inverse of the diagonal)

Referenced by CG_solver(), conjugate_gradient_residual(), init(), parallel_apply_preconditioner(), solve(), and ~CG_solver().

◆ max_num_iterations

int CG_solver::max_num_iterations
private

Maximum number of iterations before giving up.

Referenced by CG_solver(), init(), solve(), and ~CG_solver().

◆ N

◆ q

scalar* CG_solver::q
private

Vector needed for use by conjugate gradient solver.

Referenced by CG_solver(), init(), solve(), and ~CG_solver().

◆ r

scalar* CG_solver::r
private

Vector needed for use by conjugate gradient solver.

Referenced by CG_solver(), conjugate_gradient_residual(), init(), parallel_apply_preconditioner(), residual2(), solve(), and ~CG_solver().

◆ s

scalar* CG_solver::s
private

Vector needed for use by conjugate gradient solver.

Referenced by CG_solver(), init(), parallel_apply_preconditioner(), solve(), and ~CG_solver().

◆ tol

scalar CG_solver::tol
private

The convergence tolerance threshold.

Referenced by CG_solver(), init(), solve(), and ~CG_solver().


The documentation for this class was generated from the following files: