NcmDiff

NcmDiff — Numerical differentiation object

Functions

Properties

double ini-h Read / Write / Construct
guint max-order Read / Write / Construct
double richardson-step Read / Write / Construct
double round-off-pad Read / Write / Construct
double terr-pad Read / Write / Construct

Types and Values

#define NCM_TYPE_DIFF
  NcmDiff

Object Hierarchy

    GObject
    ╰── NcmDiff

Description

Class to perform numerical differentiation.

Functions

NcmDiffFuncNtoM ()

void
(*NcmDiffFuncNtoM) (NcmVector *x,
                    NcmVector *y,
                    gpointer user_data);

Functon $f(x)$ call back.

Parameters

x

function argument

 

y

function value

 

user_data

user data.

[nullable]

NcmDiffFunc1toM ()

void
(*NcmDiffFunc1toM) (const gdouble x,
                    NcmVector *y,
                    gpointer user_data);

Functon $f(x)$ call back.

Parameters

x

function argument

 

y

function value

 

user_data

user data.

[nullable]

NcmDiffFuncNto1 ()

gdouble
(*NcmDiffFuncNto1) (NcmVector *x,
                    gpointer user_data);

Functon $f(x)$ call back.

Parameters

x

function argument

 

user_data

user data.

[nullable]

NcmDiffFunc1to1 ()

gdouble
(*NcmDiffFunc1to1) (const gdouble x,
                    gpointer user_data);

Functon $f(x)$ call back.

Parameters

x

function argument

 

user_data

user data.

[nullable]

ncm_diff_new ()

NcmDiff *
ncm_diff_new (void);

Creates a new NcmDiff object.

Returns

a new NcmDiff.


ncm_diff_ref ()

NcmDiff *
ncm_diff_ref (NcmDiff *diff);

Increase the reference of diff by one.

Parameters

diff

a NcmDiff

 

Returns

diff .

[transfer full]


ncm_diff_free ()

void
ncm_diff_free (NcmDiff *diff);

Decrease the reference count of diff by one.

Parameters

diff

a NcmDiff

 

ncm_diff_clear ()

void
ncm_diff_clear (NcmDiff **diff);

Decrease the reference count of diff by one, and sets the pointer *diff to NULL.

Parameters

diff

a NcmDiff

 

ncm_diff_get_max_order ()

guint
ncm_diff_get_max_order (NcmDiff *diff);

Gets the maximum order used when calculating the derivatives.

Parameters

diff

a NcmDiff

 

Returns

the maximum order.


ncm_diff_get_richardson_step ()

gdouble
ncm_diff_get_richardson_step (NcmDiff *diff);

Gets the current Richardson step used in the tables.

Parameters

diff

a NcmDiff

 

Returns

the maximum order.


ncm_diff_get_round_off_pad ()

gdouble
ncm_diff_get_round_off_pad (NcmDiff *diff);

Gets the current round-off padding used in calculations.

Parameters

diff

a NcmDiff

 

Returns

the round-off padding.


ncm_diff_get_trunc_error_pad ()

gdouble
ncm_diff_get_trunc_error_pad (NcmDiff *diff);

Gets the current truncation error padding used in calculations.

Parameters

diff

a NcmDiff

 

Returns

the truncation error padding.


ncm_diff_get_ini_h ()

gdouble
ncm_diff_get_ini_h (NcmDiff *diff);

Gets the current initial step used in calculations.

Parameters

diff

a NcmDiff

 

Returns

the initial step.


ncm_diff_set_max_order ()

void
ncm_diff_set_max_order (NcmDiff *diff,
                        const guint maxorder);

Sets the maximum order used when calculating the derivatives to maxorder .

Parameters

diff

a NcmDiff

 

maxorder

the new maximum order

 

ncm_diff_set_richardson_step ()

void
ncm_diff_set_richardson_step (NcmDiff *diff,
                              const gdouble rs);

Sets the Richardson step used in the tables.

Parameters

diff

a NcmDiff

 

rs

the new Richardson step

 

ncm_diff_set_round_off_pad ()

void
ncm_diff_set_round_off_pad (NcmDiff *diff,
                            const gdouble roff_pad);

Sets the round-off padding used in the calculations.

Parameters

diff

a NcmDiff

 

roff_pad

the new round-off padding

 

ncm_diff_set_trunc_error_pad ()

void
ncm_diff_set_trunc_error_pad (NcmDiff *diff,
                              const gdouble terr_pad);

Sets the truncation error padding used in the calculations.

Parameters

diff

a NcmDiff

 

terr_pad

the new truncation error padding

 

ncm_diff_set_ini_h ()

void
ncm_diff_set_ini_h (NcmDiff *diff,
                    const gdouble ini_h);

Sets the initial step used in the calculations.

Parameters

diff

a NcmDiff

 

ini_h

the new initial step

 

ncm_diff_log_central_tables ()

void
ncm_diff_log_central_tables (NcmDiff *diff);

Logs all central tables.

Parameters

diff

a NcmDiff

 

ncm_diff_log_forward_tables ()

void
ncm_diff_log_forward_tables (NcmDiff *diff);

Logs all central tables.

Parameters

diff

a NcmDiff

 

ncm_diff_log_backward_tables ()

void
ncm_diff_log_backward_tables (NcmDiff *diff);

Logs all central tables.

Parameters

diff

a NcmDiff

 

ncm_diff_rf_d1_N_to_M ()

GArray *
ncm_diff_rf_d1_N_to_M (NcmDiff *diff,
                       GArray *x_a,
                       const guint dim,
                       NcmDiffFuncNtoM f,
                       gpointer user_data,
                       GArray **Eerr);

Calculates the first derivative of f : $\partial_i f$ using the forward method plus Richardson extrapolation. The function $f$ is considered as a $f:\mathbb{R}^N\to \mathbb{R}^M$, where $N = $ length of x_a and $M = $ dim .

Parameters

diff

a NcmDiff

 

x_a

function argument.

[array][element-type double][in]

dim

dimension of f

 

f

function to differentiate.

[scope call]

user_data

function user data.

[nullable]

Eerr

estimated errors.

[array][element-type double][out][transfer full]

Returns

The derivative of f at x_a .

[transfer full][array][element-type double]


ncm_diff_rc_d1_N_to_M ()

GArray *
ncm_diff_rc_d1_N_to_M (NcmDiff *diff,
                       GArray *x_a,
                       const guint dim,
                       NcmDiffFuncNtoM f,
                       gpointer user_data,
                       GArray **Eerr);

Calculates the first derivative of f : $\partial_i f$ using the central method plus Richardson extrapolation. The function $f$ is considered as a $f:\mathbb{R}^N\to \mathbb{R}^M$, where $N = $ length of x_a and $M = $ dim .

Parameters

diff

a NcmDiff

 

x_a

function argument.

[array][element-type double][in]

dim

dimension of f

 

f

function to differentiate.

[scope call]

user_data

function user data.

[nullable]

Eerr

estimated errors.

[array][element-type double][out][transfer full]

Returns

The derivative of f at x_a .

[transfer full][array][element-type double]


ncm_diff_rc_d2_N_to_M ()

GArray *
ncm_diff_rc_d2_N_to_M (NcmDiff *diff,
                       GArray *x_a,
                       const guint dim,
                       NcmDiffFuncNtoM f,
                       gpointer user_data,
                       GArray **Eerr);

Calculates the second derivative of f : $\partial_i^2 f$ using the central method plus Richardson extrapolation. The function $f$ is considered as a $f:\mathbb{R}^N\to \mathbb{R}^M$, where $N = $ length of x_a and $M = $ dim .

Parameters

diff

a NcmDiff

 

x_a

function argument.

[array][element-type double][in]

dim

dimension of f

 

f

function to differentiate.

[scope call]

user_data

function user data.

[nullable]

Eerr

estimated errors.

[array][element-type double][out][transfer full]

Returns

The derivative of f at x_a .

[transfer full][array][element-type double]


ncm_diff_rf_d1_1_to_M ()

GArray *
ncm_diff_rf_d1_1_to_M (NcmDiff *diff,
                       const gdouble x,
                       const guint dim,
                       NcmDiffFunc1toM f,
                       gpointer user_data,
                       GArray **Eerr);

Calculates the first derivative of f : $\partial_i f$ using the forward method plus Richardson extrapolation. The function $f$ is considered as a $f:\mathbb{R}^N \to \mathbb{R}$, where $N = $ length of x_a .

Parameters

diff

a NcmDiff

 

x

function argument

 

dim

dimension of f

 

f

function to differentiate.

[scope call]

user_data

function user data.

[nullable]

Eerr

estimated errors.

[array][element-type double][out][transfer full]

Returns

The derivative of f at x_a .

[transfer full][array][element-type double]


ncm_diff_rc_d1_1_to_M ()

GArray *
ncm_diff_rc_d1_1_to_M (NcmDiff *diff,
                       const gdouble x,
                       const guint dim,
                       NcmDiffFunc1toM f,
                       gpointer user_data,
                       GArray **Eerr);

Calculates the first derivative of f : $\partial_i f$ using the central method plus Richardson extrapolation. The function $f$ is considered as a $f:\mathbb{R}^N \to \mathbb{R}$, where $N = $ length of x_a .

Parameters

diff

a NcmDiff

 

x

function argument

 

dim

dimension of f

 

f

function to differentiate.

[scope call]

user_data

function user data.

[nullable]

Eerr

estimated errors.

[array][element-type double][out][transfer full]

Returns

The derivative of f at x_a .

[transfer full][array][element-type double]


ncm_diff_rc_d2_1_to_M ()

GArray *
ncm_diff_rc_d2_1_to_M (NcmDiff *diff,
                       const gdouble x,
                       const guint dim,
                       NcmDiffFunc1toM f,
                       gpointer user_data,
                       GArray **Eerr);

Calculates the second derivative of f : $\partial_i^2 f$ using the central method plus Richardson extrapolation. The function $f$ is considered as a $f:\mathbb{R}^N \to \mathbb{R}$, where $N = $ length of x_a .

Parameters

diff

a NcmDiff

 

x

function argument

 

dim

dimension of f

 

f

function to differentiate.

[scope call]

user_data

function user data.

[nullable]

Eerr

estimated errors.

[array][element-type double][out][transfer full]

Returns

The derivative of f at x_a .

[transfer full][array][element-type double]


ncm_diff_rf_d1_N_to_1 ()

GArray *
ncm_diff_rf_d1_N_to_1 (NcmDiff *diff,
                       GArray *x_a,
                       NcmDiffFuncNto1 f,
                       gpointer user_data,
                       GArray **Eerr);

Calculates the first derivative of f : $\partial_i f$ using the forward method plus Richardson extrapolation. The function $f$ is considered as a $f:\mathbb{R}^N \to \mathbb{R}$, where $N = $ length of x_a .

Parameters

diff

a NcmDiff

 

x_a

function argument.

[array][element-type double][in]

f

function to differentiate.

[scope call]

user_data

function user data.

[nullable]

Eerr

estimated errors.

[array][element-type double][out][transfer full]

Returns

The derivative of f at x_a .

[transfer full][array][element-type double]


ncm_diff_rc_d1_N_to_1 ()

GArray *
ncm_diff_rc_d1_N_to_1 (NcmDiff *diff,
                       GArray *x_a,
                       NcmDiffFuncNto1 f,
                       gpointer user_data,
                       GArray **Eerr);

Calculates the first derivative of f : $\partial_i f$ using the central method plus Richardson extrapolation. The function $f$ is considered as a $f:\mathbb{R}^N \to \mathbb{R}$, where $N = $ length of x_a .

Parameters

diff

a NcmDiff

 

x_a

function argument.

[array][element-type double][in]

f

function to differentiate.

[scope call]

user_data

function user data.

[nullable]

Eerr

estimated errors.

[array][element-type double][out][transfer full]

Returns

The derivative of f at x_a .

[transfer full][array][element-type double]


ncm_diff_rc_d2_N_to_1 ()

GArray *
ncm_diff_rc_d2_N_to_1 (NcmDiff *diff,
                       GArray *x_a,
                       NcmDiffFuncNto1 f,
                       gpointer user_data,
                       GArray **Eerr);

Calculates the second derivative of f : $\partial_i^2 f$ using the central method plus Richardson extrapolation. The function $f$ is considered as a $f:\mathbb{R}^N \to \mathbb{R}$, where $N = $ length of x_a .

Parameters

diff

a NcmDiff

 

x_a

function argument.

[array][element-type double][in]

f

function to differentiate.

[scope call]

user_data

function user data.

[nullable]

Eerr

estimated errors.

[array][element-type double][out][transfer full]

Returns

The derivative of f at x_a .

[transfer full][array][element-type double]


ncm_diff_rf_Hessian_N_to_1 ()

GArray *
ncm_diff_rf_Hessian_N_to_1 (NcmDiff *diff,
                            GArray *x_a,
                            NcmDiffFuncNto1 f,
                            gpointer user_data,
                            GArray **Eerr);

Calculates the Hessian of f $\partial_i\partial_j f$ using the forward method plus Richardson extrapolation. The function $f$ is considered as a $f:\mathbb{R}^N \to \mathbb{R}$, where $N = $ length of x_a .

Parameters

diff

a NcmDiff

 

x_a

function argument.

[array][element-type double][in]

f

function to differentiate.

[scope call]

user_data

function user data.

[nullable]

Eerr

estimated errors.

[array][element-type double][out][transfer full]

Returns

The Hessian of f at x_a .

[transfer full][array][element-type double]


ncm_diff_rf_d1_1_to_1 ()

gdouble
ncm_diff_rf_d1_1_to_1 (NcmDiff *diff,
                       const gdouble x,
                       NcmDiffFunc1to1 f,
                       gpointer user_data,
                       gdouble *err);

Calculates the first derivative of f : $\partial_i f$ using the forward method plus Richardson extrapolation. The function $f$ is considered as a $f:\mathbb{R} \to \mathbb{R}$.

Parameters

diff

a NcmDiff

 

x

function argument

 

f

function to differentiate.

[scope call]

user_data

function user data.

[nullable]

err

estimated error.

[out][nullable]

Returns

The derivative of f at x .


ncm_diff_rc_d1_1_to_1 ()

gdouble
ncm_diff_rc_d1_1_to_1 (NcmDiff *diff,
                       const gdouble x,
                       NcmDiffFunc1to1 f,
                       gpointer user_data,
                       gdouble *err);

Calculates the first derivative of f : $\partial_i f$ using the central method plus Richardson extrapolation. The function $f$ is considered as a $f:\mathbb{R} \to \mathbb{R}$.

Parameters

diff

a NcmDiff

 

x

function argument

 

f

function to differentiate.

[scope call]

user_data

function user data.

[nullable]

err

estimated error.

[out][nullable]

Returns

The derivative of f at x .


ncm_diff_rc_d2_1_to_1 ()

gdouble
ncm_diff_rc_d2_1_to_1 (NcmDiff *diff,
                       const gdouble x,
                       NcmDiffFunc1to1 f,
                       gpointer user_data,
                       gdouble *err);

Calculates the second derivative of f : $\partial_i^2 f$ using the central method plus Richardson extrapolation. The function $f$ is considered as a $f:\mathbb{R} \to \mathbb{R}$.

Parameters

diff

a NcmDiff

 

x

function argument

 

f

function to differentiate.

[scope call]

user_data

function user data.

[nullable]

err

estimated error.

[out][nullable]

Returns

The derivative of f at x .

Types and Values

NCM_TYPE_DIFF

#define NCM_TYPE_DIFF (ncm_diff_get_type ())

NcmDiff

typedef struct _NcmDiff NcmDiff;

Property Details

The “ini-h” property

  “ini-h”                    double

Initial h.

Owner: NcmDiff

Flags: Read / Write / Construct

Allowed values: >= 2.22045e-16

Default value: 0.0110485


The “max-order” property

  “max-order”                guint

Maximum order.

Owner: NcmDiff

Flags: Read / Write / Construct

Allowed values: >= 1

Default value: 30


The “richardson-step” property

  “richardson-step”          double

Richardson extrapolation step.

Owner: NcmDiff

Flags: Read / Write / Construct

Allowed values: >= 1.1

Default value: 2


The “round-off-pad” property

  “round-off-pad”            double

Round off padding.

Owner: NcmDiff

Flags: Read / Write / Construct

Allowed values: >= 1.01

Default value: 30000


The “terr-pad” property

  “terr-pad”                 double

Truncation error padding.

Owner: NcmDiff

Flags: Read / Write / Construct

Allowed values: >= 1.1

Default value: 30000