-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
63 lines (50 loc) · 1.88 KB
/
main.cpp
File metadata and controls
63 lines (50 loc) · 1.88 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
#include "data_channel.hpp"
/* Main function */
int main()
{
/* Open input file of matrices */
std::ifstream inputMatrices("input_matrices.txt");
if (inputMatrices.is_open())
{
/* Store number of matrices */
unsigned int numberOfMatrices;
inputMatrices >> numberOfMatrices;
/* Store matrices in numberOfMatrices * 4 * 4 tensor */
auto matrices = create_tensor(numberOfMatrices, MATRIX_DIMENSION_SIZE, MATRIX_DIMENSION_SIZE);
for (unsigned int i = 0; i < numberOfMatrices; i++)
{
for (unsigned int y = 0; y < MATRIX_DIMENSION_SIZE; y++)
{
for (unsigned int k = 0; k < MATRIX_DIMENSION_SIZE; k++)
{
inputMatrices >> matrices[i][y][k];
}
}
}
inputMatrices.close();
/* Open input file of vectors */
std::ifstream inputVectors("input_points.txt");
if (inputVectors.is_open())
{
/* Store number of vectors */
unsigned int numberOfVectors;
inputVectors >> numberOfVectors;
/* Store vectors in numberOfVectors * (3 + 1) matrix.
Create additional row for simpler multiplication */
auto vectors = create_matrix(numberOfVectors, (VECTOR_DIMENSION_SIZE + 1));
for (unsigned int i = 0; i < numberOfVectors; i++)
{
for (unsigned int y = 0; y < VECTOR_DIMENSION_SIZE; y++)
{
inputVectors >> vectors[i][y];
}
/* Fill the last row with ones */
vectors[i][VECTOR_DIMENSION_SIZE] = 1;
}
inputVectors.close();
/* Start threads, data channel and data flow */
startDataFlow(numberOfMatrices, numberOfVectors, vectors, matrices);
}
}
return 0;
}