#include <simplex.h>
Public Member Functions | |
| Simplex (int dimension) | |
| ~Simplex () | |
| Vec_DP & | operator[] (int i) const |
| int | high (double *val=0) const |
| int | low (double *val=0) const |
| void | centroid (Vec_DP &vec) const |
| double | size () const |
| int | reflect () |
| int | reflect_exp () |
| int | contract () |
| void | reduce () |
Public Attributes | |
| CoordCalcFunction * | functionObject |
Private Attributes | |
| int | nverts |
| Vec_DP ** | verts |
| int | dim |
Definition at line 16 of file simplex.h.
| Simplex::Simplex | ( | int | dimension | ) |
| Simplex::~Simplex | ( | ) |
| void Simplex::centroid | ( | Vec_DP & | vec | ) | const |
Definition at line 69 of file simplex.cc.
Referenced by contract(), reflect(), reflect_exp(), and size().
00070 { 00071 Vec_DP ce(dim); 00072 int hi = high(); 00073 00074 for (int i=0; i<nverts; i++) 00075 if (i != hi) 00076 ce += *verts[i]; 00077 00078 vec = ce / (nverts-1); 00079 }
| int Simplex::contract | ( | ) |
Definition at line 116 of file simplex.cc.
Referenced by CoordCalcFunction::simplex_min().
00117 { 00118 int hi = high(); 00119 Vec_DP ce(dim); 00120 00121 centroid(ce); 00122 *verts[hi] = ce + 0.5*(*verts[hi] - ce); 00123 return hi; 00124 }
| int Simplex::high | ( | double * | val = 0 |
) | const |
Definition at line 35 of file simplex.cc.
Referenced by centroid(), contract(), reflect(), reflect_exp(), and CoordCalcFunction::simplex_min().
00036 { 00037 double test; 00038 double max = functionObject->f(*verts[0]); 00039 int idx = 0; 00040 for (int i=1; i<nverts; i++) { 00041 test = functionObject->f(*verts[i]); 00042 if (test > max) { 00043 max = test; 00044 idx = i; 00045 } 00046 } 00047 if (0 != val) 00048 *val = max; 00049 return idx; 00050 }
| int Simplex::low | ( | double * | val = 0 |
) | const |
Definition at line 52 of file simplex.cc.
Referenced by reduce(), and CoordCalcFunction::simplex_min().
00053 { 00054 double test; 00055 double min = functionObject->f(*verts[0]);; 00056 int idx = 0; 00057 for (int i=1; i<nverts; i++) { 00058 test = functionObject->f(*verts[i]); 00059 if (test < min) { 00060 min = test; 00061 idx = i; 00062 } 00063 } 00064 if (0 != val) 00065 *val = min; 00066 return idx; 00067 }
| Vec_DP& Simplex::operator[] | ( | int | i | ) | const [inline] |
| void Simplex::reduce | ( | ) |
Definition at line 126 of file simplex.cc.
Referenced by CoordCalcFunction::simplex_min().
00127 { 00128 int lo = low(); 00129 00130 for (int i = 0; i<nverts; i++) { 00131 if (i != lo) { 00132 *verts[i] = 0.5 * (*verts[i] + *verts[lo]); 00133 } 00134 } 00135 }
| int Simplex::reflect | ( | ) |
Definition at line 96 of file simplex.cc.
Referenced by CoordCalcFunction::simplex_min().
00097 { 00098 int hi = high(); 00099 Vec_DP ce(dim); 00100 00101 centroid(ce); 00102 *verts[hi] = ce + (ce - *verts[hi]); 00103 return hi; 00104 }
| int Simplex::reflect_exp | ( | ) |
Definition at line 106 of file simplex.cc.
Referenced by CoordCalcFunction::simplex_min().
00107 { 00108 int hi = high(); 00109 Vec_DP ce(dim); 00110 00111 centroid(ce); 00112 *verts[hi] = ce + 2*(ce - *verts[hi]); 00113 return hi; 00114 }
| double Simplex::size | ( | ) | const |
Definition at line 83 of file simplex.cc.
Referenced by CoordCalcFunction::simplex_min().
00084 { 00085 Vec_DP ce(dim); 00086 centroid(ce); 00087 double dp, size = 0; 00088 00089 for (int i=0; i<nverts; i++) { 00090 dp = dot(*verts[i]-ce, *verts[i]-ce); 00091 size += sqrt(dp); 00092 } 00093 return size; 00094 }
int Simplex::dim [private] |
Definition at line 21 of file simplex.h.
Referenced by centroid(), contract(), reflect(), reflect_exp(), Simplex(), and size().
Definition at line 24 of file simplex.h.
Referenced by high(), low(), and CoordCalcFunction::simplex_min().
int Simplex::nverts [private] |
Definition at line 19 of file simplex.h.
Referenced by centroid(), high(), low(), reduce(), Simplex(), size(), and ~Simplex().
Vec_DP** Simplex::verts [private] |
Definition at line 20 of file simplex.h.
Referenced by centroid(), contract(), high(), low(), operator[](), reduce(), reflect(), reflect_exp(), Simplex(), size(), and ~Simplex().
1.5.8