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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
// Copyright © 2026 Mikhail Hogrefe
//
// This file is part of Malachite.
//
// Malachite is free software: you can redistribute it and/or modify it under the terms of the GNU
// Lesser General Public License (LGPL) as published by the Free Software Foundation; either version
// 3 of the License, or (at your option) any later version. See <https://www.gnu.org/licenses/>.
/// Implementations of [`Add`](core::ops::Add) and [`AddAssign`](core::ops::AddAssign), for adding
/// two polynomials.
/// Implementations of [`AddTruncated`](malachite_base::polynomial::AddTruncated) and
/// [`AddTruncatedAssign`](malachite_base::polynomial::AddTruncatedAssign), for adding two
/// polynomials and keeping only their low coefficients.
/// Implementations of [`BalancedMod`](malachite_base::num::arithmetic::traits::BalancedMod) and
/// [`BalancedModAssign`](malachite_base::num::arithmetic::traits::BalancedModAssign), which reduce
/// every coefficient of a polynomial to the representative closest to zero.
/// Implementations of [`BitPack`](malachite_base::polynomial::BitPack), which packs a polynomial's
/// coefficients into fixed-width fields of a single integer.
/// Implementations of [`BitUnpack`](malachite_base::polynomial::BitUnpack), which unpacks a
/// polynomial from the fixed-width fields of a single number.
/// Implementations of
/// [`CanonicalizeUnit`](malachite_base::num::arithmetic::traits::CanonicalizeUnit) and
/// [`CanonicalizeUnitAssign`](malachite_base::num::arithmetic::traits::CanonicalizeUnitAssign),
/// which bring a polynomial into canonical unit form.
/// Implementations of [`ComposePowerOfX`](malachite_base::polynomial::ComposePowerOfX) and
/// [`ComposePowerOfXAssign`](malachite_base::polynomial::ComposePowerOfXAssign), for substituting a
/// power of the variable into a polynomial.
/// Implementations of [`Content`](malachite_base::polynomial::Content),
/// [`PrimitivePart`](malachite_base::polynomial::PrimitivePart),
/// [`PrimitivePartAssign`](malachite_base::polynomial::PrimitivePartAssign), and
/// [`ContentAndPrimitivePart`](malachite_base::polynomial::ContentAndPrimitivePart), which compute
/// the GCD of a polynomial's coefficients and the polynomial divided by it.
/// Implementations of [`DeflatePowerOfX`](malachite_base::polynomial::DeflatePowerOfX) and
/// [`DeflatePowerOfXAssign`](malachite_base::polynomial::DeflatePowerOfXAssign), for undoing the
/// substitution of a power of the variable into a polynomial.
/// Implementations of [`Derivative`](malachite_base::polynomial::Derivative) and
/// [`DerivativeAssign`](malachite_base::polynomial::DerivativeAssign), for differentiating a
/// polynomial.
/// Implementations of [`DivExact`](malachite_base::num::arithmetic::traits::DivExact) and
/// [`DivExactAssign`](malachite_base::num::arithmetic::traits::DivExactAssign), for dividing a
/// polynomial by an [`Integer`](crate::integer::Integer) that divides every coefficient.
/// Implementations of [`DivPowerOfX`](malachite_base::polynomial::DivPowerOfX) and
/// [`DivPowerOfXAssign`](malachite_base::polynomial::DivPowerOfXAssign), for dividing a polynomial
/// by a power of its variable and discarding the remainder.
/// Implementations of [`Evaluate`](malachite_base::polynomial::Evaluate), which evaluates a
/// polynomial at a value.
/// An implementation of [`ExponentGcd`](malachite_base::polynomial::ExponentGcd), the greatest
/// common divisor of the exponents at which a polynomial has nonzero coefficients.
/// An implementation of [`FloorL2Norm`](malachite_base::polynomial::FloorL2Norm), the floor of a
/// polynomial's $L^2$ norm.
/// Implementations of [`Height`](malachite_base::num::arithmetic::traits::Height) and
/// [`HeightRef`](malachite_base::num::arithmetic::traits::HeightRef), the largest of the magnitudes
/// of a polynomial's coefficients.
/// An implementation of [`IsUnit`](malachite_base::num::arithmetic::traits::IsUnit), a trait for
/// determining whether a number is a unit of its ring.
/// An implementation of [`L2NormSquared`](malachite_base::polynomial::L2NormSquared), the sum of
/// the squares of a polynomial's coefficients.
/// Implementations of [`Mod`](malachite_base::num::arithmetic::traits::Mod), which reduces every
/// coefficient of a polynomial into $[0, m)$, producing a
/// [`NaturalPolynomial`](crate::natural_polynomial::NaturalPolynomial) or an
/// [`UnsignedPolynomial`](malachite_base::unsigned_polynomial::UnsignedPolynomial), and of
/// [`Rem`](core::ops::Rem) and [`RemAssign`](core::ops::RemAssign), which keep each remainder's
/// sign.
/// Implementations of [`ModPowerOf2`](malachite_base::num::arithmetic::traits::ModPowerOf2), which
/// reduces every coefficient of a polynomial into $[0, 2^k)$, producing a
/// [`NaturalPolynomial`](crate::natural_polynomial::NaturalPolynomial), and of
/// [`RemPowerOf2`](malachite_base::num::arithmetic::traits::RemPowerOf2) and
/// [`RemPowerOf2Assign`](malachite_base::num::arithmetic::traits::RemPowerOf2Assign), which keep
/// each remainder's sign.
/// Implementations of [`Mul`](core::ops::Mul) and [`MulAssign`](core::ops::MulAssign), for
/// multiplying two polynomials.
/// Implementations of [`MulPowerOfX`](malachite_base::polynomial::MulPowerOfX) and
/// [`MulPowerOfXAssign`](malachite_base::polynomial::MulPowerOfXAssign), for multiplying a
/// polynomial by a power of its variable.
/// Implementations of [`MulTruncated`](malachite_base::polynomial::MulTruncated) and
/// [`MulTruncatedAssign`](malachite_base::polynomial::MulTruncatedAssign), for multiplying two
/// polynomials and keeping only the low coefficients of the product.
/// Implementations of [`Neg`](core::ops::Neg) and
/// [`NegAssign`](malachite_base::num::arithmetic::traits::NegAssign), for negating a polynomial.
/// Implementations of [`NthDerivative`](malachite_base::polynomial::NthDerivative) and
/// [`NthDerivativeAssign`](malachite_base::polynomial::NthDerivativeAssign), for differentiating a
/// polynomial any number of times.
/// Implementations of [`Pow`](malachite_base::num::arithmetic::traits::Pow) and
/// [`PowAssign`](malachite_base::num::arithmetic::traits::PowAssign), for raising a polynomial to a
/// power.
/// Implementations of [`PowTruncated`](malachite_base::polynomial::PowTruncated) and
/// [`PowTruncatedAssign`](malachite_base::polynomial::PowTruncatedAssign), for raising a polynomial
/// to a power and keeping only the low coefficients of the power.
/// Left-shifting an [`IntegerPolynomial`](super::IntegerPolynomial) (multiplying it by a power of
/// 2), by shifting every coefficient.
///
/// # shl
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::basic::traits::Zero;
/// use malachite_nz::integer_polynomial::IntegerPolynomial;
///
/// assert_eq!((IntegerPolynomial::ZERO << 10u8).to_string(), "0");
/// assert_eq!(
/// (IntegerPolynomial::from_str("x^2-3*x+5").unwrap() << 0u16).to_string(),
/// "x^2-3*x+5"
/// );
/// assert_eq!(
/// (IntegerPolynomial::from_str("x^2-3*x+5").unwrap() << 2u32).to_string(),
/// "4*x^2-12*x+20"
/// );
/// assert_eq!(
/// (IntegerPolynomial::from_str("x^2-3*x+5").unwrap() << 100u64).to_string(),
/// "1267650600228229401496703205376*x^2-3802951800684688204490109616128*x+\
/// 6338253001141147007483516026880"
/// );
///
/// assert_eq!((&IntegerPolynomial::ZERO << 10u8).to_string(), "0");
/// assert_eq!(
/// (&IntegerPolynomial::from_str("x^2-3*x+5").unwrap() << 0u16).to_string(),
/// "x^2-3*x+5"
/// );
/// assert_eq!(
/// (&IntegerPolynomial::from_str("x^2-3*x+5").unwrap() << 2u32).to_string(),
/// "4*x^2-12*x+20"
/// );
/// assert_eq!(
/// (&IntegerPolynomial::from_str("x^2-3*x+5").unwrap() << 100u64).to_string(),
/// "1267650600228229401496703205376*x^2-3802951800684688204490109616128*x+\
/// 6338253001141147007483516026880"
/// );
/// ```
///
/// # shl_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::basic::traits::Zero;
/// use malachite_nz::integer_polynomial::IntegerPolynomial;
///
/// let mut p = IntegerPolynomial::ZERO;
/// p <<= 10u8;
/// assert_eq!(p.to_string(), "0");
///
/// let mut p = IntegerPolynomial::from_str("x^2-3*x+5").unwrap();
/// p <<= 0u16;
/// assert_eq!(p.to_string(), "x^2-3*x+5");
///
/// let mut p = IntegerPolynomial::from_str("x^2-3*x+5").unwrap();
/// p <<= 2u32;
/// assert_eq!(p.to_string(), "4*x^2-12*x+20");
///
/// let mut p = IntegerPolynomial::from_str("x^2-3*x+5").unwrap();
/// p <<= 100u64;
/// assert_eq!(
/// p.to_string(),
/// "1267650600228229401496703205376*x^2-3802951800684688204490109616128*x+\
/// 6338253001141147007483516026880"
/// );
/// ```
/// Implementations of [`Square`](malachite_base::num::arithmetic::traits::Square) and
/// [`SquareAssign`](malachite_base::num::arithmetic::traits::SquareAssign), for squaring a
/// polynomial.
/// Implementations of [`SquareTruncated`](malachite_base::polynomial::SquareTruncated) and
/// [`SquareTruncatedAssign`](malachite_base::polynomial::SquareTruncatedAssign), for squaring a
/// polynomial and keeping only the low coefficients of the square.
/// Implementations of [`Sub`](core::ops::Sub) and [`SubAssign`](core::ops::SubAssign), for
/// subtracting one polynomial from another.
/// Implementations of [`SubTruncated`](malachite_base::polynomial::SubTruncated) and
/// [`SubTruncatedAssign`](malachite_base::polynomial::SubTruncatedAssign), for subtracting one
/// polynomial from another and keeping only their low coefficients.