1 #ifndef realroot_ARITHM_INTERVAL_C
2 #define realroot_ARITHM_INTERVAL_C
11 template<
typename T>
inline
12 int sign(
const T& x) {
return ( x < T(0) ? -1 : (T(0) < x ? 1 : 0) ); }
15 template<
class C,
int r>
inline bool
20 template<
class T,
int r>
24 inline static T
dwmul(
const T& a,
const T&
b ) {
return a*
b; };
25 inline static T
upmul(
const T& a,
const T&
b ) {
return a*
b; };
26 inline static T
dwdiv(
const T& a,
const T&
b ) {
return a/
b; };
27 inline static T
updiv(
const T& a,
const T&
b ) {
return a/
b; };
28 inline static T
dwadd(
const T& a,
const T&
b ) {
return a+
b; };
29 inline static T
upadd(
const T& a,
const T&
b ) {
return a+
b; };
30 inline static T
dwsub(
const T& a,
const T&
b ) {
return a-
b; };
31 inline static T
upsub(
const T& a,
const T&
b ) {
return a-
b; };
64 template<
class T,
int r>
struct Interval;
67 template<
class T,
int r>
68 void assign( Interval<T,r>& i,
const char * s );
71 template<
class C,
int r>
inline
73 template<
class C,
int r>
inline
75 template<
class C,
int r>
inline
77 template<
class C,
int r>
inline
79 template<
class C,
int r>
inline
81 if ( a > b ) m =
b, M = a;
84 template<
class C,
int r>
inline
86 template<
class T,
int r>
inline
88 template<
class T,
int r>
inline
90 template<
class T,
int r>
inline
92 template<
class T,
int r>
inline
94 template<
class T,
int r>
inline
96 template<
class T,
int r>
inline
98 {
return x.
lower() <=
static_cast<T
>(0) && x.
upper() >=
static_cast<T
>(0); };
99 template<
class T,
int r>
inline
102 template<
class T,
int r>
inline
103 std::pair< Interval<T,r>, Interval<T,r> >
108 return std::pair<I,I>(
I(x.
lower(), m),
I(m, x.
upper()));
111 template<
class T,
int r>
inline void
119 template<
class T,
int r>
inline void
124 template<
class T,
int r>
inline Interval<T,r>
129 template<
class T,
int r>
inline Interval<T,r>
134 template<
class T,
int r>
inline Interval<T,r>
139 template<
class T,
int r>
inline bool
144 template<
class T,
int r >
inline Interval<T,r>
149 template<
class T,
int r>
inline bool
173 template<
class T,
int r>
177 template<
class T,
int r>
178 std::ostream& operator<<( std::ostream& o, const Interval<T,r>& i )
180 o <<
"[" << (i.lower()) <<
", " << (i.upper()) <<
"]";
184 template<
class C,
int r >
199 template<
class C,
int r>
inline void
207 template<
class C,
int r>
inline void
214 template<
class C,
int r>
inline void
222 template<
class C,
int r>
inline void
226 template<
class C,
int r>
inline void
230 template<
class C,
int r>
inline void
234 template<
class C,
int r>
inline void
238 template<
class C,
int r>
inline void
242 template<
class C,
int r>
inline void
246 template<
class C,
int r>
inline void
250 template<
class C,
int r>
inline void
254 template<
class C,
int r>
inline void
258 template<
class C,
int r>
inline void
273 template<
class C,
int r>
inline void
275 if ( &a == &b ) {
mul(a,x);
return; };
288 template<
class C,
int r>
inline void
293 template<
class C,
int r>
inline void
352 if ( m0 > m1 ) m0 = m1;
355 if ( M0 < M1 ) M0 = M1;
361 template<
class C,
int r>
inline void
363 if ( &x == &a ) {
mul(x,b);
return; };
364 if ( &x == &b ) {
mul(x,a);
return; };
419 if ( m0 > m1 ) m0 = m1;
423 if ( M0 < M1 ) M0 = M1;
429 template<
class C,
int r>
inline void
444 template<
class C,
int r>
inline void
446 if ( &a == &b ) {
div(a,x);
return; };
459 template<
class C,
int r>
inline void
473 template<
class C,
int r>
inline void
536 template<
class C,
int r>
inline void
614 template<
class T,
int r>
void
623 while ( *sM !=
',' ) sM++;
627 while ( *e && *e !=
']' ) e++;
641 template<
class C,
int R>
void
644 r.
m = (l.
M+l.
m)/
C(2);
648 template<
class C,
int R> Interval<C,R>
652 #define TMPL template<class Ca, int Na, class Cb, int Nb>
653 #define ARG0 Interval<Ca,Na>
654 #define ARG1 Interval<Cb,Nb>
670 #define TMPL template<class Ca, int Na, class Cb>
674 typename texp::sup<ARG0,ARG1>::T res;
add(res,Ia,(
typename texp::sup<Ca,Cb>::T)Ib);
return res;
677 typename texp::sup<ARG0,ARG1>::T res;
sub(res,Ia,(
typename texp::sup<Ca,Cb>::T)Ib);
return res;
680 typename texp::sup<ARG0,ARG1>::T res;
mul(res,Ia,(
typename texp::sup<Ca,Cb>::T)Ib);
return res;
683 typename texp::sup<ARG0,ARG1>::T res;
div(res,Ia,(
typename texp::sup<Ca,Cb>::T)Ib);
return res;
705 #define TMPL template<class Ca, int Na, class K>
706 #define ARG1 typename K::integer
708 typename texp::sup<ARG0,ARG1>::T res;
add(res,Ia,(Ca)Ib);
return res;
711 typename texp::sup<ARG0,ARG1>::T res;
sub(res,Ia,(Ca)Ib);
return res;
714 typename texp::sup<ARG0,ARG1>::T res;
mul(res,Ia,Ib);
return res;
717 typename texp::sup<ARG0,ARG1>::T res;
div(res,Ia,Ib);
return res;
730 #define TMPL template<class Ca, int Na, class K>
731 #define ARG1 typename K::floating
742 #define TMPL template<class Ca, int Na, class K>
743 #define ARG1 typename K::rational
Interval()
default constructor sets values to zero
Definition: Interval_fcts.hpp:72
Definition: Interval.hpp:40
T upadd(const T &a, const T &b)
Definition: rounding_mode.hpp:86
void neg(Interval< C, r > &a)
Definition: Interval_fcts.hpp:200
Definition: Interval_fcts.hpp:23
const C & b
Definition: Interval_glue.hpp:25
Interval< C, 2 > rup_t
Definition: Interval_fcts.hpp:608
Definition: Interval.hpp:51
Interval< T, r > intersection(const Interval< T, r > &a, const Interval< T, r > &b)
Definition: Interval_fcts.hpp:145
#define TMPL
Definition: Interval_fcts.hpp:742
const Interval & I
Definition: Interval_glue.hpp:49
void define(const T &m, const T &M)
Definition: Interval.hpp:77
static T updiv(const T &a, const T &b)
Definition: Interval_fcts.hpp:27
const T & upper() const
Definition: Interval.hpp:99
static T upadd(const T &a, const T &b)
Definition: Interval_fcts.hpp:29
T upper(const Interval< T, r > &x)
Definition: Interval_fcts.hpp:89
bool with_plus_sign(const ZZ &c)
Definition: GMP.hpp:62
static T upmul(const T &a, const T &b)
Definition: Interval_fcts.hpp:48
static T upsub(const T &a, const T &b)
Definition: Interval_fcts.hpp:31
extended< NT > operator-(const extended< NT > &lhs, const extended< NT > &rhs)
Definition: extended.hpp:132
extended< NT > operator/(const extended< NT > &lhs, const extended< NT > &rhs)
Definition: extended.hpp:111
rnd()
Definition: Interval_fcts.hpp:59
declare_binary_operator(TMPL, ARG1, ARG0, _add_, operator+)
T upmul(const T &a, const T &b)
Definition: rounding_mode.hpp:94
static T dwsub(const T &a, const T &b)
Definition: Interval_fcts.hpp:41
static T dwdiv(const T &a, const T &b)
Definition: Interval_fcts.hpp:26
bool intersectp(const Interval< T, r > &a, const Interval< T, r > &b)
Definition: Interval_fcts.hpp:140
bool intersect(Interval< T, r > &result, const Interval< T, r > &a, const Interval< T, r > &b)
Definition: Interval_fcts.hpp:150
static T updiv(const T &a, const T &b)
Definition: Interval_fcts.hpp:49
static T dwadd(const T &a, const T &b)
Definition: Interval_fcts.hpp:28
static T dwmul(const T &a, const T &b)
Definition: Interval_fcts.hpp:38
void mul(Interval< C, r > &a, const C &x)
Definition: Interval_fcts.hpp:259
Interval< C, 3 > autoround_t
Definition: Interval_fcts.hpp:609
void split(Interval< C, R > &l, Interval< C, R > &r)
Definition: Interval_fcts.hpp:642
extended< NT > operator+(const extended< NT > &lhs, const extended< NT > &rhs)
Definition: extended.hpp:122
Definition: rounding_mode.hpp:71
const T & lower() const
Definition: Interval.hpp:98
bool singleton(const Interval< T, r > &x)
Definition: Interval_fcts.hpp:95
Interval< T, r > min(const Interval< T, r > &a, const Interval< T, r > &b)
Definition: Interval_fcts.hpp:130
TMPL void copy(Polynomial &r, const Polynomial &a)
Copy of a in r.
Definition: sparse_monomials.hpp:613
bool in(const T &x, const Interval< T, r > &y)
Definition: Interval_fcts.hpp:100
void hull(Interval< T, r > &v, const Interval< T, r > &a, const Interval< T, r > &b)
Definition: Interval_fcts.hpp:120
#define min(a, b)
Definition: parser_def.c:475
void sub(Interval< C, r > &a, const C &x)
Definition: Interval_fcts.hpp:231
std::pair< Interval< T, r >, Interval< T, r > > bissect(const Interval< T, r > &x)
Definition: Interval_fcts.hpp:104
#define Interval
Definition: Interval_glue.hpp:8
static T dwmul(const T &a, const T &b)
Definition: Interval_fcts.hpp:24
Definition: Interval_fcts.hpp:604
T updiv(const T &a, const T &b)
Definition: rounding_mode.hpp:98
ZZ size(const ZZ &z)
Definition: GMPXX.hpp:67
void abs(Interval< C, r > &x, const Interval< C, r > &a)
Definition: Interval_fcts.hpp:185
T dwmul(const T &a, const T &b)
Definition: rounding_mode.hpp:122
static T upmul(const T &a, const T &b)
Definition: Interval_fcts.hpp:25
T median(const Interval< T, r > &x)
Definition: Interval_fcts.hpp:91
bool contain_zero(const Interval< T, r > &x)
Definition: Interval_fcts.hpp:97
T lower(const Interval< T, r > &x)
Definition: Interval_fcts.hpp:87
T dwsub(const T &a, const T &b)
Definition: rounding_mode.hpp:118
T size() const
same as width
Definition: Interval.hpp:127
T width(const Interval< T, r > &x)
Definition: Interval_fcts.hpp:93
T dwdiv(const T &a, const T &b)
Definition: rounding_mode.hpp:126
T upsub(const T &a, const T &b)
Definition: rounding_mode.hpp:90
Generic class for intervals.
Definition: Interval.hpp:44
static T upadd(const T &a, const T &b)
Definition: Interval_fcts.hpp:50
T m
Definition: Interval.hpp:52
Interval< C, 0 > simple_t
Definition: Interval_fcts.hpp:606
Interval< C, 1 > rdw_t
Definition: Interval_fcts.hpp:607
double C
Definition: solver_mv_fatarcs.cpp:16
#define ARG1
Definition: Interval_fcts.hpp:743
static T upsub(const T &a, const T &b)
Definition: Interval_fcts.hpp:51
sfirstnn< C, A, B >::T T
Definition: texp_sup.hpp:31
int sign(const QQ &a)
Definition: GMP.hpp:60
static T dwdiv(const T &a, const T &b)
Definition: Interval_fcts.hpp:39
void assign(A &a, const B &b)
Generic definition of the assignement function.
Definition: assign.hpp:97
Interval< T, r > max(const Interval< T, r > &a, const Interval< T, r > &b)
Definition: Interval_fcts.hpp:135
static T dwadd(const T &a, const T &b)
Definition: Interval_fcts.hpp:40
static T dwsub(const T &a, const T &b)
Definition: Interval_fcts.hpp:30
void div(Interval< C, r > &a, const C &x)
Definition: Interval_fcts.hpp:430
extended< NT > operator*(const extended< NT > &lhs, const extended< NT > &rhs)
Definition: extended.hpp:101
void add(dynamic_exp< E > &r, const dynamic_exp< E > &A, const dynamic_exp< E > &B)
Definition: dynamicexp.hpp:295
T width() const
return the width of the interval
Definition: Interval.hpp:125
T dwadd(const T &a, const T &b)
Definition: rounding_mode.hpp:114
#define ARG0
Definition: Interval_fcts.hpp:653
T M
Definition: Interval.hpp:52