NumCpp  2.12.1
A Templatized Header Only C++ Implementation of the Python NumPy Library
nc::roots::Newton Class Reference

#include <Newton.hpp>

Inherits nc::roots::Iteration.

Public Member Functions

 Newton (const double epsilon, const uint32 maxNumIterations, std::function< double(double)> f, std::function< double(double)> fPrime) noexcept
 
 Newton (const double epsilon, std::function< double(double)> f, std::function< double(double)> fPrime) noexcept
 
 ~Newton () noexcept override=default
 
uint32 numIterations () const noexcept
 
double solve (double x)
 

Protected Member Functions

void incrementNumberOfIterations ()
 
void resetNumberOfIterations () noexcept
 

Protected Attributes

const double epsilon_
 
uint32 maxNumIterations_ { 1000 }
 
uint32 numIterations_ { 0 }
 

Detailed Description

Newton root finding method

Constructor & Destructor Documentation

◆ Newton() [1/2]

nc::roots::Newton::Newton ( const double  epsilon,
std::function< double(double)>  f,
std::function< double(double)>  fPrime 
)
inlinenoexcept

Constructor

Parameters
epsilonthe epsilon value
fthe function
fPrimethe derivative of the function

◆ Newton() [2/2]

nc::roots::Newton::Newton ( const double  epsilon,
const uint32  maxNumIterations,
std::function< double(double)>  f,
std::function< double(double)>  fPrime 
)
inlinenoexcept

Constructor

Parameters
epsilonthe epsilon value
maxNumIterationsthe maximum number of iterations to perform
fthe function
fPrimethe derivative of the function

◆ ~Newton()

nc::roots::Newton::~Newton ( )
overridedefaultnoexcept

Destructor

Member Function Documentation

◆ incrementNumberOfIterations()

void nc::roots::Iteration::incrementNumberOfIterations ( )
inlineprotectedinherited

Incraments the number of iterations

◆ numIterations()

uint32 nc::roots::Iteration::numIterations ( ) const
inlinenoexceptinherited

Returns the number of iterations

Returns
: number of iterations

◆ resetNumberOfIterations()

void nc::roots::Iteration::resetNumberOfIterations ( )
inlineprotectednoexceptinherited

Resets the number of iterations

◆ solve()

double nc::roots::Newton::solve ( double  x)
inline

Solves for the root in the range [a, b]

Parameters
xthe starting point
Returns
root nearest the starting point

Field Documentation

◆ epsilon_

const double nc::roots::Iteration::epsilon_
protectedinherited

◆ maxNumIterations_

uint32 nc::roots::Iteration::maxNumIterations_ { 1000 }
protectedinherited

◆ numIterations_

uint32 nc::roots::Iteration::numIterations_ { 0 }
protectedinherited

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