1 #include <iostream>
2 #include <vector>
3 #include <complex>
4 #include <cmath>
5 #include "typedefs.h"
6 #include "check.h"
7 #include "ode.h"
8 #include "functions.h"
9
10
11 int main()
12 {
13
14 using std::cout;
15 using std::vector;
16 using std::complex;
17
18
19 Floattype eps_machine = 1.0f;
20 while (1.0f + eps_machine != 1.0f)
21 eps_machine /= 2.0f;
22
23 const int id = 20062213;
24 const char n = 10;
25 cout << "\nMy student id is \033[1;37m" << id
26 << "\033[0m, resulting in exam exercise: \033[1;31m"
27 << id%n << "\033[0m\n";
28 cout << "Examination project:\033[1;37m ODE integration "
29 << "with complex numbers\033[0m\n\n";
30
31 cout << "\033[1;33m--- Part A: Solving along a real path ---\033[0m\n";
32 complex<Floattype> a(0.0f, 0.0f);
33 complex<Floattype> b(2.0f*M_PI, 0.0f);
34 cout << "Integration path: b-a = " << b-a << '\n';
35 Inttype n_eqs = 2;
36 vector<complex<Floattype> > y_start(n_eqs);
37 complex<Floattype> y0(0.0f, 0.0f);
38 complex<Floattype> y1(1.0f, 1.0f);
39 y_start[0] = y0;
40 y_start[1] = y1;
41 Floattype h_start = 0.01f;
42 ODE realode(func1,
43 y_start,
44 a,
45 b,
46 h_start,
47 10000,
48 eps_machine*1e12f,
49 eps_machine*1e12f);
50 realode.write("funcA.dat");
51
52
53 cout << "ODE system solved in "
54 << realode.steps() << " steps.\n\n";
55
56
57 return 0;
58 }
59