Chris@16
|
1 ///////////////////////////////////////////////////////////////
|
Chris@16
|
2 // Copyright 2012 John Maddock. Distributed under the Boost
|
Chris@16
|
3 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_
|
Chris@16
|
5
|
Chris@16
|
6 #ifndef BOOST_MATH_DEBUG_ADAPTER_HPP
|
Chris@16
|
7 #define BOOST_MATH_DEBUG_ADAPTER_HPP
|
Chris@16
|
8
|
Chris@16
|
9 #include <boost/multiprecision/traits/extract_exponent_type.hpp>
|
Chris@16
|
10 #include <boost/multiprecision/detail/integer_ops.hpp>
|
Chris@16
|
11
|
Chris@16
|
12 namespace boost{
|
Chris@16
|
13 namespace multiprecision{
|
Chris@16
|
14 namespace backends{
|
Chris@16
|
15
|
Chris@16
|
16 template <class Backend>
|
Chris@16
|
17 struct debug_adaptor
|
Chris@16
|
18 {
|
Chris@16
|
19 typedef typename Backend::signed_types signed_types;
|
Chris@16
|
20 typedef typename Backend::unsigned_types unsigned_types;
|
Chris@16
|
21 typedef typename Backend::float_types float_types;
|
Chris@16
|
22 typedef typename extract_exponent_type<
|
Chris@16
|
23 Backend, number_category<Backend>::value>::type exponent_type;
|
Chris@16
|
24
|
Chris@16
|
25 private:
|
Chris@16
|
26 std::string debug_value;
|
Chris@16
|
27 Backend m_value;
|
Chris@16
|
28 public:
|
Chris@16
|
29 void update_view()
|
Chris@16
|
30 {
|
Chris@16
|
31 try
|
Chris@16
|
32 {
|
Chris@16
|
33 debug_value = m_value.str(0, static_cast<std::ios_base::fmtflags>(0));
|
Chris@16
|
34 }
|
Chris@16
|
35 catch(const std::exception& e)
|
Chris@16
|
36 {
|
Chris@16
|
37 debug_value = "String conversion failed with message: \"";
|
Chris@16
|
38 debug_value += e.what();
|
Chris@16
|
39 debug_value += "\"";
|
Chris@16
|
40 }
|
Chris@16
|
41 }
|
Chris@16
|
42 debug_adaptor()
|
Chris@16
|
43 {
|
Chris@16
|
44 update_view();
|
Chris@16
|
45 }
|
Chris@16
|
46 debug_adaptor(const debug_adaptor& o) : debug_value(o.debug_value), m_value(o.m_value)
|
Chris@16
|
47 {
|
Chris@16
|
48 }
|
Chris@16
|
49 debug_adaptor& operator = (const debug_adaptor& o)
|
Chris@16
|
50 {
|
Chris@16
|
51 debug_value = o.debug_value;
|
Chris@16
|
52 m_value = o.m_value;
|
Chris@16
|
53 return *this;
|
Chris@16
|
54 }
|
Chris@16
|
55 template <class T>
|
Chris@16
|
56 debug_adaptor(const T& i, const typename enable_if_c<is_convertible<T, Backend>::value>::type* = 0)
|
Chris@16
|
57 : m_value(i)
|
Chris@16
|
58 {
|
Chris@16
|
59 update_view();
|
Chris@16
|
60 }
|
Chris@16
|
61 template <class T>
|
Chris@16
|
62 debug_adaptor(const T& i, const T& j)
|
Chris@16
|
63 : m_value(i, j)
|
Chris@16
|
64 {
|
Chris@16
|
65 update_view();
|
Chris@16
|
66 }
|
Chris@16
|
67 template <class T>
|
Chris@16
|
68 typename enable_if_c<is_arithmetic<T>::value || is_convertible<T, Backend>::value, debug_adaptor&>::type operator = (const T& i)
|
Chris@16
|
69 {
|
Chris@16
|
70 m_value = i;
|
Chris@16
|
71 update_view();
|
Chris@16
|
72 return *this;
|
Chris@16
|
73 }
|
Chris@16
|
74 debug_adaptor& operator = (const char* s)
|
Chris@16
|
75 {
|
Chris@16
|
76 m_value = s;
|
Chris@16
|
77 update_view();
|
Chris@16
|
78 return *this;
|
Chris@16
|
79 }
|
Chris@16
|
80 void swap(debug_adaptor& o)
|
Chris@16
|
81 {
|
Chris@16
|
82 std::swap(m_value, o.value());
|
Chris@16
|
83 std::swap(debug_value, o.debug_value);
|
Chris@16
|
84 }
|
Chris@16
|
85 std::string str(std::streamsize digits, std::ios_base::fmtflags f)const
|
Chris@16
|
86 {
|
Chris@16
|
87 return m_value.str(digits, f);
|
Chris@16
|
88 }
|
Chris@16
|
89 void negate()
|
Chris@16
|
90 {
|
Chris@16
|
91 m_value.negate();
|
Chris@16
|
92 update_view();
|
Chris@16
|
93 }
|
Chris@16
|
94 int compare(const debug_adaptor& o)const
|
Chris@16
|
95 {
|
Chris@16
|
96 return m_value.compare(o.value());
|
Chris@16
|
97 }
|
Chris@16
|
98 template <class T>
|
Chris@16
|
99 int compare(const T& i)const
|
Chris@16
|
100 {
|
Chris@16
|
101 return m_value.compare(i);
|
Chris@16
|
102 }
|
Chris@16
|
103 Backend& value()
|
Chris@16
|
104 {
|
Chris@16
|
105 return m_value;
|
Chris@16
|
106 }
|
Chris@16
|
107 const Backend& value()const
|
Chris@16
|
108 {
|
Chris@16
|
109 return m_value;
|
Chris@16
|
110 }
|
Chris@16
|
111 template <class Archive>
|
Chris@16
|
112 void serialize(Archive& ar, const unsigned int /*version*/)
|
Chris@16
|
113 {
|
Chris@16
|
114 ar & m_value;
|
Chris@16
|
115 typedef typename Archive::is_loading tag;
|
Chris@16
|
116 if(tag::value)
|
Chris@16
|
117 update_view();
|
Chris@16
|
118 }
|
Chris@16
|
119 };
|
Chris@16
|
120
|
Chris@16
|
121 template <class Backend>
|
Chris@16
|
122 inline Backend const& unwrap_debug_type(debug_adaptor<Backend> const& val)
|
Chris@16
|
123 {
|
Chris@16
|
124 return val.value();
|
Chris@16
|
125 }
|
Chris@16
|
126 template <class T>
|
Chris@16
|
127 inline const T& unwrap_debug_type(const T& val)
|
Chris@16
|
128 {
|
Chris@16
|
129 return val;
|
Chris@16
|
130 }
|
Chris@16
|
131
|
Chris@16
|
132 #define NON_MEMBER_OP1(name, str) \
|
Chris@16
|
133 template <class Backend>\
|
Chris@16
|
134 inline void BOOST_JOIN(eval_, name)(debug_adaptor<Backend>& result)\
|
Chris@16
|
135 {\
|
Chris@16
|
136 using default_ops::BOOST_JOIN(eval_, name);\
|
Chris@16
|
137 BOOST_JOIN(eval_, name)(result.value());\
|
Chris@16
|
138 result.update_view();\
|
Chris@16
|
139 }
|
Chris@16
|
140
|
Chris@16
|
141 #define NON_MEMBER_OP2(name, str) \
|
Chris@16
|
142 template <class Backend, class T>\
|
Chris@16
|
143 inline void BOOST_JOIN(eval_, name)(debug_adaptor<Backend>& result, const T& a)\
|
Chris@16
|
144 {\
|
Chris@16
|
145 using default_ops::BOOST_JOIN(eval_, name);\
|
Chris@16
|
146 BOOST_JOIN(eval_, name)(result.value(), unwrap_debug_type(a));\
|
Chris@16
|
147 result.update_view();\
|
Chris@16
|
148 }\
|
Chris@16
|
149 template <class Backend>\
|
Chris@16
|
150 inline void BOOST_JOIN(eval_, name)(debug_adaptor<Backend>& result, const debug_adaptor<Backend>& a)\
|
Chris@16
|
151 {\
|
Chris@16
|
152 using default_ops::BOOST_JOIN(eval_, name);\
|
Chris@16
|
153 BOOST_JOIN(eval_, name)(result.value(), unwrap_debug_type(a));\
|
Chris@16
|
154 result.update_view();\
|
Chris@16
|
155 }
|
Chris@16
|
156
|
Chris@16
|
157 #define NON_MEMBER_OP3(name, str) \
|
Chris@16
|
158 template <class Backend, class T, class U>\
|
Chris@16
|
159 inline void BOOST_JOIN(eval_, name)(debug_adaptor<Backend>& result, const T& a, const U& b)\
|
Chris@16
|
160 {\
|
Chris@16
|
161 using default_ops::BOOST_JOIN(eval_, name);\
|
Chris@16
|
162 BOOST_JOIN(eval_, name)(result.value(), unwrap_debug_type(a), unwrap_debug_type(b));\
|
Chris@16
|
163 result.update_view();\
|
Chris@16
|
164 }\
|
Chris@16
|
165 template <class Backend, class T>\
|
Chris@16
|
166 inline void BOOST_JOIN(eval_, name)(debug_adaptor<Backend>& result, const debug_adaptor<Backend>& a, const T& b)\
|
Chris@16
|
167 {\
|
Chris@16
|
168 using default_ops::BOOST_JOIN(eval_, name);\
|
Chris@16
|
169 BOOST_JOIN(eval_, name)(result.value(), unwrap_debug_type(a), unwrap_debug_type(b));\
|
Chris@16
|
170 result.update_view();\
|
Chris@16
|
171 }\
|
Chris@16
|
172 template <class Backend, class T>\
|
Chris@16
|
173 inline void BOOST_JOIN(eval_, name)(debug_adaptor<Backend>& result, const T& a, const debug_adaptor<Backend>& b)\
|
Chris@16
|
174 {\
|
Chris@16
|
175 using default_ops::BOOST_JOIN(eval_, name);\
|
Chris@16
|
176 BOOST_JOIN(eval_, name)(result.value(), unwrap_debug_type(a), unwrap_debug_type(b));\
|
Chris@16
|
177 result.update_view();\
|
Chris@16
|
178 }\
|
Chris@16
|
179 template <class Backend>\
|
Chris@16
|
180 inline void BOOST_JOIN(eval_, name)(debug_adaptor<Backend>& result, const debug_adaptor<Backend>& a, const debug_adaptor<Backend>& b)\
|
Chris@16
|
181 {\
|
Chris@16
|
182 using default_ops::BOOST_JOIN(eval_, name);\
|
Chris@16
|
183 BOOST_JOIN(eval_, name)(result.value(), unwrap_debug_type(a), unwrap_debug_type(b));\
|
Chris@16
|
184 result.update_view();\
|
Chris@16
|
185 }
|
Chris@16
|
186
|
Chris@16
|
187 #define NON_MEMBER_OP4(name, str) \
|
Chris@16
|
188 template <class Backend, class T, class U, class V>\
|
Chris@16
|
189 inline void BOOST_JOIN(eval_, name)(debug_adaptor<Backend>& result, const T& a, const U& b, const V& c)\
|
Chris@16
|
190 {\
|
Chris@16
|
191 using default_ops::BOOST_JOIN(eval_, name);\
|
Chris@16
|
192 BOOST_JOIN(eval_, name)(result.value(), unwrap_debug_type(a), unwrap_debug_type(b), unwrap_debug_type(c));\
|
Chris@16
|
193 result.update_view();\
|
Chris@16
|
194 }\
|
Chris@16
|
195 template <class Backend, class T>\
|
Chris@16
|
196 inline void BOOST_JOIN(eval_, name)(debug_adaptor<Backend>& result, const debug_adaptor<Backend>& a, const debug_adaptor<Backend>& b, const T& c)\
|
Chris@16
|
197 {\
|
Chris@16
|
198 using default_ops::BOOST_JOIN(eval_, name);\
|
Chris@16
|
199 BOOST_JOIN(eval_, name)(result.value(), unwrap_debug_type(a), unwrap_debug_type(b), unwrap_debug_type(c));\
|
Chris@16
|
200 result.update_view();\
|
Chris@16
|
201 }\
|
Chris@16
|
202 template <class Backend, class T>\
|
Chris@16
|
203 inline void BOOST_JOIN(eval_, name)(debug_adaptor<Backend>& result, const debug_adaptor<Backend>& a, const T& b, const debug_adaptor<Backend>& c)\
|
Chris@16
|
204 {\
|
Chris@16
|
205 using default_ops::BOOST_JOIN(eval_, name);\
|
Chris@16
|
206 BOOST_JOIN(eval_, name)(result.value(), unwrap_debug_type(a), unwrap_debug_type(b), unwrap_debug_type(c));\
|
Chris@16
|
207 result.update_view();\
|
Chris@16
|
208 }\
|
Chris@16
|
209 template <class Backend, class T>\
|
Chris@16
|
210 inline void BOOST_JOIN(eval_, name)(debug_adaptor<Backend>& result, const T& a, const debug_adaptor<Backend>& b, const debug_adaptor<Backend>& c)\
|
Chris@16
|
211 {\
|
Chris@16
|
212 using default_ops::BOOST_JOIN(eval_, name);\
|
Chris@16
|
213 BOOST_JOIN(eval_, name)(result.value(), unwrap_debug_type(a), unwrap_debug_type(b), unwrap_debug_type(c));\
|
Chris@16
|
214 result.update_view();\
|
Chris@16
|
215 }\
|
Chris@16
|
216 template <class Backend>\
|
Chris@16
|
217 inline void BOOST_JOIN(eval_, name)(debug_adaptor<Backend>& result, const debug_adaptor<Backend>& a, const debug_adaptor<Backend>& b, const debug_adaptor<Backend>& c)\
|
Chris@16
|
218 {\
|
Chris@16
|
219 using default_ops::BOOST_JOIN(eval_, name);\
|
Chris@16
|
220 BOOST_JOIN(eval_, name)(result.value(), unwrap_debug_type(a), unwrap_debug_type(b), unwrap_debug_type(c));\
|
Chris@16
|
221 result.update_view();\
|
Chris@16
|
222 }\
|
Chris@16
|
223 template <class Backend, class T, class U>\
|
Chris@16
|
224 inline void BOOST_JOIN(eval_, name)(debug_adaptor<Backend>& result, const debug_adaptor<Backend>& a, const T& b, const U& c)\
|
Chris@16
|
225 {\
|
Chris@16
|
226 using default_ops::BOOST_JOIN(eval_, name);\
|
Chris@16
|
227 BOOST_JOIN(eval_, name)(result.value(), unwrap_debug_type(a), unwrap_debug_type(b), unwrap_debug_type(c));\
|
Chris@16
|
228 result.update_view();\
|
Chris@16
|
229 }\
|
Chris@16
|
230
|
Chris@16
|
231 NON_MEMBER_OP2(add, "+=");
|
Chris@16
|
232 NON_MEMBER_OP2(subtract, "-=");
|
Chris@16
|
233 NON_MEMBER_OP2(multiply, "*=");
|
Chris@16
|
234 NON_MEMBER_OP2(divide, "/=");
|
Chris@16
|
235
|
Chris@16
|
236 template <class Backend, class R>
|
Chris@16
|
237 inline void eval_convert_to(R* result, const debug_adaptor<Backend>& val)
|
Chris@16
|
238 {
|
Chris@16
|
239 using default_ops::eval_convert_to;
|
Chris@16
|
240 eval_convert_to(result, val.value());
|
Chris@16
|
241 }
|
Chris@16
|
242
|
Chris@16
|
243 template <class Backend, class Exp>
|
Chris@16
|
244 inline void eval_frexp(debug_adaptor<Backend>& result, const debug_adaptor<Backend>& arg, Exp* exp)
|
Chris@16
|
245 {
|
Chris@16
|
246 eval_frexp(result.value(), arg.value(), exp);
|
Chris@101
|
247 result.update_view();
|
Chris@16
|
248 }
|
Chris@16
|
249
|
Chris@16
|
250 template <class Backend, class Exp>
|
Chris@16
|
251 inline void eval_ldexp(debug_adaptor<Backend>& result, const debug_adaptor<Backend>& arg, Exp exp)
|
Chris@16
|
252 {
|
Chris@16
|
253 eval_ldexp(result.value(), arg.value(), exp);
|
Chris@101
|
254 result.update_view();
|
Chris@101
|
255 }
|
Chris@101
|
256
|
Chris@101
|
257 template <class Backend, class Exp>
|
Chris@101
|
258 inline void eval_scalbn(debug_adaptor<Backend>& result, const debug_adaptor<Backend>& arg, Exp exp)
|
Chris@101
|
259 {
|
Chris@101
|
260 eval_scalbn(result.value(), arg.value(), exp);
|
Chris@101
|
261 result.update_view();
|
Chris@101
|
262 }
|
Chris@101
|
263
|
Chris@101
|
264 template <class Backend>
|
Chris@101
|
265 inline typename Backend::exponent_type eval_ilogb(const debug_adaptor<Backend>& arg)
|
Chris@101
|
266 {
|
Chris@101
|
267 return eval_ilogb(arg.value());
|
Chris@16
|
268 }
|
Chris@16
|
269
|
Chris@16
|
270 NON_MEMBER_OP2(floor, "floor");
|
Chris@16
|
271 NON_MEMBER_OP2(ceil, "ceil");
|
Chris@16
|
272 NON_MEMBER_OP2(sqrt, "sqrt");
|
Chris@101
|
273 NON_MEMBER_OP2(logb, "logb");
|
Chris@16
|
274
|
Chris@16
|
275 template <class Backend>
|
Chris@16
|
276 inline int eval_fpclassify(const debug_adaptor<Backend>& arg)
|
Chris@16
|
277 {
|
Chris@16
|
278 using default_ops::eval_fpclassify;
|
Chris@16
|
279 return eval_fpclassify(arg.value());
|
Chris@16
|
280 }
|
Chris@16
|
281
|
Chris@16
|
282 /*********************************************************************
|
Chris@16
|
283 *
|
Chris@16
|
284 * Optional arithmetic operations come next:
|
Chris@16
|
285 *
|
Chris@16
|
286 *********************************************************************/
|
Chris@16
|
287
|
Chris@16
|
288 NON_MEMBER_OP3(add, "+");
|
Chris@16
|
289 NON_MEMBER_OP3(subtract, "-");
|
Chris@16
|
290 NON_MEMBER_OP3(multiply, "*");
|
Chris@16
|
291 NON_MEMBER_OP3(divide, "/");
|
Chris@16
|
292 NON_MEMBER_OP3(multiply_add, "fused-multiply-add");
|
Chris@16
|
293 NON_MEMBER_OP3(multiply_subtract, "fused-multiply-subtract");
|
Chris@16
|
294 NON_MEMBER_OP4(multiply_add, "fused-multiply-add");
|
Chris@16
|
295 NON_MEMBER_OP4(multiply_subtract, "fused-multiply-subtract");
|
Chris@16
|
296
|
Chris@16
|
297 NON_MEMBER_OP1(increment, "increment");
|
Chris@16
|
298 NON_MEMBER_OP1(decrement, "decrement");
|
Chris@16
|
299
|
Chris@16
|
300 /*********************************************************************
|
Chris@16
|
301 *
|
Chris@16
|
302 * Optional integer operations come next:
|
Chris@16
|
303 *
|
Chris@16
|
304 *********************************************************************/
|
Chris@16
|
305
|
Chris@16
|
306 NON_MEMBER_OP2(modulus, "%=");
|
Chris@16
|
307 NON_MEMBER_OP3(modulus, "%");
|
Chris@16
|
308 NON_MEMBER_OP2(bitwise_or, "|=");
|
Chris@16
|
309 NON_MEMBER_OP3(bitwise_or, "|");
|
Chris@16
|
310 NON_MEMBER_OP2(bitwise_and, "&=");
|
Chris@16
|
311 NON_MEMBER_OP3(bitwise_and, "&");
|
Chris@16
|
312 NON_MEMBER_OP2(bitwise_xor, "^=");
|
Chris@16
|
313 NON_MEMBER_OP3(bitwise_xor, "^");
|
Chris@16
|
314 NON_MEMBER_OP4(qr, "quotient-and-remainder");
|
Chris@16
|
315 NON_MEMBER_OP2(complement, "~");
|
Chris@16
|
316
|
Chris@16
|
317 template <class Backend>
|
Chris@16
|
318 inline void eval_left_shift(debug_adaptor<Backend>& arg, unsigned a)
|
Chris@16
|
319 {
|
Chris@16
|
320 using default_ops::eval_left_shift;
|
Chris@16
|
321 eval_left_shift(arg.value(), a);
|
Chris@16
|
322 arg.update_view();\
|
Chris@16
|
323 }
|
Chris@16
|
324 template <class Backend>
|
Chris@16
|
325 inline void eval_left_shift(debug_adaptor<Backend>& arg, const debug_adaptor<Backend>& a, unsigned b)
|
Chris@16
|
326 {
|
Chris@16
|
327 using default_ops::eval_left_shift;
|
Chris@16
|
328 eval_left_shift(arg.value(), a.value(), b);
|
Chris@16
|
329 arg.update_view();\
|
Chris@16
|
330 }
|
Chris@16
|
331 template <class Backend>
|
Chris@16
|
332 inline void eval_right_shift(debug_adaptor<Backend>& arg, unsigned a)
|
Chris@16
|
333 {
|
Chris@16
|
334 using default_ops::eval_right_shift;
|
Chris@16
|
335 eval_right_shift(arg.value(), a);
|
Chris@16
|
336 arg.update_view();\
|
Chris@16
|
337 }
|
Chris@16
|
338 template <class Backend>
|
Chris@16
|
339 inline void eval_right_shift(debug_adaptor<Backend>& arg, const debug_adaptor<Backend>& a, unsigned b)
|
Chris@16
|
340 {
|
Chris@16
|
341 using default_ops::eval_right_shift;
|
Chris@16
|
342 eval_right_shift(arg.value(), a.value(), b);
|
Chris@16
|
343 arg.update_view();\
|
Chris@16
|
344 }
|
Chris@16
|
345
|
Chris@16
|
346 template <class Backend, class T>
|
Chris@16
|
347 inline unsigned eval_integer_modulus(const debug_adaptor<Backend>& arg, const T& a)
|
Chris@16
|
348 {
|
Chris@16
|
349 using default_ops::eval_integer_modulus;
|
Chris@16
|
350 return eval_integer_modulus(arg.value(), a);
|
Chris@16
|
351 }
|
Chris@16
|
352
|
Chris@16
|
353 template <class Backend>
|
Chris@16
|
354 inline unsigned eval_lsb(const debug_adaptor<Backend>& arg)
|
Chris@16
|
355 {
|
Chris@16
|
356 using default_ops::eval_lsb;
|
Chris@16
|
357 return eval_lsb(arg.value());
|
Chris@16
|
358 }
|
Chris@16
|
359
|
Chris@16
|
360 template <class Backend>
|
Chris@16
|
361 inline unsigned eval_msb(const debug_adaptor<Backend>& arg)
|
Chris@16
|
362 {
|
Chris@16
|
363 using default_ops::eval_msb;
|
Chris@16
|
364 return eval_msb(arg.value());
|
Chris@16
|
365 }
|
Chris@16
|
366
|
Chris@16
|
367 template <class Backend>
|
Chris@16
|
368 inline bool eval_bit_test(const debug_adaptor<Backend>& arg, unsigned a)
|
Chris@16
|
369 {
|
Chris@16
|
370 using default_ops::eval_bit_test;
|
Chris@16
|
371 return eval_bit_test(arg.value(), a);
|
Chris@16
|
372 }
|
Chris@16
|
373
|
Chris@16
|
374 template <class Backend>
|
Chris@16
|
375 inline void eval_bit_set(const debug_adaptor<Backend>& arg, unsigned a)
|
Chris@16
|
376 {
|
Chris@16
|
377 using default_ops::eval_bit_set;
|
Chris@16
|
378 eval_bit_set(arg.value(), a);
|
Chris@16
|
379 arg.update_view();\
|
Chris@16
|
380 }
|
Chris@16
|
381 template <class Backend>
|
Chris@16
|
382 inline void eval_bit_unset(const debug_adaptor<Backend>& arg, unsigned a)
|
Chris@16
|
383 {
|
Chris@16
|
384 using default_ops::eval_bit_unset;
|
Chris@16
|
385 eval_bit_unset(arg.value(), a);
|
Chris@16
|
386 arg.update_view();\
|
Chris@16
|
387 }
|
Chris@16
|
388 template <class Backend>
|
Chris@16
|
389 inline void eval_bit_flip(const debug_adaptor<Backend>& arg, unsigned a)
|
Chris@16
|
390 {
|
Chris@16
|
391 using default_ops::eval_bit_flip;
|
Chris@16
|
392 eval_bit_flip(arg.value(), a);
|
Chris@16
|
393 arg.update_view();\
|
Chris@16
|
394 }
|
Chris@16
|
395
|
Chris@16
|
396 NON_MEMBER_OP3(gcd, "gcd");
|
Chris@16
|
397 NON_MEMBER_OP3(lcm, "lcm");
|
Chris@16
|
398 NON_MEMBER_OP4(powm, "powm");
|
Chris@16
|
399
|
Chris@16
|
400 /*********************************************************************
|
Chris@16
|
401 *
|
Chris@16
|
402 * abs/fabs:
|
Chris@16
|
403 *
|
Chris@16
|
404 *********************************************************************/
|
Chris@16
|
405
|
Chris@16
|
406 NON_MEMBER_OP2(abs, "abs");
|
Chris@16
|
407 NON_MEMBER_OP2(fabs, "fabs");
|
Chris@16
|
408
|
Chris@16
|
409 /*********************************************************************
|
Chris@16
|
410 *
|
Chris@16
|
411 * Floating point functions:
|
Chris@16
|
412 *
|
Chris@16
|
413 *********************************************************************/
|
Chris@16
|
414
|
Chris@16
|
415 NON_MEMBER_OP2(trunc, "trunc");
|
Chris@16
|
416 NON_MEMBER_OP2(round, "round");
|
Chris@16
|
417 NON_MEMBER_OP2(exp, "exp");
|
Chris@16
|
418 NON_MEMBER_OP2(log, "log");
|
Chris@16
|
419 NON_MEMBER_OP2(log10, "log10");
|
Chris@16
|
420 NON_MEMBER_OP2(sin, "sin");
|
Chris@16
|
421 NON_MEMBER_OP2(cos, "cos");
|
Chris@16
|
422 NON_MEMBER_OP2(tan, "tan");
|
Chris@16
|
423 NON_MEMBER_OP2(asin, "asin");
|
Chris@16
|
424 NON_MEMBER_OP2(acos, "acos");
|
Chris@16
|
425 NON_MEMBER_OP2(atan, "atan");
|
Chris@16
|
426 NON_MEMBER_OP2(sinh, "sinh");
|
Chris@16
|
427 NON_MEMBER_OP2(cosh, "cosh");
|
Chris@16
|
428 NON_MEMBER_OP2(tanh, "tanh");
|
Chris@16
|
429 NON_MEMBER_OP3(fmod, "fmod");
|
Chris@16
|
430 NON_MEMBER_OP3(pow, "pow");
|
Chris@16
|
431 NON_MEMBER_OP3(atan2, "atan2");
|
Chris@16
|
432
|
Chris@16
|
433 } // namespace backends
|
Chris@16
|
434
|
Chris@16
|
435 using backends::debug_adaptor;
|
Chris@16
|
436
|
Chris@16
|
437 template<class Backend>
|
Chris@16
|
438 struct number_category<backends::debug_adaptor<Backend> > : public number_category<Backend> {};
|
Chris@16
|
439
|
Chris@16
|
440 }} // namespaces
|
Chris@16
|
441
|
Chris@16
|
442 namespace std{
|
Chris@16
|
443
|
Chris@16
|
444 template <class Backend, boost::multiprecision::expression_template_option ExpressionTemplates>
|
Chris@16
|
445 class numeric_limits<boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<Backend>, ExpressionTemplates> >
|
Chris@16
|
446 : public std::numeric_limits<boost::multiprecision::number<Backend, ExpressionTemplates> >
|
Chris@16
|
447 {
|
Chris@16
|
448 typedef std::numeric_limits<boost::multiprecision::number<Backend, ExpressionTemplates> > base_type;
|
Chris@16
|
449 typedef boost::multiprecision::number<boost::multiprecision::backends::debug_adaptor<Backend>, ExpressionTemplates> number_type;
|
Chris@16
|
450 public:
|
Chris@16
|
451 static number_type (min)() BOOST_NOEXCEPT { return (base_type::min)(); }
|
Chris@16
|
452 static number_type (max)() BOOST_NOEXCEPT { return (base_type::max)(); }
|
Chris@16
|
453 static number_type lowest() BOOST_NOEXCEPT { return -(max)(); }
|
Chris@16
|
454 static number_type epsilon() BOOST_NOEXCEPT { return base_type::epsilon(); }
|
Chris@16
|
455 static number_type round_error() BOOST_NOEXCEPT { return epsilon() / 2; }
|
Chris@16
|
456 static number_type infinity() BOOST_NOEXCEPT { return base_type::infinity(); }
|
Chris@16
|
457 static number_type quiet_NaN() BOOST_NOEXCEPT { return base_type::quiet_NaN(); }
|
Chris@16
|
458 static number_type signaling_NaN() BOOST_NOEXCEPT { return base_type::signaling_NaN(); }
|
Chris@16
|
459 static number_type denorm_min() BOOST_NOEXCEPT { return base_type::denorm_min(); }
|
Chris@16
|
460 };
|
Chris@16
|
461
|
Chris@16
|
462 } // namespace std
|
Chris@16
|
463
|
Chris@16
|
464 namespace boost{ namespace math{
|
Chris@16
|
465
|
Chris@16
|
466 namespace policies{
|
Chris@16
|
467
|
Chris@16
|
468 template <class Backend, boost::multiprecision::expression_template_option ExpressionTemplates, class Policy>
|
Chris@16
|
469 struct precision< boost::multiprecision::number<boost::multiprecision::debug_adaptor<Backend>, ExpressionTemplates>, Policy>
|
Chris@16
|
470 : public precision<boost::multiprecision::number<Backend, ExpressionTemplates>, Policy>
|
Chris@16
|
471 {};
|
Chris@16
|
472
|
Chris@16
|
473 #undef NON_MEMBER_OP1
|
Chris@16
|
474 #undef NON_MEMBER_OP2
|
Chris@16
|
475 #undef NON_MEMBER_OP3
|
Chris@16
|
476 #undef NON_MEMBER_OP4
|
Chris@16
|
477
|
Chris@16
|
478 } // namespace policies
|
Chris@16
|
479
|
Chris@16
|
480 }} // namespaces boost::math
|
Chris@16
|
481
|
Chris@16
|
482
|
Chris@16
|
483 #endif
|