proj home

Files   Classes   Functions   Hierarchy  

patternsearch.h

Go to the documentation of this file.
00001 #ifndef PATTERNSEARCH_H
00002 #define PATTERNSEARCH_H
00003 
00004 #include <vec.h>
00005 #include <cirbuffarr.h>
00006 #include <typeop.h>
00007 #include <print.h>
00008 
00020 template< typename EXP >
00021 class patternsearch
00022 {
00023 public:
00024 
00025   typedef typename typeop<EXP>::Tbare::Ttype T;
00026   typedef typename typeop<EXP>::Tbare::XItype XI;
00027 
00029   EXP exp;
00030 
00032   T hstep;
00033 
00035   patternsearch( EXP exp_, T hstep_=1);
00036 
00038   cirbuffarr< T > xi0;
00039 
00041   vec< XI, T > xivec;
00042 
00044   void reset();
00045 
00047   void reset( T const * x0 )
00048     { exp.reset(x0); reset(); }
00049 
00050 
00052   void operator ++ ();
00053 
00054   bool const operator ! () const
00055     { return exp.valid; }
00056   
00057 };
00058 
00059 
00060 /*
00061  *---------------------------------------------------------------
00062  * Implementation
00063  */
00064 
00065 
00066 template< typename EXP >
00067 void patternsearch<EXP>::reset()
00068 { 
00069   exp.reset(); 
00070   xi0.push(exp.xi); 
00071   exp.move(); 
00072   xi0.push(exp.xi); 
00073 }
00074 
00075 template< typename EXP >
00076 void patternsearch<EXP>::operator ++ ()
00077 {
00078   for (bool loop=true; loop;)
00079   {
00080     xi0.push(exp.xi);
00081     xivec -= xi0[1];
00082     xivec *= hstep;
00083     xivec += xi0[0];
00084   
00085     exp.movelocal();
00086 
00087     loop = exp.evaluate();
00088   }
00089   xi0.copyto(exp.xi);
00090 }
00091 
00092 
00093 template< typename EXP >
00094 patternsearch<EXP>::patternsearch( EXP exp_, T hstep_ )
00095   : exp(exp_), hstep(hstep_), xi0(3,exp.N), xivec(exp.xi,exp.N)
00096 {
00097 }
00098 
00099 
00100 #endif
00101 
00102 

Generated on Fri Mar 4 00:49:30 2011 for Chelton Evans Source by  doxygen 1.5.8