1 /* GMP_Integer class declaration.
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_GMP_Integer_defs_hh
25 #define PPL_GMP_Integer_defs_hh 1
26 
27 #include "GMP_Integer_types.hh"
28 #include "globals_types.hh"
29 #include <cstddef>
30 
31 namespace Parma_Polyhedra_Library {
32 
33 //! \name Accessor Functions
34 //@{
35 
36 //! Returns a const reference to the underlying integer value.
37 /*! \relates GMP_Integer */
38 const mpz_class& raw_value(const GMP_Integer& x);
39 
40 //! Returns a reference to the underlying integer value.
41 /*! \relates GMP_Integer */
42 mpz_class& raw_value(GMP_Integer& x);
43 
44 //@} // Accessor Functions
45 
46 //! \name Arithmetic Operators
47 //@{
48 
49 //! Assigns to \p x its negation.
50 /*! \relates GMP_Integer */
51 void neg_assign(GMP_Integer& x);
52 
53 //! Assigns to \p x the negation of \p y.
54 /*! \relates GMP_Integer */
55 void neg_assign(GMP_Integer& x, const GMP_Integer& y);
56 
57 //! Assigns to \p x its absolute value.
58 /*! \relates GMP_Integer */
59 void abs_assign(GMP_Integer& x);
60 
61 //! Assigns to \p x the absolute value of \p y.
62 /*! \relates GMP_Integer */
63 void abs_assign(GMP_Integer& x, const GMP_Integer& y);
64 
65 //! Assigns to \p x the remainder of the division of \p y by \p z.
66 /*! \relates GMP_Integer */
67 void rem_assign(GMP_Integer& x,
68                 const GMP_Integer& y, const GMP_Integer& z);
69 
70 //! Assigns to \p x the greatest common divisor of \p y and \p z.
71 /*! \relates GMP_Integer */
72 void gcd_assign(GMP_Integer& x,
73                 const GMP_Integer& y, const GMP_Integer& z);
74 
75 //! Extended GCD.
76 /*! \relates GMP_Integer
77   Assigns to \p x the greatest common divisor of \p y and \p z, and to
78   \p s and \p t the values such that \p y * \p s + \p z * \p t = \p x.
79 */
80 void gcdext_assign(GMP_Integer& x, GMP_Integer& s, GMP_Integer& t,
81                    const GMP_Integer& y, const GMP_Integer& z);
82 
83 //! Assigns to \p x the least common multiple of \p y and \p z.
84 /*! \relates GMP_Integer */
85 void lcm_assign(GMP_Integer& x,
86                 const GMP_Integer& y, const GMP_Integer& z);
87 
88 //! Assigns to \p x the value <CODE>x + y * z</CODE>.
89 /*! \relates GMP_Integer */
90 void add_mul_assign(GMP_Integer& x,
91                     const GMP_Integer& y, const GMP_Integer& z);
92 
93 //! Assigns to \p x the value <CODE>x - y * z</CODE>.
94 /*! \relates GMP_Integer */
95 void sub_mul_assign(GMP_Integer& x,
96                     const GMP_Integer& y, const GMP_Integer& z);
97 
98 //! Assigns to \p x the value \f$ y \cdot 2^\mathtt{exp} \f$.
99 /*! \relates GMP_Integer */
100 void mul_2exp_assign(GMP_Integer& x, const GMP_Integer& y, unsigned int exp);
101 
102 //! Assigns to \p x the value \f$ y / 2^\mathtt{exp} \f$.
103 /*! \relates GMP_Integer */
104 void div_2exp_assign(GMP_Integer& x, const GMP_Integer& y, unsigned int exp);
105 
106 /*! \brief
107   If \p z divides \p y, assigns to \p x the quotient of the integer
108   division of \p y and \p z.
109 
110   \relates GMP_Integer
111   The behavior is undefined if \p z does not divide \p y.
112 */
113 void exact_div_assign(GMP_Integer& x,
114                       const GMP_Integer& y, const GMP_Integer& z);
115 
116 //! Assigns to \p x the integer square root of \p y.
117 /*! \relates GMP_Integer */
118 void sqrt_assign(GMP_Integer& x, const GMP_Integer& y);
119 
120 /*! \brief
121   Returns a negative, zero or positive value depending on whether
122   \p x is lower than, equal to or greater than \p y, respectively.
123 
124   \relates GMP_Integer
125 */
126 int cmp(const GMP_Integer& x, const GMP_Integer& y);
127 
128 //@} // Arithmetic Operators
129 
130 } // namespace Parma_Polyhedra_Library
131 
132 #include "GMP_Integer_inlines.hh"
133 
134 #endif // !defined(PPL_GMP_Integer_defs_hh)
135