ode_iv_solve Class Template Reference

Solve an initial-value ODE problems given an adaptive ODE stepper.

#include <ode_iv_solve.h>


Detailed Description

template<class param_t, class func_t = ode_funct<param_t>, class vec_t = ovector_base, class alloc_vec_t = ovector, class alloc_t = ovector_alloc>
class ode_iv_solve< param_t, func_t, vec_t, alloc_vec_t, alloc_t >

Definition at line 41 of file ode_iv_solve.h.


Public Member Functions

int set_adapt_step (adapt_step< param_t, func_t, vec_t, alloc_vec_t, alloc_t > &as)
 Set the adaptive stepper to use.
template<class mat_t , class mat_row2_t >
int solve_table (double x0, double x1, double h, size_t n, vec_t &ystart, size_t &n_sol, vec_t &x_sol, mat_t &y_sol, mat_t &dydx_sol, mat_t &yerr_sol, param_t &pa, func_t &derivs)
 Solve the initial-value problem and output a table.
template<class alloc_mat_t , class mat_row_t , class mat_alloc_t >
int solve_grid (double x0, double x1, double h, size_t n, vec_t &ystart, size_t nsol, vec_t &xsol, alloc_mat_t &ysol, alloc_mat_t &dydx_sol, param_t &pa, func_t &derivs)
 Solve the initial-value problem from x0 to x1 over a grid storing derivatives.
template<class mat_t , class mat_row_t >
int solve_grid (double x0, double x1, double h, size_t n, vec_t &ystart, size_t nsol, vec_t &xsol, mat_t &ysol, mat_t &dydx_sol, mat_t &err_sol, param_t &pa, func_t &derivs)
 Solve the initial-value problem from x0 to x1 over a grid storing derivatives.
int solve_final_value (double x0, double x1, double h, size_t n, vec_t &ystart, vec_t &yend, param_t &pa, func_t &derivs)
 Solve the initial-value problem to get the final value.
int solve_final_value (double x0, double x1, double h, size_t n, vec_t &ystart, vec_t &yend, vec_t &yerr, param_t &pa, func_t &derivs)
 Solve the initial-value problem to get the final value.
int solve_final_value (double x0, double x1, double h, size_t n, vec_t &ystart, vec_t &dydx_start, vec_t &yend, vec_t &yerr, vec_t &dydx_end, param_t &pa, func_t &derivs)
 Solve the initial-value problem to get the final value and derivative.
virtual const char * type ()
 Return the type, "ode_iv_solve".

Data Fields

int verbose
 Set output level.
size_t nsteps_out
 Number of output points if verbose is greater than zero (default 10).
size_t ntrial
 Maximum number of applications of the adaptive stepper (default 1000).
size_t nsteps
 Number of adaptive steps employed.
bool exit_on_fail
 If true, stop the solution if the adaptive stepper fails.
gsl_astep< param_t, func_t,
vec_t, alloc_vec_t, alloc_t > 
gsl_astp
 The default adaptive stepper.

Protected Member Functions

virtual int print_iter (double x, size_t nv, vec_t &y)
 Print out iteration information.

Protected Attributes

alloc_t ao
 Memory allocator.
adapt_step< param_t, func_t,
vec_t, alloc_vec_t, alloc_t > * 
astp
 The adaptive stepper.

Member Function Documentation

int solve_final_value ( double  x0,
double  x1,
double  h,
size_t  n,
vec_t &  ystart,
vec_t &  dydx_start,
vec_t &  yend,
vec_t &  yerr,
vec_t &  dydx_end,
param_t &  pa,
func_t &  derivs 
) [inline]

If verbose is greater than zero, The solution at less than or approximately equal to nsteps_out points will be written to std::cout. If verbose is greater than one, a character will be required after each selected point.

The solution fails if more than ntrial steps are required.

This function will also fail if x1>x0 and h<0 or if x1<x0 but h>0.

Definition at line 450 of file ode_iv_solve.h.

int solve_final_value ( double  x0,
double  x1,
double  h,
size_t  n,
vec_t &  ystart,
vec_t &  yend,
vec_t &  yerr,
param_t &  pa,
func_t &  derivs 
) [inline]

If verbose is greater than zero, The solution at less than or approximately equal to nsteps_out points will be written to std::cout. If verbose is greater than one, a character will be required after each selected point.

Definition at line 423 of file ode_iv_solve.h.

int solve_final_value ( double  x0,
double  x1,
double  h,
size_t  n,
vec_t &  ystart,
vec_t &  yend,
param_t &  pa,
func_t &  derivs 
) [inline]

If verbose is greater than zero, The solution at less than or approximately equal to nsteps_out points will be written to std::cout. If verbose is greater than one, a character will be required after each selected point.

Definition at line 399 of file ode_iv_solve.h.

int solve_grid ( double  x0,
double  x1,
double  h,
size_t  n,
vec_t &  ystart,
size_t  nsol,
vec_t &  xsol,
mat_t &  ysol,
mat_t &  dydx_sol,
mat_t &  err_sol,
param_t &  pa,
func_t &  derivs 
) [inline]

Initially, xsol should be an array of size nsol, and ysol should be a omatrix of size [nsol][n]. This function never takes a step larger than the grid size.

If verbose is greater than zero, The solution at each grid point will be written to std::cout. If verbose is greater than one, a character will be required after each point.

Definition at line 310 of file ode_iv_solve.h.

int solve_grid ( double  x0,
double  x1,
double  h,
size_t  n,
vec_t &  ystart,
size_t  nsol,
vec_t &  xsol,
alloc_mat_t &  ysol,
alloc_mat_t &  dydx_sol,
param_t &  pa,
func_t &  derivs 
) [inline]

Initially, xsol should be an array of size nsol, and ysol should be a omatrix of size [nsol][n]. This function never takes a step larger than the grid size.

If verbose is greater than zero, The solution at each grid point will be written to std::cout. If verbose is greater than one, a character will be required after each point.

Definition at line 284 of file ode_iv_solve.h.

int solve_table ( double  x0,
double  x1,
double  h,
size_t  n,
vec_t &  ystart,
size_t &  n_sol,
vec_t &  x_sol,
mat_t &  y_sol,
mat_t &  dydx_sol,
mat_t &  yerr_sol,
param_t &  pa,
func_t &  derivs 
) [inline]

Initially, x_sol should be a vector of size n_sol, and y_sol, dydx_sol, and yerr_sol should be matrices with size [n_sol][n]. On exit, n_sol will will be the size of the solution table, less than or equal to the original value of n_sol. This function avoids performing extra calls to the adaptive stepper, and the table will be approximately evenly spaced.

This template function works with any matrix class mat_t which can be accessed using successive applications of operator[] and which has an associated class mat_row2_t which returns a row of a matrix of type mat_t as an object with type vec_t.

If verbose is greater than zero, The solution at each internal point will be written to std::cout. If verbose is greater than one, a character will be required after each point.

Definition at line 114 of file ode_iv_solve.h.


Field Documentation

If this is false, then failures in the adaptive stepper are ignored.

Definition at line 630 of file ode_iv_solve.h.

size_t nsteps_out

This is used in functions solve_table() and solve_final_value() to control how often steps are output when verbose is greater than zero.

Definition at line 616 of file ode_iv_solve.h.


The documentation for this class was generated from the following file:

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page