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
20namespace
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
27int
28main()
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(a&: m) = 0;
37 A01(a&: m) = -A2(a&: x);
38 A02(a&: m) = A1(a&: x);
39 A10(a&: m) = A2(a&: x);
40 A11(a&: m) = 0;
41 A12(a&: m) = -A0(a&: x);
42 A20(a&: m) = -A1(a&: x);
43 A21(a&: m) = A0(a&: x);
44 A22(a&: m) = 0;
45 {
46 test_same_type(x,cross(a: x,b: y));
47 test_qvm::vector<V1,3> c=cross(a: x,b: y);
48 test_qvm::multiply_mv(r&: c.b,a&: m.a,b&: y.a);
49 BOOST_QVM_TEST_EQ(c.a,c.b);
50 }
51 {
52 test_qvm::vector<V2,3> c=cross(a: vref(a&: x),b: y);
53 test_qvm::multiply_mv(r&: c.b,a&: m.a,b&: y.a);
54 BOOST_QVM_TEST_EQ(c.a,c.b);
55 }
56 {
57 test_qvm::vector<V2,3> c=cross(a: x,b: vref(a&: y));
58 test_qvm::multiply_mv(r&: c.b,a&: m.a,b&: 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(a: x,b: 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 }
72

source code of boost/libs/qvm/test/cross_test.cpp