]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/qvm/test/cross_test.cpp
1 // Copyright 2008-2022 Emil Dotchevski and Reverge Studios, Inc.
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)
6 #ifdef BOOST_QVM_TEST_SINGLE_HEADER
7 # include BOOST_QVM_TEST_SINGLE_HEADER
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>
16 #include "test_qvm_vector.hpp"
17 #include "test_qvm_matrix.hpp"
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
>(); }
30 using namespace boost::qvm
;
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
;
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
);
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
);
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
);
64 test_qvm::vector
<V1
,2> x(42,1);
65 test_qvm::vector
<V1
,2,int> y(43,1);
67 BOOST_QVM_TEST_EQ(r
, x
.a
[0]*y
.a
[1] - x
.a
[1]*y
.a
[0]);
70 return boost::report_errors();