CFL
Function.hpp
Go to the documentation of this file.
1 //Copyright (c) Dmitry Kramkov, 2000-2006. All rights reserved.
2 
3 #ifndef __cflFunction_hpp__
4 #define __cflFunction_hpp__
5 
6 #include <functional>
7 #include <limits>
8 #include <memory>
9 #include <valarray>
10 #include "cfl/Macros.hpp"
11 
12 
24 namespace cfl
25 {
40 
42 
47  class IFunction
48  {
49  public:
53  virtual ~IFunction(){}
54 
60  virtual double operator()(double dX) const = 0;
61 
68  virtual bool belongs(double dX) const = 0;
69  };
70 
72 
78  class Function: public std::function<double(double)>
79  {
80  public:
89  explicit Function(double dV=0.,
90  double dLeft=-std::numeric_limits<double>::max(),
91  double dRight=std::numeric_limits<double>::max());
92 
100  explicit Function(IFunction * pNewP);
101 
109  Function & operator=(double dV);
110 
117  double operator()(double dX) const;
118 
122  bool belongs(double dX) const;
123 
133  Function & operator+=(const Function & rF);
134 
144  Function & operator*=(const Function & rF);
145 
155  Function & operator-=(const Function & rF);
156 
167  Function & operator/=(const Function & rF);
168 
176  Function & operator+=(double dV);
177 
186  Function & operator-=(double dV);
187 
195  Function & operator*=(double dV);
196 
204  Function & operator/=(double dV);
205 
206  private:
211  };
212 
221  Function operator-(const Function & rF);
222 
233  Function
234  operator*(const Function & rF, const Function & rG);
235 
246  Function
247  operator+(const Function & rF, const Function & rG);
248 
259  Function
260  operator-(const Function & rF, const Function & rG);
261 
272  Function
273  operator/(const Function & rF, const Function & rG);
274 
285  Function
286  operator*(double dV, const Function & rF);
287 
298  Function
299  operator-(double dV, const Function & rF);
300 
311  Function
312  operator/(double dV, const Function & rF);
313 
324  Function
325  operator+(double dV, const Function & rF);
326 
337  Function
338  operator/(const Function & rF, double dV);
339 
350  Function
351  operator+(const Function & rF,double dV);
352 
363  Function
364  operator*(const Function & rF, double dV);
365 
376  Function
377  operator-(const Function & rF, double dV);
378 
389  Function max(const Function & rF, const Function & rG);
390 
401  Function max(double dV, const Function & rF);
402 
413  Function max(const Function & rF, double dV);
414 
425  Function min(const Function & rF, const Function & rG);
426 
437  Function min(double dV, const Function & rF);
438 
449  Function min(const Function & rF, double dV);
450 
460  Function pow(const Function & rF, double dV);
461 
471  Function abs(const Function & rF);
472 
482  Function exp(const Function & rF);
483 
493  Function log(const Function & rF);
494 
504  Function sqrt(const Function & rF);
505 
519  template <class F>
520  Function toFunction(const F & rF,
521  double dLeft=-std::numeric_limits<double>::infinity(),
522  double dRight=std::numeric_limits<double>::infinity());
523 
524  class MultiFunction;
539  Function toFunction(const MultiFunction & rF,
540  unsigned iArg=0,
541  const std::valarray<double> & rOtherArg = std::valarray<double>());
542 
544 }
545 
546 #include "cfl/Inline/iFunction.hpp"
547 #endif // of __cflFunction_hpp__
548 
Function operator-(const Function &rF)
Function max(const Function &rF, const Function &rG)
Function pow(const Function &rF, double dV)
Function toFunction(const F &rF, double dLeft=-std::numeric_limits< double >::infinity(), double dRight=std::numeric_limits< double >::infinity())
virtual bool belongs(double dX) const =0
virtual double operator()(double dX) const =0
virtual ~IFunction()
Definition: Function.hpp:53
Concrete class for a one-dimensional function.
Definition: Function.hpp:78
complex< _Tp > & operator/=(const _Tp &)
complex< _Tp > & operator=(const _Tp &)
complex< _Tp > & operator-=(const complex< _Up > &)
Function log(const Function &rF)
Function exp(const Function &rF)
Function abs(const Function &rF)
Function operator/(const Function &rF, const Function &rG)
Function operator*(const Function &rF, const Function &rG)
Function min(const Function &rF, const Function &rG)
Macros and constants for cfl library.
complex< _Tp > & operator*=(const _Tp &)
Main namespace for cfl library.
Definition: Approx.hpp:22
Standard concrete class for multi-dimensional function object.
Definition: MultiFunction.hpp:79
Interface for a one-dimensional function.
Definition: Function.hpp:47
Function sqrt(const Function &rF)
Function operator+(const Function &rF, const Function &rG)
complex< _Tp > & operator+=(const complex< _Up > &)