source/inc/numeric/diff.hxx

Go to the documentation of this file.
00001 /*************************************************************************
00002  *
00003  *  The Contents of this file are made available subject to
00004  *  the terms of GNU Lesser General Public License Version 2.1.
00005  *
00006  *
00007  *    GNU Lesser General Public License Version 2.1
00008  *    =============================================
00009  *    Copyright 2005 by Kohei Yoshida.
00010  *    1039 Kingsway Dr., Apex, NC 27502, USA
00011  *
00012  *    This library is free software; you can redistribute it and/or
00013  *    modify it under the terms of the GNU Lesser General Public
00014  *    License version 2.1, as published by the Free Software Foundation.
00015  *
00016  *    This library is distributed in the hope that it will be useful,
00017  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  *    Lesser General Public License for more details.
00020  *
00021  *    You should have received a copy of the GNU Lesser General Public
00022  *    License along with this library; if not, write to the Free Software
00023  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00024  *    MA  02111-1307  USA
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

Generated on Mon Jul 28 09:13:20 2008 for scsolver by  doxygen 1.5.3