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   // Namespace declarations
14   using std::cout;
15   using std::vector;
16   using std::complex;
17 
18   // Calculate machine precision
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);      // Lower limit
33   complex<Floattype> b(2.0f*M_PI, 0.0f); // Upper limit
34   cout << "Integration path: b-a = " << b-a << '\n';
35   Inttype n_eqs = 2; // Number of equations in ODE system
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,    // ODE system
43               y_start,  // Initial values
44               a,        // Lower limit
45               b,        // Upper limit
46               h_start,  // Start value of step size
47               10000,    // Max. number of steps
48               eps_machine*1e12f,  // Absolute precision
49               eps_machine*1e12f); // Relative precision
50   realode.write("funcA.dat"); // Write solutions to data file
51 
52   // Report to stdout
53   cout << "ODE system solved in "
54        << realode.steps() << " steps.\n\n";
55 
56   // Return successfully
57   return 0;
58 }
59