PPL  1.2
Scalar_Products.cc
Go to the documentation of this file.
1 /* Scalar_Products 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 "Scalar_Products_defs.hh"
27 #include "Coefficient_defs.hh"
28 
29 namespace PPL = Parma_Polyhedra_Library;
30 
31 void
33  const Linear_Expression& x,
34  const Linear_Expression& y) {
35  x.scalar_product_assign(z, y);
36 }
37 
38 void
40  const Constraint& c, const Generator& g) {
41  assign(z, c.expr, g.expr);
42 }
43 
44 void
46  const Generator& g, const Constraint& c) {
47  assign(z, g.expr, c.expr);
48 }
49 
50 void
52  const Grid_Generator& gg, const Congruence& cg) {
53  gg.expr.scalar_product_assign(z, cg.expr, 0, gg.space_dimension() + 1);
54 }
55 
56 void
58  const Constraint& c,
59  const Grid_Generator& gg) {
60  assign(z, c.expr, gg.expr);
61 }
62 
63 void
65  const Congruence& cg, const Grid_Generator& gg) {
66  // Scalar product is only defined if `cg' and `gg' are
67  // dimension-compatible.
68  PPL_ASSERT(cg.space_dimension() <= gg.space_dimension());
70 }
71 
72 void
74  const Linear_Expression& x,
75  const Linear_Expression& y) {
76  // The reduced scalar product is only defined
77  // if `y' has enough coefficients.
78  PPL_ASSERT(x.space_dimension() - 1 <= y.space_dimension());
79  x.scalar_product_assign(z, y, 0, x.space_dimension());
80 }
81 
82 void
84  const Grid_Generator& gg,
85  const Congruence& cg) {
86  // The reduced scalar product is only defined
87  // if `cg' has enough coefficients.
88  PPL_ASSERT(gg.space_dimension() <= cg.space_dimension());
90 }
91 
92 void
94  const Linear_Expression& x,
95  const Linear_Expression& y) {
96  // Scalar product is only defined if `x' and `y' are
97  // dimension-compatible.
98  PPL_ASSERT(x.space_dimension() <= y.space_dimension());
99  x.scalar_product_assign(z, y, 1, x.space_dimension() + 1);
100 }
101 
102 void
104  const Grid_Generator& gg,
105  const Congruence& cg) {
106  // Scalar product is only defined if `gg' and `cg' are
107  // dimension-compatible.
108  PPL_ASSERT(gg.space_dimension() <= cg.space_dimension());
109  gg.expr.scalar_product_assign(z, cg.expr, 1, gg.space_dimension() + 1);
110 }
111 
112 void
114  const Grid_Generator& gg,
115  const Constraint& c) {
116  // Scalar product is only defined if `gg' and `c' are
117  // dimension-compatible.
118  PPL_ASSERT(gg.space_dimension() <= c.space_dimension());
119  gg.expr.scalar_product_assign(z, c.expr, 1, gg.space_dimension() + 1);
120 }
A linear equality or inequality.
A line, ray, point or closure point.
Linear_Expression expr
The linear expression encoding *this.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
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.
Result assign(Boundary_Type to_type, To &to, To_Info &to_info, Boundary_Type type, const T &x, const Info &info, bool should_shrink=false)
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
The entire library is confined to this namespace.
Definition: version.hh:61
dimension_type space_dimension() const
Returns the dimension of the vector space enclosing *this.
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 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
void scalar_product_assign(Coefficient &result, const Linear_Expression &y) const
Sets results to the sum of (*this)[i]*y[i], for each i.
A grid line, parameter or grid point.