]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | // test file for quaternion.hpp |
2 | ||
3 | // (C) Copyright Hubert Holin 2001. | |
4 | // Distributed under the Boost Software License, Version 1.0. (See | |
5 | // accompanying file LICENSE_1_0.txt or copy at | |
6 | // http://www.boost.org/LICENSE_1_0.txt) | |
7 | ||
8 | ||
9 | #include <boost/math/quaternion.hpp> | |
10 | ||
11 | typedef boost::math::quaternion<double> qt; | |
12 | typedef std::complex<double> ct; | |
13 | ||
14 | #ifndef BOOST_NO_CXX14_CONSTEXPR | |
15 | ||
16 | constexpr qt full_constexpr_test(qt a, qt b, double d, ct c) | |
17 | { | |
18 | a.swap(b); | |
19 | qt result(a), t; | |
20 | result += d; | |
21 | result += c; | |
22 | result += b; | |
23 | t = result; | |
24 | t = d; | |
25 | t = c; | |
26 | result -= d; | |
27 | result -= c; | |
28 | result -= a; | |
29 | result *= d; | |
30 | result *= c; | |
31 | result *= a; | |
32 | result /= d; | |
33 | result /= c; | |
34 | result /= b; | |
35 | ||
36 | result += a + d; | |
37 | result += d + a; | |
38 | result += a + c; | |
39 | result += c + a; | |
40 | result += a + b; | |
41 | ||
42 | result += a - d; | |
43 | result += d - a; | |
44 | result += a - c; | |
45 | result += c - a; | |
46 | result += a - b; | |
47 | ||
48 | result += a * d; | |
49 | result += d * a; | |
50 | result += a * c; | |
51 | result += c * a; | |
52 | result += a * b; | |
53 | ||
54 | result += a / d; | |
55 | result += d / a; | |
56 | result += a / c; | |
57 | result += c / a; | |
58 | result += a / b; | |
59 | ||
60 | result += norm(a); | |
61 | result += conj(a); | |
62 | ||
63 | return result; | |
64 | } | |
65 | ||
66 | #endif | |
67 | ||
68 | int main() | |
69 | { | |
70 | #ifndef BOOST_NO_CXX11_CONSTEXPR | |
71 | ||
72 | constexpr qt q1; | |
73 | constexpr qt q2(2.0); | |
74 | constexpr qt q3(2.0, 3.0); | |
75 | constexpr qt q4(2.0, 3.9, 3.0); | |
76 | constexpr qt q5(2.0, 3.9, 3.0, 5.); | |
77 | ||
78 | constexpr ct c1(2., 3.); | |
79 | constexpr qt q6(c1); | |
80 | constexpr qt q7(c1, c1); | |
81 | constexpr qt q8(q1); | |
82 | ||
83 | constexpr double d1 = q5.real(); | |
84 | constexpr qt q9 = q1.unreal(); | |
85 | constexpr double d2 = q1.R_component_1(); | |
86 | constexpr double d3 = q1.R_component_2(); | |
87 | constexpr double d4 = q1.R_component_3(); | |
88 | constexpr double d5 = q1.R_component_4(); | |
89 | constexpr ct c2 = q1.C_component_1(); | |
90 | constexpr ct c3 = q1.C_component_1(); | |
91 | ||
92 | constexpr qt q10 = q1 + d1; | |
93 | constexpr qt q11 = d1 + q1; | |
94 | constexpr qt q12 = c2 + q1; | |
95 | constexpr qt q13 = q1 + c2; | |
96 | constexpr qt q14 = q1 + q2; | |
97 | ||
98 | constexpr qt q15 = q1 - d1; | |
99 | constexpr qt q16 = d1 - q1; | |
100 | constexpr qt q17 = c2 - q1; | |
101 | constexpr qt q18 = q1 - c2; | |
102 | constexpr qt q19 = q1 - q2; | |
103 | ||
104 | constexpr qt q20 = q1 * d1; | |
105 | constexpr qt q21 = d1 * q1; | |
106 | constexpr qt q22 = q5 / d1; | |
107 | ||
108 | constexpr double d6 = real(q5); | |
109 | constexpr qt q23 = unreal(q1); | |
110 | ||
111 | constexpr bool b1 = q1 == d1; | |
112 | constexpr bool b2 = d1 == q1; | |
113 | constexpr bool b3 = q1 != d1; | |
114 | constexpr bool b4 = d1 != q1; | |
115 | ||
116 | constexpr bool b5 = q1 == c2; | |
117 | constexpr bool b6 = c2 == q1; | |
118 | constexpr bool b7 = q1 != c2; | |
119 | constexpr bool b8 = c2 != q1; | |
120 | constexpr bool b9 = q2 == q1; | |
121 | constexpr bool b10 = q1 != q2; | |
122 | ||
92f5a8d4 TL |
123 | (void)q9; |
124 | (void)d2; | |
125 | (void)d3; | |
126 | (void)d4; | |
127 | (void)d6; | |
128 | (void)d5; | |
129 | (void)c3; | |
130 | (void)q10; | |
131 | (void)q11; | |
132 | (void)q12; | |
133 | (void)q13; | |
134 | (void)q14; | |
135 | (void)q15; | |
136 | (void)q16; | |
137 | (void)q17; | |
138 | (void)q18; | |
139 | (void)q19; | |
140 | (void)q20; | |
141 | (void)q21; | |
142 | (void)q22; | |
143 | (void)q23; | |
144 | (void)b1; | |
145 | (void)b2; | |
146 | (void)b3; | |
147 | (void)b4; | |
148 | (void)b5; | |
149 | (void)b6; | |
150 | (void)b7; | |
151 | (void)b8; | |
152 | (void)b9; | |
153 | (void)b10; | |
154 | ||
b32b8144 FG |
155 | #endif |
156 | ||
157 | #ifndef BOOST_NO_CXX14_CONSTEXPR | |
158 | ||
159 | constexpr qt q24 = full_constexpr_test(q5, q5 + 1, 3.2, q5.C_component_1()); | |
92f5a8d4 | 160 | (void)q24; |
b32b8144 FG |
161 | |
162 | #endif | |
163 | ||
164 | return 0; | |
165 | } |