|
1 #include <xmmintrin.h> |
1 #include "vector.h" |
2 #include "vector.h" |
2 |
3 |
3 int main() { |
4 int main() { |
|
5 { |
|
6 /* Vector3 */ |
4 Vector3 a(1, 2, 3); |
7 Vector3 a(1, 2, 3); |
5 cout << "=== Vector3 test ===" << endl; |
8 cout << "=== Vector3 test ===" << endl; |
6 cout << "a = " << a << endl; |
9 cout << "a = " << a << endl; |
7 Vector3 b(2, 3, 2); |
10 Vector3 b(2, 3, 2); |
8 cout << "b = " << b << endl; |
11 cout << "b = " << b << endl; |
9 |
12 |
10 cout << "a + b = " << a + b << endl; |
13 cout << "a + b = " << a + b << endl; |
11 cout << "b - a = " << b - a << endl; |
14 cout << "b - a = " << b - a << endl; |
12 cout << "dot(a,b) = " << dot(a,b) << endl; |
15 cout << "dot(a,b) = " << dot(a,b) << endl; |
13 cout << "cross(a,b) = " << cross(a,b) << endl; |
16 cout << "cross(a,b) = " << cross(a,b) << endl; |
14 cout << "a * 2 = " << a * 2 << endl; |
17 cout << "a * 2 = " << a * 2 << endl; |
15 cout << "3 * b = " << 3 * b << endl; |
18 cout << "3 * b = " << 3 * b << endl; |
16 cout << "-a = " << -a << endl; |
19 cout << "-a = " << -a << endl; |
17 |
20 |
18 cout << "a.mag() = " << a.mag() << endl; |
21 cout << "a.mag() = " << a.mag() << endl; |
19 cout << "a.unit() = " << a.unit() << endl; |
22 cout << "normalize(a) = " << normalize(a) << endl; |
20 cout << "a.unit().mag() = " << a.unit().mag() << endl; |
23 cout << "normalize(a).mag() = " << normalize(a).mag() << endl; |
|
24 } |
|
25 |
|
26 { |
|
27 /* VectorPacket */ |
|
28 VectorPacket a(_mm_set_ps(4,3,2,1), _mm_set_ps(8,7,6,5), _mm_set_ps(12,11,10,9)); |
|
29 VectorPacket b(_mm_set_ps(41,31,21,11), _mm_set_ps(42,32,22,12), _mm_set_ps(43,33,23,13)); |
|
30 cout << "=== VectorPacket test ===" << endl; |
|
31 cout << "a = " << a << endl; |
|
32 cout << "b = " << b << endl; |
|
33 |
|
34 cout << "a + b = " << a + b << endl; |
|
35 cout << "b - a = " << b - a << endl; |
|
36 /* cout << "dot(a,b) = " << dot(a,b) << endl; |
|
37 cout << "cross(a,b) = " << cross(a,b) << endl; |
|
38 cout << "a * 2 = " << a * 2 << endl; |
|
39 cout << "3 * b = " << 3 * b << endl; |
|
40 cout << "-a = " << -a << endl; |
|
41 |
|
42 cout << "normalize(a) = " << normalize(a) << endl;*/ |
|
43 } |
21 |
44 |
22 return 0; |
45 return 0; |
23 } |
46 } |