Paul Heidmann Fractal Example  1.0
fractal::newtonsMethod< floatType > Class Template Reference

This class implements Newton's method (the same one from your typical first year calculus class), to find zeros of complex valued functions (in the complex plain, obviously). More...

#include <newtonsMethod.hpp>

Collaboration diagram for fractal::newtonsMethod< floatType >:

Public Types

typedef std::complex< floatType > cmplxType
 This type is used to declare variables that hold complex numbers. More...
 
typedef std::function
< cmplxType(const cmplxType &)> 
funcType
 This type is used to declare variables that hold functions whose zeros are being found. More...
 

Public Member Functions

 newtonsMethod ()=delete
 
 newtonsMethod (const cmplxType &initialGuess, const funcType &f, const funcType &f_prime, const std::uint32_t maxIterations, const floatType &epsilon)
 This is the constructor that must be used to create instances of this class. More...
 
 ~newtonsMethod ()
 The class destructor. More...
 
const cmplxType findZero (std::uint32_t &numIters) const
 This method is called to find a zero of the given function, using the given initial guess. More...
 

Private Attributes

const cmplxType m_initialGuess
 This attribute holds the caller supplied initial guess. More...
 
const funcType m_f
 This attribute holds the function whose zero is to be found. More...
 
const funcType m_fPrime
 This attribute holds the derivative of the function whose zero is to be found. More...
 
const std::uint32_t m_maxIterations
 This attribute holds the maximum number of iterations allowed when searching for a zero. More...
 
const floatType m_epsilon
 This attribute holds the required accuracy (that is, tolerance). More...
 

Detailed Description

template<typename floatType>
class fractal::newtonsMethod< floatType >

This class implements Newton's method (the same one from your typical first year calculus class), to find zeros of complex valued functions (in the complex plain, obviously).

Template Parameters
floatTypeThe floating point type to be used in the underlying computations.
Author
Paul S. Heidmann

Definition at line 38 of file newtonsMethod.hpp.

Member Typedef Documentation

template<typename floatType >
typedef std::complex<floatType> fractal::newtonsMethod< floatType >::cmplxType

This type is used to declare variables that hold complex numbers.

Definition at line 44 of file newtonsMethod.hpp.

template<typename floatType >
typedef std::function<cmplxType(const cmplxType&)> fractal::newtonsMethod< floatType >::funcType

This type is used to declare variables that hold functions whose zeros are being found.

Definition at line 48 of file newtonsMethod.hpp.

Constructor & Destructor Documentation

template<typename floatType >
fractal::newtonsMethod< floatType >::newtonsMethod ( )
delete
template<typename floatType >
fractal::newtonsMethod< floatType >::newtonsMethod ( const cmplxType initialGuess,
const funcType f,
const funcType f_prime,
const std::uint32_t  maxIterations,
const floatType &  epsilon 
)
inline

This is the constructor that must be used to create instances of this class.

Parameters
initialGuessThe complex number that is to serve as the initial guess of the zero to be found.
fThe function whose zero is to be found.
f_primeThe derivative of the function whose zero is to be found.
maxIterationsThe maximum number of iterations that may be used by this implementation to find a zero.
epsilonThe required accuracy. The zero must be found within this tolerance.

Definition at line 63 of file newtonsMethod.hpp.

template<typename floatType >
fractal::newtonsMethod< floatType >::~newtonsMethod ( )
inline

The class destructor.

Definition at line 78 of file newtonsMethod.hpp.

Member Function Documentation

template<typename floatType >
const cmplxType fractal::newtonsMethod< floatType >::findZero ( std::uint32_t &  numIters) const
inline

This method is called to find a zero of the given function, using the given initial guess.

Parameters
numItersAn output parameter. The number of iterations actually required to find the given zero.
Returns
The zero found.

Definition at line 85 of file newtonsMethod.hpp.

References fractal::newtonsMethod< floatType >::m_epsilon, fractal::newtonsMethod< floatType >::m_f, fractal::newtonsMethod< floatType >::m_fPrime, fractal::newtonsMethod< floatType >::m_initialGuess, and fractal::newtonsMethod< floatType >::m_maxIterations.

Member Data Documentation

template<typename floatType >
const floatType fractal::newtonsMethod< floatType >::m_epsilon
private

This attribute holds the required accuracy (that is, tolerance).

Definition at line 125 of file newtonsMethod.hpp.

Referenced by fractal::newtonsMethod< floatType >::findZero().

template<typename floatType >
const funcType fractal::newtonsMethod< floatType >::m_f
private

This attribute holds the function whose zero is to be found.

Definition at line 114 of file newtonsMethod.hpp.

Referenced by fractal::newtonsMethod< floatType >::findZero().

template<typename floatType >
const funcType fractal::newtonsMethod< floatType >::m_fPrime
private

This attribute holds the derivative of the function whose zero is to be found.

Definition at line 118 of file newtonsMethod.hpp.

Referenced by fractal::newtonsMethod< floatType >::findZero().

template<typename floatType >
const cmplxType fractal::newtonsMethod< floatType >::m_initialGuess
private

This attribute holds the caller supplied initial guess.

Definition at line 111 of file newtonsMethod.hpp.

Referenced by fractal::newtonsMethod< floatType >::findZero().

template<typename floatType >
const std::uint32_t fractal::newtonsMethod< floatType >::m_maxIterations
private

This attribute holds the maximum number of iterations allowed when searching for a zero.

Definition at line 122 of file newtonsMethod.hpp.

Referenced by fractal::newtonsMethod< floatType >::findZero().


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