-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimeseries.h
More file actions
68 lines (52 loc) · 1.3 KB
/
Timeseries.h
File metadata and controls
68 lines (52 loc) · 1.3 KB
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
61
62
63
64
65
66
67
68
/*
* Timeseries.h
*
* Created on: 25 Feb 2014
* Author: rusty
*/
#ifndef TIMESERIES_H_
#define TIMESERIES_H_
#include <vector>
using namespace std;
class Timeseries{
// as declared also in GeneralisedSimulationState.h
public:
int length;
int width;
double stepLength;
vector<vector<double> > timeseries;
~Timeseries(){
for (int i=0; i<width;i++){
timeseries.at(i).erase(timeseries.at(i).begin(), timeseries.at(i).end());
}
timeseries.erase(timeseries.begin(), timeseries.end());
}
Timeseries(int length, int width, double stepLength){
this->length = length;
this->width = width;
this-> stepLength = stepLength;
// initialise to zero.. (beware length of simulation output+1)
for (int i=0; i<width;i++){
timeseries.push_back(vector<double> ());
for (int j=0;j<length;j++){
timeseries[i].push_back(0);
}
}
}
Timeseries(Timeseries* other){
this->length = other->length;
this->width = other->width;
this->stepLength = other->stepLength;
this-> timeseries = other->timeseries;
}
void copyTimeseries(Timeseries* other){
if (this->length==other->length && this->width==other->width){
for (int i=0;i<width;i++){
for (int j=0;j<length;j++){
this->timeseries.at(i).at(j) = other->timeseries.at(i).at(j);
}
}
}
}
};
#endif /* TIMESERIES_H_ */