proj home

Files   Classes   Functions   Hierarchy  

explorepd1.h

Go to the documentation of this file.
00001 #ifndef EXPLOREPD1_H
00002 #define EXPLOREPD1_H
00003 
00004 #include <cassert>
00005 #include <iostream>
00006 using namespace std
00007 
00008 #include <typeop.h>
00009 #include <print.h>
00010 
00011 template < typename EXP, typename LNM >
00012 class explorepd1 : public EXP
00013 {
00014 public:
00015 
00016   typedef typename typeop<EXP>::Targ::FNtype FN;
00017   typedef typename typeop<EXP>::Tbare::Ttype T;
00018 
00020   T delta;
00021 
00023   T* linex0;
00025   T* linedi;
00027   T linet0;
00029   T linet1;
00030 
00032   LNM linemin;
00033 
00035   uint lineiterations;
00036 
00038   explorepd1
00039   (
00040     uintc N_, 
00041     uintc lineiterations_,
00042     T const h0step=20.0, 
00043     uintc indexmax_=100
00044   );
00045 
00047   explorepd1
00048   (
00049     FN fn_,
00050     uintc N_, 
00051     uintc lineiterations_,
00052     T const h0step=20.0, 
00053     uintc indexmax_=100
00054   );
00055 
00057   ~explorepd1();
00058 
00059   void reset( T const * x0 );
00060 
00062   void operator ++ ();
00063 
00064 };
00065 
00066 //----------------------------------------------------------
00067 //  Implementation
00068 
00069 template < typename EXP, typename LNM >
00070 void explorepd1<EXP,LNM>::reset( T const * x0 )
00071 {
00072 //cout << "explorepd1<EXP,LNM>::reset(T const *)" << endl;
00073   EXP::reset(x0);
00074 }
00075 
00076 template < typename EXP, typename LNM >
00077 explorepd1<EXP,LNM>::explorepd1
00078 (
00079   uintc N_, 
00080   uintc lineiterations_,
00081   T const h0step, 
00082   uintc indexmax_
00083 )
00084   : EXP(N_,h0step,indexmax_),
00085   delta(0.01),
00086   linex0(new T[N_]), linedi(new T[N_]),
00087   linet0(-2.0), linet1(2.0), 
00088   linemin(N_,EXP::fn,EXP::xi,linex0,linedi),
00089   lineiterations(lineiterations_)
00090 { 
00091 }
00092 
00093 template < typename EXP, typename LNM >
00094 explorepd1<EXP,LNM>::explorepd1
00095 (
00096   FN fn_,
00097   uintc N_, 
00098   uintc lineiterations_,
00099   T const h0step, 
00100   uintc indexmax_
00101 )
00102   : EXP(fn_,N_,h0step,indexmax_), 
00103   delta(0.01),
00104   linex0(new T[N_]), linedi(new T[N_]),
00105   linet0(-2.0), linet1(2.0), 
00106   linemin(N_,EXP::fn_,EXP::xi,linex0,linedi),
00107   lineiterations(lineiterations_)
00108 { 
00109 }
00110 
00111 template < typename EXP, typename LNM >
00112 explorepd1<EXP,LNM>::~explorepd1()
00113 {
00114   delete[] linex0;
00115   delete[] linedi;
00116 }
00117 
00118 
00119 
00120 template < typename EXP, typename LNM >
00121 void explorepd1<EXP,LNM>::operator ++ ()
00122 {
00123   //EXP::operator++();
00124   EXP::move();
00125 //cout << printvecfunc(EXP::fn.xi,EXP::N) << endl;
00126 //cout << SHOW(EXP::fmin) << endl;
00127 
00128 
00129   T x;
00130   T fnb;
00131   T fna;
00132 
00133   T h;
00134 
00135   for (uint i=0; i<EXP::N; ++i)
00136   {
00137     linedi[i] = 0;
00138     linex0[i] = EXP::fn.xi[i];
00139 
00140   }
00141 
00142   for (uint i=0; i<EXP::N; ++i)
00143   {
00144     h = EXP::hi[i]*delta;
00145     x = EXP::fn.xi[i];
00146     EXP::fn.xi[i] -= h;
00147     EXP::fn(fna);
00148     EXP::fn.xi[i] = x + h;
00149     EXP::fn(fnb);
00150     linex0[i] = x;
00151     linedi[i] = (fnb-fna)/h*0.5;
00152 
00153     //EXP::fn.xi = x;
00154 
00155 
00156     // Minimize on the line.
00157     linemin.reset(linet0,linet1);
00158     for (uint k=0; k<lineiterations; ++k)
00159     {
00160       ++linemin;
00161     }
00162 
00163     linedi[i] = 0;
00164     for (uint k=0; k<EXP::N; ++k)
00165       linex0[k] = EXP::fn.xi[k];
00166 
00167   }
00168 
00169 
00170 }
00171 
00172 
00173 #endif
00174 
00175 

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