//$Header: /home/ben/Mapper/include/RCS/func.h,v 6.4 2002/06/10 22:16:17 ben Exp $
#ifndef FUNC_H
#define FUNC_H
// Copyright Benedict Adamson 2002.
// This file is part of Mapper.
// Mapper is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// Mapper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Mapper; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include <vector>
namespace func {
class single_dimension
{
public: //attributes
virtual double operator() ( const double x ) const = 0;
};
template< class T >
class single_dimension_implicit
{
public: //constructors, destructor
inline single_dimension_implicit(
const T &fx,
const double tol
);
inline virtual ~single_dimension_implicit(void);
public: //attributes
T default_guess;
double default_tol;
virtual T evaluate(
const double x,
T fx1,
T fx2,
const double tol
) const = 0;
virtual T evaluate(
const double x,
const double tol
) const = 0;
};
template< class T >
inline single_dimension_implicit< T >::single_dimension_implicit(
const T &fx,
const double tol
)
:
default_guess( fx ),
default_tol( tol )
{
}
template< class T >
inline single_dimension_implicit< T >::~single_dimension_implicit(void)
{
//Do nothing
}
class multi_dimensional
{
public: //attributes
virtual double operator() (
const vector<double> &x
) const = 0;
};
class multi_dimensional_with_derivatives
:
public multi_dimensional
{
public: //attributes
virtual double operator() (
const vector<double> &x
) const = 0;
virtual void evaluate(
const vector<double> &x,
double &f, //output
vector<double> &gradient //output
) const = 0;
};
class projection
:public single_dimension
{
public: //constructors & destructors
projection(
const vector<double> &ix0,
const vector<double> &idxdt,
const multi_dimensional *f = 0
);
virtual ~projection(void);
public: //attributes
virtual double operator() ( const double x ) const;
vector<double> x0;
vector<double> dxdt;
vector< double > line(
const double t
) const;
public: //associations
const multi_dimensional *multi_dimensional_function;
};
};
#endif