Logo ROOT   6.08/07
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 #ifndef ROOT_Math_IFunctionfwd
46 #include "Math/IFunctionfwd.h"
47 #endif
48 
49 #ifndef ROOT_Math_GSLFunctionAdapter
51 #endif
52 
53 #include <memory>
54 #include <cstddef>
55 
56 
57 namespace ROOT {
58 namespace Math {
59 
60 class GSLChebSeries;
61 class GSLFunctionWrapper;
62 
63 //____________________________________________________________________________
64 /**
65  Class describing a Chebyshev series which can be used to approximate a
66  function in a defined range [a,b] using Chebyshev polynomials.
67  It uses the algorithm from
68  <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Chebyshev-Approximations.html">GSL</A>
69 
70  This class does not support copying
71  @ingroup FuncApprox
72  */
73 
74 
76 
77 public:
78 
79 
80  /**
81  Construct a Chebyshev series approximation to a Function f in range [a,b];
82  constructor based on functions of type IGenFunction
83  */
84 
85  ChebyshevApprox(const ROOT::Math::IGenFunction & f, double a, double b, size_t n);
86 
87  /**
88  Construct a Chebyshev series approximation to a Function f in range [a,b];
89  constructor based on free functions with gsl_function type signature
90  */
91  ChebyshevApprox(GSLFuncPointer f, void *p, double a, double b, size_t n);
92 
93  // destructor
94  virtual ~ChebyshevApprox();
95 
96 
97 private:
98 
99  /**
100  construct a Chebyshev series or order n
101  The series must be initialized from a function
102  */
103  ChebyshevApprox(size_t n);
104 
105 // usually copying is non trivial, so we make this unaccessible
108 
109 public:
110 
111  /**
112  Evaluate the series at a given point x
113  */
114  double operator() ( double x) const;
115 
116  /**
117  Evaluate the series at a given point x estimating both the series result and its absolute error.
118  The error estimate is made from the first neglected term in the series.
119  A pair containing result and error is returned
120  */
121  std::pair<double, double> EvalErr( double x) const;
122 
123  /**
124  Evaluate the series at a given point, to (at most) the given order n
125  */
126  double operator() ( double x, size_t n) const;
127 
128  /**
129  evaluate the series at a given point x to the given order n,
130  estimating both the series result and its absolute error.
131  The error estimate is made from the first neglected term in the series.
132  A pair containing result and error is returned
133  */
134  std::pair<double, double> EvalErr( double x, size_t n) const;
135 
136  /**
137  Compute the derivative of the series and return a pointer to a new Chebyshev series with the
138  derivatives coefficients. The returned pointer must be managed by the user.
139  */
140  //TO DO: implement copying to return by value
142 
143  /**
144  Compute the integral of the series and return a pointer to a new Chebyshev series with the
145  integral coefficients. The lower limit of the integration is the left range value a.
146  The returned pointer must be managed by the user
147  */
148  //TO DO: implement copying to return by value
150 
151 protected:
152 
153  /**
154  Initialize series passing function and range
155  */
156  void Initialize( GSLFuncPointer f, void * params, double a, double b);
157 
158 private:
159 
160  size_t fOrder;
161 
163  GSLFunctionWrapper * fFunction; // pointer to function
164 
165 };
166 
167 } // namespace Math
168 } // namespace ROOT
169 
170 #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:133
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...
This namespace contains pre-defined functions to be used in conjuction with TExecutor::Map and TExecu...
Definition: StringConv.hxx:21
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.
TArc * a
Definition: textangle.C:12
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
Double_t x[n]
Definition: legend1.C:17
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...
double f(double x)
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
const Int_t n
Definition: legend1.C:16