APRONXX 0.9.14
/builddir/build/BUILD/apron-0.9.15-build/apron-0.9.15/apronxx/apxx_coeff.hh
Go to the documentation of this file.
1/* -*- C++ -*-
2 * apxx_coeff.hh
3 *
4 * APRON Library / C++ class wrappers
5 *
6 * Copyright (C) Antoine Mine' 2007
7 *
8 */
9/* This file is part of the APRON Library, released under LGPL license
10 with an exception allowing the redistribution of statically linked
11 executables.
12
13 Please read the COPYING file packaged in the distribution.
14*/
15
16#ifndef __APXX_COEFF_HH
17#define __APXX_COEFF_HH
18
19#include "ap_coeff.h"
20#include "apxx_scalar.hh"
21#include "apxx_interval.hh"
22
23
24namespace apron {
25
26
27/* ================================= */
28/* coeff */
29/* ================================= */
30
31
36class coeff : public use_malloc {
37
38protected:
39
40 ap_coeff_t c;
41
42public:
43
44
45 /* constructors */
46 /* ============ */
47
50
52 coeff();
53
55 coeff(const coeff& x);
56
58 coeff(const scalar& x);
59
61 coeff(int x);
62
64 coeff(long x);
65
67 coeff(double x);
68
70 coeff(const frac& x);
71
73 coeff(const mpq_class& x);
74
76 coeff(mpfr_t x);
77
79 coeff(const interval& x);
80
82 coeff(const scalar& inf, const scalar& sup);
83
85 coeff(int inf, int sup);
86
88 coeff(long inf, long sup);
89
91 coeff(double inf, double sup);
92
94 coeff(const frac& inf, const frac& sup);
95
97 coeff(const mpq_class& inf, const mpq_class& sup);
98
100 coeff(mpfr_t inf, mpfr_t sup);
101
103 coeff(top t);
104
106 coeff(bottom t);
107
109
110
111 /* destructor */
112 /* ========== */
113
116
117 ~coeff();
118
120
121
122 /* assignments */
123 /* =========== */
124
127
129 coeff& operator= (const coeff& x);
130
132 coeff& operator= (const scalar& x);
133
135 coeff& operator= (int x);
136
138 coeff& operator= (long x);
139
141 coeff& operator= (double x);
142
144 coeff& operator= (const frac& x);
145
147 coeff& operator= (const mpq_class& x);
148
150 coeff& operator= (mpfr_t x);
151
153 coeff& operator= (const interval& x);
154
156 coeff& operator= (top t);
157
160
162 coeff& set(const coeff& x);
163
165 coeff& set(const scalar& x);
166
168 coeff& set(int x);
169
171 coeff& set(long x);
172
174 coeff& set(double x) ;
175
177 coeff& set(const frac& x);
178
180 coeff& set(const mpq_class& x);
181
183 coeff& set(mpfr_t x);
184
186 coeff& set(const interval& x);
187
189 coeff& set(const scalar& inf, const scalar& sup);
190
192 coeff& set(int inf, int sup);
193
195 coeff& set(long inf, long sup);
196
198 coeff& set(double inf, double sup);
199
201 coeff& set(const frac& inf, const frac& sup);
202
204 coeff& set(const mpq_class& inf, const mpq_class& sup);
205
207 coeff& set(mpfr_t inf, mpfr_t sup);
208
210 coeff& set(top t);
211
213 coeff& set(bottom t);
214
215
217 friend void swap(coeff& a, coeff &b);
218
220
221
222 /* access */
223 /* ====== */
224
227
232 ap_coeff_discr_t get_discr() const;
233
239
244 const scalar& get_scalar() const;
245
246
252
257 const interval& get_interval() const;
258
260
261
262 /* print */
263 /* ===== */
264
267
269 friend std::ostream& operator<< (std::ostream& os, const coeff& s);
270
272 void print(FILE* stream=stdout) const;
273
275
276
277 /* tests */
278 /* ===== */
279
282
284 bool is_zero() const;
285
287 friend int cmp(const coeff& a, const coeff& b);
288
289 /*
291 friend bool operator<= (const coeff& a, const coeff& b);
292
294 friend bool operator>= (const coeff& a, const coeff& b);
295
297 friend bool operator< (const coeff& a, const coeff& b);
298
300 friend bool operator> (const coeff& a, const coeff& b);
301 */
302
304 friend bool operator== (const coeff& a, const coeff& b);
305
307 friend bool operator!= (const coeff& a, const coeff& b);
308
310
311
312 /* other operators */
313 /* =============== */
314
317
319 void reduce();
320
322 void neg();
323
325 coeff operator- () const;
326
328 long hash() const;
329
331
332
333 /* C-level compatibility */
334 /* ===================== */
335
338
340 const ap_coeff_t* get_ap_coeff_t() const;
341
343 ap_coeff_t* get_ap_coeff_t();
344
346};
347
348#include "apxx_coeff_inline.hh"
349
350}
351
352#endif /* __APXX_COEFF_HH */
Coefficient (ap_coeff_t wrapper).
Definition apxx_coeff.hh:36
scalar & get_scalar()
Returns a (modifiable) reference to the scalar contained in the coeff.
Definition apxx_coeff_inline.hh:240
friend bool operator!=(const coeff &a, const coeff &b)
Set inequality.
coeff & operator=(const coeff &x)
Copies the coeff into *this (setting its type and value).
Definition apxx_coeff_inline.hh:164
long hash() const
Returns a hash code.
Definition apxx_coeff_inline.hh:475
ap_coeff_discr_t get_discr() const
Whether the coeff is a scalar or an interval.
Definition apxx_coeff_inline.hh:235
coeff & set(const coeff &x)
Copies the coeff into *this (setting its type and value).
Definition apxx_coeff_inline.hh:265
void print(FILE *stream=stdout) const
Prints to a C stream.
Definition apxx_coeff_inline.hh:400
~coeff()
Definition apxx_coeff_inline.hh:155
friend bool operator==(const coeff &a, const coeff &b)
Set equality.
void neg()
Negates *this.
Definition apxx_coeff_inline.hh:465
friend std::ostream & operator<<(std::ostream &os, const coeff &s)
Printing.
friend int cmp(const coeff &a, const coeff &b)
Non-total comparison.
bool is_zero() const
Whether the coeff is the scalar 0 or the interval [0;0].
Definition apxx_coeff_inline.hh:409
coeff()
Makes a double scalar coeff equal to 0.0.
Definition apxx_coeff_inline.hh:27
void reduce()
Converts a singleton intervals to scalar.
Definition apxx_coeff_inline.hh:460
const ap_coeff_t * get_ap_coeff_t() const
Returns a pointer to the internal APRON object stored in *this.
Definition apxx_coeff_inline.hh:483
interval & get_interval()
Returns a (modifiable) reference to the interval contained in the coeff.
Definition apxx_coeff_inline.hh:252
coeff operator-() const
Returns the opposite of *this.
Definition apxx_coeff_inline.hh:470
ap_coeff_t c
Structure managed by APRON.
Definition apxx_coeff.hh:40
friend void swap(coeff &a, coeff &b)
Swaps the contents and type of both coeff.
Interval (ap_interval_t wrapper).
Definition apxx_interval.hh:47
Scalar (ap_scalar_t wrapper).
Definition apxx_scalar.hh:89
Definition apxx_abstract0.hh:27
Empty interval or domain, to simplify initialisations and assignments.
Definition apxx_interval.hh:33
A fraction with native int coefficients, to simplify initialisations and assignments.
Definition apxx_scalar.hh:41
Full interval (]-oo,+oo[) or domain, to simplify initialisations and assignments.
Definition apxx_interval.hh:27
Inherited by most wrappers to map new and delete to malloc and free.
Definition apxx_scalar.hh:69