CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
FuncGrid_Bspline.h
Go to the documentation of this file.
1 /*******************************************************************
2  * Copyright (C) 2010 by Federico Marulli and Alfonso Veropalumbo *
3  * federico.marulli3@unibo.it *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful,*
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public *
16  * License along with this program; if not, write to the Free *
17  * Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  *******************************************************************/
20 
32 #ifndef __FUNCGRIDBSPL__
33 #define __FUNCGRIDBSPL__
34 
35 #include "GSLwrapper.h"
36 
37 // =====================================================================================
38 
39 
40 namespace cbl {
41 
42  namespace glob {
43 
55  class FuncGrid_Bspline
56  {
57  private:
58 
60  std::vector<double> m_x;
61 
63  std::vector<double> m_fx;
64 
66  int m_nbreakpoints;
67 
69  int m_ncoefficients;
70 
72  int m_order;
73 
75  std::shared_ptr<gsl_bspline_workspace> m_bspline;
76 
78  std::shared_ptr<gsl_vector> m_Bcoeff;
79 
81  std::shared_ptr<gsl_vector> m_weights;
82 
84  std::shared_ptr<gsl_matrix> m_covariance;
85 
87  double m_integral;
88 
93 
107  void m_set_bspline(const std::vector<double> x, const std::vector<double> fx, const int nbreakpoints, const int order);
108 
119  void m_set_knots (const double xmin=cbl::par::defaultDouble, const double xmax=cbl::par::defaultDouble);
120 
131  void m_set_knots (const std::vector<double> breakpoints);
132 
145  void m_linear_fit (const double frac=0.1);
146 
154  void m_compute_func_integral ();
155 
157 
158  public:
163 
168  FuncGrid_Bspline () {}
169 
185  FuncGrid_Bspline (const std::vector<double> x, const std::vector<double> fx, const int nbreakpoints, const int order=4, const double frac=0.1, const double xmin=cbl::par::defaultDouble, const double xmax=cbl::par::defaultDouble);
186 
200  FuncGrid_Bspline (const std::vector<double> x, const std::vector<double> fx, const std::vector<double> breakpoints, const int order=4, const double frac=0.1);
201 
206  ~FuncGrid_Bspline () = default;
207 
209 
214 
230  void set (const std::vector<double> x, const std::vector<double> fx, const int nbreakpoints, const int order=4, const double frac=0.1, const double xmin=cbl::par::defaultDouble, const double xmax=cbl::par::defaultDouble);
231 
245  void set (const std::vector<double> x, const std::vector<double> fx, const std::vector<double> breakpoints, const int order=4, const double frac=0.1);
246 
248 
253 
261  double operator () (const double xx, const double integral=cbl::par::defaultDouble) const;
262 
270  std::vector<double> eval_func (const std::vector<double> xx, const double integral=cbl::par::defaultDouble) const;
271 
273  };
274 
275  }
276 }
277 #endif
functions that wrap GSL routines for integration, root finding and minimization
static const double defaultDouble
default double value
Definition: Constants.h:348
The global namespace of the CosmoBolognaLib
Definition: CAMB.h:38