APRONXX 0.9.15
/home/mine/apron/apronxx/apxx_texpr0.hh
Go to the documentation of this file.
1/* -*- C++ -*-
2 * apxx_texpr0.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_TEXPR0_HH
17#define __APXX_TEXPR0_HH
18
19#include <vector>
21#include "ap_texpr0.h"
22#include "ap_linearize.h"
24#include "apxx_linexpr0.hh"
25#include "apxx_environment.hh"
26
27namespace apron {
28
29class abstract0;
30
31
33class dim {
34
35public:
36
37 ap_dim_t d;
40 dim(ap_dim_t d);
41
42
46 dim(const environment& e, const var& v);
47};
49
50
52bool is_unop(ap_texpr_op_t op);
53
54//! Whether the operator is binary.
55 bool is_binop(ap_texpr_op_t op);
56
58
59
60/* ================================= */
61/* texpr0 */
62/* ================================= */
64
65
69 * Binary operators include addition, subtraction, multiplication, division, and modulo.
70 * Unary operators include opposite, square root, and typecast.
71 * Additionally, all operators are tagged with a destination type: perfect integers, reals,
72 * or floating-point numbers (of various bit-size).
73 * For integer and floating-point operators, a rounding direction can be specified
74 * (as well as 'any direction').
75 * The concrete semantics of all operators is to first perform the operation on perfect reals
76 * (typecast being the identity operator here), and then round the result to the destination type
77 * in the specified direction.
78 *
79 * A texpr0 manages a whole expression tree: assignment, copy, and destruction are deep (recursive).
80 *
81 * Complex expression trees can be constructed using the standard +, -, *, /, % operators, as well as
82 * functions such as add, mul, div, etc. (allowing to set the destination type and rounding direction).
83 * \code
84 * texpr0 x = dim(1) + dim(2) * 5;
85 * texpr0 y = add(sqrt(x), x, AP_RTYPE_FLOAT);
86 * \endcode
87 * Temporaries created by the operators have the texpr0::builder type.
88 * See the texpr0::builder class documentation for the details on operator arguments.
89 *
90 * Expression trees can be visited and/or modified using the texpr0::iterator type.
91 */
92class texpr0 : public use_malloc {
93
94protected:
95
96 ap_texpr0_t l;
97
99 texpr0(ap_texpr0_t* x);
100
102 void init_from(ap_texpr0_t* x);
104public:
105
106 class builder;
107 class iterator;
108 class const_iterator;
109
110
111 /* constructors */
112 /* ============ */
113
115 //@{
116
122 texpr0(const builder& x);
123
124 //! Makes a (deep) copy of the expression tree.
125 texpr0(const texpr0& x);
126
128 texpr0(const const_iterator& x);
129
132
133 */
134 texpr0(const linexpr0& l);
135
136
141 texpr0(const texpr0& x, const dimchange& d, bool add=true);
144 texpr0(const texpr0& x, const dimperm& d);
145
147 texpr0(const texpr0& x, ap_dim_t dim, const texpr0& dst);
148
150
151
152 /* destructor */
153 /* ========== */
154
157
158 //! Frees the memory occupied by the expression (and, recursively, all sub-expressions).
159 ~texpr0();
160
162
163 /* assignment */
164 /* ========== */
165
167 //@{
168
170 texpr0& operator=(const texpr0& x);
171
172 //! Makes a (deep) copy of the expression.
174
176 texpr0& operator=(const builder& x);
181
183
185
186
188 /* iterators */
189 /* ========= */
190
191
192 /** @name Iterators */
194
196
197 * For lack of better name, an 'iterator' object is used to reference an
198 * expression node within a constant expression tree.
199 * Through the 'iterator', nodes can be examined.
200 * However, 'iterators' traverse the tree in a functional way: you spawn new
201 * const_iterator objects for left and right children.
203 * Use the iterator class if you also wish to mutate an expression.
204 *
205 * \warning You can no longer use a const_iterator after the corresponding node has been discarded
206 * (i.e., part of a destroyed expression, part of a sub-expression substituted away, etc.).
207 * However, you can safely destroy the const_iterator after the node has been destroyed
208 * (provided you do not use it in the meantime).
209 *
210 */
213 protected:
214
215 ap_texpr0_t* l;
216
217 //! Internal use only.
218 const_iterator(ap_texpr0_t* l);
219
220 friend class texpr0;
221 friend class tcons0;
222 friend class texpr1;
223 friend class tcons1;
224
225 public:
226
227 /* constructors */
228 /* ============ */
229
231 //@{
232
234 const_iterator(const texpr0& e);
235
238
240
241
242 /* access */
243 /* ====== */
244
247
248
254 ap_texpr_discr_t get_discr() const;
255
260 const coeff& get_coeff() const;
261
262 /*! \brief Returns the dimension of a dimension node.
263 *
264 * \throw bad_discriminant if the node is not a dimension node.
265 */
266 ap_dim_t get_dim() const;
267
273 */
274 ap_texpr_op_t get_op() const;
275
277
279 * \c AP_RTYPE_EXTENDED (80-bit), or \c AP_RTYPE_QUAD (128-bit).
280 * \throw bad_discriminant if the node is not an operator node.
281 */
282 ap_texpr_rtype_t get_rtype() const;
283
284 /*! \brief Returns the rounding direction of an operator node.
285 *
286 * \return either \c AP_RDIR_NEAREST, \c AP_RDIR_ZERO, \c AP_RDIR_UP, \c AP_RDIR_DOWN, or \c AP_RDIR_RND.
287 * \throw bad_discriminant if the node is not an operator node.
288 */
289 ap_texpr_rdir_t get_rdir() const;
290
292
293
294 /* traversal */
295 /* ========= */
296
298
303
307 const_iterator child() const;
308
314 const_iterator left() const;
315
316 /*! \brief Constructs a const_iterator to the right sub-expression argument of a binary operator node.
317 *
318 * \throw bad_discriminant if the node is not an operator node.
319 * \throw std::out_of_range if the operator node is not binary.
320 */
322
323
324
326 /* tests, size, dimensions */
327 /* ======================= */
328
329 /** @name Tests, size, dimensions */
331
332
334 bool equal(const texpr0& x) const;
335
336 //! Whether the expression is a single coefficient node with 0 value.
337 bool is_zero() const;
338
340 size_t depth() const;
343 size_t size() const;
344
346 ap_dim_t max_dim() const;
349 bool has_dim(ap_dim_t d) const;
350
352
353 */
354 std::vector<ap_dim_t> dimlist() const;
355
357 bool is_interval_cst() const;
358
359 //! Whether the expression is linear and there is no rounding.
360 bool is_interval_linear() const;
361
363 bool is_interval_polynomial() const;
364
365 //! Whether the expression is a polynomial fraction and there is no rounding.
366 bool is_interval_polyfrac() const;
367
369 bool is_scalar() const;
370
372
373
374 /* print */
375 /* ===== */
376
379
380
382 * Variable naming can be configured through the varname stream modifier.
383 */
384 friend std::ostream& operator<< (std::ostream& os, const const_iterator& s);
385
387 void print(char** name_of_dim = NULL, FILE* stream=stdout) const;
390
391
392 /* C-level compatibility */
393 /* ===================== */
394
395 /** @name C API compatibility */
397
399 ap_texpr0_t* get_ap_texpr0_t();
400
401
402 const ap_texpr0_t* get_ap_texpr0_t() const;
403
405
406 };
407
408
409 /*! \brief Iterators to traverse and mutate an expression tree.
410 *
411 * As const_iterator, but can be used to modify as well as traverse nodes.
412 */
413 class iterator : public const_iterator {
414
415 protected:
416
418 iterator(ap_texpr0_t* l);
419
420 friend class tcons0;
421 friend class texpr1;
422 friend class tcons1;
423
424 public:
425
426 /* constructors */
427 /* ============ */
428
429 /** @name Constructors */
431
433 iterator(texpr0& e);
434
435 //! Duplicates the iterator.
436 iterator(const iterator& i);
437
439
441 /* substitution */
442 /* ============ */
443
444
445 //@{
446
449
450 * However, any iterator in the discarded part becomes invalid.
451 */
452 iterator& operator= (const builder& c);
453
454
456
457 /* access */
458 /* ====== */
459
462
465
466 */
467 coeff& get_coeff() const;
468
470
471 * \throw bad_discriminant if the node is not a dimension node.
472 */
473 ap_dim_t& get_dim() const;
474
475
477 * \return either \c AP_TEXPR_ADD, \c AP_TEXPR_SUB, \c AP_TEXPR_MUL, \c AP_TEXPR_DIV, \c AP_TEXPR_MOD, \c AP_TEXPR_POW
478 * \c AP_TEXPR_NEG, \c AP_TEXPR_CAST, or \c AP_TEXPR_SQRT.
479 * \throw bad_discriminant if the node is not an operator node.
480 */
481 ap_texpr_op_t& get_op() const;
482
485
486 * \c AP_RTYPE_EXTENDED (80-bit), or \c AP_RTYPE_QUAD (128-bit).
487 * \throw bad_discriminant if the node is not an operator node.
488 */
489 ap_texpr_rtype_t& get_rtype() const;
490
495 */
496 ap_texpr_rdir_t& get_rdir() const;
497
499
501 /* traversal */
502 /* ========= */
503
504
506
508 iterator& operator=(const iterator& i);
513
515
517
519 * \throw bad_discriminant if the node is not an operator node.
520 */
521 iterator left() const;
522
523 /*! \brief Constructs an iterator to the right sub-expression argument of a binary operator node.
524 *
525 * \throw bad_discriminant if the node is not an operator node.
526 * \throw std::out_of_range if the operator node is not binary.
527 */
528 iterator right() const;
529
531
533 /* C-level compatibility */
534 /* ===================== */
535
538
540 ap_texpr0_t* get_ap_texpr0_t();
541
543 const ap_texpr0_t* get_ap_texpr0_t() const;
544
545 //@}
546
547 };
548
549
550
552
554 iterator root();
555
556
558
559
560 /* builders */
561 /* ======== */
562
563 /** @name Builders */
565
568
569 * operators (+, -, *, /, %) and friend functions (add, sub, mul, div, mod, neg, sqrt, cast,
570 * unary, binary).
571 *
572 * Each builder object manages a single node which is allocated by the constructor and destroyed
573 * by the destructor, without considering potential sub-nodes.
574 * As their usage is temporary (they are normally destructed at the end of full expressions),
575 * assignment, copy, and destruction can be shallow, which results in improved efficiency wrt.
576 * using texpr0 as temporaries.
577 *
578 * You should not create variables of type build, nor define functions that return or take
579 * builder objects as arguments.
580 */
581 class builder : public use_malloc {
582
583 friend class texpr1;
584
585 protected:
586
587 ap_texpr0_t* l;
588
589
591 builder& operator= (const builder& x) { assert(0); return *this; }
594 void init_from(ap_texpr0_t* x);
595
597 builder(ap_texpr0_t* x);
598
599 public:
600
601 /* constructors */
602 /* ============ */
603
605
606
608 builder(const builder& x);
609
610 //! Makes a shallow copy, copying only the root node. Sub-expressions are aliased, not copied.
611 builder(const const_iterator& x);
612
614 builder(const texpr0& x);
617 builder(const coeff& x);
618
619
620 builder(const scalar& x);
621
623 builder(const mpq_class& x);
624
626 builder(mpfr_t x);
629 builder(int x);
630
632 builder(long x);
633
635 builder(double x);
636
638 builder(const frac& x);
639
640
641 builder(const interval& x);
642
644 builder(const scalar& inf, const scalar& sup);
645
646 //! Makes a constant interval leaf from two MPQ bounds (copied).
647 builder(const mpq_class& inf, const mpq_class& sup);
648
650 builder(mpfr_t inf, mpfr_t sup);
653 builder(int inf, int sup);
654
655
656 builder(long inf, long sup);
657
659 builder(double inf, double sup);
660
661 //! Makes a constant interval leaf from two fraction bounds (converted to MPQ).
662 builder(const frac& inf, const frac& sup);
663
664
666
668 builder(dim d);
671 builder(ap_texpr_op_t op, const builder& argA, ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir);
672
673 //! Makes a binary expression node.
674 builder(ap_texpr_op_t op, const builder& argA, const builder& argB, ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir);
675
676
678
679 /* destructor */
680 /* ========== */
684
685 //! Frees the memory occupied by the node, not its sub-expressions.
686 ~builder();
687
688
690
691 /* C-level compatibility */
692 /* ===================== */
696
697 //! Returns a pointer to the internal APRON object stored in *this.
698 ap_texpr0_t* get_ap_texpr0_t();
699
701 const ap_texpr0_t* get_ap_texpr0_t() const;
704
705
706 /* 'Intelligent' constructors */
707 /* ========================== */
708
710
714
716 * \arg \c op should be a unary operator: negation (\c AP_TEXPR_NEG), typecast (\c AP_TEXPR_CAST),
717 * or square root (\c AP_TEXPR_SQRT).
718 * \arg \c argA should point to the argument expression.
719 * \arg \c rtype is the destination type (for rounding): reals (\c AP_RTYPE_REAL, means no rounding),
720 * perfect integers (\c AP_RTYPE_INT), 32-bit single precision (\c AP_RTYPE_SINGLE), 64-bit double precision
721 * (\c AP_RTYPE_DOUBLE), 80-bit extended precision (\c AP_RTYPE_EXTENDED), or
722 * 128-bit quadruple precision (\c AP_RTYPE_QUAD).
723 * \arg \c rdir is the rounding direction: to nearest (\c AP_RDIR_NEAREST), truncation (\c AP_RDIR_ZERO),
724 * towards +oo (\c AP_RDIR_UP), towards -oo (\c AP_RDIR_DOWN), or non-deterministic (\c AP_RDIR_RND).
725 * \throw std::invalid_argument if \c op is not a unary operator.
726 */
727 friend builder unary(ap_texpr_op_t op, const builder& a,
728 ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir);
729
730
732 * Creates only one node. The argument expressions is aliased, not copied.
733 *
734 * \arg \c op should be a binary operator: addition (\c AP_TEXPR_ADD), subtraction (\c AP_TEXPR_SUB),
735 * multiplication (\c AP_TEXPR_MUL), division (\c AP_TEXPR_DIV), modulo (\c AP_TEXPR_MOD), or power (\c AP_TEXPR_POW).
736 * \arg \c argA should point to the left argument expression.
737 * \arg \c argB should point to the right argument expression.
738 * \arg \c rtype is the destination type (for rounding): reals (\c AP_RTYPE_REAL, means no rounding),
739 * perfect integers (\c AP_RTYPE_INT), 32-bit single precision (\c AP_RTYPE_SINGLE), 64-bit double precision
740 * (\c AP_RTYPE_DOUBLE), 80-bit extended precision (\c AP_RTYPE_EXTENDED).
741 * \arg \c rdir is the rounding direction: to nearest (\c AP_RDIR_NEAREST), truncation (\c AP_RDIR_ZERO),
742 * towards +oo (\c AP_RDIR_UP), towards -oo (\c AP_RDIR_DOWN), or non-deterministic (\c AP_RDIR_RND).
743 * \throw std::invalid_argument if \c op is not a binary operator.
744 */
745 friend builder binary(ap_texpr_op_t op, const builder& a, const builder& b,
746 ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir);
747
749 friend builder add(const builder& a, const builder& b,
750 ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir);
751
753 friend builder sub(const builder& a, const builder& b,
754 ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir);
755
757 friend builder mul(const builder& a, const builder& b,
758 ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir);
759
761 friend builder div(const builder& a, const builder& b,
762 ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir);
763
764 //! Makes an \c AP_TEXPR_MOD expression node.
765 friend builder mod(const builder& a, const builder& b,
766 ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir);
767
769 friend builder pow(const builder& a, const builder& b,
770 ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir);
771
772 //! Makes an \c AP_TEXPR_NEG expression node.
773 friend builder neg(const builder& a,
774 ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir);
775
777 friend builder cast(const builder& a, ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir);
778
779 //! Makes an \c AP_TEXPR_CAST expression node to \c AP_RTYPE_INT type rounded towards \c AP_RDIR_DOWN.
780 friend builder floor(const builder& a);
781
783 friend builder ceil(const builder& a);
784
785
786 friend builder trunc(const builder& a);
787
789 friend builder sqrt(const builder& a,
790 ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir);
791
792
793 friend builder operator+(const builder& a);
794
796 friend builder operator-(const builder& a);
797
799 friend builder operator+(const builder& a, const builder& b);
802 friend builder operator-(const builder& a, const builder& b);
803
805 friend builder operator*(const builder& a, const builder& b);
806
807 //! Makes a \c AP_TEXPR_DIV expression node using \c AP_RTYPE_REAL type (no rounding).
808 friend builder operator/(const builder& a, const builder& b);
809
811 friend builder operator%(const builder& a, const builder& b);
812
813
814 friend builder operator^(const builder& a, const builder& b);
815
817
818
820 bool is_zero() const;
822 };
823
824
825
826 /* print */
827 /* ===== */
828
831
832 /*! \brief Printing.
833 *
834 * Variable naming can be configured through the varname stream modifier.
835 */
836 friend std::ostream& operator<< (std::ostream& os, const texpr0& s);
839 void print(char** name_of_dim = NULL, FILE* stream=stdout) const;
840
841
843
844 /* tests, size, dimensions */
845 /* ======================= */
846
848
850
852 bool equal(const texpr0& x) const;
853
854 //! Whether the expression is a single coefficient node with 0 value.
855 bool is_zero() const;
856
858 size_t depth() const;
861 size_t size() const;
862
863
864 ap_dim_t max_dim() const;
865
867 bool has_dim(ap_dim_t d) const;
868
869 /*! \brief Returns a list of all dimensions occurring in the expression
870 * (in strict increasing order)
871 */
872 std::vector<ap_dim_t> dimlist() const;
873
874 //! Whether the expression is constant (i.e., has no dimension leaves).
875 bool is_interval_cst() const;
876
878 bool is_interval_linear() const;
881 bool is_interval_polynomial() const;
882
883
885
887 bool is_scalar() const;
888
890
891 /* operations */
892 /* ========== */
896
898 void substitute(ap_dim_t dim, const texpr0& dst);
899
900#if 0
903
904 * \arg \c pexact if not NULL, sets to true whenever the evaluation was exact
905 * (i.e., not over-approximated).
906 */
907 interval eval(manager& m, const abstract0& a, ap_scalar_discr_t discr=AP_SCALAR_DOUBLE,
908 bool* pexact=NULL) const;
909
910 linexpr0 intlinearize(manager& m, const abstract0& a, ap_scalar_discr_t discr=AP_SCALAR_DOUBLE,
911 bool quasilinearize=false, bool* pexact=NULL) const;
912#endif
915 long hash() const;
916
917
919 /* change of dimension */
920 /* =================== */
921
922
924
926 void add_dimensions(const dimchange& d);
927
932 void remove_dimensions(const dimchange& d);
933
935 void permute_dimensions(const dimperm& d);
936
938
939
940 /* C-level compatibility */
941 /* ===================== */
942
945
947 ap_texpr0_t* get_ap_texpr0_t();
948
950 const ap_texpr0_t* get_ap_texpr0_t() const;
951
953
954};
955
956#include "apxx_texpr0_inline.hh"
957
958}
959
960#endif /* __APXX_TEXPR0_HH */
Level 0 abstract value (ap_abstract0_t* wrapper).
Definition apxx_abstract0.hh:78
Coefficient (ap_coeff_t wrapper).
Definition apxx_coeff.hh:36
Represents a dimension (i.e., variable by index) in an expression tree.
Definition apxx_texpr0.hh:33
ap_dim_t d
Dimension index.
Definition apxx_texpr0.hh:37
dim(ap_dim_t d)
Standard constructor.
Definition apxx_texpr0.hh:20
Dimension change object (ap_dimchange_t wrapper).
Definition apxx_dimension.hh:102
Dimension permutation object (ap_dimperm_t wrapper).
Definition apxx_dimension.hh:292
Level 1 environment (ap_environment_t wrapper).
Definition apxx_environment.hh:51
Interval (ap_interval_t wrapper).
Definition apxx_interval.hh:47
Level 0 linear expression (ap_linexpr0_t wrapper).
Definition apxx_linexpr0.hh:44
Library manager (ap_manager_t wrapper).
Definition apxx_manager.hh:137
Scalar (ap_scalar_t wrapper).
Definition apxx_scalar.hh:89
Temporary expression nodes used when constructing a texpr0.
Definition apxx_texpr0.hh:581
friend builder add(const builder &a, const builder &b, ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir)
Makes an AP_TEXPR_ADD expression node.
Definition apxx_texpr0.hh:772
friend builder mod(const builder &a, const builder &b, ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir)
Makes an AP_TEXPR_MOD expression node.
Definition apxx_texpr0.hh:800
friend builder pow(const builder &a, const builder &b, ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir)
Makes an AP_TEXPR_POW expression node.
Definition apxx_texpr0.hh:807
friend builder trunc(const builder &a)
Makes an AP_TEXPR_CAST expression node to AP_RTYPE_INT type rounded towards AP_RDIR_ZERO.
Definition apxx_texpr0.hh:837
friend builder sqrt(const builder &a, ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir)
Makes an AP_TEXPR_SQRT expression node.
Definition apxx_texpr0.hh:842
void init_from(ap_texpr0_t *x)
Internal use only: makes a shallow copy, copying only the root node.
Definition apxx_texpr0.hh:627
friend builder unary(ap_texpr_op_t op, const builder &a, ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir)
Makes a unary expression node.
Definition apxx_texpr0.hh:757
friend builder operator*(const builder &a, const builder &b)
Makes a AP_TEXPR_MUL expression node using AP_RTYPE_REAL type (no rounding).
Definition apxx_texpr0.hh:869
friend builder operator^(const builder &a, const builder &b)
Makes a AP_TEXPR_POW expression node using AP_RTYPE_REAL type (no rounding).
Definition apxx_texpr0.hh:884
~builder()
Frees the memory occupied by the node, not its sub-expressions.
Definition apxx_texpr0.hh:893
friend builder floor(const builder &a)
Makes an AP_TEXPR_CAST expression node to AP_RTYPE_INT type rounded towards AP_RDIR_DOWN.
Definition apxx_texpr0.hh:827
friend builder operator/(const builder &a, const builder &b)
Makes a AP_TEXPR_DIV expression node using AP_RTYPE_REAL type (no rounding).
Definition apxx_texpr0.hh:874
friend builder binary(ap_texpr_op_t op, const builder &a, const builder &b, ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir)
Makes a binary expression node.
Definition apxx_texpr0.hh:764
friend builder div(const builder &a, const builder &b, ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir)
Makes an AP_TEXPR_DIV expression node.
Definition apxx_texpr0.hh:793
builder & operator=(const builder &x)
Not to be used. (Temporaries are not to be re-assigned).
Definition apxx_texpr0.hh:591
ap_texpr0_t * l
Definition apxx_texpr0.hh:587
friend builder operator+(const builder &a)
Makes a copy of the node.
Definition apxx_texpr0.hh:849
builder(ap_texpr0_t *x)
Internal use only: makes a shallow copy, copying only the root node.
Definition apxx_texpr0.hh:641
friend builder cast(const builder &a, ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir)
Makes an AP_TEXPR_CAST expression node.
Definition apxx_texpr0.hh:821
friend builder ceil(const builder &a)
Makes an AP_TEXPR_CAST expression node to AP_RTYPE_INT type rounded towards AP_RDIR_UP.
Definition apxx_texpr0.hh:832
friend builder operator-(const builder &a)
Makes a AP_TEXPR_NEG expression node using AP_RTYPE_REAL type (no rounding).
Definition apxx_texpr0.hh:854
friend builder mul(const builder &a, const builder &b, ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir)
Makes an AP_TEXPR_MUL expression node.
Definition apxx_texpr0.hh:786
friend class texpr1
Definition apxx_texpr0.hh:583
friend builder operator%(const builder &a, const builder &b)
Makes a AP_TEXPR_MOD expression node using AP_RTYPE_REAL type (no rounding).
Definition apxx_texpr0.hh:879
bool is_zero() const
Whether the expression is a single coefficient node with 0 value.
Definition apxx_texpr0.hh:904
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
friend builder sub(const builder &a, const builder &b, ap_texpr_rtype_t rtype, ap_texpr_rdir_t rdir)
Makes an AP_TEXPR_SUB expression node.
Definition apxx_texpr0.hh:779
ap_texpr0_t * get_ap_texpr0_t()
Returns a pointer to the internal APRON object stored in *this.
Definition apxx_texpr0.hh:913
Iterators to traverse a constant expression tree.
Definition apxx_texpr0.hh:211
size_t size() const
Returns the number of operator nodes in the expression tree.
Definition apxx_texpr0.hh:440
ap_texpr0_t * l
Definition apxx_texpr0.hh:215
bool is_interval_polynomial() const
Whether the expression is polynomial and there is no rounding.
Definition apxx_texpr0.hh:476
bool is_interval_cst() const
Whether the expression is constant (i.e., has no dimension leaves).
Definition apxx_texpr0.hh:466
bool is_zero() const
Whether the expression is a single coefficient node with 0 value.
Definition apxx_texpr0.hh:424
ap_texpr_op_t get_op() const
Returns the operator kind of an operator node.
Definition apxx_texpr0.hh:353
const_iterator & operator=(const const_iterator &i)
Resets the const_iterator at position i.
Definition apxx_texpr0.hh:375
friend std::ostream & operator<<(std::ostream &os, const const_iterator &s)
Printing.
Definition apxx_texpr0.hh:409
bool equal(const texpr0 &x) const
Whether two expressions are syntactically, structurally equal.
Definition apxx_texpr0.hh:429
const_iterator left() const
Constructs a const_iterator to the only of left sub-expression of an operator node.
Definition apxx_texpr0.hh:388
friend class texpr0
Definition apxx_texpr0.hh:220
friend class tcons1
Definition apxx_texpr0.hh:223
bool is_scalar() const
Whether all occurring constants are scalar.
Definition apxx_texpr0.hh:486
ap_texpr_discr_t get_discr() const
Returns the node kind.
Definition apxx_texpr0.hh:336
ap_texpr_rdir_t get_rdir() const
Returns the rounding direction of an operator node.
Definition apxx_texpr0.hh:365
size_t depth() const
Returns the depth of the expression tree (counting only operator nodes).
Definition apxx_texpr0.hh:435
const coeff & get_coeff() const
Returns a reference to the coefficient of a constant node.
Definition apxx_texpr0.hh:341
ap_texpr0_t * get_ap_texpr0_t()
Returns a pointer to the internal APRON object stored in *this.
Definition apxx_texpr0.hh:495
ap_dim_t max_dim() const
Returns the maximal dimension occurring in the expression (or 0 if there is no variable).
Definition apxx_texpr0.hh:445
const_iterator child() const
Constructs a const_iterator to the only or left sub-expression of an operator node.
Definition apxx_texpr0.hh:381
void print(char **name_of_dim=NULL, FILE *stream=stdout) const
Prints to a C stream.
Definition apxx_texpr0.hh:415
bool is_interval_linear() const
Whether the expression is linear and there is no rounding.
Definition apxx_texpr0.hh:471
ap_dim_t get_dim() const
Returns the dimension of a dimension node.
Definition apxx_texpr0.hh:347
const_iterator right() const
Constructs a const_iterator to the right sub-expression argument of a binary operator node.
Definition apxx_texpr0.hh:395
const_iterator(ap_texpr0_t *l)
Internal use only.
Definition apxx_texpr0.hh:321
friend class tcons0
Definition apxx_texpr0.hh:221
std::vector< ap_dim_t > dimlist() const
Returns a list of all dimensions occurring in the expression (in strict increasing order)
Definition apxx_texpr0.hh:455
bool has_dim(ap_dim_t d) const
Whether the given dimension occurs in the expression.
Definition apxx_texpr0.hh:450
bool is_interval_polyfrac() const
Whether the expression is a polynomial fraction and there is no rounding.
Definition apxx_texpr0.hh:481
ap_texpr_rtype_t get_rtype() const
Returns the destination type of an operator node.
Definition apxx_texpr0.hh:359
Iterators to traverse and mutate an expression tree.
Definition apxx_texpr0.hh:413
coeff & get_coeff() const
Returns a (modifiable) reference to the coefficient of a constant node.
Definition apxx_texpr0.hh:545
iterator left() const
Constructs an iterator to the only of left sub-expression of an operator node.
Definition apxx_texpr0.hh:592
ap_texpr_rtype_t & get_rtype() const
Returns a (modifiable) reference to the destination type of an operator node.
Definition apxx_texpr0.hh:563
iterator(ap_texpr0_t *l)
Internal use only.
Definition apxx_texpr0.hh:514
iterator child() const
Constructs an iterator to the only or left sub-expression of an operator node.
Definition apxx_texpr0.hh:585
friend class tcons1
Definition apxx_texpr0.hh:422
iterator right() const
Constructs an iterator to the right sub-expression argument of a binary operator node.
Definition apxx_texpr0.hh:599
ap_texpr_rdir_t & get_rdir() const
Returns a (modifiable) reference to the rounding direction of an operator node.
Definition apxx_texpr0.hh:569
iterator & operator=(const builder &c)
Replace the sub-expression at the iterator position with a (deep) copy of c.
Definition apxx_texpr0.hh:532
ap_texpr0_t * get_ap_texpr0_t()
Returns a pointer to the internal APRON object stored in *this.
Definition apxx_texpr0.hh:610
ap_dim_t & get_dim() const
Returns a (modifiable) reference to the dimension of a dimension node.
Definition apxx_texpr0.hh:551
friend class texpr1
Definition apxx_texpr0.hh:421
ap_texpr_op_t & get_op() const
Returns a (modifiable) reference to the operator kind of an operator node.
Definition apxx_texpr0.hh:557
friend class tcons0
Definition apxx_texpr0.hh:420
bool is_interval_linear() const
Whether the expression is linear and there is no rounding.
Definition apxx_texpr0.hh:207
~texpr0()
Frees the memory occupied by the expression (and, recursively, all sub-expressions).
Definition apxx_texpr0.hh:103
size_t size() const
Returns the number of operator nodes in the expression tree.
Definition apxx_texpr0.hh:182
size_t depth() const
Returns the depth of the expression tree (counting only operator nodes).
Definition apxx_texpr0.hh:177
ap_texpr0_t * get_ap_texpr0_t()
Returns a pointer to the internal APRON object stored in *this.
Definition apxx_texpr0.hh:294
ap_dim_t max_dim() const
Returns the maximal dimension occurring in the expression (or 0 if there is no variable).
Definition apxx_texpr0.hh:187
bool has_dim(ap_dim_t d) const
Whether the given dimension occurs in the expression.
Definition apxx_texpr0.hh:192
texpr0(ap_texpr0_t *x)
Internal use only. Shallow copy.
Definition apxx_texpr0.hh:54
const_iterator root() const
Returns a new iterator at the root of a constant expression tree.
Definition apxx_texpr0.hh:316
texpr0 & operator=(const texpr0 &x)
Makes a (deep) copy of the expression.
Definition apxx_texpr0.hh:124
bool is_interval_cst() const
Whether the expression is constant (i.e., has no dimension leaves).
Definition apxx_texpr0.hh:202
ap_texpr0_t l
Structure managed by APRON.
Definition apxx_texpr0.hh:96
void add_dimensions(const dimchange &d)
Adds some dimensions, shifting dimension if needed.
Definition apxx_texpr0.hh:273
bool is_interval_polyfrac() const
Whether the expression is a polynomial fraction and there is no rounding.
Definition apxx_texpr0.hh:217
friend std::ostream & operator<<(std::ostream &os, const texpr0 &s)
Printing.
Definition apxx_texpr0.hh:153
bool is_interval_polynomial() const
Whether the expression is polynomial and there is no rounding.
Definition apxx_texpr0.hh:212
bool equal(const texpr0 &x) const
Whether two expressions are syntactically, structurally equal.
Definition apxx_texpr0.hh:172
void permute_dimensions(const dimperm &d)
Permutes dimensions.
Definition apxx_texpr0.hh:284
long hash() const
Returns a hash code.
Definition apxx_texpr0.hh:262
bool is_scalar() const
Whether all occurring constants are scalar.
Definition apxx_texpr0.hh:222
void init_from(ap_texpr0_t *x)
Internal use only. Shallow copy.
Definition apxx_texpr0.hh:48
std::vector< ap_dim_t > dimlist() const
Returns a list of all dimensions occurring in the expression (in strict increasing order)
Definition apxx_texpr0.hh:197
bool is_zero() const
Whether the expression is a single coefficient node with 0 value.
Definition apxx_texpr0.hh:167
void substitute(ap_dim_t dim, const texpr0 &dst)
Substitutes each occurrence of dim with (a fresh copy of) dst.
Definition apxx_texpr0.hh:231
void print(char **name_of_dim=NULL, FILE *stream=stdout) const
Prints to a C stream.
Definition apxx_texpr0.hh:158
void remove_dimensions(const dimchange &d)
Removes some dimensions, shifting dimension if needed.
Definition apxx_texpr0.hh:279
Level 1 arbitrary expression tree (ap_texpr1_t wrapper).
Definition apxx_texpr1.hh:42
Variable name (ap_var_t wrapper).
Definition apxx_var.hh:39
Definition apxx_abstract0.hh:27
bool is_unop(ap_texpr_op_t op)
Whether the operator is unary.
Definition apxx_texpr0.hh:33
bool is_binop(ap_texpr_op_t op)
Whether the operator is binary.
Definition apxx_texpr0.hh:38
texpr0::builder add(const texpr0::builder &a, const texpr0::builder &b, ap_texpr_rtype_t rtype=AP_RTYPE_REAL, ap_texpr_rdir_t rdir=AP_RDIR_NEAREST)
Definition apxx_texpr0.hh:772
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