## Cubic splines

Cubic splines

## Functions

void | go_cspline_destroy ()
void | go_cspline_destroyl ()
double | go_cspline_get_deriv ()
long double | go_cspline_get_derivl ()
double * | go_cspline_get_derivs ()
long double * | go_cspline_get_derivsl ()
double * | go_cspline_get_integrals ()
long double * | go_cspline_get_integralsl ()
double | go_cspline_get_value ()
long double | go_cspline_get_valuel ()
double * | go_cspline_get_values ()
long double * | go_cspline_get_valuesl ()
GOCSpline * | go_cspline_init ()
GOCSplinel * | go_cspline_initl ()

## Types and Values

enum | GOCSplineType

## Object Hierarchy

        GBoxed
        ├── GOCSpline
        ╰── GOCSplinel

## Description

## Functions

### go_cspline_destroy ()

    void
    go_cspline_destroy (GOCSpline *sp);

Frees the spline structure when done.

#### Parameters

sp | a spline structure returned by go_cspline_init. |

### go_cspline_destroyl ()

    void
    go_cspline_destroyl (GOCSplinel *sp);

Frees the spline structure when done.

#### Parameters

sp | a spline structure returned by go_cspline_init. |

### go_cspline_get_deriv ()

    double
    go_cspline_get_deriv (GOCSpline const *sp,
                          double x);

sp must be a valid spline structure as returned by go_cspline_init.

#### Parameters

sp | a spline structure returned by go_cspline_init. |
x | the value |

#### Returns

the interpolated derivative at x, or 0 if an error occurred.

### go_cspline_get_derivl ()

    long double
    go_cspline_get_derivl (GOCSplinel const *sp,
                           long double x);

sp must be a valid spline structure as returned by go_cspline_init.

#### Parameters

sp | a spline structure returned by go_cspline_init. |
x | the value |

#### Returns

the interpolated derivative at x, or 0 if an error occurred.

### go_cspline_get_derivs ()

    double *
    go_cspline_get_derivs (GOCSpline const *sp,
                           double const *x,
                           int n);

sp must be a valid spline structure as returned by go_cspline_init. The x values must be sorted in increasing order.

#### Parameters

sp | a spline structure returned by go_cspline_init. |
x | a vector a values at which interpolation is requested. |
n | the number of interpolation requested. |

#### Returns

a newly allocated array of the n interpolated derivatives which should be destroyed by a call to g_free when not anymore needed, or `NULL` if an error occurred.

### go_cspline_get_derivsl ()

    long double *
    go_cspline_get_derivsl (GOCSplinel const *sp,
                            long double const *x,
                            int n);

sp must be a valid spline structure as returned by go_cspline_init. The x values must be sorted in increasing order.

#### Parameters

sp | a spline structure returned by go_cspline_init. |
x | a vector a values at which interpolation is requested. |
n | the number of interpolation requested. |

#### Returns

a newly allocated array of the n interpolated derivatives which should be destroyed by a call to g_free when not anymore needed, or `NULL` if an error occurred.

### go_cspline_get_integrals ()

    double *
    go_cspline_get_integrals (GOCSpline const *sp,
                              double const *x,
                              int n);

sp must be a valid spline structure as returned by go_cspline_init. The x values must be sorted in increasing order.

#### Parameters

sp | a spline structure returned by go_cspline_init. |
x | a vector a values at which interpolation is requested. |
n | the number of interpolation requested. |

#### Returns

a newly allocated array of the n-1 integrals on the intervals between two consecutive values stored in x. which should be destroyed by a call to g_free when not anymore needed, or `NULL` if an error occurred.

### go_cspline_get_integralsl ()

    long double *
    go_cspline_get_integralsl (GOCSplinel const *sp,
                               long double const *x,
                               int n);

sp must be a valid spline structure as returned by go_cspline_init. The x values must be sorted in increasing order.

#### Parameters

sp | a spline structure returned by go_cspline_init. |
x | a vector a values at which interpolation is requested. |
n | the number of interpolation requested. |

#### Returns

a newly allocated array of the n-1 integrals on the intervals between two consecutive values stored in x. which should be destroyed by a call to g_free when not anymore needed, or `NULL` if an error occurred.

### go_cspline_get_value ()

    double
    go_cspline_get_value (GOCSpline const *sp,
                          double x);

sp must be a valid spline structure as returned by go_cspline_init.

#### Parameters

sp | a spline structure returned by go_cspline_init. |
x | The value |

#### Returns

the interpolated value for x, or 0 if an error occurred.

### go_cspline_get_valuel ()

    long double
    go_cspline_get_valuel (GOCSplinel const *sp,
                           long double x);

sp must be a valid spline structure as returned by go_cspline_init.

#### Parameters

sp | a spline structure returned by go_cspline_init. |
x | The value |

#### Returns

the interpolated value for x, or 0 if an error occurred.

### go_cspline_get_values ()

    double *
    go_cspline_get_values (GOCSpline const *sp,
                           double const *x,
                           int n);

sp must be a valid spline structure as returned by go_cspline_init. The x values must be sorted in increasing order.

#### Parameters

sp | a spline structure returned by go_cspline_init. |
x | a vector a values at which interpolation is requested. |
n | the number of interpolation requested. |

#### Returns

a newly allocated array of interpolated values which should be destroyed by a call to g_free when not anymore needed, or `NULL` if an error occurred.

### go_cspline_get_valuesl ()

    long double *
    go_cspline_get_valuesl (GOCSplinel const *sp,
                            long double const *x,
                            int n);

sp must be a valid spline structure as returned by go_cspline_init. The x values must be sorted in increasing order.

#### Parameters

sp | a spline structure returned by go_cspline_init. |
x | a vector a values at which interpolation is requested. |
n | the number of interpolation requested. |

#### Returns

a newly allocated array of interpolated values which should be destroyed by a call to g_free when not anymore needed, or `NULL` if an error occurred.

### go_cspline_init ()

    GOCSpline *
    go_cspline_init (double const *x,
                     double const *y,
                     int n,
                     unsigned  limits,
                     double c0,
                     double cn);

Creates a spline structure, and computes the coefficients associated with the polynomials. The ith polynomial (between x[i-1] and x[i] is: y(x) = y[i-1] + (c[i-1] + (b[i-1] + a[i] * (x - x[i-1])) * (x - x[i-1])) * (x - x[i-1]) where a[i-1], b[i-1], c[i-1], x[i-1] and y[i-1] are the corresponding members of the new structure.

[skip]

#### Parameters

x | the x values |
y | the y values |
n | the number of x and y values |
limits | how the limits must be treated, four values are allowed: GO_CSPLINE_NATURAL: first and least second derivatives are 0. GO_CSPLINE_PARABOLIC: the curve will be a parabolic arc outside of the limits. GO_CSPLINE_CUBIC: the curve will be cubic outside of the limits. GO_CSPLINE_CLAMPED: the first and last derivatives are imposed. |
c0 | the first derivative when using clamped splines, not used in the other limit types. |
cn | the first derivative when using clamped splines, not used in the other limit types. |

#### Returns

a newly created GOCSpline instance which should be destroyed by a call to go_cspline_destroy.

### go_cspline_initl ()

    GOCSplinel *
    go_cspline_initl (long double const *x,
                      long double const *y,
                      int n,
                      unsigned  limits,
                      long double c0,
                      long double cn);

Creates a spline structure, and computes the coefficients associated with the polynomials. The ith polynomial (between x[i-1] and x[i] is: y(x) = y[i-1] + (c[i-1] + (b[i-1] + a[i] * (x - x[i-1])) * (x - x[i-1])) * (x - x[i-1]) where a[i-1], b[i-1], c[i-1], x[i-1] and y[i-1] are the corresponding members of the new structure.

[skip]

#### Parameters

x | the x values |
y | the y values |
n | the number of x and y values |
limits | how the limits must be treated, four values are allowed: GO_CSPLINE_NATURAL: first and least second derivatives are 0. GO_CSPLINE_PARABOLIC: the curve will be a parabolic arc outside of the limits. GO_CSPLINE_CUBIC: the curve will be cubic outside of the limits. GO_CSPLINE_CLAMPED: the first and last derivatives are imposed. |
c0 | the first derivative when using clamped splines, not used in the other limit types. |
cn | the first derivative when using clamped splines, not used in the other limit types. |

#### Returns

a newly created GOCSpline instance which should be destroyed by a call to go_cspline_destroy.

## Types and Values

### enum GOCSplineType

#### Members

GO_CSPLINE_NATURAL | natural. |
GO_CSPLINE_PARABOLIC | parabolic. |
GO_CSPLINE_CUBIC | cubic. |
GO_CSPLINE_CLAMPED | clamped. |