source/inc/numeric/funcobj.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 _SCSOLVER_NUMERIC_FUNCOBJ_HXX_
00029 #define _SCSOLVER_NUMERIC_FUNCOBJ_HXX_
00030 
00031 #include <vector>
00032 #include <string>
00033 #include <memory>
00034 #include <exception>
00035 
00036 namespace scsolver { namespace numeric {
00037 
00038 class SingleVarFuncObj;
00039 
00040 class VarSizeException : public ::std::exception
00041 {
00042 public:
00043         virtual const char* what() const throw();
00044 };
00045 
00049 class BaseFuncObj
00050 {
00051 public:
00052     BaseFuncObj();
00053     BaseFuncObj(size_t varCount);
00054     BaseFuncObj(const BaseFuncObj& r);
00055     virtual ~BaseFuncObj() = 0;
00056 
00057     const ::std::vector<double>& getVars() const;
00058     double getVar(size_t index) const;
00059     void setVars(const ::std::vector<double>& vars) const;
00060     void setVar(size_t index, double var) const;
00061     size_t getVarCount() const;
00062 
00063     virtual double eval() const = 0;
00064 
00068     virtual const ::std::string getFuncString() const = 0;
00069 
00070     double operator()(const ::std::vector<double>& vars) const;
00071 
00072     SingleVarFuncObj& getSingleVarFuncObj(size_t varIndex);
00073 
00074     SingleVarFuncObj& getSingleVarFuncObjByRatio(const ::std::vector<double>& ratios);
00075 
00076 private:
00077     mutable ::std::vector<double> m_vars;
00078     ::std::auto_ptr<SingleVarFuncObj> m_pSVFuncObj;
00079 };
00080 
00081 // --------------------------------------------------------------------------
00082 
00087 class SingleVarFuncObj
00088 {
00089 public:
00090     SingleVarFuncObj();
00091     virtual ~SingleVarFuncObj() = 0;
00092 
00093     virtual void setVar(double var) = 0;
00094     virtual double getVar() const = 0;
00095     virtual double eval() const = 0;
00096 
00100     virtual const ::std::string getFuncString() const = 0;
00101 
00102     double operator()(double var);
00103 };
00104 
00105 
00106 }}
00107 
00108 #endif
00109 

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