This repository has been archived by the owner on Feb 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multiplicationTests2.cpp
71 lines (55 loc) · 1.95 KB
/
multiplicationTests2.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
#include <iostream>
#include <vector>
#include <ctime>
#include <memory>
#include "Matrix.h"
#include "StaticSizeMatrix.h"
template<class MD>
void initializeCells(Matrix<long, MD> &m, long rowMultiplier, long colMultiplier) {
for (unsigned row = 0; row < m.rows(); ++row) {
for (unsigned col = 0; col < m.columns(); ++col) {
m(row, col) = row * rowMultiplier + col * colMultiplier;
}
}
}
int main() {
StaticSizeMatrix<400, 5000, long> mA;
initializeCells(mA, 12, 5);
StaticSizeMatrix<400, 5000, long> mB;
initializeCells(mB, 7, 13);
StaticSizeMatrix<5000, 2000, long> mC;
initializeCells(mC, 3, 8);
StaticSizeMatrix<5000, 2000, long> mD;
initializeCells(mD, 4, 7);
StaticSizeMatrix<2000, 400, long> mE;
initializeCells(mE, 8, 9);
StaticSizeMatrix<2000, 400, long> mF;
initializeCells(mF, 5, 11);
StaticSizeMatrix<400, 1001, long> mG;
initializeCells(mG, 54, 11);
StaticSizeMatrix<1001, 400, long> mH;
initializeCells(mH, 66, 11);
/*std::cout << "Matrix A" << std::endl;
mA.print("%2d");
std::cout << "Matrix B" << std::endl;
mB.print("%2d");
std::cout << "Matrix C" << std::endl;
mC.print("%2d");
std::cout << "Matrix D" << std::endl;
mD.print("%2d");
std::cout << "Matrix E" << std::endl;
mE.print("%2d");
std::cout << "Matrix F" << std::endl;
mF.print("%2d");*/
auto multiplication = ((mA + mB) * (mC + mD) * (mE + mF)) + (mG * mH);
std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();
long first = multiplication(0, 0);
std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();
std::cout << "The first element is " << first << ", and it took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - begin).count() / 1000.0 << " seconds" << std::endl;
std::cout << "((A + B) * (C + D) * (E + F)) + (G * H)" << std::endl;
std::cout << std::endl << std::endl;
//multiplication.getData().printTree();
std::cout << std::endl << std::endl;
std::cout << "Oks" << std::endl;
return 0;
}