malachite-base 0.14.0

A collection of utilities, including new arithmetic traits and iterators that generate all values of a type.
Documentation
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
// 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 [`CanonicalPrimitivePart`](
/// crate::num::arithmetic::traits::CanonicalPrimitivePart), [`CanonicalPrimitivePartAssign`](
/// crate::num::arithmetic::traits::CanonicalPrimitivePartAssign), and
/// [`ContentAndCanonicalPrimitivePart`](
/// crate::num::arithmetic::traits::ContentAndCanonicalPrimitivePart), which, for a vector with
/// non-negative elements, are the same as the primitive part.
pub mod canonical_primitive_part;
/// Implementations of [`Content`](crate::num::arithmetic::traits::Content),
/// [`PrimitivePart`](crate::num::arithmetic::traits::PrimitivePart),
/// [`PrimitivePartAssign`](crate::num::arithmetic::traits::PrimitivePartAssign), and
/// [`ContentAndPrimitivePart`](crate::num::arithmetic::traits::ContentAndPrimitivePart), which
/// compute the GCD of a vector's elements and the vector divided by it.
pub mod content;
/// Implementations of [`ContentChained`](crate::num::arithmetic::traits::ContentChained), which
/// computes the GCD of a number and a vector's elements.
pub mod content_chained;
/// Exact division of a vector by a scalar, by implementations of
/// [`DivExact`](crate::num::arithmetic::traits::DivExact) and
/// [`DivExactAssign`](crate::num::arithmetic::traits::DivExactAssign).
///
/// # div_exact
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::DivExact;
/// use malachite_base::unsigned_vector::UnsignedVector;
///
/// assert_eq!(
///     UnsignedVector::<u8>::from_str("()")
///         .unwrap()
///         .div_exact(5)
///         .to_string(),
///     "()"
/// );
/// assert_eq!(
///     UnsignedVector::<u8>::from_str("(0, 6, 255)")
///         .unwrap()
///         .div_exact(1)
///         .to_string(),
///     "(0, 6, 255)"
/// );
/// assert_eq!(
///     (&UnsignedVector::<u8>::from_str("(0, 6, 255)").unwrap())
///         .div_exact(3)
///         .to_string(),
///     "(0, 2, 85)"
/// );
/// assert_eq!(
///     (&UnsignedVector::<u64>::from_str("(18446744073709551614, 4)").unwrap())
///         .div_exact(2)
///         .to_string(),
///     "(9223372036854775807, 2)"
/// );
/// ```
///
/// # div_exact_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::DivExactAssign;
/// use malachite_base::unsigned_vector::UnsignedVector;
///
/// let mut v = UnsignedVector::<u8>::from_str("(0, 6, 255)").unwrap();
/// v.div_exact_assign(3);
/// assert_eq!(v.to_string(), "(0, 2, 85)");
/// ```
pub mod div_exact;
/// Dividing every element of a vector by a scalar and rounding each quotient, by implementations of
/// [`EntrywiseDivRound`](crate::num::arithmetic::traits::EntrywiseDivRound) and
/// [`EntrywiseDivRoundAssign`](crate::num::arithmetic::traits::EntrywiseDivRoundAssign).
///
/// # entrywise_div_round
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::EntrywiseDivRound;
/// use malachite_base::rounding_modes::RoundingMode::*;
/// use malachite_base::unsigned_vector::UnsignedVector;
///
/// assert_eq!(
///     UnsignedVector::<u8>::from_str("(1, 2, 3, 5)")
///         .unwrap()
///         .entrywise_div_round(2u8, Floor)
///         .to_string(),
///     "(0, 1, 1, 2)"
/// );
/// assert_eq!(
///     (&UnsignedVector::<u8>::from_str("(1, 2, 3, 5)").unwrap())
///         .entrywise_div_round(2u8, Ceiling)
///         .to_string(),
///     "(1, 1, 2, 3)"
/// );
/// assert_eq!(
///     (&UnsignedVector::<u8>::from_str("(1, 2, 3, 5)").unwrap())
///         .entrywise_div_round(2u8, Nearest)
///         .to_string(),
///     "(0, 1, 2, 2)"
/// );
/// assert_eq!(
///     UnsignedVector::<u8>::from_str("(3, 6, 255)")
///         .unwrap()
///         .entrywise_div_round(3u8, Exact)
///         .to_string(),
///     "(1, 2, 85)"
/// );
/// ```
///
/// # entrywise_div_round_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::EntrywiseDivRoundAssign;
/// use malachite_base::rounding_modes::RoundingMode::*;
/// use malachite_base::unsigned_vector::UnsignedVector;
///
/// let mut v = UnsignedVector::<u8>::from_str("(1, 2, 3, 5)").unwrap();
/// v.entrywise_div_round_assign(2u8, Nearest);
/// assert_eq!(v.to_string(), "(0, 1, 2, 2)");
/// ```
pub mod entrywise_div_round;
/// Right-shifting a vector (dividing it by a power of 2) and rounding every element, by
/// implementations of [`EntrywiseShrRound`](crate::num::arithmetic::traits::EntrywiseShrRound) and
/// [`EntrywiseShrRoundAssign`](crate::num::arithmetic::traits::EntrywiseShrRoundAssign).
///
/// # entrywise_shr_round
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::EntrywiseShrRound;
/// use malachite_base::rounding_modes::RoundingMode::*;
/// use malachite_base::unsigned_vector::UnsignedVector;
///
/// let v = UnsignedVector::<u8>::from_str("(1, 2, 3, 5)").unwrap();
/// assert_eq!(
///     (&v).entrywise_shr_round(1u8, Floor).to_string(),
///     "(0, 1, 1, 2)"
/// );
/// assert_eq!(
///     (&v).entrywise_shr_round(1u16, Ceiling).to_string(),
///     "(1, 1, 2, 3)"
/// );
/// // Ties round to even.
/// assert_eq!(
///     (&v).entrywise_shr_round(1u32, Nearest).to_string(),
///     "(0, 1, 2, 2)"
/// );
/// assert_eq!(
///     UnsignedVector::<u8>::from_str("(4, 8, 12)")
///         .unwrap()
///         .entrywise_shr_round(2u64, Exact)
///         .to_string(),
///     "(1, 2, 3)"
/// );
/// // Shifting by at least the width rounds every element to 0 or 1.
/// assert_eq!(
///     UnsignedVector::<u8>::from_str("(255, 128, 127)")
///         .unwrap()
///         .entrywise_shr_round(8u8, Nearest)
///         .to_string(),
///     "(1, 0, 0)"
/// );
/// assert_eq!(
///     UnsignedVector::<u8>::from_str("(255, 1, 0)")
///         .unwrap()
///         .entrywise_shr_round(100u128, Ceiling)
///         .to_string(),
///     "(1, 1, 0)"
/// );
/// ```
///
/// # entrywise_shr_round_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::EntrywiseShrRoundAssign;
/// use malachite_base::rounding_modes::RoundingMode::*;
/// use malachite_base::unsigned_vector::UnsignedVector;
///
/// let mut v = UnsignedVector::<u8>::from_str("(1, 2, 3, 5)").unwrap();
/// v.entrywise_shr_round_assign(1u8, Nearest);
/// assert_eq!(v.to_string(), "(0, 1, 2, 2)");
///
/// let mut v = UnsignedVector::<u8>::from_str("(1, 2, 3, 5)").unwrap();
/// v.entrywise_shr_round_assign(1u32, Up);
/// assert_eq!(v.to_string(), "(1, 1, 2, 3)");
/// ```
pub mod entrywise_shr_round;
/// An implementation of [`Height`](crate::num::arithmetic::traits::Height), the largest height of
/// any element.
pub mod height;
/// Implementations of [`ModAbsSquared`](crate::num::arithmetic::traits::ModAbsSquared), the squared
/// norm of a vector modulo a number.
pub mod mod_abs_squared;
/// Implementations of [`ModAdd`](crate::num::arithmetic::traits::ModAdd) and
/// [`ModAddAssign`](crate::num::arithmetic::traits::ModAddAssign), for adding vectors modulo a
/// number.
pub mod mod_add;
/// Implementations of [`ModAddMul`](crate::num::arithmetic::traits::ModAddMul) and
/// [`ModAddMulAssign`](crate::num::arithmetic::traits::ModAddMulAssign), for adding a scalar
/// multiple of one vector to another modulo a number.
pub mod mod_add_mul;
/// Implementations of [`ModAddMulShl`](crate::num::arithmetic::traits::ModAddMulShl) and
/// [`ModAddMulShlAssign`](crate::num::arithmetic::traits::ModAddMulShlAssign), for adding a scalar
/// multiple of one vector, shifted left, to another modulo a number.
pub mod mod_add_mul_shl;
/// Implementations of [`ModDot`](crate::num::arithmetic::traits::ModDot), the dot product of two
/// vectors modulo a number, accumulating the sum before reducing it once.
pub mod mod_dot;
/// Implementations of [`ModElementProduct`](crate::num::arithmetic::traits::ModElementProduct), the
/// product of the elements modulo a number.
pub mod mod_element_product;
/// Implementations of [`ModElementSum`](crate::num::arithmetic::traits::ModElementSum), the sum of
/// the elements modulo a number.
pub mod mod_element_sum;
/// An implementation of [`ModIsReduced`](crate::num::arithmetic::traits::ModIsReduced), which
/// checks whether every element of a vector is less than a given modulus.
pub mod mod_is_reduced;
/// Implementations of [`ModMul`](crate::num::arithmetic::traits::ModMul) and
/// [`ModMulAssign`](crate::num::arithmetic::traits::ModMulAssign), for multiplying a vector by a
/// scalar modulo a number.
pub mod mod_mul;
/// Implementations of [`ModNeg`](crate::num::arithmetic::traits::ModNeg) and
/// [`ModNegAssign`](crate::num::arithmetic::traits::ModNegAssign), for negating a vector modulo a
/// number.
pub mod mod_neg;
/// Implementations of [`Mod`](crate::num::arithmetic::traits::Mod),
/// [`ModAssign`](crate::num::arithmetic::traits::ModAssign), [`Rem`](core::ops::Rem), and
/// [`RemAssign`](core::ops::RemAssign), traits for reducing every element of a vector modulo a
/// number.
pub mod mod_op;
/// Implementations of [`ModPowerOf2`](crate::num::arithmetic::traits::ModPowerOf2) and
/// [`ModPowerOf2Assign`](crate::num::arithmetic::traits::ModPowerOf2Assign), which reduce every
/// element of a vector modulo a power of 2.
pub mod mod_power_of_2;
/// Implementations of
/// [`ModPowerOf2AbsSquared`](crate::num::arithmetic::traits::ModPowerOf2AbsSquared), the squared
/// norm of a vector modulo a power of 2.
pub mod mod_power_of_2_abs_squared;
/// Implementations of [`ModPowerOf2Add`](crate::num::arithmetic::traits::ModPowerOf2Add) and
/// [`ModPowerOf2AddAssign`](crate::num::arithmetic::traits::ModPowerOf2AddAssign), for adding
/// vectors modulo a power of 2.
pub mod mod_power_of_2_add;
/// Implementations of [`ModPowerOf2AddMul`](crate::num::arithmetic::traits::ModPowerOf2AddMul) and
/// [`ModPowerOf2AddMulAssign`](crate::num::arithmetic::traits::ModPowerOf2AddMulAssign), for adding
/// a scalar multiple of one vector to another modulo a power of 2.
pub mod mod_power_of_2_add_mul;
/// Implementations of
/// [`ModPowerOf2AddMulShl`](crate::num::arithmetic::traits::ModPowerOf2AddMulShl) and
/// [`ModPowerOf2AddMulShlAssign`](crate::num::arithmetic::traits::ModPowerOf2AddMulShlAssign), for
/// adding a scalar multiple of one vector, shifted left, to another modulo a power of 2.
pub mod mod_power_of_2_add_mul_shl;
/// Implementations of [`ModPowerOf2Dot`](crate::num::arithmetic::traits::ModPowerOf2Dot), the dot
/// product of two vectors modulo a power of 2.
pub mod mod_power_of_2_dot;
/// An implementation of
/// [`ModPowerOf2ElementProduct`](crate::num::arithmetic::traits::ModPowerOf2ElementProduct), the
/// product of the elements modulo a power of 2.
pub mod mod_power_of_2_element_product;
/// An implementation of
/// [`ModPowerOf2ElementSum`](crate::num::arithmetic::traits::ModPowerOf2ElementSum), the sum of the
/// elements modulo a power of 2.
pub mod mod_power_of_2_element_sum;
/// An implementation of
/// [`ModPowerOf2IsReduced`](crate::num::arithmetic::traits::ModPowerOf2IsReduced), which checks
/// whether every element of a vector is less than a given power of 2.
pub mod mod_power_of_2_is_reduced;
/// Implementations of [`ModPowerOf2Mul`](crate::num::arithmetic::traits::ModPowerOf2Mul) and
/// [`ModPowerOf2MulAssign`](crate::num::arithmetic::traits::ModPowerOf2MulAssign), for multiplying
/// a vector by a scalar modulo a power of 2.
pub mod mod_power_of_2_mul;
/// Implementations of [`ModPowerOf2Neg`](crate::num::arithmetic::traits::ModPowerOf2Neg) and
/// [`ModPowerOf2NegAssign`](crate::num::arithmetic::traits::ModPowerOf2NegAssign), for negating a
/// vector modulo a power of 2.
pub mod mod_power_of_2_neg;
/// Implementations of [`ModPowerOf2Shl`](crate::num::arithmetic::traits::ModPowerOf2Shl) and
/// [`ModPowerOf2ShlAssign`](crate::num::arithmetic::traits::ModPowerOf2ShlAssign), for
/// left-shifting a vector (multiplying it by a power of 2) modulo another power of 2.
///
/// # mod_power_of_2_shl
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::ModPowerOf2Shl;
/// use malachite_base::unsigned_vector::UnsignedVector;
///
/// let v = UnsignedVector::<u8>::from_str("(5, 1, 3)").unwrap();
/// assert_eq!(
///     v.clone().mod_power_of_2_shl(1u8, 3).to_string(),
///     "(2, 2, 6)"
/// );
/// // Shifting by at least the power zeroes every element, keeping the dimension.
/// assert_eq!(v.mod_power_of_2_shl(3u32, 3).to_string(), "(0, 0, 0)");
/// assert_eq!(
///     (&UnsignedVector::<u8>::from_str("(1, 128, 1)").unwrap())
///         .mod_power_of_2_shl(1u64, 8)
///         .to_string(),
///     "(2, 0, 2)"
/// );
/// assert_eq!(
///     (&UnsignedVector::<u64>::from_str("(1, 1)").unwrap())
///         .mod_power_of_2_shl(63u128, 64)
///         .to_string(),
///     "(9223372036854775808, 9223372036854775808)"
/// );
/// ```
///
/// # mod_power_of_2_shl_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::ModPowerOf2ShlAssign;
/// use malachite_base::unsigned_vector::UnsignedVector;
///
/// let mut v = UnsignedVector::<u8>::from_str("(5, 1, 3)").unwrap();
/// v.mod_power_of_2_shl_assign(1u8, 3);
/// assert_eq!(v.to_string(), "(2, 2, 6)");
///
/// let mut v = UnsignedVector::<u8>::from_str("(5, 1, 3)").unwrap();
/// v.mod_power_of_2_shl_assign(3u32, 3);
/// assert_eq!(v.to_string(), "(0, 0, 0)");
/// ```
pub mod mod_power_of_2_shl;
/// Implementations of [`ModPowerOf2Sub`](crate::num::arithmetic::traits::ModPowerOf2Sub) and
/// [`ModPowerOf2SubAssign`](crate::num::arithmetic::traits::ModPowerOf2SubAssign), for subtracting
/// vectors modulo a power of 2.
pub mod mod_power_of_2_sub;
/// Implementations of [`ModPowerOf2SubMul`](crate::num::arithmetic::traits::ModPowerOf2SubMul) and
/// [`ModPowerOf2SubMulAssign`](crate::num::arithmetic::traits::ModPowerOf2SubMulAssign), for
/// subtracting a scalar multiple of one vector from another modulo a power of 2.
pub mod mod_power_of_2_sub_mul;
/// Implementations of
/// [`ModPowerOf2SubMulShl`](crate::num::arithmetic::traits::ModPowerOf2SubMulShl) and
/// [`ModPowerOf2SubMulShlAssign`](crate::num::arithmetic::traits::ModPowerOf2SubMulShlAssign), for
/// subtracting a scalar multiple of one vector, shifted left, from another modulo a power of 2.
pub mod mod_power_of_2_sub_mul_shl;
/// Implementations of [`ModPowerOf2Sum`](crate::num::arithmetic::traits::ModPowerOf2Sum), for
/// adding up vectors entry by entry modulo a power of 2.
pub mod mod_power_of_2_sum;
/// Implementations of [`ModShl`](crate::num::arithmetic::traits::ModShl) and
/// [`ModShlAssign`](crate::num::arithmetic::traits::ModShlAssign), for left-shifting a vector
/// (multiplying it by a power of 2) modulo a number.
///
/// # mod_shl
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::ModShl;
/// use malachite_base::unsigned_vector::UnsignedVector;
///
/// let v = UnsignedVector::<u8>::from_str("(5, 1, 3)").unwrap();
/// assert_eq!(v.clone().mod_shl(1u8, 7).to_string(), "(3, 2, 6)");
/// // The modulus need not be odd, so elements can become zero, keeping the dimension.
/// assert_eq!(v.mod_shl(3u32, 8).to_string(), "(0, 0, 0)");
/// assert_eq!(
///     (&UnsignedVector::<u8>::from_str("(1, 2)").unwrap())
///         .mod_shl(8u64, 255)
///         .to_string(),
///     "(1, 2)"
/// );
/// ```
///
/// # mod_shl_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::ModShlAssign;
/// use malachite_base::unsigned_vector::UnsignedVector;
///
/// let mut v = UnsignedVector::<u8>::from_str("(5, 1, 3)").unwrap();
/// v.mod_shl_assign(1u8, 7);
/// assert_eq!(v.to_string(), "(3, 2, 6)");
/// ```
pub mod mod_shl;
/// Implementations of [`ModSub`](crate::num::arithmetic::traits::ModSub) and
/// [`ModSubAssign`](crate::num::arithmetic::traits::ModSubAssign), for subtracting vectors modulo a
/// number.
pub mod mod_sub;
/// Implementations of [`ModSubMul`](crate::num::arithmetic::traits::ModSubMul) and
/// [`ModSubMulAssign`](crate::num::arithmetic::traits::ModSubMulAssign), for subtracting a scalar
/// multiple of one vector from another modulo a number.
pub mod mod_sub_mul;
/// Implementations of [`ModSubMulShl`](crate::num::arithmetic::traits::ModSubMulShl) and
/// [`ModSubMulShlAssign`](crate::num::arithmetic::traits::ModSubMulShlAssign), for subtracting a
/// scalar multiple of one vector, shifted left, from another modulo a number.
pub mod mod_sub_mul_shl;
/// Implementations of [`ModSum`](crate::num::arithmetic::traits::ModSum), for adding up vectors
/// entry by entry modulo a number.
pub mod mod_sum;
/// Implementations of [`Div`](core::ops::Div) and [`DivAssign`](core::ops::DivAssign), for dividing
/// a vector by a scalar.
///
/// # div
/// ```
/// use core::str::FromStr;
/// use malachite_base::unsigned_vector::UnsignedVector;
///
/// assert_eq!(
///     (UnsignedVector::<u8>::from_str("()").unwrap() / 5u8).to_string(),
///     "()"
/// );
/// assert_eq!(
///     (UnsignedVector::<u8>::from_str("(0, 7, 255)").unwrap() / 1u8).to_string(),
///     "(0, 7, 255)"
/// );
/// assert_eq!(
///     (&UnsignedVector::<u8>::from_str("(0, 7, 255)").unwrap() / 2u8).to_string(),
///     "(0, 3, 127)"
/// );
/// assert_eq!(
///     (&UnsignedVector::<u8>::from_str("(0, 7, 255)").unwrap() / 255u8).to_string(),
///     "(0, 0, 1)"
/// );
/// ```
///
/// # div_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::unsigned_vector::UnsignedVector;
///
/// let mut v = UnsignedVector::<u8>::from_str("(0, 7, 255)").unwrap();
/// v /= 2u8;
/// assert_eq!(v.to_string(), "(0, 3, 127)");
/// ```
pub mod scalar_div;
/// Right-shifting a vector (dividing it by a power of 2 and taking the floor), by implementations
/// of [`Shr`](core::ops::Shr) and [`ShrAssign`](core::ops::ShrAssign).
///
/// # shr
/// ```
/// use core::str::FromStr;
/// use malachite_base::unsigned_vector::UnsignedVector;
///
/// assert_eq!(
///     (UnsignedVector::<u8>::from_str("()").unwrap() >> 10u8).to_string(),
///     "()"
/// );
/// assert_eq!(
///     (UnsignedVector::<u8>::from_str("(1, 2, 3, 5)").unwrap() >> 0u16).to_string(),
///     "(1, 2, 3, 5)"
/// );
/// assert_eq!(
///     (UnsignedVector::<u8>::from_str("(1, 2, 3, 5)").unwrap() >> 1u32).to_string(),
///     "(0, 1, 1, 2)"
/// );
/// assert_eq!(
///     (&UnsignedVector::<u8>::from_str("(255, 128)").unwrap() >> 7u64).to_string(),
///     "(1, 1)"
/// );
/// // Shifting by at least the width zeroes every element, keeping the dimension.
/// assert_eq!(
///     (&UnsignedVector::<u8>::from_str("(255, 128)").unwrap() >> 8u128).to_string(),
///     "(0, 0)"
/// );
/// assert_eq!(
///     (UnsignedVector::<u64>::from_str("(18446744073709551615, 1)").unwrap() >> 63usize)
///         .to_string(),
///     "(1, 0)"
/// );
/// ```
///
/// # shr_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::unsigned_vector::UnsignedVector;
///
/// let mut v = UnsignedVector::<u8>::from_str("(1, 2, 3, 5)").unwrap();
/// v >>= 1u8;
/// assert_eq!(v.to_string(), "(0, 1, 1, 2)");
///
/// let mut v = UnsignedVector::<u8>::from_str("(255, 128)").unwrap();
/// v >>= 200u32;
/// assert_eq!(v.to_string(), "(0, 0)");
/// ```
pub mod shr;