-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
72 lines (56 loc) · 1.54 KB
/
main.cpp
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
69
70
71
72
#include "main.h"
using namespace std;
/**
* Read the given file and load up a vector of plots
*/
__host__
thrust::host_vector< thrust::host_vector<double> > loadPlots(std::fstream& dataFile){
int n, m;
//find total number of plots n and number of attributes m
dataFile >> n >> m;
//Create a vector of size n
thrust::host_vector< thrust::host_vector<double> > H(n);
//make sure that the plots vector is empty
H.clear();
//find all attributes for all plots
for (int i = 0; i < n; i++){
thrust::host_vector<double> row(m);
long double r;
for (int j = 0; j < m; j++){
dataFile >> r;
row.push_back(r);
}
H.push_back(row);
}
return H;
}
__host__
thrust::host_vector< thrust::host_vector<double> > loadLandUses(std::fstream& dataFile){
int l, m;
//find total number of land uses and criteria then load all values
dataFile >> l >> m;
thrust::host_vector< thrust::host_vector<double> > landUses(l);
//make sure the landUses vector is clear
landUses.clear();
for(int i = 0; i < l; i++){
thrust::host_vector<double> row;
long double r;
for (int j = 0; j < m; j++ ){
dataFile >> r;
row.push_back(r);
}
landUses.push_back(row);
}
return landUses;
}
__host__
thrust::host_vector< pair<int, int> > loadAssignments(std::fstream& dataFile, int n){
thrust::host_vector< pair<int, int> > assignments(n);
int p, a;
//find all assignments
for(int i = 0; i < n; i++){
dataFile >> p >> a;
assignments.push_back(make_pair(p, a));
}
return assignments;
}