29 ap_coeff_init(&c, AP_COEFF_SCALAR);
32 inline coeff::coeff(
const coeff& x)
34 ap_coeff_init(&c, x.c.discr);
35 ap_coeff_set(&c, const_cast<ap_coeff_t*>(x.get_ap_coeff_t()));
41 inline coeff::coeff(
const scalar& x)
43 ap_coeff_init(&c, AP_COEFF_SCALAR);
44 ap_coeff_set_scalar(&c, const_cast<ap_scalar_t*>(x.get_ap_scalar_t()));
47 inline coeff::coeff(
int x)
49 ap_coeff_init(&c, AP_COEFF_SCALAR);
50 ap_coeff_set_scalar_int(&c, x);
53 inline coeff::coeff(
long x)
55 ap_coeff_init(&c, AP_COEFF_SCALAR);
56 ap_coeff_set_scalar_int(&c, x);
59 inline coeff::coeff(
double x)
61 ap_coeff_init(&c, AP_COEFF_SCALAR);
62 ap_coeff_set_scalar_double(&c, x);
65 inline coeff::coeff(
const frac& x)
67 ap_coeff_init(&c, AP_COEFF_SCALAR);
68 ap_coeff_set_scalar_frac(&c, x.num, x.den);
71 inline coeff::coeff(
const mpq_class& x)
73 ap_coeff_init(&c, AP_COEFF_SCALAR);
74 ap_coeff_set_scalar_mpq(&c, const_cast<mpq_class&>(x).get_mpq_t());
77 inline coeff::coeff(mpfr_t x)
79 ap_coeff_init(&c, AP_COEFF_SCALAR);
80 ap_coeff_set_scalar_mpfr(&c,x);
86 inline coeff::coeff(
const interval& x)
88 ap_coeff_init(&c, AP_COEFF_INTERVAL);
89 ap_coeff_set_interval(&c,
90 const_cast<ap_interval_t*>(x.get_ap_interval_t()));
93 inline coeff::coeff(
const scalar& inf,
const scalar& sup)
95 ap_coeff_init(&c, AP_COEFF_INTERVAL);
96 ap_coeff_set_interval_scalar(&c,
97 const_cast<ap_scalar_t*>(inf.get_ap_scalar_t()),
98 const_cast<ap_scalar_t*>(sup.get_ap_scalar_t()));
101 inline coeff::coeff(
int inf,
int sup)
103 ap_coeff_init(&c, AP_COEFF_INTERVAL);
104 ap_coeff_set_interval_int(&c, inf, sup);
107 inline coeff::coeff(
long inf,
long sup)
109 ap_coeff_init(&c, AP_COEFF_INTERVAL);
110 ap_coeff_set_interval_int(&c, inf, sup);
113 inline coeff::coeff(
double inf,
double sup)
115 ap_coeff_init(&c, AP_COEFF_INTERVAL);
116 ap_coeff_set_interval_double(&c, inf, sup);
119 inline coeff::coeff(
const frac& inf,
const frac& sup)
121 ap_coeff_init(&c, AP_COEFF_INTERVAL);
122 ap_coeff_set_interval_frac(&c, inf.num, inf.den, sup.num, sup.den);
125 inline coeff::coeff(
const mpq_class& inf,
const mpq_class& sup)
127 ap_coeff_init(&c, AP_COEFF_INTERVAL);
128 ap_coeff_set_interval_mpq(&c,
129 const_cast<mpq_class&>(inf).get_mpq_t(),
130 const_cast<mpq_class&>(sup).get_mpq_t());
133 inline coeff::coeff(mpfr_t inf, mpfr_t sup)
135 ap_coeff_init(&c, AP_COEFF_INTERVAL);
136 ap_coeff_set_interval_mpfr(&c,inf,sup);
139 inline coeff::coeff(top t)
141 ap_coeff_init(&c, AP_COEFF_INTERVAL);
142 ap_coeff_set_interval_top(&c);
145 inline coeff::coeff(bottom t)
147 ap_coeff_init(&c, AP_COEFF_INTERVAL);
148 ap_coeff_set_interval_int(&c, 1, -1);
155 inline coeff::~coeff()
164 inline coeff& coeff::operator= (
const coeff& x)
166 ap_coeff_set(&c, const_cast<ap_coeff_t*>(x.get_ap_coeff_t()));
170 inline coeff& coeff::operator= (
const scalar& x)
172 ap_coeff_set_scalar(&c, const_cast<ap_scalar_t*>(x.get_ap_scalar_t()));
176 inline coeff& coeff::operator= (
int x)
178 ap_coeff_set_scalar_int(&c, x);
182 inline coeff& coeff::operator= (
long x)
184 ap_coeff_set_scalar_int(&c, x);
188 inline coeff& coeff::operator= (
double x)
190 ap_coeff_set_scalar_double(&c, x);
194 inline coeff& coeff::operator= (
const frac& x)
196 ap_coeff_set_scalar_frac(&c, x.num, x.den);
200 inline coeff& coeff::operator= (
const mpq_class& x)
202 ap_coeff_set_scalar_mpq(&c, const_cast<mpq_class&>(x).get_mpq_t());
206 inline coeff& coeff::operator= (mpfr_t x)
208 ap_coeff_set_scalar_mpfr(&c, x);
212 inline coeff& coeff::operator= (
const interval& x)
214 ap_coeff_set_interval(&c, const_cast<ap_interval_t*>(x.get_ap_interval_t()));
218 inline coeff& coeff::operator= (top t)
220 ap_coeff_set_interval_top(&c);
224 inline coeff& coeff::operator= (bottom t)
226 ap_coeff_set_interval_int(&c, 1, -1);
235 inline ap_coeff_discr_t coeff::get_discr()
const 240 inline scalar& coeff::get_scalar()
242 if (c.discr!=AP_COEFF_SCALAR)
throw(bad_discriminant(
"coeff::get_scalar"));
243 return reinterpret_cast<scalar&>(*c.val.scalar);
246 inline const scalar& coeff::get_scalar()
const 248 if (c.discr!=AP_COEFF_SCALAR)
throw(bad_discriminant(
"coeff::get_scalar"));
249 return reinterpret_cast<const scalar&>(*c.val.scalar);
252 inline interval& coeff::get_interval()
254 if (c.discr!=AP_COEFF_INTERVAL)
throw(bad_discriminant(
"coeff::get_interval"));
255 return reinterpret_cast<interval&>(*c.val.interval);
258 inline const interval& coeff::get_interval()
const 260 if (c.discr!=AP_COEFF_INTERVAL)
throw(bad_discriminant(
"coeff::get_interval"));
261 return reinterpret_cast<const interval&>(*c.val.interval);
265 inline coeff&coeff::set(
const coeff& x)
267 ap_coeff_set(&c, const_cast<ap_coeff_t*>(x.get_ap_coeff_t()));
271 inline coeff&coeff::set(
const scalar& x)
273 ap_coeff_set_scalar(&c, const_cast<ap_scalar_t*>(x.get_ap_scalar_t()));
277 inline coeff&coeff::set(
int x)
279 ap_coeff_set_scalar_int(&c, x);
283 inline coeff&coeff::set(
long x)
285 ap_coeff_set_scalar_int(&c, x);
289 inline coeff&coeff::set(
double x)
291 ap_coeff_set_scalar_double(&c, x);
295 inline coeff&coeff::set(
const frac& x)
297 ap_coeff_set_scalar_frac(&c, x.num, x.den);
301 inline coeff&coeff::set(
const mpq_class& x)
303 ap_coeff_set_scalar_mpq(&c, const_cast<mpq_class&>(x).get_mpq_t());
307 inline coeff&coeff::set(mpfr_t x)
309 ap_coeff_set_scalar_mpfr(&c, x);
314 inline coeff&coeff::set(
const interval& x)
316 ap_coeff_set_interval(&c, const_cast<ap_interval_t*>(x.get_ap_interval_t()));
320 inline coeff&coeff::set(
const scalar& inf,
const scalar& sup)
322 ap_coeff_set_interval_scalar(&c,
323 const_cast<ap_scalar_t*>(inf.get_ap_scalar_t()),
324 const_cast<ap_scalar_t*>(sup.get_ap_scalar_t()));
328 inline coeff&coeff::set(
int inf,
int sup)
330 ap_coeff_set_interval_int(&c, inf, sup);
334 inline coeff&coeff::set(
long inf,
long sup)
336 ap_coeff_set_interval_int(&c, inf, sup);
340 inline coeff&coeff::set(
double inf,
double sup)
342 ap_coeff_set_interval_double(&c, inf, sup);
346 inline coeff&coeff::set(
const frac& inf,
const frac& sup)
348 ap_coeff_set_interval_frac(&c, inf.num, inf.den, sup.num, sup.den);
352 inline coeff&coeff::set(
const mpq_class& inf,
const mpq_class& sup)
354 ap_coeff_set_interval_mpq(&c,
355 const_cast<mpq_class&>(inf).get_mpq_t(),
356 const_cast<mpq_class&>(sup).get_mpq_t());
360 inline coeff&coeff::set(mpfr_t inf, mpfr_t sup)
362 ap_coeff_set_interval_mpfr(&c, inf, sup);
366 inline coeff&coeff::set(top t)
368 ap_coeff_set_interval_top(&c);
372 inline coeff&coeff::set(bottom t)
374 ap_coeff_set_interval_int(&c, 1, -1);
381 inline void swap(coeff& a, coeff &b)
383 ap_coeff_swap(&a.c, &b.c);
391 inline std::ostream&
operator<< (std::ostream& os,
const coeff& s)
394 case AP_COEFF_SCALAR:
return os << *(reinterpret_cast<scalar*>(s.c.val.scalar));
395 case AP_COEFF_INTERVAL:
return os << *(reinterpret_cast<interval*>(s.c.val.interval));
400 inline void coeff::print(FILE* stream)
const 402 ap_coeff_fprint(stream, const_cast<ap_coeff_t*>(&c));
409 inline bool coeff::is_zero()
const 411 return ap_coeff_zero(const_cast<ap_coeff_t*>(&c));
414 inline int cmp(
const coeff& a,
const coeff& b)
416 return ap_coeff_cmp(const_cast<ap_coeff_t*>(&a.c), const_cast<ap_coeff_t*>(&b.c));
446 return ap_coeff_equal(const_cast<ap_coeff_t*>(&a.c), const_cast<ap_coeff_t*>(&b.c));
451 return !ap_coeff_equal(const_cast<ap_coeff_t*>(&a.c), const_cast<ap_coeff_t*>(&b.c));
460 inline void coeff::reduce()
467 ap_coeff_neg(&c, &c);
472 coeff r = *
this; r.
neg();
return r;
475 inline long coeff::hash()
const 477 return ap_coeff_hash(const_cast<ap_coeff_t*>(&c));
483 inline const ap_coeff_t* coeff::get_ap_coeff_t()
const 488 inline ap_coeff_t* coeff::get_ap_coeff_t()
texpr0::builder neg(const texpr0::builder &a, ap_texpr_rtype_t rtype=AP_RTYPE_REAL, ap_texpr_rdir_t rdir=AP_RDIR_NEAREST)
Definition: apxx_texpr0.hh:814
std::ostream & operator<<(std::ostream &os, const coeff &s)
Definition: apxx_coeff_inline.hh:391
texpr0::builder operator-(const texpr0::builder &a)
Definition: apxx_texpr0.hh:854
friend builder neg(const builder &a, ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir)
Makes an AP_TEXPR_NEG expression node.
Definition: apxx_texpr0.hh:814
bool operator==(const coeff &a, const coeff &b)
Definition: apxx_coeff_inline.hh:444
bool operator!=(const coeff &a, const coeff &b)
Definition: apxx_coeff_inline.hh:449
void swap(coeff &a, coeff &b)
Definition: apxx_coeff_inline.hh:381
int cmp(const coeff &a, const coeff &b)
Definition: apxx_coeff_inline.hh:414