Class interp_monotonic (o2scl)

O2scl : Class List

template<class vec_t, class vec2_t = vec_t, class fp_t = double>
class interp_monotonic : public o2scl::interp_base<vec_t, vec_t, double>

Monotonicity-preserving interpolation.

This class uses a method based on cubic Hermite interpolation, modifying the slopes to guarantee monotonicity. In the notation of [Fritsch80], if

\[ \alpha_i^2+\beta_i^2 \geq 9 \, , \]
then \( \alpha \) and \( \beta \) are decreased by the factor \( \tau \) as described at the end of section 4.

Based on [Fritsch80].

Todo

Future: Convert into fewer loops over the data

Warning

This class is experimental. Integrals don’t work yet.

Note

The results of the interpolation will only be monotonic in the regions where the original data set is also monotonic. Also, this interpolation routine does not enforce strict monotonicity, and the results of the interpolation will be flat where the data is also flat.

Public Types

typedef boost::numeric::ublas::vector<fp_t> ubvector

Public Functions

inline interp_monotonic()
inline virtual ~interp_monotonic()
inline virtual void set(size_t size, const vec_t &x, const vec2_t &y)

Initialize interpolation routine.

inline virtual fp_t eval(fp_t x0) const

Give the value of the function \( y(x=x_0) \) .

inline virtual fp_t deriv(fp_t x0) const

Give the value of the derivative \( y^{\prime}(x=x_0) \) .

inline virtual fp_t deriv2(fp_t x0) const

Give the value of the second derivative \( y^{\prime \prime}(x=x_0) \).

inline virtual fp_t integ(fp_t a, fp_t b) const

Give the value of the integral \( \int_a^{b}y(x)~dx \) .

inline virtual const char *type() const

Return the type, "interp_monotonic".

Protected Attributes

ubvector m

Slopes.

ubvector Delta

Finite differences.

ubvector alpha

Ratio.

ubvector beta

Staggered ratio.

Private Functions

interp_monotonic(const interp_monotonic<vec_t, vec2_t, fp_t>&)
interp_monotonic<vec_t, vec2_t, fp_t> &operator=(const interp_monotonic<vec_t, vec2_t, fp_t>&)