Files Classes Functions Hierarchy
00001 #ifndef POWELL03_H 00002 #define POWELL03_H 00003 00004 #include <print.h> 00005 00006 #include <linepathd1.h> 00007 00008 00009 template< typename LNM, typename T > 00010 class powell03 00011 { 00012 public: 00013 00014 LNM opt; 00016 uint optiterations; 00017 00018 uintc dim; 00019 00020 T * memoryblock; 00021 00023 T * pos; 00025 T * dir; 00027 T * xi; 00028 00030 uintc dir_current; 00031 00032 T ** linepathx0; 00033 T ** linepathdi; 00034 00036 uint optiterations; 00037 00038 powell03(LNM opt_) 00039 : opt(opt_), optiterations(10), dim(opt.linepath.dim) 00040 { 00041 memoryblock = new T[dim*dim*2 + dim*2]; 00042 uint memi=0; 00043 pos = & memoryblock[memi]; 00044 memi += dim*dim; 00045 dir = & memoryblock[memi]; 00046 memi += dim*dim; 00047 xi = & memoryblock[memi]; 00048 memi += dim; 00049 u0 = & memoryblock[memi]; 00050 memi += dim; 00051 00052 opt.linepath.xi = xi; 00053 linepathx0 = & opt.linepath.xo; 00054 linepathdi = & opt.linepath.di; 00055 } 00056 00057 ~powell03() 00058 { delete[] memoryblock; } 00059 00061 void dirUnitVectors(); 00062 00063 protected: 00064 00066 void minimize(uintc k) 00067 { 00068 *linepathx0 = pos+dim*k; 00069 uintc k2 = (dir_current + k ) % dim; 00070 *linepathd1 = dir+dim*k2; 00071 00072 opt.reset(0.0,5.0); 00073 for (uint i=0; i<optiterations; ++i) 00074 ++opt; 00075 } 00076 00077 }; 00078 00079 00080 template< typename LNM, typename T > 00081 void powell03<LNM,T>::dirUnitVectors() 00082 { 00083 for (uint i=0; i<dim*dim; ++i) 00084 dir[i]=0; 00085 for (uint i=0; i<dim; ++i) 00086 dir[i*N+i]=(T)1; 00087 } 00088 00089 00090 00091 00092 00093 00094 #endif 00095 00096
1.5.8