-
Notifications
You must be signed in to change notification settings - Fork 0
/
supportLib.h
39 lines (27 loc) · 722 Bytes
/
supportLib.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
#include "supportLibdef.h"
unsigned char *DoubleArrayToByteArray(double *data, size_t length){
unsigned char *out;
size_t i;
out = (unsigned char*)malloc(sizeof(unsigned char)*length);
for(i = 0; i < length; i++){
out[i] = data[i];
}
return out;
}
void WriteToFile(double *data, size_t dataLength, char *filename){
unsigned char *bytes;
bytes = DoubleArrayToByteArray(data, dataLength);
FILE* file = fopen(filename, "wb");
fwrite(bytes, 1, dataLength, file);
fclose(file);
free(bytes);
}
double *ByteArrayToDoubleArray(unsigned char *data, size_t length){
double *out;
size_t i;
out = (double*)malloc(sizeof(double)*length);
for(i = 0; i < length; i++){
out[i] = data[i];
}
return out;
}