]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/qvm/test/test_qvm_quaternion.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / qvm / test / test_qvm_quaternion.hpp
1 //Copyright (c) 2008-2016 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 #ifndef UUID_EF9152E42E4711DFB699737156D89593
7 #define UUID_EF9152E42E4711DFB699737156D89593
8
9 #include <boost/qvm/deduce_quat.hpp>
10 #include <boost/qvm/assert.hpp>
11 #include "test_qvm.hpp"
12
13 namespace
14 test_qvm
15 {
16 template <class Tag,class T=float>
17 struct
18 quaternion
19 {
20 T a[4];
21 mutable T b[4];
22
23 explicit
24 quaternion( T start=T(0), T step=T(0) )
25 {
26 for( int i=0; i!=4; ++i,start+=step )
27 a[i]=b[i]=start;
28 }
29 };
30
31 template <class Tag1,class T1,class Tag2,class T2>
32 void
33 dump_ab( quaternion<Tag1,T1> const & a, quaternion<Tag2,T2> const & b )
34 {
35 detail::dump_ab(a.a,b.a);
36 }
37 }
38
39 namespace
40 boost
41 {
42 namespace
43 qvm
44 {
45 template <class Tag,class T>
46 struct
47 quat_traits< test_qvm::quaternion<Tag,T> >
48 {
49 typedef T scalar_type;
50 typedef test_qvm::quaternion<Tag,T> this_quaternion_type;
51
52 template <int I>
53 static
54 scalar_type &
55 write_element( this_quaternion_type & m )
56 {
57 BOOST_QVM_STATIC_ASSERT(I>=0);
58 BOOST_QVM_STATIC_ASSERT(I<4);
59 return m.a[I];
60 }
61
62 template <int I>
63 static
64 scalar_type
65 read_element( this_quaternion_type const & m )
66 {
67 BOOST_QVM_STATIC_ASSERT(I>=0);
68 BOOST_QVM_STATIC_ASSERT(I<4);
69 return m.a[I];
70 }
71
72 static
73 inline
74 scalar_type &
75 write_element_idx( int i, this_quaternion_type & m )
76 {
77 BOOST_QVM_ASSERT(i>=0);
78 BOOST_QVM_ASSERT(i<4);
79 return m.a[i];
80 }
81
82 static
83 inline
84 scalar_type
85 read_element_idx( int i, this_quaternion_type const & m )
86 {
87 BOOST_QVM_ASSERT(i>=0);
88 BOOST_QVM_ASSERT(i<4);
89 return m.a[i];
90 }
91 };
92
93 template <class Tag,class T>
94 struct
95 deduce_quat2<test_qvm::quaternion<Tag,T>,test_qvm::quaternion<Tag,T> >
96 {
97 typedef test_qvm::quaternion<Tag,T> type;
98 };
99 }
100 }
101
102 namespace
103 {
104 struct Q1;
105 struct Q2;
106 struct Q3;
107 }
108
109 #endif