Thermal-FIST  1.3
Package for hadron resonance gas model applications
Classes | Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
thermalfist::Broyden Class Reference

Class implementing the Broyden method to solve a system of non-linear equations. More...

#include <Broyden.h>

Classes

class  BroydenSolutionCriterium
 Sub-class where it is determined whether the required accuracy is achieved in the Broyden's method. More...
 

Public Member Functions

 Broyden (BroydenEquations *eqs=NULL, BroydenJacobian *jaco=NULL)
 Construct a new Broyden object. More...
 
virtual ~Broyden (void)
 Destroy the Broyden object. More...
 
virtual std::vector< double > Solve (const std::vector< double > &x0, BroydenSolutionCriterium *solcrit=NULL, int max_iterations=MAX_ITERS)
 
int Iterations () const
 
int MaxIterations () const
 
double MaxDifference () const
 
void UseNewton (bool flag)
 
bool UseNewton () const
 

Static Public Attributes

static const double TOL = 1.0E-10
 Default desired solution accuracy. More...
 
static const int MAX_ITERS = 200
 Maximum number of Broyden iterations before terminating. More...
 

Protected Attributes

BroydenEquationsm_Equations
 
BroydenJacobianm_Jacobian
 
int m_Iterations
 
int m_MaxIterations
 
double m_MaxDifference
 
bool m_UseNewton
 

Detailed Description

Class implementing the Broyden method to solve a system of non-linear equations.

Definition at line 131 of file Broyden.h.

Constructor & Destructor Documentation

thermalfist::Broyden::Broyden ( BroydenEquations eqs = NULL,
BroydenJacobian jaco = NULL 
)
inline

Construct a new Broyden object.

Parameters
eqsA pointer to BroydenEquations object which specifies the equations to be solved.
jacoA pointer to BroydenJacobian object which calulates the Jacobian matrix. If nullptr is passed then the Jacobian will be computed using finite differences.

Definition at line 197 of file Broyden.h.

virtual thermalfist::Broyden::~Broyden ( void  )
inlinevirtual

Destroy the Broyden object.

Definition at line 203 of file Broyden.h.

Member Function Documentation

int thermalfist::Broyden::Iterations ( ) const
inline

Returns number of Broyden/Newton iterations used to obtain the solution. Only meaningful to call this after the Solve() method was called. If Iterations() equals MaxIterations(), then the convergence was not achieved.

Returns
Number of Broyden/Newton iterations.

Definition at line 229 of file Broyden.h.

double thermalfist::Broyden::MaxDifference ( ) const
inline
Returns
Maximum deviation from zero of any of the equations.

Definition at line 239 of file Broyden.h.

int thermalfist::Broyden::MaxIterations ( ) const
inline
Returns
Maximum number of Broyden/Newton iterations.

Definition at line 234 of file Broyden.h.

std::vector< double > thermalfist::Broyden::Solve ( const std::vector< double > &  x0,
BroydenSolutionCriterium solcrit = NULL,
int  max_iterations = MAX_ITERS 
)
virtual

Solves the system of equations. Will use at most max_iterations iterations. Uses the Broyden's method by default, see https://en.wikipedia.org/wiki/Broyden%27s_method Will use the Newton's method https://en.wikipedia.org/wiki/Newton%27s_method if the corresponding flag was set with the UseNewton(bool) method.

Parameters
x0A vector of starting values of the variables.
solcritCriterium used to determine whether the desired accuracy is achieved.
max_iterationsMaximum number of iterations before the Broyden's method terminates.
Returns
std::vector<double> A vector of the variables' values which wolve the equations.

Definition at line 77 of file Broyden.cpp.

void thermalfist::Broyden::UseNewton ( bool  flag)
inline

Specify whether to use Newton's method instead of the Broyden's method. In the Newton's method the Jacobian will be re-evaluated from scrath at each iteration.

Parameters
flagUse Newton's method if true, use Broyden's method otherwise.

Definition at line 249 of file Broyden.h.

bool thermalfist::Broyden::UseNewton ( ) const
inline
Returns
true Newton's method is to be used
false Broyden's method is to be used

Definition at line 255 of file Broyden.h.

Member Data Documentation

BroydenEquations* thermalfist::Broyden::m_Equations
protected

Definition at line 258 of file Broyden.h.

int thermalfist::Broyden::m_Iterations
protected

Definition at line 260 of file Broyden.h.

BroydenJacobian* thermalfist::Broyden::m_Jacobian
protected

Definition at line 259 of file Broyden.h.

double thermalfist::Broyden::m_MaxDifference
protected

Definition at line 262 of file Broyden.h.

int thermalfist::Broyden::m_MaxIterations
protected

Definition at line 261 of file Broyden.h.

bool thermalfist::Broyden::m_UseNewton
protected

Definition at line 263 of file Broyden.h.

const int thermalfist::Broyden::MAX_ITERS = 200
static

Maximum number of Broyden iterations before terminating.

Definition at line 185 of file Broyden.h.

const double thermalfist::Broyden::TOL = 1.0E-10
static

Default desired solution accuracy.

Definition at line 183 of file Broyden.h.


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