blobt 4 years ago
parent
commit
56e30b29f9
  1. BIN
      .vs/3dMath/v15/.suo
  2. 5
      GMath.cpp
  3. 65
      main.cpp

BIN
.vs/3dMath/v15/.suo

5
GMath.cpp

@ -909,7 +909,7 @@ GMatrix RowEchelonForm(const GMatrix & m)
//如果最大值是0的话,那么直接跳过这一列
if (EQ_ZERO(max, PRECISION)) {
shift++;
i--; //记得要返回上一
i--; //记得要返回上一
continue;
}
@ -964,7 +964,8 @@ GMatrix ReduceRowEchelonForm(const GMatrix & m)
//如果最大值是0的话,那么直接跳过这一列
if (EQ_ZERO(max, PRECISION)) {
shift++;
i--; //记得要返回上一列
i--; //记得要返回上一行
continue;
}

65
main.cpp

@ -4,50 +4,45 @@
#include "CFloat32Array.h"
int main() {
/*int linda = 4;
/*
matrix P = p1, p2, p3, ......, pn
matrix A;
A * P = (A*p1, A*p2, A*p3, ......, A*pn)
*/
float a[] = {
3, -1, 0,
4, -1, 0,
-1, 0, 0
2, -2, 0,
-2, 1, -2,
0, -2, 0
};
GMatrix A(3, 3, a);
float p[] = {
1, 2, 3,
1, 2, 3,
1, 2, 3
};
GMatrix P(3, 3, p);
GMatrix E(3, 3);
E.SetIdentity();
E = E * linda;
//模拟P矩阵的第二列
float x[] = {
2,
2,
2
};
GMatrix X(3, 1, x);
cout << A * P << endl;
cout << A * X << endl;
/*
matrix P = p1, p2, p3, ......, pn
vector v = v1, v2, v3, ......, vn
cout << ReduceRowEchelonForm(A -E) << endl;*/
P * V = (p1 * v1) + (p2 * v2) + (p3 * v3) + ...... + (pn * vn)
*/
GVector c1 = A.GetColVec(0);
GVector c2 = A.GetColVec(1);
GVector c3 = A.GetColVec(2);
float a[] = {
2, -2, 0,
-2, 1, -2,
0, -2, 0
};
GMatrix A(3, 3, a);
GVector ret = c1 * X[0][0] + c2 * X[1][0] + c3 * X[2][0];
cout << ret << endl;
GVector3 x1(0.5, 1, 1);
GVector3 x2(-1, -0.5, 1);
GVector3 x3(2, -2, 1);
x1.normalize();
x2.normalize();
x3.normalize();
GMatrix Q(3, 3);
Q.SetColVec(0, x1);
Q.SetColVec(1, x2);
Q.SetColVec(2, x3);
return 0;
cout << Inverse(Q)*A*Q << endl;
return 0;
}
Loading…
Cancel
Save