carl  24.04
Computer ARithmetic Library
parser.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../parser/parser.h"
4 #include "operations.h"
5 
6 namespace boost { namespace spirit { namespace traits {
7 #if BOOST_VERSION >= 105900
8  template<> inline bool scale(int exp, mpz_class& n, mpz_class acc_n) {
9  if (exp >= 0)
10  n = acc_n * carl::pow(mpz_class(10), unsigned(exp));
11  else
12  n = carl::div(acc_n, carl::pow(mpz_class(10), unsigned(-exp)));
13  return true;
14  }
15  template<> inline bool scale(int exp, mpq_class& n, mpq_class acc_n) {
16  if (exp >= 0)
17  n = acc_n * carl::pow(mpq_class(10), unsigned(exp));
18  else
19  n = acc_n / carl::pow(mpq_class(10), unsigned(-exp));
20  return true;
21  }
22 #else
23  template<> inline void scale(int exp, mpz_class& n) {
24  if (exp >= 0)
25  n *= carl::pow(mpz_class(10), unsigned(exp));
26  else
27  n = carl::div(n, carl::pow(mpz_class(10), unsigned(-exp)));
28  }
29  template<> inline void scale(int exp, mpq_class& n) {
30  if (exp >= 0)
31  n *= carl::pow(mpq_class(10), unsigned(exp));
32  else
33  n /= carl::pow(mpq_class(10), unsigned(-exp));
34  }
35 #endif
36 #if BOOST_VERSION < 107000
37  template<> inline bool is_equal_to_one(const mpz_class& value) {
38  return carl::is_one(value);
39  }
40  template<> inline bool is_equal_to_one(const mpq_class& value) {
41  return carl::is_one(value);
42  }
43 #endif
44 }}}
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