00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _NUMERIC_ALGORITHM_HXX_
00029 #define _NUMERIC_ALGORITHM_HXX_
00030
00031 #include <memory>
00032 #include <boost/shared_ptr.hpp>
00033 #include <vector>
00034
00035 namespace scsolver { namespace numeric {
00036
00037 class BaseFuncObj;
00038 class SingleVarFuncObj;
00039
00040 class FuncObjectNotSet : public ::std::exception {};
00041
00046 class NumericalDiffer
00047 {
00048 static const double OMEGA;
00049
00050 public:
00051 NumericalDiffer();
00052 ~NumericalDiffer() throw();
00053
00054 void setPrecision(unsigned long n);
00055 void setSecondOrder(bool b);
00056 void setVariable(double var);
00057 void setFuncObject(SingleVarFuncObj* pFuncObj);
00058
00059 double run();
00060
00061 private:
00062 void initialize();
00063 void setDirty();
00064 void appendNewH();
00065 void setT(unsigned long m, unsigned long i, double fVal);
00066 double getT(unsigned long m, unsigned long i);
00067 double T0(unsigned long i);
00068 double Tm();
00069 double Tm(unsigned long m, unsigned long i = 0);
00070
00071 private:
00072 unsigned long m_nPrec;
00073 bool m_bSecondOrder;
00074 SingleVarFuncObj* m_pFuncObj;
00075 double m_var;
00076
00077 ::std::vector<double> m_cnX;
00078 ::std::vector<double> m_cnH;
00079 ::std::vector< ::std::vector<double> > m_cnT;
00080 };
00081
00082 }}
00083
00084 #endif