12#include <gsl/gsl_interp.h>
65 Interp1D(
const double* x_,
const double* y_,
const size_t n_,
68 const bool xLog_ =
false,
const bool yLog_ =
false,
69 const double yLo_ = 0.0,
const double yHi_ = 0.0) :
82 interp = gsl_interp_alloc(gsl_interp_steffen,
n);
85 acc[i] = gsl_interp_accel_alloc();
89 mLo = (
y[1] -
y[0]) / (
x[1] -
x[0]);
101 gsl_interp_accel_free(
acc[i]);
108 double xMin()
const {
return xLog ? std::pow(10.,
x[0]) :
x[0]; }
130 double x1 =
xLog ? std::log10(x_) : x_;
132 if (x1 <
x[0] &&
x[0] - x1 < 1.0e-10) x1 =
x[0];
133 else if (!(x1 <
x[
n-1]) && x1 -
x[
n-1] <
tol) x1 =
x[
n-1];
142 y1 =
y[0] +
mLo * (x1 -
x[0]);
156 }
else if (x1 >
x[
n-1]) {
160 y1 =
y[
n-1] +
mHi * (x1 -
x[
n-1]);
179 return std::pow(10., y1);
198 static constexpr double tol = 1.0e-8;
A file containing a set of enumerated error codes.
A class to hold objects where one copy is required per thread.
Basic integer and real types.
A class to handle interpolation on 1D tables.
Definition Interp1D.H:42
Interp1D(const double *x_, const double *y_, const size_t n_, const extrapType extrapLo_=extrapError, const extrapType extrapHi_=extrapError, const bool xLog_=false, const bool yLog_=false, const double yLo_=0.0, const double yHi_=0.0)
Constructor.
Definition Interp1D.H:65
double operator()(const Real &x_) const
Caclulate an interpolated value from the table.
Definition Interp1D.H:122
const double * x
Definition Interp1D.H:187
double xMin() const
Return lower limit of table.
Definition Interp1D.H:108
const double yLo
Definition Interp1D.H:194
const double * y
Definition Interp1D.H:188
~Interp1D()
Destructor.
Definition Interp1D.H:97
const double yHi
Definition Interp1D.H:195
gsl_interp * interp
Definition Interp1D.H:202
const bool xLog
Definition Interp1D.H:192
const bool yLog
Definition Interp1D.H:193
double mLo
Definition Interp1D.H:196
const size_t n
Definition Interp1D.H:189
static constexpr double tol
Definition Interp1D.H:198
ThreadVec< gsl_interp_accel * > acc
Definition Interp1D.H:203
double xMax() const
Return upper limit of table.
Definition Interp1D.H:114
const extrapType extrapLo
Definition Interp1D.H:190
double mHi
Definition Interp1D.H:197
const extrapType extrapHi
Definition Interp1D.H:191
A class to automate private thread copies of objects.
Definition ThreadVec.H:35
IdxType size() const
Return the number of distinct objects stored.
Definition ThreadVec.H:59
The primary namespace for criptic objects.
Definition AdvancePacket.H:25
extrapType
Enum describing different ways to handle extrapolation.
Definition Interp1D.H:22
@ extrapConst
Definition Interp1D.H:25
@ extrapLinear
Definition Interp1D.H:24
@ extrapError
Definition Interp1D.H:23
@ extrapFixedVal
Definition Interp1D.H:27
@ errBadXLoExtrapolation
Definition ErrCodes.H:28
@ errBadXHiExtrapolation
Definition ErrCodes.H:30
std::vector< Real >::size_type IdxType
Definition Types.H:45
double Real
Definition Types.H:38