ROBOOP, A Robotics Object Oriented Package in C++
utils.cpp File Reference

Utility functions. More...

#include "utils.h"

Go to the source code of this file.

Macros

#define PGROW   -0.20
 
#define PSHRNK   -0.25
 
#define FCOR   0.06666666
 
#define SAFETY   0.9
 
#define ERRCON   6.0E-4
 
#define MAXSTP   10000
 
#define TINY   1.0e-30
 

Functions

ReturnMatrix x_prod_matrix (const ColumnVector &x)
 Cross product matrix.
 
ReturnMatrix pinv (const Matrix &M)
 Matrix pseudo inverse using SVD. More...
 
ReturnMatrix Integ_Trap (const ColumnVector &present, ColumnVector &past, const Real dt)
 Trapezoidal integration.
 
void Runge_Kutta4_Real_time (ReturnMatrix(*xdot)(Real time, const Matrix &xin, bool &exit, bool &init), const Matrix &xo, Real to, Real tf, int nsteps)
 Fixed step size fourth-order Runge-Kutta integrator.
 
void Runge_Kutta4_Real_time (ReturnMatrix(*xdot)(const Real time, const Matrix &xin), const Matrix &xo, const Real to, const Real tf, const int nsteps)
 
void Runge_Kutta4 (ReturnMatrix(*xdot)(Real time, const Matrix &xin), const Matrix &xo, Real to, Real tf, int nsteps, RowVector &tout, Matrix &xout)
 Fixed step size fourth-order Runge-Kutta integrator.
 
ReturnMatrix rk4 (const Matrix &x, const Matrix &dxdt, Real t, Real h, ReturnMatrix(*xdot)(Real time, const Matrix &xin))
 Compute one Runge-Kutta fourth order step. More...
 
void rkqc (Matrix &x, Matrix &dxdt, Real &t, Real htry, Real eps, Matrix &xscal, Real &hdid, Real &hnext, ReturnMatrix(*xdot)(Real time, const Matrix &xin))
 Compute one adaptive step based on two rk4. More...
 
void odeint (ReturnMatrix(*xdot)(Real time, const Matrix &xin), Matrix &xo, Real to, Real tf, Real eps, Real h1, Real hmin, int &nok, int &nbad, RowVector &tout, Matrix &xout, Real dtsav)
 Integrate the ordinary differential equation xdot from time to to time tf using an adaptive step size strategy. More...
 
ReturnMatrix sign (const Matrix &x)
 Sign of a matrix.
 
short sign (const Real x)
 Sign of real.
 

Detailed Description

Utility functions.

Definition in file utils.cpp.

Function Documentation

void odeint ( ReturnMatrix(*)(Real time, const Matrix &xin)  xdot,
Matrix &  xo,
Real  to,
Real  tf,
Real  eps,
Real  h1,
Real  hmin,
int &  nok,
int &  nbad,
RowVector &  tout,
Matrix &  xout,
Real  dtsav 
)

Integrate the ordinary differential equation xdot from time to to time tf using an adaptive step size strategy.

adapted from: Numerical Recipes in C, The Art of Scientific Computing, Press, William H. and Flannery, Brian P. and Teukolsky, Saul A. and Vetterling, William T., Cambridge University Press, 1988.

Definition at line 346 of file utils.cpp.

References rkqc().

ReturnMatrix pinv ( const Matrix &  M)

Matrix pseudo inverse using SVD.

If $ A = U^{*}QV $ is a singular value decomposition of A, then $ A^{\dagger} = V^{*}Q^{\dagger}U$ where $ X^{*} $ is the conjugate transpose of $ X $ and $ Q^{\dagger} = \left [ \begin{array}{cccc} 1/\sigma_1 & & & \\ & 1/\sigma_2& & \\ & & \ddots & \\ & & & 0 \end{array} \right ]$ where the $1/\sigma_i $ are replaced by 0 when $1/\sigma_i < tol $

Definition at line 98 of file utils.cpp.

References pinv().

Referenced by pinv().

ReturnMatrix rk4 ( const Matrix &  x,
const Matrix &  dxdt,
Real  t,
Real  h,
ReturnMatrix(*)(Real time, const Matrix &xin)  xdot 
)

Compute one Runge-Kutta fourth order step.

adapted from: Numerical Recipes in C, The Art of Scientific Computing, Press, William H. and Flannery, Brian P. and Teukolsky, Saul A. and Vetterling, William T., Cambridge University Press, 1988.

Definition at line 259 of file utils.cpp.

Referenced by rkqc().

void rkqc ( Matrix &  x,
Matrix &  dxdt,
Real &  t,
Real  htry,
Real  eps,
Matrix &  xscal,
Real &  hdid,
Real &  hnext,
ReturnMatrix(*)(Real time, const Matrix &xin)  xdot 
)

Compute one adaptive step based on two rk4.

adapted from: Numerical Recipes in C, The Art of Scientific Computing, Press, William H. and Flannery, Brian P. and Teukolsky, Saul A. and Vetterling, William T., Cambridge University Press, 1988.

Definition at line 294 of file utils.cpp.

References rk4().

Referenced by odeint().