59 std::vector<double> m_x, m_y;
63 std::vector<double> m_b, m_c, m_d;
66 bd_type m_left, m_right;
67 double m_left_value, m_right_value;
68 bool m_made_monotonic;
69 void set_coeffs_from_b();
70 size_t find_closest(
double x)
const;
77 , m_left(second_deriv)
78 , m_right(second_deriv)
81 , m_made_monotonic(
false)
85 spline(
const std::vector<double> &X,
86 const std::vector<double> &Y,
87 spline_type type = cspline,
88 bool make_monotonic =
false,
89 bd_type left = second_deriv,
90 double left_value = 0.0,
91 bd_type right = second_deriv,
92 double right_value = 0.0)
96 , m_left_value(left_value)
97 , m_right_value(right_value)
98 , m_made_monotonic(
false)
100 this->set_points(X, Y, m_type);
103 this->make_monotonic();
108 void set_boundary(bd_type left,
114 void set_points(
const std::vector<double> &x,
115 const std::vector<double> &y,
116 spline_type type = cspline);
125 bool make_monotonic();
128 double operator()(
double x)
const;
129 double deriv(
int order,
double x)
const;
132 std::vector<double> solve(
double y,
bool ignore_extrapolation =
true)
const;
135 std::vector<double> get_x()
const {
return m_x; }
136 std::vector<double> get_y()
const {
return m_y; }
137 double get_x_min()
const
139 assert(!m_x.empty());
142 double get_x_max()
const
144 assert(!m_x.empty());
156 std::vector<std::vector<double>> m_upper;
157 std::vector<std::vector<double>> m_lower;
162 void resize(
int dim,
int n_u,
int n_l);
164 int num_upper()
const {
return (
int)m_upper.size() - 1; }
165 int num_lower()
const {
return (
int)m_lower.size() - 1; }
167 double &operator()(
int i,
int j);
168 double operator()(
int i,
int j)
const;
170 double &saved_diag(
int i);
171 double saved_diag(
int i)
const;
173 std::vector<double> r_solve(
const std::vector<double> &b)
const;
174 std::vector<double> l_solve(
const std::vector<double> &b)
const;
175 std::vector<double> lu_solve(
const std::vector<double> &b,
176 bool is_lu_decomposed =
false);