#include <cubic_spline.h>
Definition at line 121 of file cubic_spline.h.
◆ Extr
◆ Type
Enumerator |
---|
LINEAR | |
CUBIC | |
CONSTRAINED_CUBIC | |
Definition at line 125 of file cubic_spline.h.
◆ constructAndReset()
template<typename Container >
void Spline::constructAndReset |
( |
const Container & |
x, |
|
|
const Container & |
y |
|
) |
| |
|
inline |
Definition at line 246 of file cubic_spline.h.
void set_points(const Container &x, const Container &y)
◆ eval() [1/2]
Definition at line 268 of file cubic_spline.h.
279 int idx=std::max(it-1,0);
Float extrapolate_right(double x) const
Float extrapolate_left(double x) const
int my_lower_bound(const T &val, const T *arr, const int arrlen)
Float eval(Float x) const
◆ eval() [2/2]
◆ extrapolate_left()
Float Spline::extrapolate_left |
( |
double |
x | ) |
const |
|
inline |
◆ extrapolate_right()
Float Spline::extrapolate_right |
( |
double |
x | ) |
const |
|
inline |
◆ print()
Definition at line 293 of file cubic_spline.h.
294 std::cout <<
"Spline: \n";
296 std::cout << std::right << std::setw(10) << std::setfill(
' ') <<
m_x[i] <<
" " 297 << std::right << std::setw(10) << std::setfill(
' ') <<
m_y[i] <<
" " 298 << std::right << std::setw(10) << std::setfill(
' ') <<
m_a[i] <<
" " 299 << std::right << std::setw(10) << std::setfill(
' ') <<
m_b[i] <<
" " 300 << std::right << std::setw(10) << std::setfill(
' ') <<
m_c[i] <<
" " 303 std:: cout << std::endl;
◆ set_points()
template<typename Container >
void Spline::set_points |
( |
const Container & |
x, |
|
|
const Container & |
y |
|
) |
| |
|
inline |
Definition at line 139 of file cubic_spline.h.
140 assert(x.size() == y.size());
141 m_x.assign(x.begin(), x.end());
142 m_y.assign(y.begin(), y.end());
150 for(
int i=0; i<
npoints-1; i++) {
void solve_coeffs_linear()
void solve_coeffs_constrained_cubic()
void solve_coeffs_cubic()
◆ solve_coeffs_constrained_cubic()
void Spline::solve_coeffs_constrained_cubic |
( |
| ) |
|
|
inline |
Definition at line 219 of file cubic_spline.h.
222 std::vector <double> m(n);
223 for (
int i=1; i<n-1; ++i){
226 if (fplus*fminus < 0) m[i] = 0;
227 else m[i] = 2/(1/fplus + 1/fminus);
232 m[n-1] = 3*(
m_y[n-1]-
m_y[n-2])/(
m_x[n-1]-
m_x[n-2])/2 - m[n-2]/2;
234 for (
int i=0; i<n-1; ++i){
236 double hi =
m_x[i+1]-
m_x[i];
237 m_b[i] = ( 3*(
m_y[i+1]-
m_y[i] - m[i]*hi) - hi*(m[i+1]-m[i]))/hi/hi;
238 m_a[i] = (-2*(
m_y[i+1]-
m_y[i] - m[i]*hi) + hi*(m[i+1]-m[i]))/hi/hi/hi;
◆ solve_coeffs_cubic()
void Spline::solve_coeffs_cubic |
( |
| ) |
|
|
inline |
Definition at line 179 of file cubic_spline.h.
184 std::vector <Float> l(n,0), m(n,0), u(n,0);
185 std::vector<double> rhs(n);
186 for(
int i=1; i<n-1; i++) {
187 l[i] =1.0/3.0*(
m_x[i]-
m_x[i-1]);
188 m[i] =2.0/3.0*(
m_x[i+1]-
m_x[i-1]);
189 u[i] =1.0/3.0*(
m_x[i+1]-
m_x[i]);
205 for(
int i=0; i<n-1; i++) {
206 m_a[i]=1.0/3.0*(m_b[i+1]-m_b[i])/(
m_x[i+1]-
m_x[i]);
208 - 1.0/3.0*(2.0*m_b[i]+m_b[i+1])*(
m_x[i+1]-
m_x[i]);
212 double h=
m_x[n-1]-
m_x[n-2];
215 m_c[n-1]=3.0*
m_a[n-2]*h*h+2.0*m_b[n-2]*h+
m_c[n-2];
void thomas_solve(double *a, double *b, double *c, double *d, int n)
◆ solve_coeffs_linear()
void Spline::solve_coeffs_linear |
( |
| ) |
|
|
inline |
◆ extrapolate
◆ m_a
std::vector<Float> Spline::m_a |
|
protected |
◆ m_b
std::vector<Float> Spline::m_b |
|
protected |
◆ m_c
std::vector<Float> Spline::m_c |
|
protected |
◆ m_x
std::vector<Float> Spline::m_x |
|
protected |
◆ m_y
std::vector<Float> Spline::m_y |
|
protected |
◆ npoints
◆ splineType
The documentation for this class was generated from the following file: