Files Classes Functions Hierarchy
#include <partialderivative.h>
Public Types | |
| typedef typeop< EXP > ::Tbare::FNtype | FN |
| typedef typeop< EXP >::Tbare::Ttype | T |
Public Member Functions | |
| partialderivative (typename typeop< EXP >::Tref exp_) | |
| Construct with explorer. | |
| ~partialderivative () | |
| Clean up memory. | |
| void | operator() () |
| Evaluate the partial derivative, store result in dxi. | |
| T const | squared () const |
| The partial derivative doted with itself. | |
| T const | absvalue () const |
| The sum of the absolute value of the components. | |
Public Attributes | |
| typeop< EXP >::Tref | exp |
| Explorer. | |
| T * | dxi |
| The partial derivative. | |
| uintc | N |
| The dimension. | |
This class numerically calculates the partial derivative from another algorithm exp which has f(x).
Definition at line 17 of file partialderivative.h.
| typedef typeop<EXP>::Tbare::FNtype partialderivative< EXP >::FN |
Definition at line 24 of file partialderivative.h.
| typedef typeop<EXP>::Tbare::Ttype partialderivative< EXP >::T |
Definition at line 25 of file partialderivative.h.
| partialderivative< EXP >::partialderivative | ( | typename typeop< EXP >::Tref | exp_ | ) | [inline] |
| partialderivative< EXP >::~partialderivative | ( | ) | [inline] |
Clean up memory.
Definition at line 111 of file partialderivative.h.
References partialderivative< EXP >::dxi.
00112 { 00113 delete[] dxi; 00114 }
| T const partialderivative< EXP >::absvalue | ( | ) | const [inline] |
The sum of the absolute value of the components.
Definition at line 56 of file partialderivative.h.
References partialderivative< EXP >::dxi, and partialderivative< EXP >::N.
Referenced by partialderivativetest01().
00057 { 00058 T val(0); 00059 for (uint i=0; i<N; ++i) 00060 val += abs(dxi[i]); 00061 00062 return val; 00063 }
| void partialderivative< EXP >::operator() | ( | ) | [inline] |
Evaluate the partial derivative, store result in dxi.
Definition at line 71 of file partialderivative.h.
References partialderivative< EXP >::dxi, partialderivative< EXP >::exp, and partialderivative< EXP >::N.
00072 { 00073 T x; 00074 T fnb; 00075 T fna; 00076 00077 T h; 00078 00079 // O(N).O(fn) complexity 00080 for (uint i=0; i<N; ++i) 00081 { 00082 h = exp.hi[i]; 00083 x = exp.fn.xi[i]; 00084 exp.fn.xi[i] -= h; 00085 exp.fn(fna); 00086 exp.fn.xi[i] = x + h; 00087 exp.fn(fnb); 00088 // Restore xi 00089 exp.fn.xi[i] = x; 00090 00091 // Compute the partial derivative. 00092 assert(h!=0.0); 00093 dxi[i] = (fnb-fna)/h*0.5; 00094 } 00095 00096 // Restore the current state. 00097 exp.fn(fna); 00098 }
| T const partialderivative< EXP >::squared | ( | ) | const [inline] |
The partial derivative doted with itself.
Definition at line 46 of file partialderivative.h.
References partialderivative< EXP >::dxi, and partialderivative< EXP >::N.
00047 { 00048 T val(0); 00049 for (uint i=0; i<N; ++i) 00050 val += dxi[i]*dxi[i]; 00051 00052 return val; 00053 }
| T* partialderivative< EXP >::dxi |
The partial derivative.
Definition at line 28 of file partialderivative.h.
Referenced by partialderivative< EXP >::absvalue(), partialderivative< EXP >::operator()(), partialderivative< EXP >::squared(), and partialderivative< EXP >::~partialderivative().
| typeop<EXP>::Tref partialderivative< EXP >::exp |
Explorer.
Definition at line 22 of file partialderivative.h.
Referenced by partialderivative< EXP >::operator()().
| uintc partialderivative< EXP >::N |
The dimension.
Definition at line 31 of file partialderivative.h.
Referenced by partialderivative< EXP >::absvalue(), partialderivative< EXP >::operator()(), and partialderivative< EXP >::squared().
1.5.8