-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatrix-mul.cpp
38 lines (34 loc) · 1.05 KB
/
matrix-mul.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
#include "multiplication.h"
#include "transposition.h"
#include "common.h"
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <random>
using namespace std;
template<class URNG>
TMatrix RandomMatrix(size_t n, size_t m, URNG&& g) {
normal_distribution<double> distribution(0.0, 1.0);
TMatrix result(n, vector<double>(m));
for (size_t i = 0; i < n; ++i)
generate(result[i].begin(), result[i].end(), [&g, &distribution]()->double { return distribution(g); });
return result;
}
ostream& operator<<(ostream& out, const TMatrix& m) {
for (const auto& row: m) {
for (auto v: row)
out << setw(8) << fixed << setprecision(4) << v;
out << endl;
}
}
int main() {
const size_t N = 1000;
TMatrix a = RandomMatrix(N, N, default_random_engine(1));
TMatrix b = RandomMatrix(N, N, default_random_engine(2));
TMatrix res;
//MultiplyMatricesParallel(a, b, res);
//cout << res << endl;
MultiplyMatricesParallelWithTransposition(a, b, res);
//cout << res << endl;
return 0;
}