ROOT logo
// @(#)root/mathmore:$Id: Chebyshev.h 21503 2007-12-19 17:34:54Z moneta $
// Authors: L. Moneta, A. Zsenei   08/2005 

 /**********************************************************************
  *                                                                    *
  * Copyright (c) 2004 ROOT Foundation,  CERN/PH-SFT                   *
  *                                                                    *
  * This library 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.             *
  *                                                                    *
  * This library 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 this library (see file COPYING); if not, write          *
  * to the Free Software Foundation, Inc., 59 Temple Place, Suite      *
  * 330, Boston, MA 02111-1307 USA, or contact the author.             *
  *                                                                    *
  **********************************************************************/

// Header file for class Chebyshev
// 
// Created by: moneta  at Thu Dec  2 14:51:15 2004
// 
// Last update: Thu Dec  2 14:51:15 2004
// 
#ifndef ROOT_Math_Chebyshev
#define ROOT_Math_Chebyshev

/**
   @defgroup NumAlgo Numerical Algorithms
   Numerical Algorithm mainly from the \ref MathMore and implemented using the 
   <A HREF="http://www.gnu.org/software/gsl/manual/html_node/">GSL</A> library
 */


/**
   @defgroup FuncApprox Function Approximation (Chebyshev)
   @ingroup NumAlgo
 */


#ifndef ROOT_Math_IFunctionfwd
#include "Math/IFunctionfwd.h"
#endif

#ifndef ROOT_Math_GSLFunctionAdapter
#include "Math/GSLFunctionAdapter.h"
#endif

#include <memory>



namespace ROOT {
namespace Math {

class GSLChebSeries; 
class GSLFunctionWrapper; 

//____________________________________________________________________________
/**
   Class describing a Chebyshev series which can be used to approximate a 
   function in a defined range [a,b] using Chebyshev polynomials.
   It uses the algorithm from 
   <A HREF="http://www.gnu.org/software/gsl/manual/html_node/Chebyshev-Approximations.html">GSL</A>

   This class does not support copying
   @ingroup FuncApprox
 */


class Chebyshev {

public: 


   /**
      Construct a Chebyshev series approximation to a Function f in range [a,b];
      constructor based on functions of type IGenFunction
   */

  Chebyshev(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 free functions with gsl_function type signature
   */
   Chebyshev(GSLFuncPointer f, void *p, double a, double b, size_t n); 

   // destructor
   virtual ~Chebyshev(); 


private:

   /**
      construct a Chebyshev series or order n
      The series must be initialized from a function 
   */
   Chebyshev(size_t n); 

// usually copying is non trivial, so we make this unaccessible
   Chebyshev(const Chebyshev &); 
   Chebyshev & operator = (const Chebyshev &); 

public: 
  
   /** 
       Evaluate the series at a given point x
   */
   double operator() ( double x) const;

   /**
      Evaluate the series at a given point x estimating both the series result and its absolute error. 
      The error estimate is made from the first neglected term in the series.
      A pair containing result and error is returned
   */
   std::pair<double, double>  EvalErr( double x) const; 

   /**
      Evaluate the series at a given point, to (at most) the given order n
   */
   double operator() ( double x, size_t n) const; 

   /**
      evaluate the series at a given point x to the given order n, 
      estimating both the series result and its absolute error. 
      The error estimate is made from the first neglected term in the series.
      A pair containing result and error is returned
   */
   std::pair<double, double>  EvalErr( double x, size_t n) const; 

   /**
      Compute the derivative of the series and return a pointer to a new Chebyshev series with the 
      derivatives coefficients. The returned pointer must be managed by the user.
   */
   //TO DO: implement copying to return by value
   Chebyshev * Deriv(); 

   /**
      Compute the integral of the series and return a pointer to a new Chebyshev series with the 
      integral coefficients. The lower limit of the integration is the left range value a.
      The returned pointer must be managed by the user
   */
   //TO DO: implement copying to return by value
   Chebyshev * Integral(); 

protected: 

   /** 
       Initialize series passing function and range
   */
   void Initialize( GSLFuncPointer f, void * params, double a, double b);

private: 

   size_t fOrder;

   GSLChebSeries * fSeries;
   GSLFunctionWrapper * fFunction;     // pointer to function

}; 

} // namespace Math
} // namespace ROOT

#endif /* ROOT_Math_Chebyshev */
 Chebyshev.h:1
 Chebyshev.h:2
 Chebyshev.h:3
 Chebyshev.h:4
 Chebyshev.h:5
 Chebyshev.h:6
 Chebyshev.h:7
 Chebyshev.h:8
 Chebyshev.h:9
 Chebyshev.h:10
 Chebyshev.h:11
 Chebyshev.h:12
 Chebyshev.h:13
 Chebyshev.h:14
 Chebyshev.h:15
 Chebyshev.h:16
 Chebyshev.h:17
 Chebyshev.h:18
 Chebyshev.h:19
 Chebyshev.h:20
 Chebyshev.h:21
 Chebyshev.h:22
 Chebyshev.h:23
 Chebyshev.h:24
 Chebyshev.h:25
 Chebyshev.h:26
 Chebyshev.h:27
 Chebyshev.h:28
 Chebyshev.h:29
 Chebyshev.h:30
 Chebyshev.h:31
 Chebyshev.h:32
 Chebyshev.h:33
 Chebyshev.h:34
 Chebyshev.h:35
 Chebyshev.h:36
 Chebyshev.h:37
 Chebyshev.h:38
 Chebyshev.h:39
 Chebyshev.h:40
 Chebyshev.h:41
 Chebyshev.h:42
 Chebyshev.h:43
 Chebyshev.h:44
 Chebyshev.h:45
 Chebyshev.h:46
 Chebyshev.h:47
 Chebyshev.h:48
 Chebyshev.h:49
 Chebyshev.h:50
 Chebyshev.h:51
 Chebyshev.h:52
 Chebyshev.h:53
 Chebyshev.h:54
 Chebyshev.h:55
 Chebyshev.h:56
 Chebyshev.h:57
 Chebyshev.h:58
 Chebyshev.h:59
 Chebyshev.h:60
 Chebyshev.h:61
 Chebyshev.h:62
 Chebyshev.h:63
 Chebyshev.h:64
 Chebyshev.h:65
 Chebyshev.h:66
 Chebyshev.h:67
 Chebyshev.h:68
 Chebyshev.h:69
 Chebyshev.h:70
 Chebyshev.h:71
 Chebyshev.h:72
 Chebyshev.h:73
 Chebyshev.h:74
 Chebyshev.h:75
 Chebyshev.h:76
 Chebyshev.h:77
 Chebyshev.h:78
 Chebyshev.h:79
 Chebyshev.h:80
 Chebyshev.h:81
 Chebyshev.h:82
 Chebyshev.h:83
 Chebyshev.h:84
 Chebyshev.h:85
 Chebyshev.h:86
 Chebyshev.h:87
 Chebyshev.h:88
 Chebyshev.h:89
 Chebyshev.h:90
 Chebyshev.h:91
 Chebyshev.h:92
 Chebyshev.h:93
 Chebyshev.h:94
 Chebyshev.h:95
 Chebyshev.h:96
 Chebyshev.h:97
 Chebyshev.h:98
 Chebyshev.h:99
 Chebyshev.h:100
 Chebyshev.h:101
 Chebyshev.h:102
 Chebyshev.h:103
 Chebyshev.h:104
 Chebyshev.h:105
 Chebyshev.h:106
 Chebyshev.h:107
 Chebyshev.h:108
 Chebyshev.h:109
 Chebyshev.h:110
 Chebyshev.h:111
 Chebyshev.h:112
 Chebyshev.h:113
 Chebyshev.h:114
 Chebyshev.h:115
 Chebyshev.h:116
 Chebyshev.h:117
 Chebyshev.h:118
 Chebyshev.h:119
 Chebyshev.h:120
 Chebyshev.h:121
 Chebyshev.h:122
 Chebyshev.h:123
 Chebyshev.h:124
 Chebyshev.h:125
 Chebyshev.h:126
 Chebyshev.h:127
 Chebyshev.h:128
 Chebyshev.h:129
 Chebyshev.h:130
 Chebyshev.h:131
 Chebyshev.h:132
 Chebyshev.h:133
 Chebyshev.h:134
 Chebyshev.h:135
 Chebyshev.h:136
 Chebyshev.h:137
 Chebyshev.h:138
 Chebyshev.h:139
 Chebyshev.h:140
 Chebyshev.h:141
 Chebyshev.h:142
 Chebyshev.h:143
 Chebyshev.h:144
 Chebyshev.h:145
 Chebyshev.h:146
 Chebyshev.h:147
 Chebyshev.h:148
 Chebyshev.h:149
 Chebyshev.h:150
 Chebyshev.h:151
 Chebyshev.h:152
 Chebyshev.h:153
 Chebyshev.h:154
 Chebyshev.h:155
 Chebyshev.h:156
 Chebyshev.h:157
 Chebyshev.h:158
 Chebyshev.h:159
 Chebyshev.h:160
 Chebyshev.h:161
 Chebyshev.h:162
 Chebyshev.h:163
 Chebyshev.h:164
 Chebyshev.h:165
 Chebyshev.h:166
 Chebyshev.h:167
 Chebyshev.h:168
 Chebyshev.h:169
 Chebyshev.h:170
 Chebyshev.h:171
 Chebyshev.h:172