1
2 #ifndef ODE_H_
3 #define ODE_H_
4
5 #include <vector>
6 #include <complex>
7 #include "typedefs.h"
8
9
10 class ODE {
11
12
13 private:
14
15
16 std::vector<std::complex<Floattype> >
17 (*f)(const std::complex<Floattype> x,
18 const std::vector<std::complex<Floattype> > &y);
19
20
21 std::vector<std::complex<Floattype> > x_list;
22
23
24 const std::complex<Floattype> a;
25 const std::complex<Floattype> b;
26
27
28 std::complex<Floattype> h;
29
30
31 std::vector<std::vector<std::complex<Floattype> > > y_list;
32
33
34 const Inttype n_max;
35
36
37 const Floattype delta;
38 const Floattype epsilon;
39
40
41 Floattype tau(const std::vector<std::complex<Floattype> > &y,
42 const std::complex<Floattype> h);
43
44
45 void rkstep12(const std::complex<Floattype> x0,
46 const std::vector<std::complex<Floattype> > &y0,
47 std::vector<std::complex<Floattype> > &y1,
48 std::vector<std::complex<Floattype> > &dy);
49
50
51 const Floattype power;
52 const Floattype safety;
53
54
55 void rkdriver();
56
57
58
59 public:
60
61
62 ODE(std::vector<std::complex<Floattype> >
63 (*f_in)(const std::complex<Floattype> x,
64 const std::vector<std::complex<Floattype> > &y),
65 const std::vector<std::complex<Floattype> > y_start,
66 const std::complex<Floattype> a_in,
67 const std::complex<Floattype> b_in,
68 const Floattype h_start = 0.01f,
69 const Inttype max_steps = 1e4,
70 const Floattype delta_in = 1e-3f,
71 const Floattype epsilon_in = 1e-3f,
72 const Floattype power_in = 0.25f,
73 const Floattype safety_in = 0.95f
74 );
75
76
77 Inttype steps();
78
79
80 void print();
81
82
83 void write(const char* filename);
84
85 };
86
87 #endif