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.

79 lines
1.3 KiB

#include "GMath.h"
#include "CArrayBuffer.h"
#include "CDataView.h"
#include "CFloat32Array.h"
int main() {
printf("arr0 内部生成CArrayBuffer\n");
CFloat32Array arr0(8);
for (int i = 0; i < arr0.length(); i++) {
arr0[i] = i * 100.0;
}
for (int i = 0; i < arr0.length(); i++) {
printf("%f\n", arr0[i]);
}
printf("arr1 共享 arr0 中 CArrayBuffer 的部分区块\n");
CFloat32Array arr1(arr0.buffer, 4 * sizeof(float32), 4);
for (int i = 0; i < arr1.length(); i++) {
printf("%f\n", arr1[i]);
}
printf("重置arr1的各个元素为10.0的倍数\n");
for (int i = 0; i < arr1.length(); i++) {
arr1[i] = i * 10.0;
}
for (int i = 0; i < arr1.length(); i++) {
printf("%f\n", arr1[i]);
}
/*GVector l(3);
l += 2;
cout << l*3 << endl;
float a[] = {
2, -1, 3,
4, -2, 5,
6, -3, 8
};
GMatrix A(3, 3, a);
float b[] = {
2, -1, 9,
2, -2, 5,
3, 1, 2
};
GMatrix B(3, 3, b);
GMatrix C = A*B;
cout << A << endl;
cout << B << endl;
cout << C << endl;
GVector ret(3);
GVector rv = B.GetColVec(1);
for (int i = 0; i < A.GetColNum(); i++) {
GVector l = A.GetColVec(i);
ret += rv[i]*l;
}
cout << ret << endl;
*/
/*float a[] = {
1,0,
1,4
};
GMatrix A(2, 2, a);
float c[] = {
0,1,
1,0
};
GMatrix C(2, 2, c);
cout << A*A << endl;*/
return 0;
}