Logo ROOT   6.13/01
Reference Guide
ChebyshevApprox.h
Go to the documentation of this file.
1 // @(#)root/mathmore:$Id$
2 // Authors: L. Moneta, A. Zsenei 08/2005
3 
4  /**********************************************************************
5  * *
6  * Copyright (c) 2004 ROOT Foundation, CERN/PH-SFT *
7  * *
8  * This library is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU General Public License *
10  * as published by the Free Software Foundation; either version 2 *
11  * of the License, or (at your option) any later version. *
12  * *
13  * This library is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16  * General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this library (see file COPYING); if not, write *
20  * to the Free Software Foundation, Inc., 59 Temple Place, Suite *
21  * 330, Boston, MA 02111-1307 USA, or contact the author. *
22  * *
23  **********************************************************************/
24 
25 // Header file for class ChebyshevApprox
26 //
27 // Created by: moneta at Thu Dec 2 14:51:15 2004
28 //
29 // Last update: Thu Dec 2 14:51:15 2004
30 //
31 #ifndef ROOT_Math_ChebyshevApprox
32 #define ROOT_Math_ChebyshevApprox
33 
34 
35 
36 /**
37  @defgroup FuncApprox Function Approximation (ChebyshevApprox)
38  Numerical algorithm from the \ref MathMore library and implemented using the
39  <A HREF="http://www.gnu.org/software/gsl/manual/html_node/">GSL</A> library
40 
41  @ingroup NumAlgo
42  */
43 
44 
45 #include "Math/IFunctionfwd.h"
46 
48 
49 #include <memory>
50 #include <cstddef>
51 
52 
53 namespace ROOT {
54 namespace Math {
55 
56 class GSLChebSeries;
57 class GSLFunctionWrapper;
58 
59 //____________________________________________________________________________
60 /**
61  Class describing a Chebyshev series which can be used to approximate a
62  function in a defined range [a,b] using Chebyshev polynomials.
63  It uses the algorithm from
64  <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Chebyshev-Approximations.html">GSL</A>
65 
66  This class does not support copying
67  @ingroup FuncApprox
68  */
69 
70 
72 
73 public:
74 
75 
76  /**
77  Construct a Chebyshev series approximation to a Function f in range [a,b];
78  constructor based on functions of type IGenFunction
79  */
80 
81  ChebyshevApprox(const ROOT::Math::IGenFunction & f, double a, double b, size_t n);
82 
83  /**
84  Construct a Chebyshev series approximation to a Function f in range [a,b];
85  constructor based on free functions with gsl_function type signature
86  */
87  ChebyshevApprox(GSLFuncPointer f, void *p, double a, double b, size_t n);
88 
89  // destructor
90  virtual ~ChebyshevApprox();
91 
92 
93 private:
94 
95  /**
96  construct a Chebyshev series or order n
97  The series must be initialized from a function
98  */
99  ChebyshevApprox(size_t n);
100 
101 // usually copying is non trivial, so we make this unaccessible
104 
105 public:
106 
107  /**
108  Evaluate the series at a given point x
109  */
110  double operator() ( double x) const;
111 
112  /**
113  Evaluate the series at a given point x estimating both the series result and its absolute error.
114  The error estimate is made from the first neglected term in the series.
115  A pair containing result and error is returned
116  */
117  std::pair<double, double> EvalErr( double x) const;
118 
119  /**
120  Evaluate the series at a given point, to (at most) the given order n
121  */
122  double operator() ( double x, size_t n) const;
123 
124  /**
125  evaluate the series at a given point x to the given order n,
126  estimating both the series result and its absolute error.
127  The error estimate is made from the first neglected term in the series.
128  A pair containing result and error is returned
129  */
130  std::pair<double, double> EvalErr( double x, size_t n) const;
131 
132  /**
133  Compute the derivative of the series and return a pointer to a new Chebyshev series with the
134  derivatives coefficients. The returned pointer must be managed by the user.
135  */
136  //TO DO: implement copying to return by value
138 
139  /**
140  Compute the integral of the series and return a pointer to a new Chebyshev series with the
141  integral coefficients. The lower limit of the integration is the left range value a.
142  The returned pointer must be managed by the user
143  */
144  //TO DO: implement copying to return by value
146 
147 protected:
148 
149  /**
150  Initialize series passing function and range
151  */
152  void Initialize( GSLFuncPointer f, void * params, double a, double b);
153 
154 private:
155 
156  size_t fOrder;
157 
159  GSLFunctionWrapper * fFunction; // pointer to function
160 
161 };
162 
163 } // namespace Math
164 } // namespace ROOT
165 
166 #endif /* ROOT_Math_ChebyshevApprox */
Class describing a Chebyshev series which can be used to approximate a function in a defined range [a...
Interface (abstract class) for generic functions objects of one-dimension Provides a method to evalua...
Definition: IFunction.h:135
std::pair< double, double > EvalErr(double x) const
Evaluate the series at a given point x estimating both the series result and its absolute error...
Namespace for new ROOT classes and functions.
Definition: TFoamSampler.h:19
ChebyshevApprox * Integral()
Compute the integral of the series and return a pointer to a new Chebyshev series with the integral c...
void Initialize(GSLFuncPointer f, void *params, double a, double b)
Initialize series passing function and range.
double operator()(double x) const
Evaluate the series at a given point x.
wrapper class for C struct gsl_cheb_series
Definition: GSLChebSeries.h:44
GSLFunctionWrapper * fFunction
ChebyshevApprox & operator=(const ChebyshevApprox &)
ChebyshevApprox(const ROOT::Math::IGenFunction &f, double a, double b, size_t n)
Construct a Chebyshev series approximation to a Function f in range [a,b]; constructor based on funct...
double(* GSLFuncPointer)(double, void *)
Function pointer corresponding to gsl_function signature.
ChebyshevApprox * Deriv()
Compute the derivative of the series and return a pointer to a new Chebyshev series with the derivati...
* x
Deprecated and error prone model selection interface.
Definition: TRolke.cxx:630
Namespace for new Math classes and functions.
Wrapper class to the gsl_function C structure.
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630