File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed
Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -186,4 +186,38 @@ int main() {
186186
187187 det_test.minor_matrix ().print ();
188188 det_test.algebraic_additions ().print ();
189+
190+ Matrix aaa ({
191+ {1 , 2 },
192+ {3 , 4 }
193+ });
194+ aaa.print ();
195+
196+ aaa.inverse ().print ();
197+
198+ Matrix a100 ({
199+ {1 , 18 , 4 , 6 , 9 },
200+ {11 , 17 , 13 , 14 , 8 },
201+ {25 , 2 , 19 , 15 , 21 },
202+ {10 , 5 , 12 , 3 , 7 },
203+ {24 , 20 , 22 , 16 , 23 }
204+ });
205+ a100.print ();
206+
207+ cout << a100.determinant () << endl << endl;
208+ a100.inverse ().print ();
209+
210+ Matrix mult_a ({
211+ {13 , 26 },
212+ {39 , 13 }
213+ });
214+
215+ Matrix mult_b ({
216+ {7 , 4 },
217+ {2 , 3 }
218+ });
219+
220+ // для проверки
221+ // https://ru.wikihow.com/делить-матрицы
222+ (mult_a / mult_b).print ();
189223}
Original file line number Diff line number Diff line change @@ -176,6 +176,12 @@ Matrix Matrix::algebraic_additions() {
176176 return temp;
177177}
178178
179+ Matrix Matrix::inverse () {
180+ Matrix alg_add_T = this ->algebraic_additions ().transpose ();
181+ alg_add_T /= this ->determinant ();
182+ return alg_add_T;
183+ }
184+
179185// операторы
180186
181187Matrix& Matrix::operator +=(const Matrix& m) {
@@ -258,6 +264,23 @@ Matrix operator*(Matrix a, const double &b) {
258264 return a;
259265}
260266
267+ Matrix& Matrix::operator /=(const Matrix &b) {
268+ *this *= Matrix (b).inverse ();
269+ return *this ;
270+
271+ /* поэлементное деление - не гуд
272+ for (int x = 0; x < b.arr.size(); x++)
273+ for (int y = 0; y < b.arr.size(); y++)
274+ arr[y][x] /= b.arr[y][x];
275+ return *this;
276+ */
277+ }
278+
279+ Matrix operator /(Matrix a, const Matrix &b) {
280+ a /= b;
281+ return a;
282+ }
283+
261284Matrix& Matrix::operator /=(const double & n) {
262285 for (int x = 0 ; x < arr.size (); x++) {
263286 for (int y = 0 ; y < arr.size (); y++) {
You can’t perform that action at this time.
0 commit comments