NcmSpline

NcmSpline — Abstract class for implementing splines.

Stability Level

Stable, unless otherwise indicated

Functions

Properties

guint length Read / Write / Construct Only
NcmVector * x Read / Write
NcmVector * y Read / Write

Types and Values

Object Hierarchy

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

Includes

#include <numcosmo/math/ncm_spline.h>

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

a NcmSpline.

[transfer none]


ncm_spline_ref ()

NcmSpline *
ncm_spline_ref (NcmSpline *s);

Increases the reference count of s by one.

Parameters

s

a NcmSpline

 

Returns

s .

[transfer full]


ncm_spline_acc ()

void
ncm_spline_acc (NcmSpline *s,
                gboolean enable);

Enables or disables spline accelerator. Note that, if enabled, the spline becomes non-reentrant. In other words, if enable is TRUE, the spline evaluation is not thread safe. Therefore, it should not be called concomitantly by two different threads.

Warning: the accelerator must be reset if the spline's size changes, otherwise, it can accessan out-of-bound index.

Parameters

s

a NcmSpline

 

enable

a boolean

 

ncm_spline_peek_acc ()

gsl_interp_accel *
ncm_spline_peek_acc (NcmSpline *s);

This function returns the spline accelerator if it is enabled. Otherwise, it returns NULL.

[skip]

Parameters

s

a NcmSpline

 

Returns

a gsl_interp_accel.

[transfer none]


ncm_spline_set_len ()

void
ncm_spline_set_len (NcmSpline *s,
                    guint len);

This function sets len as the length of the spline, it allocates the necessary NcmVector. If it is already allocated with different length it frees the current vectors and allocates new ones.

Parameters

s

a NcmSpline

 

len

number of knots in the spline

 

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_len ()

guint
ncm_spline_get_len (NcmSpline *s);

This function gets the length of the spline.

Parameters

s

a NcmSpline

 

Returns

spline's size.


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_peek_xv ()

NcmVector *
ncm_spline_peek_xv (NcmSpline *s);

This function returns the s NcmVector of knots.

Parameters

s

a NcmSpline

 

Returns

a NcmVector.

[transfer none]


ncm_spline_peek_yv ()

NcmVector *
ncm_spline_peek_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 none]


ncm_spline_get_bounds ()

void
ncm_spline_get_bounds (NcmSpline *s,
                       gdouble *lb,
                       gdouble *ub);

This function returns the lower and upper bound of s .

Parameters

s

a NcmSpline

 

lb

spline lower bound.

[out]

ub

spline upper bound.

[out]

ncm_spline_is_init ()

gboolean
ncm_spline_is_init (NcmSpline *s);

This function returns TRUE if s is initialized or FALSE otherwise.

Parameters

s

a NcmSpline

 

Returns

TRUE if s is initialized or FALSE otherwise.


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);

Parameters

s

a constant NcmSpline

 

Returns

TRUE If s is empty or FALSE otherwise.


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

NCM_TYPE_SPLINE

#define NCM_TYPE_SPLINE (ncm_spline_get_type ())

struct NcmSplineClass

struct NcmSplineClass {
};

NcmSpline

typedef struct _NcmSpline NcmSpline;

Property Details

The “length” property

  “length”                   guint

The spline length (total number of knots).

Owner: NcmSpline

Flags: Read / Write / Construct Only

Default value: 0


The “x” property

  “x”                        NcmVector *

NcmVector with the spline knots.

Owner: NcmSpline

Flags: Read / Write


The “y” property

  “y”                        NcmVector *

NcmVector with the spline values.

Owner: NcmSpline

Flags: Read / Write