PPL  1.2
math_utilities_defs.hh
Go to the documentation of this file.
1 /* Declarations of some math utility 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_math_utilities_defs_hh
25 #define PPL_math_utilities_defs_hh 1
26 
27 #include "Coefficient_types.hh"
28 #include "Checked_Number_defs.hh"
29 #include <gmpxx.h>
30 
31 namespace Parma_Polyhedra_Library {
32 
33 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
34 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
36 template <typename T>
37 typename Enable_If<Is_Native_Or_Checked<T>::value, void>::type
38 numer_denom(const T& from,
39  Coefficient& numer, Coefficient& denom);
40 
41 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
42 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
44 template <typename T>
45 typename Enable_If<Is_Native_Or_Checked<T>::value, void>::type
46 div_round_up(T& to,
47  Coefficient_traits::const_reference x,
48  Coefficient_traits::const_reference y);
49 
50 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
51 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
53 template <typename N>
54 void
55 min_assign(N& x, const N& y);
56 
57 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
58 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
60 template <typename N>
61 void
62 max_assign(N& x, const N& y);
63 
64 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
65 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
67 template <typename T>
68 typename Enable_If<Is_Native_Or_Checked<T>::value, bool>::type
69 is_even(const T& x);
70 
71 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
72 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
74 template <typename T>
75 typename Enable_If<Is_Native_Or_Checked<T>::value, bool>::type
76 is_additive_inverse(const T& x, const T& y);
77 
78 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
79 
87 #endif
88 void
89 normalize2(Coefficient_traits::const_reference x,
90  Coefficient_traits::const_reference y,
91  Coefficient& n_x, Coefficient& n_y);
92 
93 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
94 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
96 bool
97 is_canonical(const mpq_class& x);
98 
99 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
100 #endif
102 template <typename T>
103 T
104 low_bits_mask(unsigned n);
105 
106 } // namespace Parma_Polyhedra_Library
107 
108 #include "math_utilities_inlines.hh"
109 
110 #endif // !defined(PPL_math_utilities_defs_hh)
Enable_If< Is_Native_Or_Checked< T >::value, void >::type numer_denom(const T &from, Coefficient &numer, Coefficient &denom)
Extract the numerator and denominator components of from.
void max_assign(N &x, const N &y)
Assigns to x the maximum between x and y.
T low_bits_mask(unsigned n)
Returns a mask for the lowest n bits,.
Enable_If< Is_Native_Or_Checked< T >::value, void >::type div_round_up(T &to, Coefficient_traits::const_reference x, Coefficient_traits::const_reference y)
Divides x by y into to, rounding the result towards plus infinity.
bool is_canonical(const mpq_class &x)
Returns true if and only if x is in canonical form.
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_even(const T &x)
Returns true if and only if x is an even number.
Coefficient value
Definition: PIP_Tree.cc:618
PPL_COEFFICIENT_TYPE Coefficient
An alias for easily naming the type of PPL coefficients.
Enable_If< Is_Native_Or_Checked< T >::value, bool >::type is_additive_inverse(const T &x, const T &y)
Returns true if and only if .
The entire library is confined to this namespace.
Definition: version.hh:61
void normalize2(Coefficient_traits::const_reference x, Coefficient_traits::const_reference y, Coefficient &n_x, Coefficient &n_y)
If is the GCD of x and y, the values of x and y divided by are assigned to n_x and n_y...
void min_assign(N &x, const N &y)
Assigns to x the minimum between x and y.