QuOc

 

Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

aol::DerivativeValidatorBase< RealType, VecType > Class Template Reference

#include <gradientflow.h>

Inheritance diagram for aol::DerivativeValidatorBase< RealType, VecType >:
aol::FirstDerivativeValidator< VecType, DerivativeType, RealType >

List of all members.

Public Types

enum  StepSizeFunctionType { LINEAR, EXPONENTIAL }

Public Member Functions

 DerivativeValidatorBase (const RealType H, StepSizeFunctionType stepsizeFctType, const RealType StepSize, const RealType StepSizeMin, const RealType StepSizeMax)
void setSkipPlottingWithSmallError (const bool SkipPlottingWithSmallError)
void setSkippingThreshold (const RealType SkippingThreshold)
void setCatchCtrlC (bool catchCtrlC)
void setMask (const BitVector &mask)
void unsetMask ()
const BitVectorgetMask () const
void setNegRate (const RealType negRate)
 set parameter negRate which is passed to validateAndPlotToPNG

Protected Member Functions

int buildPositionsVector (aol::Vector< RealType > &Positions) const
 fill passed vector with values at which the difference quotients will be evaluated.
aol::Vec< VecType::Depth, intsetIthComponent (const int I, const RealType Value, VecType &Vec) const
string getSuffixString (const aol::Vec< VecType::Depth, int > &idxVec) const
bool wantsToCheckEntry (const int I) const
 checks if mask is stored. If so, checks I'th entry.
void setCtrlCHandler () const
void unsetCtrlCHandler () const
bool wantsInterrupt () const

Protected Attributes

const RealType _h
const StepSizeFunctionType _stepSizeFctType
const RealType _stepSize
const RealType _stepSizeMin
const RealType _stepSizeMax
bool _resizePositionVector
bool _skipPlottingWithSmallError
RealType _skippingThreshold
aol::Vector< RealType > _positions
const BitVector_maskPtr
bool _catchCtrlC
RealType _negRate
sigfunc _previousCtrlCHandler

Detailed Description

template<typename RealType, typename VecType>
class aol::DerivativeValidatorBase< RealType, VecType >

Class that collects the code shared by FirstDerivativeValidator and SecondDerivativeValidator.

Author:
Berkels

Definition at line 661 of file gradientflow.h.


Member Enumeration Documentation

template<typename RealType, typename VecType>
enum aol::DerivativeValidatorBase::StepSizeFunctionType
Enumerator:
LINEAR 
EXPONENTIAL 

Reimplemented in aol::FirstDerivativeValidator< VecType, DerivativeType, RealType >, and aol::SecondDerivativeValidator< VecType, SecondDerivativeType >.

Definition at line 663 of file gradientflow.h.

{ LINEAR, EXPONENTIAL };


Constructor & Destructor Documentation

template<typename RealType, typename VecType>
aol::DerivativeValidatorBase< RealType, VecType >::DerivativeValidatorBase ( const RealType  H,
StepSizeFunctionType  stepsizeFctType,
const RealType  StepSize,
const RealType  StepSizeMin,
const RealType  StepSizeMax 
) [inline]

Definition at line 665 of file gradientflow.h.

    : _h(H),
      _stepSizeFctType ( stepsizeFctType ),
      _stepSize ( StepSize ),
      _stepSizeMin ( StepSizeMin ),
      _stepSizeMax ( StepSizeMax ),
      _skipPlottingWithSmallError ( false ),
      _skippingThreshold ( 1e-8 ),
      _maskPtr ( NULL ),
      _catchCtrlC ( false ),
      _negRate ( 0. ) {
    this->buildPositionsVector ( _positions );
  }


Member Function Documentation

template<typename RealType, typename VecType>
int aol::DerivativeValidatorBase< RealType, VecType >::buildPositionsVector ( aol::Vector< RealType > &  Positions  )  const [inline, protected]

fill passed vector with values at which the difference quotients will be evaluated.

If StepSizeFctType in the constructor was passed as LINEAR (default), a vector of size 120 with entries i * StepSize * h will be constructed.

In case of StepSizeFctType = EXPONENTIAL, entries of Positions will be $ \mbox{StepSizeMin} \cdot \mbox{StepSize}^i $ for $ i = 1,\dots,\log(\mbox{StepSizeMin} / \mbox{StepSizeMax}) / \log \mbox{StepSize} $. If the same value of StepSizeMin and StepSizeMax was passed in the constructor, a vector with one entry is built.

Returns:
length of Positions after filling.
Author:
von Deylen

Definition at line 756 of file gradientflow.h.

Referenced by aol::DerivativeValidatorBase< VecType::DataType, VecType >::DerivativeValidatorBase().

                                                                     {
    switch ( _stepSizeFctType ) {
      case LINEAR:
        Positions.resize ( 120 );
        for ( int i = 0; i < 120; ++i )
          Positions[i] = i * _stepSize * Sqr ( _h );
        return 120;
      case EXPONENTIAL: {
        int n;
        if ( log ( 1. / _stepSize ) < 1E-15 )
          n = 1;
        else
          n = static_cast<int> ( log ( _stepSizeMax / _stepSizeMin ) / log ( 1. / _stepSize ) );
        Positions.resize ( n );
        if ( n ) Positions[0] = _stepSizeMax;
        for ( int i = 1; i < n; ++i )
          Positions[i] = Positions[i - 1] * _stepSize;
        return n;
      }
      default:
        throw ( aol::UnimplementedCodeException ( "Unimplemented StepSizeFunctionType value.", __FILE__, __LINE__ ) );
    }
  }

template<typename RealType, typename VecType>
const BitVector& aol::DerivativeValidatorBase< RealType, VecType >::getMask (  )  const [inline]

Definition at line 714 of file gradientflow.h.

                                     {
    return *_maskPtr;
  }

template<typename RealType, typename VecType>
string aol::DerivativeValidatorBase< RealType, VecType >::getSuffixString ( const aol::Vec< VecType::Depth, int > &  idxVec  )  const [inline, protected]

Definition at line 784 of file gradientflow.h.

Referenced by aol::FirstDerivativeValidator< VecType, DerivativeType, RealType >::testAllDirections().

                                                                            {
    char fn[1024];
    switch ( VecType::Depth ){
      case 1: sprintf( fn, "%03d", idxVec[0] ); break;
      case 2: sprintf( fn, "%d_%03d", idxVec[0], idxVec[1] ); break;
      case 3: sprintf( fn, "%d_%03d_%d", idxVec[0], idxVec[1], idxVec[2] );  break;
      default: throw aol::Exception ( "aol::DerivativeValidatorBase<>::getSuffixString: unvalid VecTyp.", __FILE__, __LINE__ );
    }
    string temp = fn;
    return temp;
  }

template<typename RealType, typename VecType>
void aol::DerivativeValidatorBase< RealType, VecType >::setCatchCtrlC ( bool  catchCtrlC  )  [inline]

All derivative tests that loop over multiple directions can be interrupted by Ctrl-C if you have set catchCtrlC to true. The normal Ctrl-C handler is replaced by the QuocMesh handler during the iteration. When you press Ctrl-C, the test for the current derivative direction is finished, and afterwards a message is printed you really want to interrupt. There you can choose between terminating the program by pressing Ctrl-C again, cancelling the current derivative test and continuing the program or even resuming the derivative test.

Definition at line 700 of file gradientflow.h.

                                         {
    _catchCtrlC = catchCtrlC;
  }

template<typename RealType, typename VecType>
void aol::DerivativeValidatorBase< RealType, VecType >::setCtrlCHandler (  )  const [inline, protected]
template<typename RealType, typename VecType>
aol::Vec< VecType::Depth, int> aol::DerivativeValidatorBase< RealType, VecType >::setIthComponent ( const int  I,
const RealType  Value,
VecType &  Vec 
) const [inline, protected]
template<typename RealType, typename VecType>
void aol::DerivativeValidatorBase< RealType, VecType >::setMask ( const BitVector mask  )  [inline]

if you do not want all entries to be tested, you may set a mask before calling testAllDirections() or similar fct's.

Definition at line 706 of file gradientflow.h.

                                          {
    _maskPtr = &mask;
  }

template<typename RealType, typename VecType>
void aol::DerivativeValidatorBase< RealType, VecType >::setNegRate ( const RealType  negRate  )  [inline]

set parameter negRate which is passed to validateAndPlotToPNG

Definition at line 719 of file gradientflow.h.

                                             {
    _negRate = negRate;
  }

template<typename RealType, typename VecType>
void aol::DerivativeValidatorBase< RealType, VecType >::setSkippingThreshold ( const RealType  SkippingThreshold  )  [inline]

Definition at line 687 of file gradientflow.h.

                                                                 {
    _skippingThreshold = SkippingThreshold;
  }

template<typename RealType, typename VecType>
void aol::DerivativeValidatorBase< RealType, VecType >::setSkipPlottingWithSmallError ( const bool  SkipPlottingWithSmallError  )  [inline]

Definition at line 683 of file gradientflow.h.

                                                                               {
    _skipPlottingWithSmallError = SkipPlottingWithSmallError;
  }

template<typename RealType, typename VecType>
void aol::DerivativeValidatorBase< RealType, VecType >::unsetCtrlCHandler (  )  const [inline, protected]
template<typename RealType, typename VecType>
void aol::DerivativeValidatorBase< RealType, VecType >::unsetMask (  )  [inline]

Definition at line 710 of file gradientflow.h.

                    {
    _maskPtr = NULL;
  }

template<typename RealType, typename VecType>
bool aol::DerivativeValidatorBase< RealType, VecType >::wantsInterrupt (  )  const [inline, protected]

Definition at line 811 of file gradientflow.h.

Referenced by aol::FirstDerivativeValidator< VecType, DerivativeType, RealType >::derivMinusDiffQuotientsAllDirections(), and aol::FirstDerivativeValidator< VecType, DerivativeType, RealType >::testAllDirections().

                              {
    if (!_catchCtrlC || !getCtrlCState())
      return false;

    signal ( InterruptSignal, DefaultHandler );
    cerr << endl << endl << aol::color::error
         << "Do you really want to interrupt the derivative test "
            "(y/n, Ctrl-C to kill program)? ";
    cerr << aol::color::reset;
    string yes_no;
    cin >> yes_no;
    signal ( InterruptSignal, ctrlCHandler );

    if (yes_no == "y" || yes_no == "yes")
      return true;
    else {
      resetCtrlCState();
      return false;
    }
  }

template<typename RealType, typename VecType>
bool aol::DerivativeValidatorBase< RealType, VecType >::wantsToCheckEntry ( const int  I  )  const [inline, protected]

Member Data Documentation

template<typename RealType, typename VecType>
const RealType aol::DerivativeValidatorBase< RealType, VecType >::_h [protected]
template<typename RealType, typename VecType>
RealType aol::DerivativeValidatorBase< RealType, VecType >::_negRate [protected]
template<typename RealType, typename VecType>
bool aol::DerivativeValidatorBase< RealType, VecType >::_resizePositionVector [protected]

Definition at line 728 of file gradientflow.h.

template<typename RealType, typename VecType>
const RealType aol::DerivativeValidatorBase< RealType, VecType >::_stepSize [protected]
template<typename RealType, typename VecType>
const StepSizeFunctionType aol::DerivativeValidatorBase< RealType, VecType >::_stepSizeFctType [protected]
template<typename RealType, typename VecType>
const RealType aol::DerivativeValidatorBase< RealType, VecType >::_stepSizeMax [protected]
template<typename RealType, typename VecType>
const RealType aol::DerivativeValidatorBase< RealType, VecType >::_stepSizeMin [protected]

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

Generated on Fri Sep 9 2011 21:09:07 for QuocMesh by doxygen 1.7.1