1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
/* Scalar_Products class implementation (inline functions).
Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
This file is part of the Parma Polyhedra Library (PPL).
The PPL is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3 of the License, or (at your
option) any later version.
The PPL is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
For the most up-to-date information see the Parma Polyhedra Library
site: http://bugseng.com/products/ppl/ . */
#ifndef PPL_Scalar_Products_inlines_hh
#define PPL_Scalar_Products_inlines_hh 1
#include "Linear_Expression_defs.hh"
#include "Constraint_defs.hh"
#include "Generator_defs.hh"
#include "Congruence_defs.hh"
#include "Grid_Generator_defs.hh"
namespace Parma_Polyhedra_Library {
inline int
Scalar_Products::sign(const Linear_Expression& x, const Linear_Expression& y) {
PPL_DIRTY_TEMP_COEFFICIENT(z);
assign(z, x, y);
return sgn(z);
}
inline int
Scalar_Products::reduced_sign(const Linear_Expression& x,
const Linear_Expression& y) {
PPL_DIRTY_TEMP_COEFFICIENT(z);
reduced_assign(z, x, y);
return sgn(z);
}
inline int
Scalar_Products::homogeneous_sign(const Linear_Expression& x,
const Linear_Expression& y) {
PPL_DIRTY_TEMP_COEFFICIENT(z);
homogeneous_assign(z, x, y);
return sgn(z);
}
inline int
Scalar_Products::sign(const Constraint& c, const Generator& g) {
return sign(c.expr, g.expr);
}
inline int
Scalar_Products::sign(const Generator& g, const Constraint& c) {
return sign(g.expr, c.expr);
}
inline int
Scalar_Products::sign(const Constraint& c, const Grid_Generator& g) {
PPL_DIRTY_TEMP_COEFFICIENT(z);
assign(z, c, g);
return sgn(z);
}
inline int
Scalar_Products::reduced_sign(const Constraint& c, const Generator& g) {
// The reduced scalar product is only defined if the topology of `c' is
// NNC.
PPL_ASSERT(!c.is_necessarily_closed());
return reduced_sign(c.expr, g.expr);
}
inline int
Scalar_Products::reduced_sign(const Generator& g, const Constraint& c) {
// The reduced scalar product is only defined if the topology of `g' is
// NNC.
PPL_ASSERT(!c.is_necessarily_closed());
return reduced_sign(g.expr, c.expr);
}
inline void
Scalar_Products::homogeneous_assign(Coefficient& z,
const Linear_Expression& e,
const Generator& g) {
homogeneous_assign(z, e, g.expr);
}
inline void
Scalar_Products::homogeneous_assign(Coefficient& z,
const Linear_Expression& e,
const Grid_Generator& g) {
homogeneous_assign(z, e, g.expr);
}
inline int
Scalar_Products::homogeneous_sign(const Linear_Expression& e,
const Generator& g) {
return homogeneous_sign(e, g.expr);
}
inline int
Scalar_Products::homogeneous_sign(const Linear_Expression& e,
const Grid_Generator& g) {
return homogeneous_sign(e, g.expr);
}
inline int
Scalar_Products::homogeneous_sign(const Grid_Generator& g,
const Constraint& c) {
PPL_DIRTY_TEMP_COEFFICIENT(z);
homogeneous_assign(z, g, c);
return sgn(z);
}
inline
Topology_Adjusted_Scalar_Product_Sign
::Topology_Adjusted_Scalar_Product_Sign(const Constraint& c)
: sps_fp(c.is_necessarily_closed()
? static_cast<SPS_type>(&Scalar_Products::sign)
: static_cast<SPS_type>(&Scalar_Products::reduced_sign)) {
}
inline
Topology_Adjusted_Scalar_Product_Sign
::Topology_Adjusted_Scalar_Product_Sign(const Generator& g)
: sps_fp(g.is_necessarily_closed()
? static_cast<SPS_type>(&Scalar_Products::sign)
: static_cast<SPS_type>(&Scalar_Products::reduced_sign)) {
}
inline int
Topology_Adjusted_Scalar_Product_Sign::operator()(const Constraint& c,
const Generator& g) const {
PPL_ASSERT(c.space_dimension() <= g.space_dimension());
PPL_ASSERT(sps_fp == (c.is_necessarily_closed()
? static_cast<SPS_type>(&Scalar_Products::sign)
: static_cast<SPS_type>(&Scalar_Products::reduced_sign)));
return sps_fp(c.expr, g.expr);
}
inline int
Topology_Adjusted_Scalar_Product_Sign::operator()(const Generator& g,
const Constraint& c) const {
PPL_ASSERT(g.space_dimension() <= c.space_dimension());
PPL_ASSERT(sps_fp == (g.is_necessarily_closed()
? static_cast<SPS_type>(&Scalar_Products::sign)
: static_cast<SPS_type>(&Scalar_Products::reduced_sign)));
return sps_fp(g.expr, c.expr);
}
} // namespace Parma_Polyhedra_Library
#endif // !defined(PPL_Scalar_Products_inlines_hh)
|