-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsupportLib.cpp
More file actions
39 lines (27 loc) · 732 Bytes
/
supportLib.cpp
File metadata and controls
39 lines (27 loc) · 732 Bytes
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
#include "supportLib.hpp"
unsigned char *DoubleArrayToByteArray(vector<double> *data){
unsigned char *out;
size_t i;
out = new unsigned char[data->size()];
for(i = 0; i < data->size(); i++){
out[i] = data->at(i);
}
return out;
}
void WriteToFile(vector<double> *data, string filename){
unsigned char *bytes;
bytes = DoubleArrayToByteArray(data);
ofstream file(filename.c_str(), ios::binary);
file.write(reinterpret_cast<char *>(bytes), data->size());
file.close();
delete bytes;
}
vector<double> *ByteArrayToDoubleArray(vector<unsigned char> *data){
vector<double> *out;
size_t i;
out = new vector<double>(data->size());
for(i = 0; i < data->size(); i++){
out->at(i) = data->at(i);
}
return out;
}