Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:48:23

0001 /**
0002  * @file CubicSpline.h
0003  * @author Cédric Mezrag (ANL)
0004  * @date 14 April 2017
0005  * @version 0.1
0006  */
0007 
0008 #ifndef CUBICSPLINE_H_
0009 #define CUBICSPLINE_H_
0010 
0011 #include <iostream>
0012 #include <sstream>
0013 #include <vector>
0014 #include <cmath>
0015 
0016 
0017 
0018 /*
0019  * Cubic spline algorithm based on wikipedia :
0020  * https://en.wikipedia.org/w/index.php?title=Spline_%28mathematics%29&oldid=288288033#Algorithm_for_computing_natural_cubic_splines
0021  *
0022  *
0023  */
0024 
0025 namespace NumA{
0026 
0027 class CubicSpline{
0028 
0029 public:
0030 
0031     CubicSpline(std::vector<double> x, std::vector<double> y);
0032     virtual ~CubicSpline();
0033 
0034     void ConstructSpline(); // construct natural cubic splines
0035 
0036     double getSplineInsideValue(double z); //Return natural cubic splines for xmin < z < xmax and 0 if z is outside the set of point.
0037 
0038 private:
0039 
0040     const unsigned int m_N ; // size of the point sample
0041 
0042     std::vector<double> m_X ;  // x coordinate of the sample
0043     std::vector<double> m_Y ;  // y coordinate of the sample
0044 
0045     std::vector<double> m_aCoeff ; // coefficient a as defined on wikipedia
0046     std::vector<double> m_bCoeff ;  // coefficient b as defined on wikipedia
0047     std::vector<double> m_cCoeff ; // coefficient c as defined on wikipedia
0048     std::vector<double> m_dCoeff ; // coefficient d as defined on wikipedia
0049 
0050     bool m_SplineDefined ; // Turn to true if ConstructSpline is run at least once.
0051 
0052 };
0053 
0054 
0055 }
0056 
0057 
0058 #endif