]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/qvm/test/deduce_scalar_mv_test.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / qvm / test / deduce_scalar_mv_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/deduce_scalar.hpp>
10 # include <boost/qvm/mat.hpp>
11 # include <boost/qvm/mat_operations.hpp>
12 # include <boost/qvm/vec.hpp>
13 # include <boost/qvm/vec_mat_operations3.hpp>
14 #endif
15
16 #include <boost/core/lightweight_test.hpp>
17
18 template <class T>
19 struct
20 wrap
21 {
22 T t;
23 wrap() { }
24 explicit wrap(T t):t(t) { }
25 };
26
27 template <class S, class T>
28 wrap<T>
29 operator*(S s, wrap<T> w)
30 {
31 return wrap<T>(s * w.t);
32 }
33
34 template <class T>
35 wrap<T> operator+(wrap<T> a, wrap<T> b)
36 {
37 return wrap<T>(a.t + b.t);
38 }
39
40 namespace
41 boost
42 {
43 namespace
44 qvm
45 {
46 template <class T>
47 struct
48 is_scalar<wrap<T> >
49 {
50 static bool const value=true;
51 };
52 template <class S, class T>
53 struct
54 deduce_scalar<S, wrap<T> >
55 {
56 typedef wrap<typename deduce_scalar<S, T>::type> type;
57 };
58 }
59 }
60
61 int
62 main()
63 {
64 using namespace boost::qvm;
65 mat<double, 3, 3> m = rotz_mat<3>(3.14159);
66 vec<wrap<double>, 3> v;
67 v.a[0] = wrap<double>(1.0);
68 v.a[1] = wrap<double>(0);
69 v.a[2] = wrap<double>(0);
70 vec<wrap<double>, 3> r = m * v;
71 BOOST_TEST_LT(fabs(r.a[0].t+1), 0.0001);
72 BOOST_TEST_LT(fabs(r.a[1].t), 0.0001);
73 BOOST_TEST_LT(fabs(r.a[2].t), 0.0001);
74 return boost::report_errors();
75 }