carl  24.04
Computer ARithmetic Library
parser.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <carl-common/config.h>
4 
5 #ifdef USE_CLN_NUMBERS
6 
7 #include "../parser/parser.h"
8 #include "operations.h"
9 #include "typetraits.h"
10 
11 namespace boost { namespace spirit { namespace traits {
12 #if BOOST_VERSION >= 105900
13  template<> inline bool scale(int exp, cln::cl_I& r, cln::cl_I rin) {
14  if (exp >= 0)
15  r = rin * carl::pow(cln::cl_I(10), static_cast<unsigned>(exp));
16  else
17  r = carl::div(rin, carl::pow(cln::cl_I(10), static_cast<unsigned>(-exp)));
18  return true;
19  }
20  template<> inline bool scale(int exp, cln::cl_RA& r, cln::cl_RA rin) {
21  if (exp >= 0)
22  r = rin * carl::pow(cln::cl_RA(10), static_cast<unsigned>(exp));
23  else
24  r = rin / carl::pow(cln::cl_RA(10), static_cast<unsigned>(-exp));
25  return true;
26  }
27 #else
28  template<> inline void scale(int exp, cln::cl_I& r) {
29  if (exp >= 0)
30  r *= carl::pow(cln::cl_I(10), static_cast<unsigned>(exp));
31  else
32  r = carl::div(r, carl::pow(cln::cl_I(10), static_cast<unsigned>(-exp)));
33  }
34  template<> inline void scale(int exp, cln::cl_RA& r) {
35  if (exp >= 0)
36  r *= carl::pow(cln::cl_RA(10), static_cast<unsigned>(exp));
37  else
38  r /= carl::pow(cln::cl_RA(10), static_cast<unsigned>(-exp));
39  }
40 #endif
41 #if BOOST_VERSION < 107000
42  template<> inline bool is_equal_to_one(const cln::cl_I& value) {
43  return carl::is_one(value);
44  }
45  template<> inline bool is_equal_to_one(const cln::cl_RA& value) {
46  return carl::is_one(value);
47  }
48 #endif
49 }}}
50 
51 #endif
Interval< Number > exp(const Interval< Number > &i)
Definition: Exponential.h:10
Interval< Number > div(const Interval< Number > &_lhs, const Interval< Number > &_rhs)
Implements the division which assumes that there is no remainder.
Definition: Interval.h:1476
Interval< Number > pow(const Interval< Number > &i, Integer exp)
Definition: Power.h:11
bool is_one(const Interval< Number > &i)
Check if this interval is a point-interval containing 1.
Definition: Interval.h:1462