Click or drag to resize

RationalCubicSpline Class

This kind of generalized splines give much more pleasent 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.3179.0 (4.8.3179.0)
Syntax
C#
public class RationalCubicSpline : CurveBase, 
	IInterpolationFunction, IInterpolationCurve

The RationalCubicSpline type exposes the following members.

Constructors
 NameDescription
Public methodRationalCubicSplineInitializes a new instance of the RationalCubicSpline class
Top
Properties
 NameDescription
Public propertySmoothing Set the value of the smoothing paramenter. 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" that means overshooting oscillations. A value of p with p > 0 gives increasing smoothness. p to infinity results in a linear interpolation. A value smaller 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, the 1st derivative vector y1, the 2nd derivative vector y2, and the 3rd derivative vector y3, using the Horner scheme.
(Inherited from CurveBase)
Public methodCubicSplineHorner1stDerivative
(Inherited from CurveBase)
Public methodStatic memberDifferences Calculate difference vector dx(i) from vector x(i) and assure that x(i) is strictly monotone increasing or decreasing. Can be called with both arguments the same vector in order to do it inplace!
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 and the two condition parameters.
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
(Overrides CurveBaseGetXOfU(Double))
Public methodGetYOfU
(Overrides CurveBaseGetYOfU(Double))
Public methodGetYOfX 
Public methodInterpolate
(Overrides CurveBaseInterpolate(IReadOnlyListDouble, IReadOnlyListDouble))
Public methodStatic memberInverseDifferences Calculate inverse difference vector dx(i) from vector x(i) and assure that x(i) is strictly monotone increasing or decreasing. Can be called with both arguments the same vector in order to do it inplace!
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 
Protected methodSplineB1 
Protected methodSplineB2 
Protected methodSplineC1 
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 paramenter. 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" that means
overshooting oscillations. A value of p with p > 0 gives increasing
smoothness. p to infinity results in a linear interpolation. A value
smaller 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, that means 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 ordinata 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