spline.h
Go to the documentation of this file.
1 /*
2  * spline.h
3  *
4  * The original version of this file can be found at with:
5  * https://github.com/joshhooker/CubicSplineClass
6  *
7  * This file has MIT license.
8  *
9  * Actual version is modified to adapt to Fields2Cover requirements.
10  *
11  * ---------------------------------------------------------------------
12  * Copyright (c) 2017 Joshua Hooker
13  *
14  * Permission is hereby granted, free of charge, to any person obtaining
15  * a copy of this software and associated documentation files (the "Software"),
16  * to deal in the Software without restriction, including without limitation
17  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18  * and/or sell copies of the Software, and to permit persons to whom the
19  * Software is furnished to do so, subject to the following conditions:
20  *
21  * The above copyright notice and this permission notice shall be included
22  * in all copies or substantial portions of the Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30  * DEALINGS IN THE SOFTWARE.
31  * ---------------------------------------------------------------------
32  *
33  */
34 
35 
36 #ifndef FIELDS2COVER_UTILS_SPLINE_H_
37 #define FIELDS2COVER_UTILS_SPLINE_H_
38 
39 #include <vector>
40 #include <string>
41 
42 namespace f2c {
43 
44 class CubicSpline {
45  public:
46  CubicSpline();
47  CubicSpline(const std::vector<double> &x, const std::vector<double> &y,
48  bool monotonic = false);
49 
50  ~CubicSpline();
51 
52  void SetPoints(const std::vector<double> &x, const std::vector<double> &y,
53  bool monotonic = false);
54 
55  double operator()(double x) const;
56 
57 
58  private:
59  size_t size_{0};
60  std::vector<double> x_vec_, y_vec_;
61  std::vector<double> b_vec_, c_vec_, d_vec_;
62 
63  bool monotonic_{false};
64 
65  void SetSpline();
66 
67  void SetSplineCubic();
68 
69  void check_error(bool cond, const std::string& msg) const;
70 };
71 
72 } // namespace f2c
73 
74 #endif // FIELDS2COVER_UTILS_SPLINE_H_
f2c::CubicSpline::y_vec_
std::vector< double > y_vec_
Definition: spline.h:60
f2c::CubicSpline::monotonic_
bool monotonic_
Definition: spline.h:63
f2c::CubicSpline::check_error
void check_error(bool cond, const std::string &msg) const
Definition: spline.cpp:195
f2c::CubicSpline::SetSplineCubic
void SetSplineCubic()
Definition: spline.cpp:115
f2c::CubicSpline
Definition: spline.h:44
f2c::CubicSpline::CubicSpline
CubicSpline()
f2c::CubicSpline::size_
size_t size_
Definition: spline.h:59
f2c::CubicSpline::c_vec_
std::vector< double > c_vec_
Definition: spline.h:61
f2c::CubicSpline::x_vec_
std::vector< double > x_vec_
Definition: spline.h:60
f2c::CubicSpline::SetPoints
void SetPoints(const std::vector< double > &x, const std::vector< double > &y, bool monotonic=false)
Definition: spline.cpp:68
f2c
Main namespace of the fields2cover library.
Definition: boustrophedon_decomp.h:14
f2c::CubicSpline::b_vec_
std::vector< double > b_vec_
Definition: spline.h:61
f2c::CubicSpline::operator()
double operator()(double x) const
Definition: spline.cpp:88
f2c::CubicSpline::SetSpline
void SetSpline()
Definition: spline.cpp:111
f2c::CubicSpline::d_vec_
std::vector< double > d_vec_
Definition: spline.h:61
f2c::CubicSpline::~CubicSpline
~CubicSpline()


fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31