1 /* Polyhedron class implementation (non-inline template operators that
2 may change the dimension of the vector space).
3 Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
4 Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
5
6 This file is part of the Parma Polyhedra Library (PPL).
7
8 The PPL is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12
13 The PPL is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software Foundation,
20 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
21
22 For the most up-to-date information see the Parma Polyhedra Library
23 site: http://bugseng.com/products/ppl/ . */
24
25 #ifndef PPL_Polyhedron_chdims_templates_hh
26 #define PPL_Polyhedron_chdims_templates_hh 1
27
28 namespace Parma_Polyhedra_Library {
29
30 template <typename Linear_System1, typename Linear_System2>
31 void
add_space_dimensions(Linear_System1 & sys1,Linear_System2 & sys2,Bit_Matrix & sat1,Bit_Matrix & sat2,dimension_type add_dim)32 Polyhedron::add_space_dimensions(Linear_System1& sys1,
33 Linear_System2& sys2,
34 Bit_Matrix& sat1,
35 Bit_Matrix& sat2,
36 dimension_type add_dim) {
37 PPL_ASSERT(sys1.topology() == sys2.topology());
38 PPL_ASSERT(sys1.space_dimension() == sys2.space_dimension());
39 PPL_ASSERT(add_dim != 0);
40
41 sys1.set_space_dimension(sys1.space_dimension() + add_dim);
42 sys2.add_universe_rows_and_space_dimensions(add_dim);
43
44 // The resulting saturation matrix will be as follows:
45 // from row 0 to add_dim-1 : only zeroes
46 // add_dim add_dim+num_rows-1 : old saturation matrix
47
48 // In fact all the old generators saturate all the new constraints
49 // because the polyhedron has not been embedded in the new space.
50 sat1.resize(sat1.num_rows() + add_dim, sat1.num_columns());
51 // The old matrix is moved to the end of the new matrix.
52 for (dimension_type i = sat1.num_rows() - add_dim; i-- > 0; ) {
53 swap(sat1[i], sat1[i+add_dim]);
54 }
55 // Computes the "sat_c", too.
56 sat2.transpose_assign(sat1);
57 }
58
59 } // namespace Parma_Polyhedra_Library
60
61 #endif // !defined(PPL_Polyhedron_chdims_templates_hh)
62