You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
876 B

#include "GMath.h"
#include "CArrayBuffer.h"
#include "CDataView.h"
#include "CFloat32Array.h"
int main() {
/*
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
};
GMatrix A(3, 3, a);
float p[] = {
1, 2, 3,
1, 2, 3,
1, 2, 3
};
GMatrix P(3, 3, p);
//模拟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)
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);
GVector ret = c1 * X[0][0] + c2 * X[1][0] + c3 * X[2][0];
cout << ret << endl;
return 0;
}