Back to index

extremetuxracer  0.5beta
Functions | Variables
nmrcl.cpp File Reference
#include "etracer.h"
#include "nmrcl.h"

Go to the source code of this file.

Functions

ode_data_teuler_new_ode_data ()
int euler_num_estimates ()
void euler_init_ode_data (ode_data_t *p, double init_val, double h)
double euler_next_time (ode_data_t *p, int step)
double euler_next_val (ode_data_t *p, int step)
void euler_update_estimate (ode_data_t *p, int step, double val)
double euler_final_estimate (ode_data_t *p)
ode_solver_t new_euler_solver ()
ode_data_tode23_new_ode_data ()
int ode23_num_estimates ()
void ode23_init_ode_data (ode_data_t *p, double init_val, double h)
double ode23_next_time (ode_data_t *p, int step)
double ode23_next_val (ode_data_t *p, int step)
void ode23_update_estimate (ode_data_t *p, int step, double val)
double ode23_final_estimate (ode_data_t *p)
double ode23_estimate_error (ode_data_t *p)
double ode23_time_step_exponent ()
ode_solver_t new_ode23_solver ()
ode_data_tode45_new_ode_data ()
int ode45_num_estimates ()
void ode45_init_ode_data (ode_data_t *p, double init_val, double h)
double ode45_next_time (ode_data_t *p, int step)
double ode45_next_val (ode_data_t *p, int step)
void ode45_update_estimate (ode_data_t *p, int step, double val)
double ode45_final_estimate (ode_data_t *p)
double ode45_estimate_error (ode_data_t *p)
double ode45_time_step_exponent ()
ode_solver_t new_ode45_solver ()
double lin_interp (const double x[], const double y[], double val, int n)

Variables

const double ode23_time_step_mat [] = { 0., 1./2., 3./4., 1. }
const double ode23_coeff_mat [][4]
const double ode23_error_mat [] = { -5./72., 1./12., 1./9., -1./8. }
const double ode23_time_step_exp = 1./3.
const double ode45_time_step_mat []
const double ode45_coeff_mat [][7]
const double ode45_error_mat []
const double ode45_time_step_exp = 1./5.

Function Documentation

Definition at line 95 of file nmrcl.cpp.

{
    euler_data_t *data = (euler_data_t*)p;
    double val = data->init_val;

    val += 0.5 * (data->k[0] + data->k[1] );
    return val;
}

Here is the caller graph for this function:

void euler_init_ode_data ( ode_data_t p,
double  init_val,
double  h 
)

Definition at line 63 of file nmrcl.cpp.

{
    euler_data_t *data = (euler_data_t*)p;
    data->init_val = init_val;
    data->h = h;
}

Here is the caller graph for this function:

Definition at line 51 of file nmrcl.cpp.

{
    euler_data_t *data;
    data = (euler_data_t*)malloc(sizeof(euler_data_t));
    return (ode_data_t*) data;
}

Here is the caller graph for this function:

double euler_next_time ( ode_data_t p,
int  step 
)

Definition at line 70 of file nmrcl.cpp.

{
    euler_data_t *data = (euler_data_t*)p;
    check_assertion( 0 <= step && step < 2, 
                   "invalid step number in euler ode solver" );
    return step * data->h;
}

Here is the caller graph for this function:

double euler_next_val ( ode_data_t p,
int  step 
)

Definition at line 78 of file nmrcl.cpp.

{
    euler_data_t *data = (euler_data_t*)p;
    double val = data->init_val;

    if ( step == 1 ) 
       val += data->k[0];

    return val;
}

Here is the caller graph for this function:

Definition at line 58 of file nmrcl.cpp.

{
    return 2;
}

Here is the caller graph for this function:

void euler_update_estimate ( ode_data_t p,
int  step,
double  val 
)

Definition at line 89 of file nmrcl.cpp.

{
    euler_data_t *data = (euler_data_t*)p;
    data->k[step] = data->h * val;
}

Here is the caller graph for this function:

double lin_interp ( const double  x[],
const double  y[],
double  val,
int  n 
)

Definition at line 296 of file nmrcl.cpp.

{
    int i;
    double m, b;

    check_assertion( 
       n>=2, "linear interpolation requires at least two data points" );

    if ( val < x[0] ) {
       i = 0;
    } else if ( val >= x[n-1] ) {
       i = n-2;
    } else {
       /* should replace with binary search if we ever use large tables */
       for ( i=0; i<n-1; i++ ) {
           if ( val < x[i+1] ) break;
       }
    }

    m = ( y[i+1] - y[i] ) / ( x[i+1] - x[i] );
    b =  y[i] - m * x[i];

    return m * val + b;
}

Here is the caller graph for this function:

Definition at line 104 of file nmrcl.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 176 of file nmrcl.cpp.

{
    ode23_data_t *data = (ode23_data_t*)p;
    double err=0.;
    int i;

    for ( i=0; i<4; i++ ) {
       err += ode23_error_mat[i] * data->k[i];
    }
    return fabs(err);
}

Here is the caller graph for this function:

Definition at line 164 of file nmrcl.cpp.

{
    ode23_data_t *data = (ode23_data_t*)p;
    double val = data->init_val;
    int i;

    for ( i=0; i<3; i++ ) {
       val += ode23_coeff_mat[i][3] * data->k[i];
    }
    return val;
}

Here is the caller graph for this function:

void ode23_init_ode_data ( ode_data_t p,
double  init_val,
double  h 
)

Definition at line 132 of file nmrcl.cpp.

{
    ode23_data_t *data = (ode23_data_t*)p;
    data->init_val = init_val;
    data->h = h;
}

Here is the caller graph for this function:

Definition at line 120 of file nmrcl.cpp.

{
    ode23_data_t *data;
    data = (ode23_data_t*)malloc(sizeof(ode23_data_t));
    return (ode_data_t*) data;
}

Here is the caller graph for this function:

double ode23_next_time ( ode_data_t p,
int  step 
)

Definition at line 139 of file nmrcl.cpp.

{
    ode23_data_t *data = (ode23_data_t*)p;
    check_assertion( 0 <= step && step < 4, "invalid step for ode23 solver" );
    return ode23_time_step_mat[step] * data->h;
}

Here is the caller graph for this function:

double ode23_next_val ( ode_data_t p,
int  step 
)

Definition at line 146 of file nmrcl.cpp.

{
    ode23_data_t *data = (ode23_data_t*)p;
    double val = data->init_val;
    int i;

    for ( i=0; i<step; i++ ) {
       val += ode23_coeff_mat[i][step] * data->k[i];
    }
    return val;
}

Here is the caller graph for this function:

Definition at line 127 of file nmrcl.cpp.

{
    return 4;
}

Here is the caller graph for this function:

Definition at line 188 of file nmrcl.cpp.

{
    return ode23_time_step_exp;
}

Here is the caller graph for this function:

void ode23_update_estimate ( ode_data_t p,
int  step,
double  val 
)

Definition at line 158 of file nmrcl.cpp.

{
    ode23_data_t *data = (ode23_data_t*)p;
    data->k[step] = data->h * val;
}

Here is the caller graph for this function:

Definition at line 264 of file nmrcl.cpp.

{
    ode45_data_t *data = (ode45_data_t*)p;
    double err=0.;
    int i;

    for ( i=0; i<7; i++ ) {
       err += ode45_error_mat[i] * data->k[i];
    }
    return fabs(err);
}

Here is the caller graph for this function:

Definition at line 252 of file nmrcl.cpp.

{
    ode45_data_t *data = (ode45_data_t*)p;
    double val = data->init_val;
    int i;

    for ( i=0; i<6; i++ ) {
       val += ode45_coeff_mat[i][6] * data->k[i];
    }
    return val;
}

Here is the caller graph for this function:

void ode45_init_ode_data ( ode_data_t p,
double  init_val,
double  h 
)

Definition at line 220 of file nmrcl.cpp.

{
    ode45_data_t *data = (ode45_data_t*)p;
    data->init_val = init_val;
    data->h = h;
}

Here is the caller graph for this function:

Definition at line 208 of file nmrcl.cpp.

{
    ode45_data_t *data;
    data = (ode45_data_t*)malloc(sizeof(ode45_data_t));
    return (ode_data_t*) data;
}

Here is the caller graph for this function:

double ode45_next_time ( ode_data_t p,
int  step 
)

Definition at line 227 of file nmrcl.cpp.

{
    ode45_data_t *data = (ode45_data_t*)p;
    check_assertion( 0 <= step && step < 7, "invalid step for ode45 solver" );
    return ode45_time_step_mat[step] * data->h;
}

Here is the caller graph for this function:

double ode45_next_val ( ode_data_t p,
int  step 
)

Definition at line 234 of file nmrcl.cpp.

{
    ode45_data_t *data = (ode45_data_t*)p;
    double val = data->init_val;
    int i;

    for ( i=0; i<step; i++ ) {
       val += ode45_coeff_mat[i][step] * data->k[i];
    }
    return val;
}

Here is the caller graph for this function:

Definition at line 215 of file nmrcl.cpp.

{
    return 7;
}

Here is the caller graph for this function:

Definition at line 276 of file nmrcl.cpp.

{
    return ode45_time_step_exp;
}

Here is the caller graph for this function:

void ode45_update_estimate ( ode_data_t p,
int  step,
double  val 
)

Definition at line 246 of file nmrcl.cpp.

{
    ode45_data_t *data = (ode45_data_t*)p;
    data->k[step] = data->h * val;
}

Here is the caller graph for this function:


Variable Documentation

const double ode23_coeff_mat[][4]
Initial value:
 {
    { 0., 1./2.,    0.,  2./9. } ,
    { 0.,    0., 3./4.,  1./3. } ,
    { 0.,    0.,    0.,  4./9. } ,
    { 0.,    0.,    0.,     0. } 
}

Definition at line 26 of file nmrcl.cpp.

const double ode23_error_mat[] = { -5./72., 1./12., 1./9., -1./8. }

Definition at line 32 of file nmrcl.cpp.

const double ode23_time_step_exp = 1./3.

Definition at line 33 of file nmrcl.cpp.

const double ode23_time_step_mat[] = { 0., 1./2., 3./4., 1. }

Definition at line 25 of file nmrcl.cpp.

const double ode45_coeff_mat[][7]
Initial value:
 {
    { 0, 1./5., 3./40.,  44./45.,  19372./6561.,   9017./3168.,     35./384. },
    { 0, 0.,    9./40., -56./15., -25360./2187.,     -355./33.,           0. },
    { 0, 0.,         0,   32./9.,  64448./6561.,  46732./5247.,   500./1113. },
    { 0, 0.,         0,        0,    -212./729.,      49./176.,    125./192. },
    { 0, 0.,         0,        0,             0, -5103./18656., -2187./6784. },
    { 0, 0.,         0,        0,             0,             0,      11./84. },
    { 0, 0.,         0,        0,             0,             0,           0. }
}

Definition at line 37 of file nmrcl.cpp.

const double ode45_error_mat[]
Initial value:
 
{ 71./57600., 0., -71./16695., 71./1920., -17253./339200., 22./525., -1./40.}

Definition at line 47 of file nmrcl.cpp.

const double ode45_time_step_exp = 1./5.

Definition at line 49 of file nmrcl.cpp.

const double ode45_time_step_mat[]
Initial value:
 
{ 0., 1./5., 3./10., 4./5., 8./9., 1., 1. }

Definition at line 35 of file nmrcl.cpp.