lsst.afw gea5801aee3+7fc0f751c0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
lsst::afw::math::detail::TautSpline Class Reference

#include <Spline.h>

Inheritance diagram for lsst::afw::math::detail::TautSpline:
lsst::afw::math::detail::Spline

Public Types

enum  Symmetry { Unknown , Odd , Even }
 

Public Member Functions

 TautSpline (std::vector< double > const &x, std::vector< double > const &y, double const gamma=0, Symmetry type=Unknown)
 Construct cubic spline interpolant to given data. More...
 
void interpolate (std::vector< double > const &x, std::vector< double > &y) const
 Interpolate a Spline. More...
 
void derivative (std::vector< double > const &x, std::vector< double > &dydx) const
 Find the derivative of a Spline. More...
 
std::vector< double > roots (double const value, double const x0, double const x1) const
 Find the roots of Spline - val = 0 in the range [x0, x1). More...
 

Protected Member Functions

void _allocateSpline (int const nknot)
 Allocate the storage a Spline needs. More...
 

Protected Attributes

std::vector< double > _knots
 
std::vector< std::vector< double > > _coeffs
 

Detailed Description

Definition at line 59 of file Spline.h.

Member Enumeration Documentation

◆ Symmetry

Enumerator
Unknown 
Odd 
Even 

Definition at line 61 of file Spline.h.

Constructor & Destructor Documentation

◆ TautSpline()

lsst::afw::math::detail::TautSpline::TautSpline ( std::vector< double > const &  x,
std::vector< double > const &  y,
double const  gamma = 0,
Symmetry  type = Unknown 
)

Construct cubic spline interpolant to given data.

Adapted from A Practical Guide to Splines by C. de Boor (N.Y. : Springer-Verlag, 1978). (His routine tautsp converted to C by Robert Lupton and then to C++ by an older and grayer Robert Lupton)

If gamma > 0, additional knots are introduced where needed to make the interpolant more flexible locally. This avoids extraneous inflection points typical of cubic spline interpolation at knots to rapidly changing data. Values for gamma are:

  • = 0, no additional knots
  • in (0, 3), under certain conditions on the given data at points i-1, i, i+1, and i+2, a knot is added in the i-th interval, i=1,...,ntau-3. See notes below. The interpolant gets rounded with increasing gamma. A value of 2.5 for gamma is typical.
  • in (3, 6), same as above, except that knots might also be added in intervals in which an inflection point would be permitted. A value of 5.5 for gamma is typical.
Parameters
xpoints where function's specified
yvalues of function at tau[]
gammacontrol extra knots. See main description for details.
typespecify the desired symmetry (e.g. Even)
Exceptions
pex::exceptions::InvalidParameterErrorThrown if x and y do not have the same length or do not have at least two points
Note
on the i-th interval, (tau[i], tau[i+1]), the interpolant is of the form (*) f(u(x)) = a + b*u + c*h(u,z) + d*h(1-u,1-z) , with u = u(x) = (x - tau[i])/dtau[i]. Here, z = z(i) = addg(i+1)/(addg(i) + addg(i+1)) (= .5, in case the denominator vanishes). with ddg(j) = dg(j+1) - dg(j), addg(j) = abs(ddg(j)), dg(j) = divdif(j) = (gtau[j+1] - gtau[j])/dtau[j] and h(u,z) = alpha*u**3 + (1 - alpha)*(max(((u-zeta)/(1-zeta)),0)**3 with alpha(z) = (1-gamma/3)/zeta zeta(z) = 1 - gamma*min((1 - z), 1/3) thus, for 1/3 .le. z .le. 2/3, f is just a cubic polynomial on the interval i. otherwise, it has one additional knot, at tau[i] + zeta*dtau[i] . as z approaches 1, h(.,z) has an increasingly sharp bend near 1, thus allowing f to turn rapidly near the additional knot. in terms of f(j) = gtau[j] and fsecnd[j] = 2*derivative of f at tau[j], the coefficients for (*) are given as a = f(i) - d b = (f(i+1) - f(i)) - (c - d) c = fsecnd[i+1]*dtau[i]**2/hsecnd(1,z) d = fsecnd[i]*dtau[i]**2/hsecnd(1,1-z) hence can be computed once fsecnd[i],i=0,...,ntau-1, is fixed.
f is automatically continuous and has a continuous second derivat- ive (except when z = 0 or 1 for some i). we determine fscnd(.) from the requirement that also the first derivative of f be continuous. in addition, we require that the third derivative be continuous across tau[1] and across tau[ntau-2] . this leads to a strictly diagonally dominant tridiagonal linear system for the fsecnd[i] which we solve by gauss elimination without pivoting.
There must be at least 4 interpolation points for us to fit a taut cubic spline, but if you provide fewer we'll fit a quadratic or linear polynomial (but you must provide at least 2)

Definition at line 86 of file Spline.cc.

Member Function Documentation

◆ _allocateSpline()

void lsst::afw::math::detail::Spline::_allocateSpline ( int const  nknot)
protectedinherited

Allocate the storage a Spline needs.

Definition at line 21 of file Spline.cc.

◆ derivative()

void lsst::afw::math::detail::Spline::derivative ( std::vector< double > const &  x,
std::vector< double > &  dydx 
) const
inherited

Find the derivative of a Spline.

Parameters
[in]xpoints to evaluate derivative at
[out]dydxderivatives at x

Definition at line 57 of file Spline.cc.

◆ interpolate()

void lsst::afw::math::detail::Spline::interpolate ( std::vector< double > const &  x,
std::vector< double > &  y 
) const
inherited

Interpolate a Spline.

Parameters
[in]xpoints to interpolate at
[out]yvalues of spline interpolation at x

Definition at line 29 of file Spline.cc.

◆ roots()

std::vector< double > lsst::afw::math::detail::Spline::roots ( double const  value,
double const  x0,
double const  x1 
) const
inherited

Find the roots of Spline - val = 0 in the range [x0, x1).

Return a vector of all the roots found

Parameters
valuedesired value
x0,x1specify desired range is [x0,x1)

Definition at line 1226 of file Spline.cc.

Member Data Documentation

◆ _coeffs

std::vector<std::vector<double> > lsst::afw::math::detail::Spline::_coeffs
protectedinherited

Definition at line 56 of file Spline.h.

◆ _knots

std::vector<double> lsst::afw::math::detail::Spline::_knots
protectedinherited

Definition at line 55 of file Spline.h.


The documentation for this class was generated from the following files: