libode
Easy to compile, fast ODE integrators as C++ classes
Loading...
Searching...
No Matches
ode_rosenbrock.cc
Go to the documentation of this file.
1
2
3#include "ode_rosenbrock.h"
4
5namespace ode {
6
7OdeRosenbrock::OdeRosenbrock (unsigned long neq, int nk) {
8
9 //stage count
10 nk_ = nk;
11 //set up stage derivatives
12 k_ = new double*[nk];
13 for (int i=0; i<nk; i++) k_[i] = new double[neq];
14 //allocate permutation array
15 p_ = new int[neq];
16 //right hand side of matrix equations
17 rhs_ = new double[neq];
18 //temporary sol vector
19 soltemp_ = new double[neq];
20}
21
23 for (int i=0; i<nk_; i++) delete [] k_[i];
24 delete [] k_;
25 delete [] p_;
26 delete [] rhs_;
27 delete [] soltemp_;
28}
29
30void OdeRosenbrock::prep_jac (double **Jac, unsigned long n, double dt, int *p) {
31
32 unsigned long i,j;
33
34 for (i=0; i<n; i++) {
35 //flip the sign of the Jacobian across the row and multiply by gam*dt
36 for (j=0; j<n; j++) Jac[i][j] = -Jac[i][j]*gam*dt;
37 //subtract it from the identity matrix
38 Jac[i][i] += 1.0;
39 }
40 ode_crout_LU(Jac, n, p);
41}
42
43} // namespace ode
void prep_jac(double **Jac, unsigned long n, double dt, int *p)
do necessary arithmetic with the Jacobian then lu factor it
int * p_
permutation array for LU factorization
OdeRosenbrock(unsigned long neq, int nk)
constructs
double ** k_
stage derivatives
double * soltemp_
temporary sol vector
~OdeRosenbrock()
destructs
double * rhs_
right hand side of matrix equations
double gam
parameter multipying Jacobian or single diagonal gamma
void ode_crout_LU(double **A, int n, int *p)
Crout LU decomposition.
Definition ode_linalg.cc:29