-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharithmetics.cpp
73 lines (59 loc) · 2.4 KB
/
arithmetics.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
72
73
/******************************************************************************
Copyright (C) 2013 Karel Ha <[email protected]>
Distributed under the terms of the GNU General Public License (GPL)
as published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
http://www.gnu.org/licenses/
******************************************************************************/
#include "all.hpp"
int main() {
Matrix<> md;
Matrix<int> mi(pf);
cout << "md is " << (md.empty() ? "empty" : "non-void") << endl;
cin >> mi >> md;
cout << "md is " << (md.empty() ? "empty" : "non-void") << endl;
cout << "mi:\n" << mi << "\nmd:\n" << md << endl;
cout << "Skalarni nasobek: " << endl;
cout << mi.mul_by_scal(-1) << endl << endl << md.mul_by_scal(20) << endl;
cout << "Soucet matic: " << endl;
Matrix<int> mi2(pf);
cin >> mi2;
cout << "mi:\n" << mi << endl;
cout << "mi2:\n" << mi2 << endl;
swap(mi2, mi);
cout << "mi:\n" << mi << endl;
cout << "mi2:\n" << mi2 << endl;
cout << "mi + mi2:\n" << mi + mi2 << endl;
cout << "mi - mi2:\n" << mi - mi2 << endl;
cout << endl;
Matrix<> md2;
cin >> md2;
cout << "md:\n" << md << endl;
cout << "md2:\n" << md2 << endl;
cout << "md + md2:\n" << md + md2 << endl;
cout << "md - md2:\n" << md - md2 << endl;
cout << "Podmatice: " << endl;
cout << "md.subblock(1, 1, 2, 3):\n" << md.subblock(1, 1, 2, 3) << endl;
cout << "md.subblock(2, 1, 4, 4):\n" << md.subblock(2, 1, 4, 4) << endl;
for (unsigned i = 0; i < md.get_width(); i++) {
cout << i << ". column:\n" << md.column(i) << endl << endl;
}
cout << "Rovnost matic: " << endl;
cin >> mi2;
cout << ((md != md2) ? "md != md2" : "md == md2") << endl;
cout << ((mi == mi2) ? "mi == mi2" : "mi != mi2") << endl;
cout << "Velikost matic: " << endl;
cout << "mi: " << mi.size() << endl;
cout << "md: " << md.max_size() << endl;
cout << "Iteratory matic: " << endl;
int m = 3;
Matrix<int>::const_iterator iti = mi.begin();
cout << "mi:\n" << mi << endl;
cout << "mi[" << m << "]: " << iti[m] << endl;
cout << "mi[" << m-3 << "]: " << iti[m-3] << endl;
cout << "mi[" << m << "] >= mi[" << m-3 << "] is " << (iti[m] >= iti[m-3] ? "true" : "false") << endl;
cout << "Transposice: " << endl;
cout << "mi2:\n" << mi2 << endl;
cout << "mi2^T:\n" << mi2.transpose() << endl;
return 0;
}