1 /* NNC_Polyhedron class implementation (non-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 #include "ppl-config.h"
25 #include "NNC_Polyhedron_defs.hh"
26 #include "C_Polyhedron_defs.hh"
27 #include "Grid_defs.hh"
28 #include "algorithms.hh"
29 
30 namespace PPL = Parma_Polyhedra_Library;
31 
NNC_Polyhedron(const C_Polyhedron & y,Complexity_Class)32 PPL::NNC_Polyhedron::NNC_Polyhedron(const C_Polyhedron& y, Complexity_Class)
33   : Polyhedron(NOT_NECESSARILY_CLOSED, y.space_dimension(), UNIVERSE) {
34   add_constraints(y.constraints());
35   PPL_ASSERT_HEAVY(OK());
36 }
37 
NNC_Polyhedron(const Congruence_System & cgs)38 PPL::NNC_Polyhedron::NNC_Polyhedron(const Congruence_System& cgs)
39   : Polyhedron(NOT_NECESSARILY_CLOSED,
40                check_space_dimension_overflow(cgs.space_dimension(),
41                                               NOT_NECESSARILY_CLOSED,
42                                               "NNC_Polyhedron(cgs)",
43                                               "the space dimension of cgs "
44                                               "exceeds the maximum allowed "
45                                               "space dimension"),
46                UNIVERSE) {
47   add_congruences(cgs);
48   PPL_ASSERT_HEAVY(OK());
49 }
50 
NNC_Polyhedron(Congruence_System & cgs,Recycle_Input)51 PPL::NNC_Polyhedron::NNC_Polyhedron(Congruence_System& cgs, Recycle_Input)
52   : Polyhedron(NOT_NECESSARILY_CLOSED,
53                check_space_dimension_overflow(cgs.space_dimension(),
54                                               NOT_NECESSARILY_CLOSED,
55                                               "NNC_Polyhedron(cgs, recycle)",
56                                               "the space dimension of cgs "
57                                               "exceeds the maximum allowed "
58                                               "space dimension"),
59                UNIVERSE) {
60   add_congruences(cgs);
61   PPL_ASSERT_HEAVY(OK());
62 }
63 
NNC_Polyhedron(const Grid & grid,Complexity_Class)64 PPL::NNC_Polyhedron::NNC_Polyhedron(const Grid& grid, Complexity_Class)
65   : Polyhedron(NOT_NECESSARILY_CLOSED,
66                check_space_dimension_overflow(grid.space_dimension(),
67                                               NOT_NECESSARILY_CLOSED,
68                                               "NNC_Polyhedron(grid)",
69                                               "the space dimension of grid "
70                                               "exceeds the maximum allowed "
71                                               "space dimension"),
72                UNIVERSE) {
73   add_constraints(grid.constraints());
74 }
75 
76 bool
poly_hull_assign_if_exact(const NNC_Polyhedron & y)77 PPL::NNC_Polyhedron::poly_hull_assign_if_exact(const NNC_Polyhedron& y) {
78 #define USE_BHZ09 1
79 #if USE_BHZ09 // [BagnaraHZ09]
80   // Dimension-compatibility check.
81   if (space_dimension() != y.space_dimension()) {
82     throw_dimension_incompatible("poly_hull_assign_if_exact(y)", "y", y);
83   }
84   return BHZ09_poly_hull_assign_if_exact(y);
85 #else // Old implementation.
86   return PPL::poly_hull_assign_if_exact(*this, y);
87 #endif
88 #undef USE_BHZ09
89 }
90