model::Parameter source file
More...
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>
#include "DOFHandler.h"
Go to the source code of this file.
|
| double | linear_interpolate (double x, const std::vector< double > &xs, const std::vector< double > &ys) |
| | Linearly interpolate y(x) from a table of break points.
|
| double | linear_interpolate_slope (double x, const std::vector< double > &xs, const std::vector< double > &ys) |
| | Local slope dy/dx of the piecewise-linear table used by linear_interpolate.
|
model::Parameter source file
◆ linear_interpolate()
| double linear_interpolate |
( |
double | x, |
|
|
const std::vector< double > & | xs, |
|
|
const std::vector< double > & | ys ) |
Linearly interpolate y(x) from a table of break points.
Outside [xs.front(), xs.back()], the value is clamped to the nearest endpoint of ys (flat extrapolation).
- Parameters
-
| x | Value to evaluate the table at |
| xs | Break points (at least 2 entries, strictly increasing; use a pair of break points an epsilon apart to approximate a step change instead of a literal duplicate) |
| ys | Values at each break point (same size as xs) |
- Returns
- Interpolated (or boundary-clamped) value
- Exceptions
-
| std::runtime_error | if xs has fewer than 2 entries, xs and ys differ in length, or xs is not strictly increasing |
◆ linear_interpolate_slope()
| double linear_interpolate_slope |
( |
double | x, |
|
|
const std::vector< double > & | xs, |
|
|
const std::vector< double > & | ys ) |
Local slope dy/dx of the piecewise-linear table used by linear_interpolate.
Outside [xs.front(), xs.back()], the table is flat (see linear_interpolate), so the slope is 0 there. At an interior break point, the slope of the segment to its right is used.
- Parameters
-
| x | Value to evaluate the slope at |
| xs | Break points (at least 2 entries, strictly increasing; use a pair of break points an epsilon apart to approximate a step change instead of a literal duplicate) |
| ys | Values at each break point (same size as xs) |
- Returns
- Local slope of the interpolated table at x
- Exceptions
-
| std::runtime_error | if xs has fewer than 2 entries, xs and ys differ in length, or xs is not strictly increasing |