carl  24.04
Computer ARithmetic Library
IntervalContractionExample.cpp
Go to the documentation of this file.
1 /*
2  * File: IntervalContractionExample.cpp
3  * Author: stefan
4  *
5  * Created on September 11, 2013, 4:56 PM
6  */
7 
13 #include <chrono>
14 #include <set>
15 
16 #ifdef USE_CLN_NUMBERS
17 #include <cln/cln.h>
18 typedef cln::cl_RA Rational;
19 typedef cln::cl_I Integer;
20 #else
21 #include <gmpxx.h>
22 typedef mpq_class Rational;
23 typedef mpz_class Integer;
24 #endif
25 
26 
27 using namespace carl;
28 
29 template<template<typename> class Operator>
31 
33 
34 /*
35  *
36  */
37 int main(int /*argc*/, char** /*argv*/) {
38 
39  DoubleInterval ia = DoubleInterval( 1, 4 );
40  DoubleInterval ib = DoubleInterval( 2, 5 );
41  DoubleInterval ic = DoubleInterval( -2, 3 );
42  DoubleInterval id = DoubleInterval( 0, 2 );
43  DoubleInterval resA, resB;
44 
46 
51 
52  map[a] = ia;
53  map[b] = ib;
54  map[c] = ic;
55  map[d] = id;
56 
59 
60  std::set<Variable> variables = {a,b,c,d};
61 
62  typedef std::chrono::high_resolution_clock clock;
63  ///
64  typedef std::chrono::microseconds timeunit;
65 
66  clock::time_point start = clock::now();
67 
68  for( auto variableIt = variables.begin(); variableIt != variables.end(); ++variableIt )
69  {
70  int count = 0;
71  while (count < 100000)
72  {
73  contractor(map,*variableIt,resA,resB);
74  ++count;
75  }
76  }
77 
78  std::cout << "Total time: " << std::chrono::duration_cast<timeunit>( clock::now() - start ).count()/1000 << std::endl;
79 
80 
81  return 0;
82 }
83 
mpq_class Rational
Definition: HornerTest.cpp:12
int main(int, char **)
mpq_class Rational
Interval< double > DoubleInterval
mpz_class Integer
carl is the main namespace for the library.
Monomial::Arg createMonomial(T &&... t)
Definition: MonomialPool.h:168
Variable fresh_real_variable() noexcept
Definition: VariablePool.h:198
void variables(const BasicConstraint< Pol > &c, carlVariables &vars)
clock::time_point time_point
The type of a time point.
Definition: Timing.h:14
auto now()
Return the current time point.
Definition: Timing.h:17
std::chrono::high_resolution_clock clock
The clock type used here.
Definition: Timing.h:10
A Variable represents an algebraic variable that can be used throughout carl.
Definition: Variable.h:85
std::map< Variable, Interval< double > > evalintervalmap
Definition: Interval.h:144