cloudy  trunk
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
iter_track_basic< T > Class Template Reference

#include <iter_track.h>

Collaboration diagram for iter_track_basic< T >:
Collaboration graph
[legend]

Public Member Functions

 iter_track_basic ()
 
void clear ()
 
next_val (T current, T next_est)
 

Static Public Attributes

static const int PREV_ITER =2
 

Private Member Functions

void p_clear1 ()
 

Private Attributes

p_lo_bound
 
p_hi_bound
 

Detailed Description

template<class T>
class iter_track_basic< T >

iter_track_basic is a lightweight version of iter_track designed to keep the state information to an absolute minimum (2 FP numbers). This is also why it is implemented as a template so that you can choose a single- or a double- precision version according to your needs.

when you are trying to iteratively converge a quantity using an algorithm some_func(), iter_track_basic will help you by establishing a bracket and performing a bisection search once the bracket is found. The reason for using this algorithm is that it can speed up convergence. Once the bracket is established, the width of the bracket is guaranteed to halve every iteration. Use it by replacing the following (oversimplified) code

realnum old, new; while( abs(old-new) > tol ) { old = new; new = some_func(old); }

with

iter_track_basic<realnum> tr; realnum old, new; while( abs(old-new) > tol ) { old = new; new = tr.next_val( old, some_func(old) ); }

the algorithm assumes that some_func() is well-behaved in the sense that when old < some_func(old) then also old < final, and when old > some_func(old) then also old > final, where "final" is the true converged value. These assumptions are used to establish a bracket. If these assumptions are violated, it may be impossible to converge onto the correct value!

Definition at line 231 of file iter_track.h.

Constructor & Destructor Documentation

template<class T>
iter_track_basic< T >::iter_track_basic ( )
inline

Definition at line 242 of file iter_track.h.

References iter_track_basic< T >::p_clear1().

Here is the call graph for this function:

Member Function Documentation

template<class T>
void iter_track_basic< T >::clear ( )
inline

Definition at line 246 of file iter_track.h.

References iter_track_basic< T >::p_clear1().

Here is the call graph for this function:

template<class T>
T iter_track_basic< T >::next_val ( current,
next_est 
)
inline
template<class T>
void iter_track_basic< T >::p_clear1 ( )
inlineprivate

Definition at line 235 of file iter_track.h.

References max(), min(), iter_track_basic< T >::p_hi_bound, and iter_track_basic< T >::p_lo_bound.

Referenced by iter_track_basic< T >::clear(), and iter_track_basic< T >::iter_track_basic().

Here is the call graph for this function:

Field Documentation

template<class T>
T iter_track_basic< T >::p_hi_bound
private
template<class T>
T iter_track_basic< T >::p_lo_bound
private
template<class T>
const int iter_track_basic< T >::PREV_ITER =2
static

Definition at line 264 of file iter_track.h.


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