Click or drag to resize

RationalCubicSpline Class

This kind of generalized spline gives much more pleasant results than cubic splines when interpolating, e.g., experimental data. A control parameter p can be used to tune the interpolation smoothly between cubic splines and a linear interpolation. But this doesn't mean smoothing of the data - the rational spline curve will still go through all data points.
Inheritance Hierarchy
SystemObject
  Altaxo.Calc.InterpolationCurveBase
    Altaxo.Calc.InterpolationRationalCubicSpline

Namespace: Altaxo.Calc.Interpolation
Assembly: AltaxoCore (in AltaxoCore.dll) Version: 4.8.3448.0 (4.8.3448.0)
Syntax
C#
public class RationalCubicSpline : CurveBase, 
	IInterpolationFunction, IInterpolationCurve

The RationalCubicSpline type exposes the following members.

Constructors
 NameDescription
Public methodRationalCubicSpline Initializes a new instance of the `RationalCubicSpline` class.
Top
Properties
 NameDescription
Public propertySmoothing Gets or sets the value of the smoothing parameter. A value of p = 0 results in a standard cubic spline. A value of -1 < p < 0 results in "unsmoothing", i.e. overshooting oscillations. A value of p > 0 yields increasing smoothness. p to infinity results in a linear interpolation. A value smaller than or equal to -1.0 leads to an error.
Top
Methods
 NameDescription
Public methodCubicSplineCoefficients Calculate the spline coefficients y2(i) and y3(i) for a natural cubic spline, given the abscissa x(i), the ordinate y(i), and the 1st derivative y1(i).
(Inherited from CurveBase)
Public methodCubicSplineHorner Return the interpolation value P(u) for a piecewise cubic curve determined by the abscissa vector x, the ordinate vector y, and derivative coefficient vectors y1, y2, and y3, using the Horner scheme.
(Inherited from CurveBase)
Public methodCubicSplineHorner1stDerivative Return the first derivative P'(u) of the piecewise cubic curve evaluated using Horner's scheme.
(Inherited from CurveBase)
Public methodStatic memberDifferences Calculates the difference vector dx(i) from vector x(i) and ensures that x is strictly monotone increasing or decreasing. Can be called with both arguments referring to the same vector in order to do it in place.
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Public methodGetBoundaryConditions Gets the boundary condition.
Public methodGetBoundaryConditions(Double, Double) Gets the boundary condition and the two condition parameters.
Public methodGetCurvePoints Get curve points to draw an interpolation curve between the abscissa values xlo and xhi. It calls the virtual methods MpCurveBase::GetXOfU() and GetYOfU() to obtain the interpolation values. Note, that before method DrawCurve() can be called the method Interpolate() must have been called. Otherwise, not interpolation is available.
(Inherited from CurveBase)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Public methodGetXOfU Get the abscissa value in dependence on parameter u.
(Overrides CurveBaseGetXOfU(Double))
Public methodGetYOfU Gets the ordinate value on dependence on parameter u.
(Overrides CurveBaseGetYOfU(Double))
Public methodGetYOfX Returns the y value in dependence of a given x value.
Public methodInterpolate
(Overrides CurveBaseInterpolate(IReadOnlyListDouble, IReadOnlyListDouble))
Public methodStatic memberInverseDifferences Calculates the inverse difference vector dx(i) from vector x(i) and ensures that x is strictly monotone increasing or decreasing. Can be called with both arguments referring to the same vector in order to do it in place.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Public methodParametrize Curve length parametrization. Returns the accumulated "distances" between the points (x(i),y(i)) and (x(i+1),y(i+1)) in t(i+1) for i = lo ... hi. t(lo) = 0.0 always.
(Inherited from CurveBase)
Public methodSetBoundaryConditions Sets the boundary conditions.
Protected methodSplineA Computes the coefficient vector used by `SplineB1` and `SplineB2`.
Protected methodSplineB1 Computes the 1st derivative vector for interior points, given boundary values and the coefficients computed by `SplineA`.
Protected methodSplineB2 Computes the 2nd derivative vector for interior points, given boundary values and the coefficients computed by `SplineA`.
Protected methodSplineC1 Calculates the spline coefficients a(i), b(i), c(i), d(i) for a spline with a given 1st derivative vector. Uses the coefficients calculated by `SplineA` and `SplineB1`.
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Fields
 NameDescription
Protected fielda 
Protected fieldb 
Protected fieldboundary 
Protected fieldc 
Protected fieldd 
Protected fielddx 
Protected fielddy 
Protected fieldp 
Protected fieldr1 
Protected fieldr2 
Protected fieldxReference to the vector of the independent variable.
(Inherited from CurveBase)
Protected fieldyReference to the vector of the dependent variable.
(Inherited from CurveBase)
Top
Remarks
C#
The basis functions for rational cubic splines are

  g1 = u
  g2 = t                     with   t = (x - x(i)) / (x(i+1) - x(i))
  g3 = u^3 / (p*t + 1)              u = 1 - t
  g4 = t^3 / (p*u + 1)

A rational spline with coefficients a(i),b(i),c(i),d(i) is determined by

         f(i)(x) = a(i)*g1 + b(i)*g2 + c(i)*g3 + d(i)*g4

Choosing the smoothing parameter p:
-----------------------------------

Use the method

     void MpRationalCubicSpline::SetSmoothing (double smoothing)

to set the value of the smoothing parameter. A value of p = 0
for the smoothing parameter results in a standard cubic spline.
A value of p with -1 < p < 0 results in "unsmoothing", i.e.
overshooting oscillations. A value of p with p > 0 gives increasing
smoothness. p to infinity results in a linear interpolation. A value
smaller than or equal to -1.0 leads to an error.


Choosing the boundary conditions:
---------------------------------

Use the method

     void MpRationalCubicSpline::SetBoundaryConditions (int boundary,
                      double b1, double b2)

to set the boundary conditions. The following values are possible:

     Natural
         natural boundaries, i.e. the 2nd derivatives are zero
         at both boundaries. This is the default value.

     FiniteDifferences
         use finite difference approximation for 1st derivatives.

     Supply1stDerivative
         user supplied values for 1st derivatives are given in b1 and b2
         i.e. f'(x_lo) in b1
              f'(x_hi) in b2

     Supply2ndDerivative
         user supplied values for 2nd derivatives are given in b1 and b2
         i.e. f''(x_lo) in b1
              f''(x_hi) in b2

     Periodic
         periodic boundary conditions for periodic curves or functions.
         NOT YET IMPLEMENTED IN THIS VERSION.


If the parameters b1,b2 are omitted the default value is 0.0.


Input parameters:
-----------------

     Vector x(lo,hi)  The abscissa vector
     Vector y(lo,hi)  The ordinate vector
                      If the spline is not parametric then the
                      abscissa must be strictly monotone increasing
                      or decreasing!


References:
-----------
  Dr.rer.nat. Helmuth Spaeth,
  Spline-Algorithmen zur Konstruktion glatter Kurven und Flaechen,
  3. Auflage, R. Oldenburg Verlag, Muenchen, Wien, 1983.
See Also