Class ostk::astrodynamics::RootSolver

class RootSolver

A Root Solver is a method for finding the roots (a.k.a. zeros) of an equation.

Public Functions

RootSolver(const Size &aMaximumIterationCount, const Real &aTolerance)

Constructor.

RootSolver rootSolver = {aMaximumIterationCount, aTolerance};
Parameters:
  • aMaximumIterationCount -- The maximum iteration count for the solver

  • aTolerance -- The tolerance

virtual ~RootSolver()

Virtual destructor.

Size getMaximumIterationCount() const

Get maximum iterations count.

Returns:

Maximum iterations count

Real getTolerance() const

Get number of digits of precision.

Returns:

Number of digits of precision

Solution bracketAndSolve(const std::function<double(const double&)> &aFunction, const double &anInitialGuess, const bool &isRising, const double &aFactor = 2.0) const

Solve for root given a function, an initial guess and function direction.

Parameters:
  • aFunction -- A function

  • anInitialGuess -- An initial guess

  • isRising -- A boolean indicating whether the function is rising

  • (optional) -- aFactor A factor

Returns:

The solution

Solution solve(const std::function<double(const double&)> &aFunction, const double &aLowerBound, const double &anUpperBound) const

Solve for root given a function, and bounds.

Parameters:
  • aFunction -- A function

  • aLowerBound -- A lower bound

  • anUpperBound -- An upper bound

Returns:

The solution

Solution bisection(const std::function<double(const double&)> &aFunction, const double &aLowerBound, const double &anUpperBound) const

Bisection solve for root given a function, and bounds.

Parameters:
  • aFunction -- A function

  • aLowerBound -- A lower bound

  • anUpperBound -- An upper bound

Returns:

The solution

void print(std::ostream &anOutputStream, bool displayDecorator = true) const

Print root solver.

Parameters:
  • anOutputStream -- An output stream

  • (optional) -- displayDecorators If true, display decorators

Public Static Functions

static RootSolver Default()

Default root solver.

Returns:

Default root solver

Friends

friend std::ostream &operator<<(std::ostream &anOutputStream, const RootSolver &aRootSolver)

Output stream operator.

Parameters:
  • anOutputStream -- An output stream

  • aRootSolver -- A Root Solver

Returns:

An output stream

struct Solution

Public Members

Real root
Size iterationCount
bool hasConverged