-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupportLib.c
More file actions
38 lines (26 loc) · 704 Bytes
/
supportLib.c
File metadata and controls
38 lines (26 loc) · 704 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
#include "supportLib.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);
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;
}