PPL  1.2
Scalar_Products_inlines.hh
Go to the documentation of this file.
1 /* Scalar_Products 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_Scalar_Products_inlines_hh
25 #define PPL_Scalar_Products_inlines_hh 1
26 
28 #include "Constraint_defs.hh"
29 #include "Generator_defs.hh"
30 #include "Congruence_defs.hh"
31 #include "Grid_Generator_defs.hh"
32 
33 namespace Parma_Polyhedra_Library {
34 
35 inline int
38  assign(z, x, y);
39  return sgn(z);
40 }
41 
42 inline int
44  const Linear_Expression& y) {
46  reduced_assign(z, x, y);
47  return sgn(z);
48 }
49 
50 inline int
52  const Linear_Expression& y) {
54  homogeneous_assign(z, x, y);
55  return sgn(z);
56 }
57 
58 inline int
60  return sign(c.expr, g.expr);
61 }
62 
63 inline int
65  return sign(g.expr, c.expr);
66 }
67 
68 inline int
71  assign(z, c, g);
72  return sgn(z);
73 }
74 
75 inline int
77  // The reduced scalar product is only defined if the topology of `c' is
78  // NNC.
79  PPL_ASSERT(!c.is_necessarily_closed());
80  return reduced_sign(c.expr, g.expr);
81 }
82 
83 inline int
85  // The reduced scalar product is only defined if the topology of `g' is
86  // NNC.
87  PPL_ASSERT(!c.is_necessarily_closed());
88  return reduced_sign(g.expr, c.expr);
89 }
90 
91 inline void
93  const Linear_Expression& e,
94  const Generator& g) {
95  homogeneous_assign(z, e, g.expr);
96 }
97 
98 inline void
100  const Linear_Expression& e,
101  const Grid_Generator& g) {
102  homogeneous_assign(z, e, g.expr);
103 }
104 
105 inline int
107  const Generator& g) {
108  return homogeneous_sign(e, g.expr);
109 }
110 
111 inline int
113  const Grid_Generator& g) {
114  return homogeneous_sign(e, g.expr);
115 }
116 
117 inline int
119  const Constraint& c) {
121  homogeneous_assign(z, g, c);
122  return sgn(z);
123 }
124 
125 inline
128  : sps_fp(c.is_necessarily_closed()
129  ? static_cast<SPS_type>(&Scalar_Products::sign)
130  : static_cast<SPS_type>(&Scalar_Products::reduced_sign)) {
131 }
132 
133 inline
136  : sps_fp(g.is_necessarily_closed()
137  ? static_cast<SPS_type>(&Scalar_Products::sign)
138  : static_cast<SPS_type>(&Scalar_Products::reduced_sign)) {
139 }
140 
141 inline int
143  const Generator& g) const {
144  PPL_ASSERT(c.space_dimension() <= g.space_dimension());
145  PPL_ASSERT(sps_fp == (c.is_necessarily_closed()
146  ? static_cast<SPS_type>(&Scalar_Products::sign)
147  : static_cast<SPS_type>(&Scalar_Products::reduced_sign)));
148  return sps_fp(c.expr, g.expr);
149 }
150 
151 inline int
153  const Constraint& c) const {
154  PPL_ASSERT(g.space_dimension() <= c.space_dimension());
155  PPL_ASSERT(sps_fp == (g.is_necessarily_closed()
156  ? static_cast<SPS_type>(&Scalar_Products::sign)
157  : static_cast<SPS_type>(&Scalar_Products::reduced_sign)));
158  return sps_fp(g.expr, c.expr);
159 }
160 
161 } // namespace Parma_Polyhedra_Library
162 
163 #endif // !defined(PPL_Scalar_Products_inlines_hh)
static int homogeneous_sign(const Linear_Expression &x, const Linear_Expression &y)
Returns the sign of the homogeneous scalar product of x and y, where the inhomogeneous terms are igno...
A linear equality or inequality.
int(*const SPS_type)(const Linear_Expression &, const Linear_Expression &)
The type of the scalar product sign function pointer.
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
int operator()(const Constraint &, const Generator &) const
Computes the (topology adjusted) scalar product sign of c and g.
A line, ray, point or closure point.
Linear_Expression expr
The linear expression encoding *this.
#define PPL_DIRTY_TEMP_COEFFICIENT(id)
Declare a local variable named id, of type Coefficient, and containing an unknown initial value...
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
static void reduced_assign(Coefficient &z, const Linear_Expression &x, const Linear_Expression &y)
Computes the reduced scalar product of x and y, where the coefficient of x is ignored, and assigns the result to z.
Topology_Adjusted_Scalar_Product_Sign(const Constraint &c)
Constructs the function object according to the topology of c.
static int reduced_sign(const Linear_Expression &x, const Linear_Expression &y)
Returns the sign of the reduced scalar product of x and y, where the coefficient of x is ignored...
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
The entire library is confined to this namespace.
Definition: version.hh:61
int sgn(Boundary_Type type, const T &x, const Info &info)
static void homogeneous_assign(Coefficient &z, const Linear_Expression &x, const Linear_Expression &y)
Computes the homogeneous scalar product of x and y, where the inhomogeneous terms are ignored...
static int sign(const Linear_Expression &x, const Linear_Expression &y)
Returns the sign of the scalar product between x and y.
bool is_necessarily_closed() const
Returns true if and only if the topology of *this row is necessarily closed.
static void assign(Coefficient &z, const Linear_Expression &x, const Linear_Expression &y)
Computes the scalar product of x and y and assigns it to z.
Coefficient c
Definition: PIP_Tree.cc:64
SPS_type sps_fp
The scalar product sign function pointer.
A grid line, parameter or grid point.
A class implementing various scalar product functions.