]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/qvm/test/cross_test.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / qvm / test / cross_test.cpp
1 // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
2
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
6 #ifdef BOOST_QVM_TEST_SINGLE_HEADER
7 # include BOOST_QVM_TEST_SINGLE_HEADER
8 #else
9 # include <boost/qvm/vec_operations.hpp>
10 # include <boost/qvm/vec_access.hpp>
11 # include <boost/qvm/mat_access.hpp>
12 # include <boost/qvm/vec_operations3.hpp>
13 # include <boost/qvm/vec.hpp>
14 #endif
15
16 #include "test_qvm_vector.hpp"
17 #include "test_qvm_matrix.hpp"
18 #include "gold.hpp"
19
20 namespace
21 {
22 template <class T,class U> struct same_type_tester;
23 template <class T> struct same_type_tester<T,T> { };
24 template <class T,class U> void test_same_type( T, U ) { same_type_tester<T,U>(); }
25 }
26
27 int
28 main()
29 {
30 using namespace boost::qvm;
31
32 {
33 test_qvm::vector<V1,3> x(42,1);
34 test_qvm::vector<V1,3> y=x*2;
35 test_qvm::matrix<M1,3,3> m;
36 A00(m) = 0;
37 A01(m) = -A2(x);
38 A02(m) = A1(x);
39 A10(m) = A2(x);
40 A11(m) = 0;
41 A12(m) = -A0(x);
42 A20(m) = -A1(x);
43 A21(m) = A0(x);
44 A22(m) = 0;
45 {
46 test_same_type(x,cross(x,y));
47 test_qvm::vector<V1,3> c=cross(x,y);
48 test_qvm::multiply_mv(c.b,m.a,y.a);
49 BOOST_QVM_TEST_EQ(c.a,c.b);
50 }
51 {
52 test_qvm::vector<V2,3> c=cross(vref(x),y);
53 test_qvm::multiply_mv(c.b,m.a,y.a);
54 BOOST_QVM_TEST_EQ(c.a,c.b);
55 }
56 {
57 test_qvm::vector<V2,3> c=cross(x,vref(y));
58 test_qvm::multiply_mv(c.b,m.a,y.a);
59 BOOST_QVM_TEST_EQ(c.a,c.b);
60 }
61 }
62
63 {
64 test_qvm::vector<V1,2> x(42,1);
65 test_qvm::vector<V1,2,int> y(43,1);
66 float r = cross(x,y);
67 BOOST_QVM_TEST_EQ(r, x.a[0]*y.a[1] - x.a[1]*y.a[0]);
68 }
69
70 return boost::report_errors();
71 }