Go to the documentation of this file.
47 const std::vector<double> &x,
const std::vector<double> &y,
50 "In CubicSpline initialization, x vector size != y vector size\n");
52 "In CubicSpline initialization, array size must be larger than 1\n");
69 const std::vector<double> &x,
const std::vector<double> &y,
72 "In CubicSpline SetPoints, x vector size != y vector size\n");
74 "In CubicSpline initialization, array size must be larger than 1\n");
89 const auto xs =
static_cast<double>(x);
94 int mid = (l + h) / 2;
102 size_t idx = l == 0 ? 0 : l - 1;
104 double xi = xs -
x_vec_[idx];
105 double xi2 = xi * xi;
106 double xi3 = xi2 * xi;
126 for (
unsigned int i = 1; i <
size_ - 1; i++) {
128 "In CubicSpline SetSpline, x array is not sorted"
129 "from smallest to largest\n");
132 alpha[i] = 3. / h[i] * (
y_vec_[i + 1] -
y_vec_[i]) - 3. /
134 l[i] = 2. * (
x_vec_[i + 1] -
x_vec_[i - 1]) - h[i - 1] * u[i - 1];
136 z[i] = (alpha[i] - h[i - 1] * z[i - 1]) / l[i];
139 for (
int i =
size_ - 2; i > -1; i--) {
149 bool changed =
false;
150 for (
unsigned int i = 0; i <
size_; i++) {
151 int i_low = std::max(
static_cast<int>(i - 1), 0);
153 std::min(
static_cast<int>(i + 1),
static_cast<int>(
size_) - 1);
164 if (slope == 0.0 && (
b_vec_[i] != 0.0 ||
b_vec_[i + 1] != 0.0)) {
180 for (
unsigned int i = 0; i <
size_; i++) {
181 double inv_h = 1.0 / h[i];
197 throw std::out_of_range(msg);
std::vector< double > y_vec_
void check_error(bool cond, const std::string &msg) const
std::vector< double > c_vec_
std::vector< double > x_vec_
void SetPoints(const std::vector< double > &x, const std::vector< double > &y, bool monotonic=false)
Main namespace of the fields2cover library.
std::vector< double > b_vec_
double operator()(double x) const
std::vector< double > d_vec_
fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31