carl  24.04
Computer ARithmetic Library
IntervalExample.cpp
Go to the documentation of this file.
1 /**
2  * An example how to use the general type interval with different instantiations.
3  * @file IntervalExample.cpp
4  * @author Stefan Schupp <stefan.schupp@cs.rwth-aachen.de>
5  *
6  * @since 2013-12-20
7  * @version 2014-01-30
8  */
9 
12 
13 #ifdef USE_CLN_NUMBERS
14 typedef cln::cl_RA Rational;
15 typedef cln::cl_I Integer;
16 #else
17 typedef mpq_class Rational;
18 typedef mpz_class Integer;
19 #endif
20 
21 int main (int argc, char** argv)
22 {
23  carl::Interval<double> doubleInterval(2.0);
25 
26  Rational a = 2;
27  Rational b = 4;
28  Rational c = 6;
29  Rational d = 3;
30 
31  Rational e = 2;
32  Rational f = 4;
33  Rational g = 6;
34  Rational h = 3;
35 
38 
39  double mag = doubleInterval.magnitude();
40 
41  Rational magMpq = mpqInterval.magnitude();
42 
43  Rational magCln = clnInterval.magnitude();
44 
45  std::cout << "Magnitudes: " << mag << " MPQ: " << mpqInterval << " -> "<< magMpq << " CLN:" << clnInterval << " -> " << magCln << std::endl;
46 #ifdef USE_MPFR_FLOAT
48 
49  result = doubleInterval.log();
50 
51  mpfrInterval.log_assign();
52 
53  std::cout << "Result: " << result << " and mpfr: " << mpfrInterval << std::endl;
54 #endif
55 }
mpq_class Rational
Definition: HornerTest.cpp:12
int main(int argc, char **argv)
mpq_class Rational
mpz_class Integer
@ WEAK
the given bound is compared by a weak ordering relation
@ STRICT
the given bound is compared by a strict ordering relation
Number magnitude() const
Returns the magnitude of the interval.
Templated wrapper class which allows universal usage of different IEEE 754 implementations.
Definition: FLOAT_T.h:114