-
Notifications
You must be signed in to change notification settings - Fork 8
/
solver.h
60 lines (48 loc) · 1023 Bytes
/
solver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* solver.h
* lorenz
*
* Created by McK on 16/02/10.
* Copyright 2010 __MyCompanyName__. All rights reserved.
*
*/
#include <vector>
#include <string>
using namespace std;
class DiffFunction
{
protected:
vector<double> params;
vector<string> paramNames;
public:
virtual Vector applyFunction(double t, Vector previousPoint);
vector<double> &getParams();
vector<string> &getParamNames();
};
class Lorenz : public DiffFunction {
public:
Lorenz(double sigma, double r, double b);
Vector applyFunction(double t, Vector previousPoint);
/* double getSigma() {
return params[0];
}
double getR() {
return params[1];
}
double getB() {
return params[2];
}*/
};
class Solver
{
public:
virtual void step(double &t, Vector &y, double &h);
};
class SolverRungeKutta2 : public Solver {
public:
void step(double &t, Vector &y, double &h);
};
#define min(a,b) ((a<b)?(a):(b))
#define max(a,b) ((a>b)?(a):(b))
#define clamp(mn,v,mx) max(min(v,mx),mn)
void step(double &t, Vector &y, double &h);