-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
133 lines (94 loc) · 3.38 KB
/
test.cpp
File metadata and controls
133 lines (94 loc) · 3.38 KB
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
#include "test.h"
QString test::test_mAlg()
{
mMatrix A1_({{-1,-2,1},{5,9,-8}});
mMatrix B1_({{10,-25,98},{3,0,-14}});
QString out = A1_.toQStr()+ "\n+\n"+
B1_.toQStr()+ "\n=\n" +
(A1_+B1_).toQStr() + "\n\n";
mMatrix A2_({{-1,-2,7},{4,9,0}});
out += " 3*\n"+A2_.toQStr()+ "\n=\n"+( 3*A2_).toQStr()+ "\n\n";
out += "-5*\n"+A2_.toQStr()+ "\n=\n"+(-5*A2_).toQStr()+ "\n\n";
mMatrix A3_({{-1, 2, -3, 0},
{ 5, 4, -2, 1},
{-8,11,-10,-5}});
mMatrix B3_({{-9, 3},
{ 6,20},
{ 7, 0},
{12,-4}});
out += A3_.toQStr()+ "\n*\n"+
B3_.toQStr()+ "\n=\n" +
(A3_*B3_).toQStr()+ "\n\n";
mMatrix A4_({{5,8,-4},
{6,9,-5},
{4,7,-3}});
out += A4_.toQStr()+ " T\n=\n"+
(A4_.T()).toQStr()+ "\n\n";
mMatrix A5_({{2,5,7},{6,3,4},{5,-2,-3}});
out += A5_.toQStr()+ " det = "+
QString::number(A5_.det())+ "\n\n";
out += A5_.toQStr()+ "\n MinorMatr = \n"+
A5_.MMatr().toQStr()+ "\n\n";
out += A5_.toQStr()+ "\n AlgDopMatr = \n"+
A5_.adMatr().toQStr()+ "\n\n";
out += A5_.toQStr()+ "\n AlgDopMatr T = \n"+
A5_.adMatr().T().toQStr()+ "\n\n";
out += A5_.toQStr()+ "\n ^-1 = \n"+
(A5_.adMatr().T()*(1.0/A5_.det())).toQStr()+ "\n\n";
out += A5_.toQStr()+ "\n*\n"+
(A5_.adMatr().T()*(1.0/A5_.det())).toQStr()+ "\n=\n" +
(A5_*(A5_.adMatr().T()*(1.0/A5_.det()))).toQStr()+ "\n\n";
// mVector v({2,-3,1},mvtCol);
// auto m00 = c.Minor(0,0);
// double det = c.det();
// double detB = B.det();
// mMatrix min = c.MMatr();
// mMatrix ad = c.adMatr();
// mMatrix obr = c.inv();
// auto res = obr*c;
// bool us = res.isE();
mMatrix A6_({{3,2,1},{2,3,1},{2,1,3}});
out += A6_.toQStr()+ " det = "+
QString::number(A5_.det())+ "\n\n";
out += A6_.toQStr()+ "\n MinorMatr = \n"+
A6_.MMatr().toQStr()+ "\n\n";
out += A6_.toQStr()+ "\n AlgDopMatr = \n"+
A6_.adMatr().toQStr()+ "\n\n";
out += A6_.toQStr()+ "\n AlgDopMatr T = \n"+
A6_.adMatr().T().toQStr()+ "\n\n";
out += A6_.toQStr()+ "\n ^-1 = \n"+
(A6_.inv()).toQStr()+ "\n\n";
mVector V6_({5,-1,4},mvtColI);
auto X = mMatrix::solve(A6_,V6_);
// mMatrix A2({{4,8},{6,2}});
out += QString("AX=B\n A=\n%1\nB=\n%2\nX=\n%3\n\n").
arg(A6_.toQStr()).
arg(V6_.toQStr()).
arg(X.toQStr());
// auto X = A1.solve(A1,A2);
return out;
}
QString test::test_anGeom()
{
QString out = "";
lP2D A (2.0,1.0);
lP2D B (-2.0,3.0);
out += QString("A%1\nB%2\n")
.arg(A.toQStr())
.arg(B.toQStr());
lV2D f (A,B);
out += QString("AB(f)%1\n\n")
.arg(f.toQStr(true));
lV3D a (-1,2,-3);
lV3D b (0,-4,1);
lV3D c = a*b;
out += QString("f vec\n%1\n")
.arg(f.vec().toQStr());
out += QString("\nVector multiply c = [a,b]\na%1\nb%2\nc%3\n")
.arg(a.toQStr())
.arg(b.toQStr())
.arg(c.toQStr());
out += QString("c vec\n%1\n")
.arg(c.vec().toQStr());
return out;
}