-
Notifications
You must be signed in to change notification settings - Fork 2
/
interval.hpp
97 lines (92 loc) · 3.45 KB
/
interval.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// any implementation of interval you want to do
// you can do it here
// alternatively you can also link link libraries and define the type here
// but whatever you do, remember you need to define lower and upper function for your interval
// this is for the convenience of yourself so that you don't need to define it over and over
// in the computation part
#pragma once
#include <stdlib.h>
#include <functional>
#include <random>
// ================================================================
// ================================================================
// include filib c version interval
// do not change the order, always put this one first
// otherwise there gonna be some error
// and id rather not deal with those errors
#include "filib/interval.hpp"
typedef interval fic_interval;
#define fic_interval(v) \
{ \
v, v \
}
double lower(fic_interval v)
{
return v.INF;
}
double upper(fic_interval v)
{
return v.SUP;
}
// ================================================================
// ================================================================
// ==============================================================================================
// ==============================================================================================
// include boost interval
#if defined(__APPLE__)
#warning "__APPLE__ defined so explicitly defining __USE_ISOC99"
#define __USE_ISOC99
#endif
#include "boost/numeric/interval.hpp"
namespace interval_options
{
typedef boost::numeric::interval_lib::checking_base<double> CheckingPolicy;
} // namespace interval_options
#if defined(__APPLE__)
typedef boost::numeric::interval<
double,
boost::numeric::interval_lib::policies<
boost::numeric::interval_lib::save_state<
boost::numeric::interval_lib::rounded_transc_std<double>>,
interval_options::CheckingPolicy>>
boost_interval;
#else
typedef boost::numeric::interval<
double,
boost::numeric::interval_lib::policies<
boost::numeric::interval_lib::save_state<
boost::numeric::interval_lib::rounded_transc_std<double>>,
interval_options::CheckingPolicy>>
boost_interval;
#endif
double lower(boost_interval v)
{
return v.lower();
}
double upper(boost_interval v)
{
return v.upper();
}
// ==============================================================================================
// ==============================================================================================
// ==================================================================================================================
// ==================================================================================================================
// include filib c++ version interval
#ifdef USE_FILIB_PLUSPLUS
#include "interval/interval.hpp"
typedef filib::interval<double, filib::native_switched, filib::i_mode_normal> fi_native_switched;
typedef filib::interval<double, filib::pred_succ_rounding, filib::i_mode_normal> fi_pred_succ;
typedef filib::interval<double, filib::multiplicative, filib::i_mode_normal> fi_multiplicative;
template <typename T>
double lower(T v)
{
return v.inf();
}
template <typename T>
double upper(T v)
{
return v.sup();
}
#endif
// ==================================================================================================================
// ==================================================================================================================