PPL  1.2
Linear_Expression_inlines.hh
Go to the documentation of this file.
1 /* Linear_Expression class implementation: inline functions.
2  Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3  Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_Linear_Expression_inlines_hh
25 #define PPL_Linear_Expression_inlines_hh 1
26 
28 
29 namespace Parma_Polyhedra_Library {
30 
31 inline Linear_Expression&
33  Linear_Expression tmp = e;
34  swap(*this, tmp);
35  return *this;
36 }
37 
38 inline
40  delete impl;
41 }
42 
43 inline Representation
45  return impl->representation();
46 }
47 
48 inline dimension_type
50  return impl->space_dimension();
51 }
52 
53 inline void
56 }
57 
58 inline Coefficient_traits::const_reference
60  return impl->coefficient(v);
61 }
62 
63 inline void
65 ::set_coefficient(Variable v, Coefficient_traits::const_reference n) {
66  impl->set_coefficient(v, n);
67 }
68 
69 inline Coefficient_traits::const_reference
71  return impl->inhomogeneous_term();
72 }
73 
74 inline void
76 ::set_inhomogeneous_term(Coefficient_traits::const_reference n) {
77  impl->set_inhomogeneous_term(n);
78 }
79 
80 inline void
82  impl->swap_space_dimensions(v1, v2);
83 }
84 
85 inline void
88 }
89 
90 inline bool
92  return impl->is_zero();
93 }
94 
95 inline bool
98 }
99 
100 inline const Linear_Expression&
102  PPL_ASSERT(zero_p != 0);
103  return *zero_p;
104 }
105 
106 inline memory_size_type
108  return impl->total_memory_in_bytes();
109 }
110 
111 inline memory_size_type
113  return external_memory_in_bytes() + sizeof(*this);
114 }
115 
117 inline Linear_Expression
119  return e;
120 }
121 
123 inline Linear_Expression
124 operator+(const Linear_Expression& e, Coefficient_traits::const_reference n) {
125  Linear_Expression x = e;
126  x += n;
127  return x;
128 }
129 
131 inline Linear_Expression
133  Linear_Expression x = e;
134  x += v;
135  return x;
136 }
137 
139 inline Linear_Expression
140 operator-(const Linear_Expression& e, Coefficient_traits::const_reference n) {
141  Linear_Expression x = e;
142  x -= n;
143  return x;
144 }
145 
147 inline Linear_Expression
148 operator-(const Variable v, const Variable w) {
149  const dimension_type v_space_dim = v.space_dimension();
150  const dimension_type w_space_dim = w.space_dimension();
151  const dimension_type space_dim = std::max(v_space_dim, w_space_dim);
152  if (space_dim > Linear_Expression::max_space_dimension()) {
153  throw std::length_error("Linear_Expression "
154  "PPL::operator+(v, w):\n"
155  "v or w exceed the maximum allowed "
156  "space dimension.");
157  }
158  if (v_space_dim >= w_space_dim) {
159  Linear_Expression e(v);
160  e -= w;
161  return e;
162  }
163  else {
164  Linear_Expression e(w.space_dimension(), true);
165  e -= w;
166  e += v;
167  return e;
168  }
169 }
170 
172 inline Linear_Expression
173 operator*(const Linear_Expression& e, Coefficient_traits::const_reference n) {
174  Linear_Expression x = e;
175  x *= n;
176  return x;
177 }
178 
180 inline Linear_Expression&
181 operator+=(Linear_Expression& e, Coefficient_traits::const_reference n) {
182  *e.impl += n;
183  return e;
184 }
185 
187 inline Linear_Expression&
188 operator-=(Linear_Expression& e, Coefficient_traits::const_reference n) {
189  *e.impl -= n;
190  return e;
191 }
192 
193 inline void
195  using std::swap;
196  swap(impl, y.impl);
197 }
198 
199 inline void
201  impl->normalize();
202 }
203 
204 inline void
205 Linear_Expression::ascii_dump(std::ostream& s) const {
206  impl->ascii_dump(s);
207 }
208 
209 inline bool
211  return impl->ascii_load(s);
212 }
213 
214 inline void
217 }
218 
219 inline void
220 Linear_Expression::permute_space_dimensions(const std::vector<Variable>& cycle) {
222 }
223 
225 inline Linear_Expression
227  if (e1.space_dimension() >= e2.space_dimension()) {
228  Linear_Expression e = e1;
229  e += e2;
230  return e;
231  }
232  else {
233  Linear_Expression e = e2;
234  e += e1;
235  return e;
236  }
237 }
238 
240 inline Linear_Expression
242  return e + v;
243 }
244 
246 inline Linear_Expression
247 operator+(Coefficient_traits::const_reference n,
248  const Linear_Expression& e) {
249  return e + n;
250 }
251 
253 inline Linear_Expression
254 operator+(const Variable v, const Variable w) {
255  const dimension_type v_space_dim = v.space_dimension();
256  const dimension_type w_space_dim = w.space_dimension();
257  const dimension_type space_dim = std::max(v_space_dim, w_space_dim);
258  if (space_dim > Linear_Expression::max_space_dimension()) {
259  throw std::length_error("Linear_Expression "
260  "PPL::operator+(v, w):\n"
261  "v or w exceed the maximum allowed "
262  "space dimension.");
263  }
264  if (v_space_dim >= w_space_dim) {
265  Linear_Expression e(v);
266  e += w;
267  return e;
268  }
269  else {
270  Linear_Expression e(w);
271  e += v;
272  return e;
273  }
274 }
275 
277 inline Linear_Expression
279  Linear_Expression r(e);
280  neg_assign(r);
281  return r;
282 }
283 
285 inline Linear_Expression
287  if (e1.space_dimension() >= e2.space_dimension()) {
288  Linear_Expression e = e1;
289  e -= e2;
290  return e;
291  }
292  else {
293  Linear_Expression e = e2;
294  neg_assign(e);
295  e += e1;
296  return e;
297  }
298 }
299 
301 inline Linear_Expression
303  Linear_Expression result(e, std::max(v.space_dimension(), e.space_dimension()));
304  result.negate(0, e.space_dimension() + 1);
305  result += v;
306  return result;
307 }
308 
310 inline Linear_Expression
312  Linear_Expression result(e, std::max(v.space_dimension(), e.space_dimension()));
313  result -= v;
314  return result;
315 }
316 
318 inline Linear_Expression
319 operator-(Coefficient_traits::const_reference n,
320  const Linear_Expression& e) {
321  Linear_Expression result(e);
322  neg_assign(result);
323  result += n;
324  return result;
325 }
326 
328 inline Linear_Expression
329 operator*(Coefficient_traits::const_reference n,
330  const Linear_Expression& e) {
331  return e * n;
332 }
333 
335 inline Linear_Expression&
337  *e1.impl += *e2.impl;
338  return e1;
339 }
340 
342 inline Linear_Expression&
344  *e.impl += v;
345  return e;
346 }
347 
349 inline Linear_Expression&
351  *e1.impl -= *e2.impl;
352  return e1;
353 }
354 
356 inline Linear_Expression&
358  *e.impl -= v;
359  return e;
360 }
361 
363 inline Linear_Expression&
364 operator*=(Linear_Expression& e, Coefficient_traits::const_reference n) {
365  *e.impl *= n;
366  return e;
367 }
368 
370 inline Linear_Expression&
371 operator/=(Linear_Expression& e, Coefficient_traits::const_reference n) {
372  *e.impl /= n;
373  return e;
374 }
375 
377 inline void
379  e.impl->negate();
380 }
381 
383 inline Linear_Expression&
385  Coefficient_traits::const_reference n,
386  const Variable v) {
387  e.impl->add_mul_assign(n, v);
388  return e;
389 }
390 
392 inline Linear_Expression&
394  Coefficient_traits::const_reference n,
395  const Variable v) {
396  e.impl->sub_mul_assign(n, v);
397  return e;
398 }
399 
400 inline void
402  Coefficient_traits::const_reference factor,
403  const Linear_Expression& e2) {
404  e1.impl->add_mul_assign(factor, *e2.impl);
405 }
406 
407 inline void
409  Coefficient_traits::const_reference factor,
410  const Linear_Expression& e2) {
411  e1.impl->sub_mul_assign(factor, *e2.impl);
412 }
413 
414 inline Coefficient_traits::const_reference
416  return impl->get(i);
417 }
418 
419 inline void
421  Coefficient_traits::const_reference n) {
422  impl->set(i, n);
423 }
424 
425 inline Coefficient_traits::const_reference
427  return impl->get(v.space_dimension());
428 }
429 
430 inline void
432  Coefficient_traits::const_reference n) {
433  impl->set(v.space_dimension(), n);
434 }
435 
436 inline bool
438  return impl->all_zeroes(start, end);
439 }
440 
441 inline dimension_type
443  return impl->num_zeroes(start, end);
444 }
445 
446 inline Coefficient
448  return impl->gcd(start, end);
449 }
450 
451 inline void
453 ::exact_div_assign(Coefficient_traits::const_reference c,
454  dimension_type start, dimension_type end) {
455  impl->exact_div_assign(c, start, end);
456 }
457 
458 inline void
460 ::mul_assign(Coefficient_traits::const_reference c,
461  dimension_type start, dimension_type end) {
462  impl->mul_assign(c, start, end);
463 }
464 
465 inline void
467  impl->sign_normalize();
468 }
469 
470 inline void
472  impl->negate(first, last);
473 }
474 
475 inline bool
477  return impl->all_zeroes(vars);
478 }
479 
480 inline bool
482  dimension_type start,
483  dimension_type end) const {
484  return impl->all_zeroes_except(vars, start, end);
485 }
486 
487 inline dimension_type
489  return impl->last_nonzero();
490 }
491 
492 inline void
495  scalar_product_assign(result, y, 0, space_dimension() + 1);
496 }
497 
498 inline void
501  dimension_type start, dimension_type end) const {
502  impl->scalar_product_assign(result, *(y.impl), start, end);
503 }
504 
505 inline int
508  return scalar_product_sign(y, 0, space_dimension() + 1);
509 }
510 
511 inline int
514  dimension_type start, dimension_type end) const {
515  return impl->scalar_product_sign(*(y.impl), start, end);
516 }
517 
518 inline dimension_type
521  return impl->first_nonzero(first, last);
522 }
523 
524 inline dimension_type
527  return impl->last_nonzero(first, last);
528 }
529 
530 inline void
532 ::has_a_free_dimension_helper(std::set<dimension_type>& x) const {
533  return impl->has_a_free_dimension_helper(x);
534 }
535 
536 inline bool
539  dimension_type start, dimension_type end) const {
540  return impl->is_equal_to(*(x.impl), start, end);
541 }
542 
543 inline bool
546  Coefficient_traits::const_reference c1,
547  Coefficient_traits::const_reference c2,
548  dimension_type start, dimension_type end) const {
549  return impl->is_equal_to(*(x.impl), c1, c2, start, end);
550 }
551 
552 inline void
554 ::get_row(Dense_Row& r) const {
555  return impl->get_row(r);
556 }
557 
558 inline void
561  return impl->get_row(r);
562 }
563 
564 inline void
567  impl->linear_combine(*y.impl, i);
568 }
569 
570 inline void
573  Coefficient_traits::const_reference c1,
574  Coefficient_traits::const_reference c2) {
575  impl->linear_combine(*y.impl, c1, c2);
576 }
577 
578 inline void
581  Coefficient_traits::const_reference c1,
582  Coefficient_traits::const_reference c2) {
583  impl->linear_combine_lax(*y.impl, c1, c2);
584 }
585 
586 inline int
588  return x.impl->compare(*y.impl);
589 }
590 
591 inline bool
593  return impl->is_equal_to(*x.impl);
594 }
595 
596 inline void
598  Coefficient_traits::const_reference c1,
599  Coefficient_traits::const_reference c2,
600  dimension_type start,
601  dimension_type end) {
602  impl->linear_combine(*y.impl, c1, c2, start, end);
603 }
604 
605 inline void
607  Coefficient_traits::const_reference c1,
608  Coefficient_traits::const_reference c2,
609  dimension_type start,
610  dimension_type end) {
611  impl->linear_combine_lax(*y.impl, c1, c2, start, end);
612 }
613 
614 inline bool
617  Variable first, Variable last) const {
618  return impl->have_a_common_variable(*(x.impl), first, last);
619 }
620 
621 inline
624  : itr(NULL) {
625 }
626 
627 inline
630  : itr(i.itr->clone()) {
631 }
632 
633 inline
636  // Note that this does nothing if itr == NULL.
637  delete itr;
638 }
639 
640 inline void
642  using std::swap;
643  swap(itr, i.itr);
644 }
645 
649  const_iterator tmp = i;
650  using std::swap;
651  swap(*this, tmp);
652  return *this;
653 }
654 
658  PPL_ASSERT(itr != NULL);
659  ++(*itr);
660  return *this;
661 }
662 
666  PPL_ASSERT(itr != NULL);
667  --(*itr);
668  return *this;
669 }
670 
673 ::operator*() const {
674  PPL_ASSERT(itr != NULL);
675  return *(*itr);
676 }
677 
678 inline Variable
680 ::variable() const {
681  PPL_ASSERT(itr != NULL);
682  return itr->variable();
683 }
684 
685 inline bool
687 ::operator==(const const_iterator& i) const {
688  PPL_ASSERT(itr != NULL);
689  PPL_ASSERT(i.itr != NULL);
690  return *itr == *(i.itr);
691 }
692 
693 inline bool
695 ::operator!=(const const_iterator& i) const {
696  return !(*this == i);
697 }
698 
699 inline
702  : itr(i) {
703  PPL_ASSERT(i != NULL);
704 }
705 
708 ::begin() const {
709  return const_iterator(impl->begin());
710 }
711 
714 ::end() const {
715  return const_iterator(impl->end());
716 }
717 
721  return const_iterator(impl->lower_bound(v));
722 }
723 
724 template <typename LE_Adapter>
725 inline
727 ::Linear_Expression(const LE_Adapter& e,
729  LE_Adapter>::value,
730  void*>::type)
731  : impl(NULL) {
732  Linear_Expression tmp(e.representation());
733  tmp.set_space_dimension(e.space_dimension());
734  tmp.set_inhomogeneous_term(e.inhomogeneous_term());
735  for (typename LE_Adapter::const_iterator i = e.begin(),
736  i_end = e.end(); i != i_end; ++i) {
737  add_mul_assign(tmp, *i, i.variable());
738  }
739  using std::swap;
740  swap(impl, tmp.impl);
741 }
742 
743 template <typename LE_Adapter>
744 inline
746 ::Linear_Expression(const LE_Adapter& e,
747  Representation r,
749  LE_Adapter>::value,
750  void*>::type)
751  : impl(NULL) {
752  Linear_Expression tmp(r);
753  tmp.set_space_dimension(e.space_dimension());
754  tmp.set_inhomogeneous_term(e.inhomogeneous_term());
755  for (typename LE_Adapter::const_iterator i = e.begin(),
756  i_end = e.end(); i != i_end; ++i) {
757  add_mul_assign(tmp, *i, i.variable());
758  }
759  using std::swap;
760  swap(impl, tmp.impl);
761 }
762 
763 template <typename LE_Adapter>
764 inline
766 ::Linear_Expression(const LE_Adapter& e,
767  dimension_type space_dim,
769  LE_Adapter>::value,
770  void*>::type)
771  : impl(NULL) {
772  Linear_Expression tmp(e.representation());
773  tmp.set_space_dimension(space_dim);
774  tmp.set_inhomogeneous_term(e.inhomogeneous_term());
775  typedef typename LE_Adapter::const_iterator itr_t;
776  itr_t i_end;
777  if (space_dim <= e.space_dimension()) {
778  i_end = e.lower_bound(Variable(space_dim));
779  }
780  else {
781  i_end = e.end();
782  }
783  for (itr_t i = e.begin(); i != i_end; ++i) {
784  add_mul_assign(tmp, *i, i.variable());
785  }
786  using std::swap;
787  swap(impl, tmp.impl);
788 }
789 
790 template <typename LE_Adapter>
791 inline
793 ::Linear_Expression(const LE_Adapter& e,
794  dimension_type space_dim,
795  Representation r,
797  LE_Adapter>::value,
798  void*>::type)
799  : impl(NULL) {
800  Linear_Expression tmp(r);
801  tmp.set_space_dimension(space_dim);
802  tmp.set_inhomogeneous_term(e.inhomogeneous_term());
803  typedef typename LE_Adapter::const_iterator itr_t;
804  itr_t i_end;
805  if (space_dim <= e.space_dimension()) {
806  i_end = e.lower_bound(Variable(space_dim));
807  }
808  else {
809  i_end = e.end();
810  }
811  for (itr_t i = e.begin(); i != i_end; ++i) {
812  add_mul_assign(tmp, *i, i.variable());
813  }
814  using std::swap;
815  swap(impl, tmp.impl);
816 }
817 
818 namespace IO_Operators {
819 
821 inline std::ostream&
822 operator<<(std::ostream& s, const Linear_Expression& e) {
823  e.impl->print(s);
824  return s;
825 }
826 
827 } // namespace IO_Operators
828 
830 inline void
832  x.m_swap(y);
833 }
834 
836 inline void
839  x.m_swap(y);
840 }
841 
842 } // namespace Parma_Polyhedra_Library
843 
844 #endif // !defined(PPL_Linear_Expression_inlines_hh)
Linear_Expression & operator-=(Linear_Expression &e1, const Linear_Expression &e2)
bool operator==(const const_iterator &i) const
Compares *this with i.
virtual Representation representation() const =0
Returns the current representation of this linear expression.
bool all_zeroes_except(const Variables_Set &vars, dimension_type start, dimension_type end) const
Returns true if all coefficients in [start,end), except those corresponding to variables in vars...
Linear_Expression operator+(const Variable v, const Linear_Expression &e)
void swap(CO_Tree &x, CO_Tree &y)
void set_space_dimension(dimension_type n)
Sets the dimension of the vector space enclosing *this to n .
virtual bool all_homogeneous_terms_are_zero() const =0
Returns true if and only if all the homogeneous terms of *this are .
Linear_Expression operator-(const Linear_Expression &e1, const Linear_Expression &e2)
Linear_Expression operator+(const Variable v, const Variable w)
A finite sequence of coefficients.
size_t dimension_type
An unsigned integral type for representing space dimensions.
virtual void ascii_dump(std::ostream &s) const =0
Writes to s an ASCII representation of *this.
An std::set of variables' indexes.
void set(dimension_type i, Coefficient_traits::const_reference n)
Sets the i-th coefficient to n.
Linear_Expression operator-(const Linear_Expression &e, const Variable v)
Coefficient_traits::const_reference get(dimension_type i) const
Returns the i-th coefficient.
Variable variable() const
Returns the variable of the coefficient pointed to by *this.
virtual void linear_combine(const Linear_Expression_Interface &y, Variable v)=0
bool ascii_load(std::istream &s)
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
Coefficient_traits::const_reference inhomogeneous_term() const
Returns the inhomogeneous term of *this.
std::ostream & operator<<(std::ostream &s, const Linear_Expression &e)
Output operator.
virtual void set_space_dimension(dimension_type n)=0
Sets the dimension of the vector space enclosing *this to n .
Linear_Expression operator+(const Linear_Expression &e1, const Linear_Expression &e2)
Linear_Expression & add_mul_assign(Linear_Expression &e, Coefficient_traits::const_reference n, const Variable v)
void add_mul_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
Linear_Expression & operator=(const Linear_Expression &e)
Assignment operator.
Linear_Expression operator-(Coefficient_traits::const_reference n, const Linear_Expression &e)
A finite sparse sequence of coefficients.
Linear_Expression operator-(const Variable v, const Linear_Expression &e)
Linear_Expression_Interface::const_iterator_interface * itr
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
virtual void remove_space_dimensions(const Variables_Set &vars)=0
Removes all the specified dimensions from the expression.
void set_coefficient(Variable v, Coefficient_traits::const_reference n)
Sets the coefficient of v in *this to n.
void set_inhomogeneous_term(Coefficient_traits::const_reference n)
Sets the inhomogeneous term of *this to n.
virtual bool is_zero() const =0
Returns true if and only if *this is .
const_iterator & operator--()
Navigates to the previous nonzero coefficient.
void get_row(Dense_Row &r) const
Sets r to a copy of the row that implements *this.
Linear_Expression operator+(const Linear_Expression &e, Coefficient_traits::const_reference n)
void swap(Linear_Expression::const_iterator &x, Linear_Expression::const_iterator &y)
Coefficient gcd(dimension_type start, dimension_type end) const
Returns the gcd of the nonzero coefficients in [start,end). If all the coefficients in this range are...
bool is_equal_to(const Linear_Expression &x) const
Coefficient_traits::const_reference coefficient(Variable v) const
Returns the coefficient of v in *this.
virtual bool is_equal_to(const Linear_Expression_Interface &x) const =0
void ascii_dump() const
Writes to std::cerr an ASCII representation of *this.
Linear_Expression operator-(const Variable v, const Variable w)
A dimension of the vector space.
Linear_Expression operator*(Coefficient_traits::const_reference n, const Linear_Expression &e)
bool have_a_common_variable(const Linear_Expression &x, Variable first, Variable last) const
Returns true if there is a variable from index first (included) to index last (excluded) whose coeffi...
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
void negate(dimension_type first, dimension_type last)
Negates the elements from index first (included) to index last (excluded).
static dimension_type max_space_dimension()
Returns the maximum space dimension a Linear_Expression can handle.
virtual const_iterator_interface * end() const =0
virtual dimension_type space_dimension() const =0
Returns the dimension of the vector space enclosing *this.
void permute_space_dimensions(const std::vector< Variable > &cycle)
Permutes the space dimensions of the expression.
Linear_Expression & operator*=(Linear_Expression &e, Coefficient_traits::const_reference n)
Linear_Expression & sub_mul_assign(Linear_Expression &e, Coefficient_traits::const_reference n, const Variable v)
bool all_zeroes(const Variables_Set &vars) const
Returns true if the coefficient of each variable in vars[i] is .
memory_size_type total_memory_in_bytes() const
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
virtual void shift_space_dimensions(Variable v, dimension_type n)=0
A class holding a constant called value that evaluates to true if and only if Base is the same type a...
const_iterator & operator=(const const_iterator &i)
Assigns i to *this .
Linear_Expression operator*(const Linear_Expression &e, Coefficient_traits::const_reference n)
Linear_Expression & operator+=(Linear_Expression &e, const Variable v)
virtual void linear_combine_lax(const Linear_Expression_Interface &y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2)=0
virtual void set(dimension_type i, Coefficient_traits::const_reference n)=0
Sets the i-th coefficient to n.
virtual const_iterator_interface * lower_bound(Variable v) const =0
Linear_Expression & operator+=(Linear_Expression &e, Coefficient_traits::const_reference n)
Coefficient value
Definition: PIP_Tree.cc:618
const_iterator & operator++()
Navigates to the next nonzero coefficient.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
void swap_space_dimensions(Variable v1, Variable v2)
Swaps the coefficients of the variables v1 and v2 .
bool all_homogeneous_terms_are_zero() const
Returns true if and only if all the homogeneous terms of *this are .
int compare(const Linear_Expression &x, const Linear_Expression &y)
virtual bool ascii_load(std::istream &s)=0
Loads from s an ASCII representation (as produced by ascii_dump(std::ostream&) const) and sets *this ...
virtual Linear_Expression_Interface & sub_mul_assign(Coefficient_traits::const_reference n, const Variable v)=0
virtual bool all_zeroes_except(const Variables_Set &vars, dimension_type start, dimension_type end) const =0
Returns true if each coefficient in [start,end) is *not* in , disregarding coefficients of variables ...
void linear_combine_lax(const Linear_Expression &y, Coefficient_traits::const_reference c1, Coefficient_traits::const_reference c2)
Linear_Expression & operator-=(Linear_Expression &e, const Variable v)
virtual Coefficient gcd(dimension_type start, dimension_type end) const =0
Returns the gcd of the nonzero coefficients in [start,end). If all the coefficients in this range are...
void remove_space_dimensions(const Variables_Set &vars)
Removes all the specified dimensions from the expression.
void has_a_free_dimension_helper(std::set< dimension_type > &x) const
Removes from the set x all the indexes of nonzero elements of *this.
void neg_assign(GMP_Integer &x)
Linear_Expression operator-(const Linear_Expression &e, Coefficient_traits::const_reference n)
virtual const_iterator_interface * begin() const =0
The entire library is confined to this namespace.
Definition: version.hh:61
Representation representation() const
Returns the current representation of *this.
Linear_Expression operator+(const Linear_Expression &e)
virtual Linear_Expression_Interface & add_mul_assign(Coefficient_traits::const_reference n, const Variable v)=0
virtual void permute_space_dimensions(const std::vector< Variable > &cycle)=0
Permutes the space dimensions of the expression.
virtual Coefficient_traits::const_reference get(dimension_type i) const =0
Returns the i-th coefficient.
static const Linear_Expression * zero_p
Holds (between class initialization and finalization) a pointer to the (zero-dimension space) constan...
int scalar_product_sign(const Linear_Expression &y) const
Computes the sign of the sum of (*this)[i]*y[i], for each i.
bool is_zero() const
Returns true if and only if *this is .
void swap(Linear_Expression &x, Linear_Expression &y)
Swaps x with y.
virtual memory_size_type total_memory_in_bytes() const =0
Returns a lower bound to the total size in bytes of the memory occupied by *this. ...
Linear_Expression & operator+=(Linear_Expression &e1, const Linear_Expression &e2)
virtual dimension_type num_zeroes(dimension_type start, dimension_type end) const =0
Returns the number of zero coefficient in [start, end).
Adapters' base type (for template meta-programming).
void sub_mul_assign(GMP_Integer &x, const GMP_Integer &y, const GMP_Integer &z)
Linear_Expression & operator/=(Linear_Expression &e, Coefficient_traits::const_reference n)
Linear_Expression & operator-=(Linear_Expression &e, Coefficient_traits::const_reference n)
void exact_div_assign(Coefficient_traits::const_reference c, dimension_type start, dimension_type end)
Linear_Expression operator+(Coefficient_traits::const_reference n, const Linear_Expression &e)
size_t memory_size_type
An unsigned integral type for representing memory size in bytes.
void mul_assign(Coefficient_traits::const_reference n, dimension_type start, dimension_type end)
Equivalent to (*this)[i] *= n, for each i in [start, end).
virtual void swap_space_dimensions(Variable v1, Variable v2)=0
Swaps the coefficients of the variables v1 and v2 .
Coefficient c
Definition: PIP_Tree.cc:64
void scalar_product_assign(Coefficient &result, const Linear_Expression &y) const
Sets results to the sum of (*this)[i]*y[i], for each i.
void linear_combine(const Linear_Expression &y, Variable v)
dimension_type first_nonzero(dimension_type first, dimension_type last) const
virtual void negate(dimension_type first, dimension_type last)=0
Negates the elements from index first (included) to index last (excluded).
static const Linear_Expression & zero()
Returns the (zero-dimension space) constant 0.
virtual int compare(const Linear_Expression_Interface &y) const =0
The basic comparison function.
Linear_Expression operator+(const Linear_Expression &e, const Variable v)
A class that provides a type member called type equivalent to T if and only if b is true...
dimension_type num_zeroes(dimension_type start, dimension_type end) const
Returns the number of zero coefficient in [start, end).
memory_size_type external_memory_in_bytes() const
Returns the size in bytes of the memory managed by *this.
Linear_Expression operator-(const Linear_Expression &e)
reference operator*() const
Returns the current element.
void m_swap(Linear_Expression &y)
Swaps *this with y.
virtual Coefficient_traits::const_reference coefficient(Variable v) const =0
Returns the coefficient of v in *this.
friend Linear_Expression & add_mul_assign(Linear_Expression &e, Coefficient_traits::const_reference n, Variable v)
virtual void print(std::ostream &s) const =0
virtual bool all_zeroes(const Variables_Set &vars) const =0
Returns true if the coefficient of each variable in vars[i] is .
Linear_Expression(Representation r=default_representation)
Default constructor: returns a copy of Linear_Expression::zero().
bool operator!=(const const_iterator &i) const
Compares *this with i .
virtual Coefficient_traits::const_reference inhomogeneous_term() const =0
Returns the inhomogeneous term of *this.
virtual dimension_type last_nonzero() const =0
void shift_space_dimensions(Variable v, dimension_type n)