NcmSpline2d

NcmSpline2d — Abstract class for implementing bidimensional splines.

Stability Level

Stable, unless otherwise indicated

Functions

Properties

gboolean init Read / Write
NcmSpline * spline Read / Write / Construct Only
gboolean use-acc Read / Write
NcmVector * x-vector Read / Write
NcmVector * y-vector Read / Write
NcmMatrix * z-matrix Read / Write

Types and Values

Object Hierarchy

    GObject
    ╰── NcmSpline2d
        ├── NcmSpline2dBicubic
        ├── NcmSpline2dGsl
        ╰── NcmSpline2dSpline

Includes

#include <numcosmo/math/ncm_spline2d.h>

Description

This class comprises all functions to provide a NcmSpline2d, get its properties and evaluate it given an interpolation method.

Functions

ncm_spline2d_set ()

void
ncm_spline2d_set (NcmSpline2d *s2d,
                  NcmVector *xv,
                  NcmVector *yv,
                  NcmMatrix *zm,
                  gboolean init);

This funtion sets xv and yv vectors and zm matrix to s2d .

Parameters

s2d

a NcmSpline2d

 

xv

a NcmVector of knots

 

yv

a NcmVector of knots

 

zm

a NcmMatrix of the values of the function, to be interpolated, computed at xv and yv

 

init

TRUE to prepare the NcmSpline2d or FALSE to not prepare it

 

ncm_spline2d_set_function ()

void
ncm_spline2d_set_function (NcmSpline2d *s2d,
                           NcmSplineFuncType ftype,
                           gsl_function *Fx,
                           gsl_function *Fy,
                           gdouble xl,
                           gdouble xu,
                           gdouble yl,
                           gdouble yu,
                           gdouble rel_err);

This function automatically determines the knots of s2d in the intervals [xl , xu ] and [yl , yu ] given a ftype and rel_error .

The functions Fx and Fy are the bidimensional function given at specific values of y and x, respectively. These x and y values must be in the the intervals [xl , xu ] and [yl , yu ].

[skip]

Parameters

s2d

a NcmSpline2d

 

ftype

a NcmSplineFuncType

 

Fx

function of x variable to be approximated by spline functions

 

Fy

function of y variable to be approximated by spline functions

 

xl

lower knot of x-coordinate

 

xu

upper knot of x-coordinate

 

yl

lower knot of y-coordinate

 

yu

upper knot of y-coordinate

 

rel_err

relative error between the function to be interpolated and the spline result

 

ncm_spline2d_prepare ()

void
ncm_spline2d_prepare (NcmSpline2d *s2d);

This function prepares the bi-dimensional spline s2d such that one can evaluate it (ncm_spline2d_eval), as well as to compute its integration in x, y or both directions.

Parameters

s2d

a NcmSpline2d

 

ncm_spline2d_min_size ()

guint
ncm_spline2d_min_size (NcmSpline2d *s2d);

Parameters

s2d

a NcmSpline2d

 

Returns

The size of the NcmSpline member of s2d .


ncm_spline2d_copy_empty ()

NcmSpline2d *
ncm_spline2d_copy_empty (const NcmSpline2d *s2d);

This function copies the bidimensional spline s2d into an initialized empty NcmSpline2d of a specific type.

Parameters

s2d

a NcmSpline2d

 

Returns

a NcmSpline2d.

[transfer full]


ncm_spline2d_copy ()

NcmSpline2d *
ncm_spline2d_copy (NcmSpline2d *s2d);

This function copies the two NcmVector and the NcmMatrix of the bidimensional spline s2d into those two NcmVector and NcmMatrix of a new NcmSpline2d.

Parameters

s2d

a NcmSpline2d

 

Returns

A NcmSpline2d.

[transfer full]


ncm_spline2d_new ()

NcmSpline2d *
ncm_spline2d_new (const NcmSpline2d *s2d,
                  NcmVector *xv,
                  NcmVector *yv,
                  NcmMatrix *zm,
                  gboolean init);

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

Parameters

s2d

a constant NcmSpline2d

 

xv

NcmVector of knots

 

yv

NcmVector of knots

 

zm

NcmMatrix of the values of the function, to be interpolated, computed at xv and yv

 

init

TRUE to prepare the new NcmSpline2d or FALSE to not prepare it

 

Returns

A new NcmSpline2d.

[transfer full]


ncm_spline2d_ref ()

NcmSpline2d *
ncm_spline2d_ref (NcmSpline2d *s2d);

Atomically increases the reference count of s2d by one.

Parameters

s2d

a NcmSpline2d

 

Returns

the same object s2d .

[transfer full]


ncm_spline2d_free ()

void
ncm_spline2d_free (NcmSpline2d *s2d);

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

Parameters

s2d

a NcmSpline2d

 

ncm_spline2d_clear ()

void
ncm_spline2d_clear (NcmSpline2d **s2d);

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

Parameters

s2d

a NcmSpline2d

 

ncm_spline2d_use_acc ()

void
ncm_spline2d_use_acc (NcmSpline2d *s2d,
                      gboolean use_acc);

Whether to use accelerated bsearch to find the right knots. When enabled evaluation functions are not reentrant.

Parameters

s2d

a NcmSpline2d

 

use_acc

a boolean

 

ncm_spline2d_set_init ()

void
ncm_spline2d_set_init (NcmSpline2d *s2d,
                       gboolean init);

Whether to mark the NcmSpline2d as initialized. This method is intended for internal use only.

Parameters

s2d

a NcmSpline2d

 

init

a boolean

 

ncm_spline2d_peek_spline ()

NcmSpline *
ncm_spline2d_peek_spline (NcmSpline2d *s2d);

Get the NcmSpline of the NcmSpline2d. This method is intended for internal use only.

Parameters

s2d

a NcmSpline2d

 

Returns

The NcmSpline of the NcmSpline2d.

[transfer none]


ncm_spline2d_peek_xv ()

NcmVector *
ncm_spline2d_peek_xv (NcmSpline2d *s2d);

Get the NcmVector of knots in the x-direction. This method is intended for internal use only.

Parameters

s2d

a NcmSpline2d

 

Returns

The NcmVector of knots in the x-direction.

[transfer none]


ncm_spline2d_peek_yv ()

NcmVector *
ncm_spline2d_peek_yv (NcmSpline2d *s2d);

Get the NcmVector of knots in the y-direction. This method is intended for internal use only.

Parameters

s2d

a NcmSpline2d

 

Returns

The NcmVector of knots in the y-direction.

[transfer none]


ncm_spline2d_peek_zm ()

NcmMatrix *
ncm_spline2d_peek_zm (NcmSpline2d *s2d);

Get the NcmMatrix of the values of the function, to be interpolated, computed at the knots. This method is intended for internal use only.

Parameters

s2d

a NcmSpline2d

 

Returns

The NcmMatrix of the values of the function, to be interpolated, computed at the knots.

[transfer none]


ncm_spline2d_peek_acc_x ()

gsl_interp_accel *
ncm_spline2d_peek_acc_x (NcmSpline2d *s2d);

Get the gsl_interp_accel of the NcmSpline2d in the x-direction. This method is intended for internal use only.

[skip]

Parameters

s2d

a NcmSpline2d

 

Returns

The gsl_interp_accel of the NcmSpline2d in the x-direction.

[transfer none]


ncm_spline2d_peek_acc_y ()

gsl_interp_accel *
ncm_spline2d_peek_acc_y (NcmSpline2d *s2d);

Get the gsl_interp_accel of the NcmSpline2d in the y-direction. This method is intended for internal use only.

[skip]

Parameters

s2d

a NcmSpline2d

 

Returns

The gsl_interp_accel of the NcmSpline2d in the y-direction.

[transfer none]


ncm_spline2d_is_init ()

gboolean
ncm_spline2d_is_init (NcmSpline2d *s2d);

Whether the NcmSpline2d is initialized.

Parameters

s2d

a NcmSpline2d

 

Returns

TRUE if the NcmSpline2d is initialized.


ncm_spline2d_has_no_stride ()

gboolean
ncm_spline2d_has_no_stride (NcmSpline2d *s2d);

Whether the NcmSpline2d has stride 1 in both knots vectors.

Parameters

s2d

a NcmSpline2d

 

Returns

TRUE if the NcmSpline2d has stride 1 in both knots vectors.


ncm_spline2d_using_acc ()

gboolean
ncm_spline2d_using_acc (NcmSpline2d *s2d);

Whether the NcmSpline2d is using accelerated bsearch to find the right knots.

Parameters

s2d

a NcmSpline2d

 

Returns

TRUE if the NcmSpline2d is using accelerated bsearch to find the right knots.


ncm_spline2d_eval ()

gdouble
ncm_spline2d_eval (NcmSpline2d *s2d,
                   gdouble x,
                   gdouble y);

Parameters

s2d

a NcmSpline2d

 

x

x-coordinate value

 

y

y-coordinate value

 

Returns

The interpolated value of a function computed at the point (x , y ).


ncm_spline2d_integ_dx ()

gdouble
ncm_spline2d_integ_dx (NcmSpline2d *s2d,
                       gdouble xl,
                       gdouble xu,
                       gdouble y);

This function computes the integration in x over the interval [xl , xu ] and at y .

[virtual int_dx]

Parameters

s2d

a NcmSpline2d

 

xl

lower limit of integration

 

xu

upper limit of integration

 

y

y-coordinate value

 

Returns

The numerical integral in x of an interpolated function over the range [xl , xu ] and at y .


ncm_spline2d_integ_dy ()

gdouble
ncm_spline2d_integ_dy (NcmSpline2d *s2d,
                       gdouble x,
                       gdouble yl,
                       gdouble yu);

This function computes the integration in y over the interval [yl , yu ] and at x .

[virtual int_dy]

Parameters

s2d

a NcmSpline2d

 

x

x-coordinate value

 

yl

lower limit of integration

 

yu

upper limit of integration

 

Returns

The numerical integral in y of an interpolated function over the range [yl , yu ] and at x .


ncm_spline2d_integ_dxdy ()

gdouble
ncm_spline2d_integ_dxdy (NcmSpline2d *s2d,
                         gdouble xl,
                         gdouble xu,
                         gdouble yl,
                         gdouble yu);

This function computes the integration in both x and y directions over the intervals [xl , xu ] and [yl , yu ].

[virtual int_dxdy]

Parameters

s2d

a NcmSpline2d

 

xl

lower limit of integration in the x-direction

 

xu

upper limit of integration in the x-direction

 

yl

lower limit of integration in the y-direction

 

yu

upper limit of integration in the y-direction

 

Returns

The numerical integral in x and y of an interpolated function over the ranges [xl , xu ] and [yl , yu ].


ncm_spline2d_integ_dx_spline ()

NcmSpline *
ncm_spline2d_integ_dx_spline (NcmSpline2d *s2d,
                              gdouble xl,
                              gdouble xu);

This function computes the integral in x of the bidimensional interpolated function over the range [xl , xu ] resulting in a one dimensional function.

Parameters

s2d

a NcmSpline2d

 

xl

lower limit of integration x

 

xu

upper limit of integration x

 

Returns

A NcmSpline.

[transfer full]


ncm_spline2d_integ_dy_spline ()

NcmSpline *
ncm_spline2d_integ_dy_spline (NcmSpline2d *s2d,
                              gdouble yl,
                              gdouble yu);

This function computes the integral in y of the bidimensional interpolated function over the range [yl , yu ] resulting in a one dimensional function.

Parameters

s2d

a NcmSpline2d

 

yl

lower limit of integration

 

yu

upper limit of integration

 

Returns

A NcmSpline.

[transfer full]


ncm_spline2d_integ_dx_spline_val ()

gdouble
ncm_spline2d_integ_dx_spline_val (NcmSpline2d *s2d,
                                  gdouble xl,
                                  gdouble xu,
                                  gdouble y);

This function calls ncm_spline2d_integ_dx_spline and evaluates the resulting NcmSpline at y .

Parameters

s2d

a NcmSpline2d

 

xl

lower limit of integration

 

xu

upper limit of integration

 

y

y-coordinate value

 

Returns

The value of s2d integrated in x over the range [xl , xu ] and computed at y .


ncm_spline2d_integ_dy_spline_val ()

gdouble
ncm_spline2d_integ_dy_spline_val (NcmSpline2d *s2d,
                                  gdouble x,
                                  gdouble yl,
                                  gdouble yu);

This function calls ncm_spline2d_integ_dy_spline and evaluates the resulting NcmSpline at x .

Parameters

s2d

a NcmSpline2d

 

x

x-coordinate value

 

yl

lower limit of integration

 

yu

upper limit of integration

 

Returns

The value of s2d integrated in y over the range [yl , yu ] and computed at x .


ncm_spline2d_integ_dxdy_spline_x ()

gdouble
ncm_spline2d_integ_dxdy_spline_x (NcmSpline2d *s2d,
                                  gdouble xl,
                                  gdouble xu,
                                  gdouble yl,
                                  gdouble yu);

This function calls ncm_spline2d_integ_dx_spline and integrates the resulting NcmSpline over the interval [yl , yu ].

Parameters

s2d

a NcmSpline2d

 

xl

lower limit of integration in the x-direction

 

xu

upper limit of integration in the x-direction

 

yl

lower limit of integration in the y-direction

 

yu

upper limit of integration in the y-direction

 

Returns

The value of s2d integrated in x and y over the ranges [xl , xu ] and [yl , yu ], respectively.


ncm_spline2d_integ_dxdy_spline_y ()

gdouble
ncm_spline2d_integ_dxdy_spline_y (NcmSpline2d *s2d,
                                  gdouble xl,
                                  gdouble xu,
                                  gdouble yl,
                                  gdouble yu);

This function calls ncm_spline2d_integ_dy_spline and integrates the resulting NcmSpline over the interval [xl , xu ].

Parameters

s2d

a NcmSpline2d

 

xl

lower limit of integration in the x-direction

 

xu

upper limit of integration in the x-direction

 

yl

lower limit of integration in the y-direction

 

yu

upper limit of integration in the y-direction

 

Returns

The value of s2d integrated in x and y over the ranges [xl , xu ] and [yl , yu ], respectively.


ncm_spline2d_deriv_dzdx ()

gdouble
ncm_spline2d_deriv_dzdx (NcmSpline2d *s2d,
                         gdouble x,
                         gdouble y);

[virtual dzdx]

Parameters

s2d

a NcmSpline2d

 

x

x-coordinate value

 

y

y-coordinate value

 

Returns

The interpolated derivative $\mathrm{d}z/\mathrm{d}x$ computed at the point (x , y ).


ncm_spline2d_deriv_dzdy ()

gdouble
ncm_spline2d_deriv_dzdy (NcmSpline2d *s2d,
                         gdouble x,
                         gdouble y);

[virtual dzdy]

Parameters

s2d

a NcmSpline2d

 

x

x-coordinate value

 

y

y-coordinate value

 

Returns

The interpolated derivative $\mathrm{d}z/\mathrm{d}y$ computed at the point (x , y ).


ncm_spline2d_deriv_d2zdxy ()

gdouble
ncm_spline2d_deriv_d2zdxy (NcmSpline2d *s2d,
                           gdouble x,
                           gdouble y);

[virtual d2zdxy]

Parameters

s2d

a NcmSpline2d

 

x

x-coordinate value

 

y

y-coordinate value

 

Returns

The interpolated derivative $\mathrm{d}^2z/\mathrm{d}x\mathrm{d}y$ computed at the point (x , y ).


ncm_spline2d_deriv_d2zdx2 ()

gdouble
ncm_spline2d_deriv_d2zdx2 (NcmSpline2d *s2d,
                           gdouble x,
                           gdouble y);

[virtual d2zdx2]

Parameters

s2d

a NcmSpline2d

 

x

x-coordinate value

 

y

y-coordinate value

 

Returns

The interpolated derivative $\mathrm{d}^2z/\mathrm{d}x^2$ computed at the point (x , y ).


ncm_spline2d_deriv_d2zdy2 ()

gdouble
ncm_spline2d_deriv_d2zdy2 (NcmSpline2d *s2d,
                           gdouble x,
                           gdouble y);

[virtual d2zdy2]

Parameters

s2d

a NcmSpline2d

 

x

x-coordinate value

 

y

y-coordinate value

 

Returns

The interpolated derivative $\mathrm{d}^2z/\mathrm{d}y^2$ computed at the point (x , y ).


ncm_spline2dim_integ_total ()

gdouble
ncm_spline2dim_integ_total (NcmSpline2d *s2d);

Parameters

s2d

a NcmSpline2d

 

Returns

The numerical integral in both x and y directions of an interpolated function over the entire valid ranges of x and y coordinates.


ncm_spline2d_eval_vec_y ()

void
ncm_spline2d_eval_vec_y (NcmSpline2d *s2d,
                         gdouble x,
                         const NcmVector *y,
                         GArray *order,
                         GArray *res);

Computes the interpolated values of a function computed at the point (x , y ) for each element of y . The order of the indices of y is given by order .

Parameters

s2d

a NcmSpline2d

 

x

x-coordinate value

 

y

a NcmVector

 

order

an array of containing the order of the indices of y .

[element-type size_t][allow-none]

res

an array of the same size as y to store the interpolated values.

[element-type gdouble]

Types and Values

NCM_TYPE_SPLINE2D

#define NCM_TYPE_SPLINE2D (ncm_spline2d_get_type ())

struct NcmSpline2dClass

struct NcmSpline2dClass {
};

NcmSpline2d

typedef struct _NcmSpline2d NcmSpline2d;

Property Details

The “init” property

  “init”                     gboolean

boolean whether to prepare the NcmSpline2d.

Owner: NcmSpline2d

Flags: Read / Write

Default value: FALSE


The “spline” property

  “spline”                   NcmSpline *

NcmSpline object used internally.

Owner: NcmSpline2d

Flags: Read / Write / Construct Only


The “use-acc” property

  “use-acc”                  gboolean

Use accelerated bsearch.

Owner: NcmSpline2d

Flags: Read / Write

Default value: FALSE


The “x-vector” property

  “x-vector”                 NcmVector *

x vector.

Owner: NcmSpline2d

Flags: Read / Write


The “y-vector” property

  “y-vector”                 NcmVector *

y vector.

Owner: NcmSpline2d

Flags: Read / Write


The “z-matrix” property

  “z-matrix”                 NcmMatrix *

z matrix.

Owner: NcmSpline2d

Flags: Read / Write