-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
225 lines (149 loc) · 5.27 KB
/
main.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#include <iostream>
#include <math.h>
//#include <boost/timer/timer.hpp>
#include "Matrix.h"
#include "LA_Vector.h"
#include <vector>
#include <boost/format.hpp>
using namespace L_Algebra;
using namespace std;
int main()
{
vector<int> vec;
vec.push_back(76);
vec.push_back(76);
vec.push_back(76);
vec.push_back(76);
vec.push_back(76);
Vector vvv(vec.begin(), vec.end());
float sd = 87, ds = 56665;
Fraction ffr(23,45);
Fraction ffrr = 10;
// cout << typeid(vec).name() << endl;
// cout << ffr.to_double() << endl;
// cout << typeid(sd).name();
Matrix b(3,4,3);
Matrix c{5,5,3};
Matrix a = {{}, {0, -5, 10, -3, 3}, {}, {4, 5, -9, 9, -7}, {-5, 10, 0, -4, 4}};
Matrix sac = {{5, 5, -6, 1, 0}, {3, 4, 5, 7, 8}, {1, 11, 6, 1, 7}, {4, 5, -9, 9, -7}, {5, 10, 0, -4, 4}};
Matrix s1 = {{5, 5, -6, 1, 0}, {3, 4, 5, 7, 8}, {1, 11, 6, 1, 7}, {4, 5, -9, 9, -7}, {5, 10, 0, -4, 4}};
//cout << s1.determinant();
Matrix sw = {{-5}};
Matrix d = {{1, 0, 2}, {2, 3, 7}};//, {-2, 2, 1, 7}, {-2, 3, 4, 1} };
Matrix e = {{1, 1}, {0, 0} };
Matrix g = {{0, 1}, {1, 0} };
Matrix h = {{1, 0}, {0, 1} };
Matrix i = {{1, 1}, {0, 1 } };
// cout << turnMatricesIntoLinearCombination({e, g, h, i});
try
{
// cout << boost::format("%1% %3%") % 36 % 77 % 34;
}
catch (exception& e)
{
cout << e.what();
}
Matrix f = { {4, 0, 8, 6}, {1, 0, 7, 7}, {8, 0, 8, 8}, {-1, -4, -5, 0} };
Matrix ff = { {4, 2, 7, 6, 5, 6}, {1, 7, 7, 7, 8, 0}, {8, 2, 8, 8, 9, 1}, {-1, -4, -5, 0, 1, 5} };
Matrix mx1 = { {4, 1, 3, 1}, {3, 1, 3, 0}, {5, 1, 4, 1} };
Matrix mx11 = { {1, 4, 8, 2}, {1, 4, 4, 9}, {1, 4, 4, 3}, {1, 4, 5, 5} };
cout << f.determinant() << endl << endl;
Fraction hv = 8;
Fraction hd = 3;
//cout << (hv - hd);
// vector<Vector> test = null_space(mx11);
//cout << f.gaussJordanElimination();
// for(auto e : test)
// cout << e << endl;
//
// cout << endl << nullity(f);
b(0,2) = 4;
b(1,2) = 5;
b(1,3) = 2;
b(2,0) = -8;
b(2,3) = 9;
b(0,0) = 1;
b(0,1) = 2;
vector<int> vvvv;
//cout << Matrix::Identity(3);
//cout << mx11 << endl << endl;
//vector<Vector> test3 = null_space(mx11);
// for(auto e : test3)
// cout << e << endl;
// cout << mx11.determinant();
/*
Vector lav1 = {1, 2, 1};
Vector lav2 = {2, 9, 0};
Vector lav = {3, 3, 4};
Vector lav1 = {1, 5, 3};
Vector lav2 = {-2, 6, 2};
Vector lav = {3, -1, 1};
Vector lav1 = {1, 2, -1};
Vector lav2 = {6, 4, 2};
Vector lav3 = {9, 2, 7};
Vector lav1 = {3, 6, -9, -3};
Vector lav2 = {6, -2, 5, 1};
Vector lav3 = {-1, -2, 3, 1};
Vector lav4 = {2, 3, 0, -2, 0};
Vector lav3 = {3, 2, 1};
*/
// cout << p.gaussJordanElimination();
Matrix mx({ {3, 1, 1, 1}, {5, 2, 3, -2}});//,{-1, -2, 3, 1}});
// cout << mx.gaussJordanElimination();
initializer_list<initializer_list<Fraction>> A = { {1, 3}, {1, -2} };
initializer_list<Vector> B = { {3, 5}, {1, 2} };
initializer_list<Vector> C = {{1, 0, 0, 0, }, {-2, 1, 0, 0, }, {5, 3, 0, 0}, {0, 0, 1, 0}, {3, 0, 0, 0} };
// Vector vec = {3, 2};
Matrix gt(A);
Matrix wz = { {0, 0, 0, 2, 9, 6}, {0, 0, 0, 4, 5, 8} };
Matrix wzf = { {3, 2, 9, 2, 9, 6}, {6, 4, 5, 4, 5, 8} };
Matrix z = { {1, 3, -2, 0, 2, 0}, {2, 6, -5, -2, 4, -3}, {0, 0, 5, 10, 0, 15}, {2, 6, 0, 8, 4, 18} };
// cout << gt;
Matrix dz = { {4, 1, 5, 1, 7, 8, 2}, {6, 3, 3, 5, 2, 3, 1}};//, {0, 0, 5, 10, 0, 15}, {2, 6, 0, 8, 4, 18} };
Matrix fz = { {1, 3, 4, 4}, {2, 3, 5, 4}, {9, 1, 7, 2}};// {-1, -4, -5, 0} };
Matrix tfz = { {1, 3, 4, 4, 1}, {2, 3, 5, 4, 5}, {9, 1, 7, 2, 3}};// {-1, -4, -5, 0} };
Matrix khan = { {1, 1, 2, 3, 2}, {1, 1, 3, 1, 4} };
Matrix kha = { {2, 0, 2}, {-1, 0, -1}, {-1, 0, -1} };
// boost::timer::cpu_timer timer;
// wz.gaussJordanElimination();
// timer.stop();
// cout << timer.format();
Vector lav1 = {0, -2, 2};
Vector lav2 = {1, 3, -1};
Vector lav3 = {9, 0, 0};
Vector lav4 = {4, 0, 2};
Vector v = { 0, 0, 0};
Matrix p = { {4, 0}, {-2, -2} };
Matrix ph = { {1, -1}, {2, 3} };
Matrix ph1 = { {0, 2}, {1, 4} };
Matrix ph2 = { {-1, 5}, {7, 1} };
Matrix ph21 = { {6, -8}, {-1, -8} };
Matrix ph3 = { {6, 0}, {3, 8} };
Matrix ph0 = { {0, 0}, {0, 0} };
Fraction fr1(27, 17);
Fraction fr2(43, 34);
Fraction fr3(-29, 306);
Matrix mcf(3, 3, {2, 3, 5, 6, 4, 5, 5, 8, 9});
double db = 10.0 / 3;
Fraction frt;
// cout << frt;
// cout << s << endl;
try
{
// cout << s.main_diagonal() << endl;
// cout << s.secondary_diagonal() << endl;
//cout << coordinate_vector_relative_to_basis({ {0,1,0}, { {-4,5}, 0, {3,5}, }, { {3,5}, 0, {4,5} } }, {1,1,1});
//cout << change_basis(vec, A, B);
//cout << kha.gaussJordanElimination() << endl;
//vector<Vector> v = null_space(kha);
// cout << coordinate_vector_relative_to_basis({ lav1, lav2,lav3}, lav4);
// for(auto e : v)
// cout << e << endl;
// cout << endl << khan.rank();
}
catch(exception& e)
{
cout << e.what();
}
//cout << lav2 * (lav ->* lav1);
}