Spline Abstract Class

Spline Abstract Class — Base class for implementing splines

Types and Values

const gdouble r1
const gdouble r2
const gdouble r12
const gdouble bterm
const gdouble cterm
const gdouble dterm

Object Hierarchy

    GObject
    ╰── NcmSpline
        ├── NcmSplineCubic
        ╰── NcmSplineGsl

Description

This class comprises all functions to provide a NcmSpline, together with all necessary methods.

Functions

ncm_spline_copy_empty ()

NcmSpline *
ncm_spline_copy_empty (const NcmSpline *s);

This function copies the spline s into an initialized empty NcmSpline of a specific type.

Parameters

s

a constant NcmSpline.

 

Returns

A NcmSpline.

[transfer full]


ncm_spline_copy ()

NcmSpline *
ncm_spline_copy (const NcmSpline *s);

This function copies the two NcmVector of the spline s into those two NcmVector of a new NcmSpline.

Parameters

s

a costant NcmSpline.

 

Returns

A NcmSpline.

[transfer full]


ncm_spline_new ()

NcmSpline *
ncm_spline_new (const NcmSpline *s,
                NcmVector *xv,
                NcmVector *yv,
                const gboolean init);

This function returns a new NcmSpline, where the knots of this new spline are given in the NcmVector xv and the values of the function, at those knots, to be interpolated are given in the NcmVector yv .

Parameters

s

a constant NcmSpline.

 

xv

NcmVector of knots.

 

yv

NcmVector of the values of the function, to be interpolated, computed at xv .

 

init

TRUE to prepare the new NcmSpline or FALSE to not prepare it.

 

Returns

A new NcmSpline.

[transfer full]


ncm_spline_new_array ()

NcmSpline *
ncm_spline_new_array (const NcmSpline *s,
                      GArray *x,
                      GArray *y,
                      const gboolean init);

This function returns a new NcmSpline, where the knots of this new spline are given in the GArray x and the values of the function, at those knots, to be interpolated are given in the GArray y .

Parameters

s

a constant NcmSpline.

 

x

GArray of knots.

[element-type double]

y

GArray of the values of the function, to be interpolated, computed at x .

[element-type double]

init

TRUE to prepare the new NcmSpline or FALSE to not prepare it.

 

Returns

A new NcmSpline.

[transfer full]


ncm_spline_new_data ()

NcmSpline *
ncm_spline_new_data (const NcmSpline *s,
                     gdouble *x,
                     gdouble *y,
                     const gsize len,
                     const gboolean init);

This function returns a new NcmSpline, where the knots of this new spline are given in the array x and the values of the function, at those knots, to be interpolated are given in the array y .

Parameters

s

a constant NcmSpline.

 

x

array of knots.

 

y

array of the values of the function, to be interpolated, computed at x .

 

len

lenght of x and y .

 

init

TRUE to prepare the new NcmSpline or FALSE to not prepare it.

 

Returns

A new NcmSpline.

[transfer full]


ncm_spline_set ()

NcmSpline *
ncm_spline_set (NcmSpline *s,
                NcmVector *xv,
                NcmVector *yv,
                gboolean init);

This funtion sets both xv and yv vectors to s . The two vectors must have the same length.

Parameters

s

a NcmSpline.

 

xv

NcmVector of knots.

 

yv

NcmVector of the values of the function, to be interpolated, computed at xv .

 

init

TRUE to prepare s or FALSE to not prepare it.

 

Returns

FIXME.

[transfer none]


ncm_spline_ref ()

NcmSpline *
ncm_spline_ref (NcmSpline *s);

FIXME

Parameters

s

a NcmSpline.

 

Returns

FIXME.

[transfer full]


ncm_spline_set_xv ()

void
ncm_spline_set_xv (NcmSpline *s,
                   NcmVector *xv,
                   gboolean init);

This function sets xv as the knot vector of the spline.

Parameters

s

a NcmSpline.

 

xv

NcmVector of knots.

 

init

TRUE to prepare s or FALSE to not prepare it.

 

ncm_spline_set_yv ()

void
ncm_spline_set_yv (NcmSpline *s,
                   NcmVector *yv,
                   gboolean init);

This function sets yv as the function values vector. This NcmVector yv comprises the function values computed at the knots of the spline.

Parameters

s

a NcmSpline.

 

yv

NcmVector of the values of the function to be interpolated.

 

init

TRUE to prepare s or FALSE to not prepare it.

 

ncm_spline_set_array ()

void
ncm_spline_set_array (NcmSpline *s,
                      GArray *x,
                      GArray *y,
                      gboolean init);

This function sets x as the knot vector and y as the function values vector of the spline.

Parameters

s

a NcmSpline.

 

x

GArray of knots.

[element-type double]

y

GArray of the values of the function, to be interpolated, computed at x .

[element-type double]

init

TRUE to prepare s or FALSE to not prepare it.

 

ncm_spline_set_data_static ()

void
ncm_spline_set_data_static (NcmSpline *s,
                            gdouble *x,
                            gdouble *y,
                            gsize len,
                            gboolean init);

This function sets x as the knot vector and y as the function values vector of the spline.

Parameters

s

a NcmSpline.

 

x

array of knots.

 

y

array of the values of the function, to be interpolated, computed at x .

 

len

lenght of x and y .

 

init

TRUE to prepare s or FALSE to not prepare it.

 

ncm_spline_get_xv ()

NcmVector *
ncm_spline_get_xv (NcmSpline *s);

This function returns the s NcmVector of knots.

Parameters

s

a NcmSpline

 

Returns

A NcmVector.

[transfer full]


ncm_spline_get_yv ()

NcmVector *
ncm_spline_get_yv (NcmSpline *s);

This function returns the s NcmVector of the values of the function to be interpolated.

Parameters

s

a NcmSpline.

 

Returns

A NcmVector.

[transfer full]


ncm_spline_free ()

void
ncm_spline_free (NcmSpline *s);

Atomically decrements the reference count of s by one. If the reference count drops to 0, all memory allocated by s is released.

Parameters

s

a NcmSpline.

 

ncm_spline_clear ()

void
ncm_spline_clear (NcmSpline **s);

Atomically decrements the reference count of s by one. If the reference count drops to 0, all memory allocated by s is released. The pointer is set to NULL.

Parameters

s

a NcmSpline.

 

ncm_spline_prepare ()

void
ncm_spline_prepare (NcmSpline *s);

This function prepares the spline s such that one can evaluate it (ncm_spline_eval), as well as to compute its first and second derivatives (ncm_spline_eval_deriv, ncm_spline_eval_deriv2) and integration (ncm_spline_eval_integ).

Parameters

s

a NcmSpline.

 

ncm_spline_prepare_base ()

void
ncm_spline_prepare_base (NcmSpline *s);

This function computes the second derivatives of s and it is used to prepare a bidimensional spline.

Parameters

s

a NcmSpline.

 

ncm_spline_eval ()

gdouble
ncm_spline_eval (const NcmSpline *s,
                 const gdouble x);

Parameters

s

a constant NcmSpline.

 

x

x-coordinate value.

 

Returns

The interpolated value of a function computed at x .


ncm_spline_eval_deriv ()

gdouble
ncm_spline_eval_deriv (const NcmSpline *s,
                       const gdouble x);

Parameters

s

a constant NcmSpline.

 

x

x-coordinate value.

 

Returns

The derivative of an interpolated function computed at x .


ncm_spline_eval_deriv2 ()

gdouble
ncm_spline_eval_deriv2 (const NcmSpline *s,
                        const gdouble x);

Parameters

s

a constant NcmSpline.

 

x

x-coordinate value.

 

Returns

The second derivative of an interpolated function computed at x .


ncm_spline_eval_deriv_nmax ()

gdouble
ncm_spline_eval_deriv_nmax (const NcmSpline *s,
                            const gdouble x);

Parameters

s

a constant NcmSpline.

 

x

x-coordinate value.

 

Returns

The highest non null derivative of an interpolated function computed at x .


ncm_spline_eval_integ ()

gdouble
ncm_spline_eval_integ (const NcmSpline *s,
                       const gdouble x0,
                       const gdouble x1);

Parameters

s

a constant NcmSpline.

 

x0

lower integration limit.

 

x1

upper integration limit.

 

Returns

The numerical integral of an interpolated function over the range [x0 , x1 ].


ncm_spline_is_empty ()

gboolean
ncm_spline_is_empty (const NcmSpline *s);

ncm_spline_min_size ()

gsize
ncm_spline_min_size (const NcmSpline *s);

Parameters

s

a constant NcmSpline.

 

Returns

Minimum number of knots required.


ncm_spline_get_index ()

guint
ncm_spline_get_index (const NcmSpline *s,
                      const gdouble x);

Parameters

s

a constant NcmSpline.

 

x

a value of the abscissa axis.

 

Returns

The index of the lower knot of the interval x belongs to.

Types and Values

r1

  const gdouble r1 = a - xi;

r2

  const gdouble r2 = b - xi;

r12

  const gdouble r12 = r1 + r2;

bterm

  const gdouble bterm = 0.5 * bi * r12;

cterm

  const gdouble cterm = (1.0 / 3.0) * ci * (r1 * r1 + r2 * r2 + r1 * r2);

dterm

  const gdouble dterm = 0.25 * di * r12 * (r1 * r1 + r2 * r2);