malachite-nz 0.14.0

The bignum types Natural and Integer, with efficient algorithms partially derived from GMP and FLINT.
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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
// 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 [`AbsSquared`](malachite_base::num::arithmetic::traits::AbsSquared), the
/// squared norm of a vector: the sum of the squares of its elements.
pub mod abs_squared;
/// Implementations of [`Add`](core::ops::Add) and [`AddAssign`](core::ops::AddAssign), for adding
/// vectors.
pub mod add;
/// Adding a multiple of one vector to another, by implementations of
/// [`AddMul`](malachite_base::num::arithmetic::traits::AddMul) and
/// [`AddMulAssign`](malachite_base::num::arithmetic::traits::AddMulAssign).
///
/// # add_mul
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::AddMul;
/// use malachite_base::num::basic::traits::{One, Zero};
/// use malachite_nz::natural::Natural;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// assert_eq!(
///     NaturalVector::from_str("()")
///         .unwrap()
///         .add_mul(NaturalVector::from_str("()").unwrap(), Natural::from(5u32))
///         .to_string(),
///     "()"
/// );
/// assert_eq!(
///     NaturalVector::from_str("(1, 2, 3)")
///         .unwrap()
///         .add_mul(NaturalVector::from_str("(4, 5, 6)").unwrap(), Natural::ZERO)
///         .to_string(),
///     "(1, 2, 3)"
/// );
/// assert_eq!(
///     NaturalVector::from_str("(1, 2, 3)")
///         .unwrap()
///         .add_mul(NaturalVector::from_str("(4, 5, 6)").unwrap(), Natural::ONE)
///         .to_string(),
///     "(5, 7, 9)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(1, 2, 3)").unwrap())
///         .add_mul(
///             &NaturalVector::from_str("(4, 5, 6)").unwrap(),
///             &Natural::from(10u32)
///         )
///         .to_string(),
///     "(41, 52, 63)"
/// );
/// assert_eq!(
///     NaturalVector::from_str("(1, 0)")
///         .unwrap()
///         .add_mul(
///             &NaturalVector::from_str("(18446744073709551615, 1)").unwrap(),
///             &Natural::from_str("18446744073709551617").unwrap()
///         )
///         .to_string(),
///     "(340282366920938463463374607431768211456, 18446744073709551617)"
/// );
/// ```
///
/// # add_mul_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::AddMulAssign;
/// use malachite_nz::natural::Natural;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// let mut v = NaturalVector::from_str("(1, 2, 3)").unwrap();
/// v.add_mul_assign(
///     NaturalVector::from_str("(4, 5, 6)").unwrap(),
///     Natural::from(10u32),
/// );
/// assert_eq!(v.to_string(), "(41, 52, 63)");
/// ```
pub mod add_mul;
/// Implementations of [`AddMulShl`](malachite_base::num::arithmetic::traits::AddMulShl) and
/// [`AddMulShlAssign`](malachite_base::num::arithmetic::traits::AddMulShlAssign), for adding a
/// scalar multiple of one vector, shifted left, to another.
pub mod add_mul_shl;
/// Implementations of [`BalancedMod`](malachite_base::num::arithmetic::traits::BalancedMod), which
/// reduces every element of a vector to the representative closest to zero modulo a number.
pub mod balanced_mod;
/// Implementations of
/// [`BalancedModPowerOf2`](malachite_base::num::arithmetic::traits::BalancedModPowerOf2), which
/// reduce every element of a vector to the representative closest to zero modulo a power of 2.
pub mod balanced_mod_power_of_2;
/// Implementations of [`CanonicalPrimitivePart`](
/// malachite_base::num::arithmetic::traits::CanonicalPrimitivePart),
/// [`CanonicalPrimitivePartAssign`](
/// malachite_base::num::arithmetic::traits::CanonicalPrimitivePartAssign), and
/// [`ContentAndCanonicalPrimitivePart`](
/// malachite_base::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`](malachite_base::num::arithmetic::traits::Content),
/// [`PrimitivePart`](malachite_base::num::arithmetic::traits::PrimitivePart),
/// [`PrimitivePartAssign`](malachite_base::num::arithmetic::traits::PrimitivePartAssign), and
/// [`ContentAndPrimitivePart`](malachite_base::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`](malachite_base::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`](malachite_base::num::arithmetic::traits::DivExact) and
/// [`DivExactAssign`](malachite_base::num::arithmetic::traits::DivExactAssign).
///
/// # div_exact
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::DivExact;
/// use malachite_base::num::basic::traits::One;
/// use malachite_nz::natural::Natural;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// assert_eq!(
///     NaturalVector::from_str("()")
///         .unwrap()
///         .div_exact(Natural::from(5u32))
///         .to_string(),
///     "()"
/// );
/// assert_eq!(
///     NaturalVector::from_str("(0, 6, 255)")
///         .unwrap()
///         .div_exact(Natural::ONE)
///         .to_string(),
///     "(0, 6, 255)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(0, 6, 255)").unwrap())
///         .div_exact(Natural::from(3u32))
///         .to_string(),
///     "(0, 2, 85)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(3802951800684688204490109616128, 6)").unwrap())
///         .div_exact(Natural::from(3u32))
///         .to_string(),
///     "(1267650600228229401496703205376, 2)"
/// );
/// ```
///
/// # div_exact_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::DivExactAssign;
/// use malachite_nz::natural::Natural;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// let mut v = NaturalVector::from_str("(0, 6, 255)").unwrap();
/// v.div_exact_assign(Natural::from(3u32));
/// assert_eq!(v.to_string(), "(0, 2, 85)");
/// ```
pub mod div_exact;
/// Implementations of [`Dot`](malachite_base::num::arithmetic::traits::Dot), the dot product of two
/// vectors.
pub mod dot;
/// Implementations of [`DotSign`](malachite_base::num::arithmetic::traits::DotSign), the sign of
/// the dot product of two vectors.
pub mod dot_sign;
/// An implementation of [`ElementLcm`](malachite_base::num::arithmetic::traits::ElementLcm), the
/// LCM of the elements.
pub mod element_lcm;
/// An implementation of
/// [`ElementProduct`](malachite_base::num::arithmetic::traits::ElementProduct), the product of the
/// elements.
pub mod element_product;
/// An implementation of [`ElementSum`](malachite_base::num::arithmetic::traits::ElementSum), the
/// sum of the elements.
pub mod element_sum;
/// Dividing every element of a vector by a scalar and rounding each quotient, by implementations of
/// [`EntrywiseDivRound`](malachite_base::num::arithmetic::traits::EntrywiseDivRound) and
/// [`EntrywiseDivRoundAssign`](malachite_base::num::arithmetic::traits::EntrywiseDivRoundAssign).
///
/// # entrywise_div_round
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::EntrywiseDivRound;
/// use malachite_base::num::basic::traits::Two;
/// use malachite_base::rounding_modes::RoundingMode::*;
/// use malachite_nz::natural::Natural;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// assert_eq!(
///     NaturalVector::from_str("(1, 2, 3, 5)")
///         .unwrap()
///         .entrywise_div_round(Natural::TWO, Floor)
///         .to_string(),
///     "(0, 1, 1, 2)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(1, 2, 3, 5)").unwrap())
///         .entrywise_div_round(Natural::TWO, Ceiling)
///         .to_string(),
///     "(1, 1, 2, 3)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(1, 2, 3, 5)").unwrap())
///         .entrywise_div_round(Natural::TWO, Nearest)
///         .to_string(),
///     "(0, 1, 2, 2)"
/// );
/// assert_eq!(
///     NaturalVector::from_str("(3, 6, 255)")
///         .unwrap()
///         .entrywise_div_round(Natural::from(3u32), Exact)
///         .to_string(),
///     "(1, 2, 85)"
/// );
/// ```
///
/// # entrywise_div_round_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::EntrywiseDivRoundAssign;
/// use malachite_base::num::basic::traits::Two;
/// use malachite_base::rounding_modes::RoundingMode::*;
/// use malachite_nz::natural::Natural;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// let mut v = NaturalVector::from_str("(1, 2, 3, 5)").unwrap();
/// v.entrywise_div_round_assign(Natural::TWO, Nearest);
/// assert_eq!(v.to_string(), "(0, 1, 2, 2)");
/// ```
pub mod entrywise_div_round;
/// Left-shifting a vector (multiplying it by a power of 2) and rounding every element, by
/// implementations of
/// [`EntrywiseShlRound`](malachite_base::num::arithmetic::traits::EntrywiseShlRound) and
/// [`EntrywiseShlRoundAssign`](malachite_base::num::arithmetic::traits::EntrywiseShlRoundAssign).
///
/// # entrywise_shl_round
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::EntrywiseShlRound;
/// use malachite_base::rounding_modes::RoundingMode::*;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// assert_eq!(
///     (NaturalVector::from_str("(1, 2, 3, 5)")
///         .unwrap()
///         .entrywise_shl_round(-1i8, Floor))
///     .to_string(),
///     "(0, 1, 1, 2)"
/// );
/// assert_eq!(
///     (NaturalVector::from_str("(1, 2, 3, 5)")
///         .unwrap()
///         .entrywise_shl_round(-1i16, Ceiling))
///     .to_string(),
///     "(1, 1, 2, 3)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(1, 2, 3, 5)")
///         .unwrap()
///         .entrywise_shl_round(-1i32, Nearest))
///         .to_string(),
///     "(0, 1, 2, 2)"
/// );
/// assert_eq!(
///     (NaturalVector::from_str("(4, 8, 12)")
///         .unwrap()
///         .entrywise_shl_round(-2i64, Exact))
///     .to_string(),
///     "(1, 2, 3)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(1, 2, 3)")
///         .unwrap()
///         .entrywise_shl_round(2i8, Exact))
///         .to_string(),
///     "(4, 8, 12)"
/// );
/// ```
///
/// # entrywise_shl_round_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::EntrywiseShlRoundAssign;
/// use malachite_base::rounding_modes::RoundingMode::*;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// let mut v = NaturalVector::from_str("(1, 2, 3, 5)").unwrap();
/// v.entrywise_shl_round_assign(-1i8, Nearest);
/// assert_eq!(v.to_string(), "(0, 1, 2, 2)");
/// let mut v = NaturalVector::from_str("(1, 2, 3)").unwrap();
/// v.entrywise_shl_round_assign(2i32, Exact);
/// assert_eq!(v.to_string(), "(4, 8, 12)");
/// ```
pub mod entrywise_shl_round;
/// Right-shifting a vector (dividing it by a power of 2) and rounding every element, by
/// implementations of
/// [`EntrywiseShrRound`](malachite_base::num::arithmetic::traits::EntrywiseShrRound) and
/// [`EntrywiseShrRoundAssign`](malachite_base::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_nz::natural_vector::NaturalVector;
///
/// assert_eq!(
///     (NaturalVector::from_str("(1, 2, 3, 5)")
///         .unwrap()
///         .entrywise_shr_round(1u8, Floor))
///     .to_string(),
///     "(0, 1, 1, 2)"
/// );
/// assert_eq!(
///     (NaturalVector::from_str("(1, 2, 3, 5)")
///         .unwrap()
///         .entrywise_shr_round(1u16, Ceiling))
///     .to_string(),
///     "(1, 1, 2, 3)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(1, 2, 3, 5)")
///         .unwrap()
///         .entrywise_shr_round(1u32, Nearest))
///         .to_string(),
///     "(0, 1, 2, 2)"
/// );
/// assert_eq!(
///     (NaturalVector::from_str("(4, 8, 12)")
///         .unwrap()
///         .entrywise_shr_round(2u64, Exact))
///     .to_string(),
///     "(1, 2, 3)"
/// );
/// assert_eq!(
///     (NaturalVector::from_str("(1, 2, 3, 5)")
///         .unwrap()
///         .entrywise_shr_round(1i8, Down))
///     .to_string(),
///     "(0, 1, 1, 2)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(1, 2, 3)")
///         .unwrap()
///         .entrywise_shr_round(-2i16, Exact))
///         .to_string(),
///     "(4, 8, 12)"
/// );
/// ```
///
/// # entrywise_shr_round_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::EntrywiseShrRoundAssign;
/// use malachite_base::rounding_modes::RoundingMode::*;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// let mut v = NaturalVector::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 = NaturalVector::from_str("(1, 2, 3, 5)").unwrap();
/// v.entrywise_shr_round_assign(1i32, Up);
/// assert_eq!(v.to_string(), "(1, 1, 2, 3)");
/// ```
pub mod entrywise_shr_round;
/// An implementation of [`Height`](malachite_base::num::arithmetic::traits::Height) and
/// [`HeightRef`](malachite_base::num::arithmetic::traits::HeightRef), the largest height of any
/// element.
pub mod height;
/// An implementation of [`L1Norm`](malachite_base::num::arithmetic::traits::L1Norm), the sum of the
/// absolute values of the elements.
pub mod l1_norm;
/// Implementations of [`ModAbsSquared`](malachite_base::num::arithmetic::traits::ModAbsSquared),
/// the squared norm of a vector modulo a number.
pub mod mod_abs_squared;
/// Implementations of [`ModAdd`](malachite_base::num::arithmetic::traits::ModAdd) and
/// [`ModAddAssign`](malachite_base::num::arithmetic::traits::ModAddAssign), for adding vectors
/// modulo a number.
pub mod mod_add;
/// Implementations of [`ModAddMul`](malachite_base::num::arithmetic::traits::ModAddMul) and
/// [`ModAddMulAssign`](malachite_base::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`](malachite_base::num::arithmetic::traits::ModAddMulShl) and
/// [`ModAddMulShlAssign`](malachite_base::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`](malachite_base::num::arithmetic::traits::ModDot), the dot product
/// of two vectors modulo a number.
pub mod mod_dot;
/// Implementations of
/// [`ModElementProduct`](malachite_base::num::arithmetic::traits::ModElementProduct), the product
/// of the elements modulo a number.
pub mod mod_element_product;
/// Implementations of [`ModElementSum`](malachite_base::num::arithmetic::traits::ModElementSum),
/// the sum of the elements modulo a number.
pub mod mod_element_sum;
/// An implementation of [`ModIsReduced`](malachite_base::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`](malachite_base::num::arithmetic::traits::ModMul) and
/// [`ModMulAssign`](malachite_base::num::arithmetic::traits::ModMulAssign), for multiplying a
/// vector by a scalar modulo a number.
pub mod mod_mul;
/// Implementations of [`ModNeg`](malachite_base::num::arithmetic::traits::ModNeg) and
/// [`ModNegAssign`](malachite_base::num::arithmetic::traits::ModNegAssign), for negating a vector
/// modulo a number.
pub mod mod_neg;
/// Implementations of [`Mod`](malachite_base::num::arithmetic::traits::Mod),
/// [`ModAssign`](malachite_base::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`](malachite_base::num::arithmetic::traits::ModPowerOf2) and
/// [`ModPowerOf2Assign`](malachite_base::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`](malachite_base::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`](malachite_base::num::arithmetic::traits::ModPowerOf2Add)
/// and [`ModPowerOf2AddAssign`](malachite_base::num::arithmetic::traits::ModPowerOf2AddAssign), for
/// adding vectors modulo a power of 2.
pub mod mod_power_of_2_add;
/// Implementations of
/// [`ModPowerOf2AddMul`](malachite_base::num::arithmetic::traits::ModPowerOf2AddMul) and
/// [`ModPowerOf2AddMulAssign`](malachite_base::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`](malachite_base::num::arithmetic::traits::ModPowerOf2AddMulShl) and
/// [`ModPowerOf2AddMulShlAssign`](
/// malachite_base::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`](malachite_base::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`](
/// malachite_base::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`](malachite_base::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`](malachite_base::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`](malachite_base::num::arithmetic::traits::ModPowerOf2Mul)
/// and [`ModPowerOf2MulAssign`](malachite_base::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`](malachite_base::num::arithmetic::traits::ModPowerOf2Neg)
/// and [`ModPowerOf2NegAssign`](malachite_base::num::arithmetic::traits::ModPowerOf2NegAssign), for
/// negating a vector modulo a power of 2.
pub mod mod_power_of_2_neg;
/// Implementations of [`ModPowerOf2Shl`](malachite_base::num::arithmetic::traits::ModPowerOf2Shl)
/// and [`ModPowerOf2ShlAssign`](malachite_base::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_nz::natural_vector::NaturalVector;
///
/// let v = NaturalVector::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!(
///     (&NaturalVector::from_str("(1, 128, 1)").unwrap())
///         .mod_power_of_2_shl(1u64, 8)
///         .to_string(),
///     "(2, 0, 2)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(1, 1)").unwrap())
///         .mod_power_of_2_shl(100u128, 101)
///         .to_string(),
///     "(1267650600228229401496703205376, 1267650600228229401496703205376)"
/// );
/// ```
///
/// # mod_power_of_2_shl_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::ModPowerOf2ShlAssign;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// let mut v = NaturalVector::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 = NaturalVector::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`](malachite_base::num::arithmetic::traits::ModPowerOf2Sub)
/// and [`ModPowerOf2SubAssign`](malachite_base::num::arithmetic::traits::ModPowerOf2SubAssign), for
/// subtracting vectors modulo a power of 2.
pub mod mod_power_of_2_sub;
/// Implementations of
/// [`ModPowerOf2SubMul`](malachite_base::num::arithmetic::traits::ModPowerOf2SubMul) and
/// [`ModPowerOf2SubMulAssign`](malachite_base::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`](malachite_base::num::arithmetic::traits::ModPowerOf2SubMulShl) and
/// [`ModPowerOf2SubMulShlAssign`](
/// malachite_base::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`](malachite_base::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`](malachite_base::num::arithmetic::traits::ModShl) and
/// [`ModShlAssign`](malachite_base::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_nz::natural::Natural;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// let v = NaturalVector::from_str("(5, 1, 3)").unwrap();
/// assert_eq!(
///     v.clone().mod_shl(1u8, Natural::from(7u32)).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, Natural::from(8u32)).to_string(),
///     "(0, 0, 0)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(1, 1)").unwrap())
///         .mod_shl(
///             100u64,
///             Natural::from_str("1000000000000000000000000000000").unwrap()
///         )
///         .to_string(),
///     "(267650600228229401496703205376, 267650600228229401496703205376)"
/// );
/// ```
///
/// # mod_shl_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::arithmetic::traits::ModShlAssign;
/// use malachite_nz::natural::Natural;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// let mut v = NaturalVector::from_str("(5, 1, 3)").unwrap();
/// v.mod_shl_assign(1u8, Natural::from(7u32));
/// assert_eq!(v.to_string(), "(3, 2, 6)");
/// ```
pub mod mod_shl;
/// Implementations of [`ModSub`](malachite_base::num::arithmetic::traits::ModSub) and
/// [`ModSubAssign`](malachite_base::num::arithmetic::traits::ModSubAssign), for subtracting vectors
/// modulo a number.
pub mod mod_sub;
/// Implementations of [`ModSubMul`](malachite_base::num::arithmetic::traits::ModSubMul) and
/// [`ModSubMulAssign`](malachite_base::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`](malachite_base::num::arithmetic::traits::ModSubMulShl) and
/// [`ModSubMulShlAssign`](malachite_base::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`](malachite_base::num::arithmetic::traits::ModSum), for adding up
/// vectors entry by entry modulo a number.
pub mod mod_sum;
/// [`NaturalVector::multi_crt`](super::NaturalVector::multi_crt), which combines vectors of
/// residues modulo many word-sized moduli by the Chinese remainder theorem.
pub mod multi_crt;
/// 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::num::basic::traits::{One, Two};
/// use malachite_nz::natural::Natural;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// assert_eq!(
///     (NaturalVector::from_str("()").unwrap() / Natural::from(5u32)).to_string(),
///     "()"
/// );
/// assert_eq!(
///     (NaturalVector::from_str("(0, 7, 255)").unwrap() / Natural::ONE).to_string(),
///     "(0, 7, 255)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(0, 7, 255)").unwrap() / Natural::TWO).to_string(),
///     "(0, 3, 127)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(3802951800684688204490109616128, 7)").unwrap()
///         / Natural::from(3u32))
///     .to_string(),
///     "(1267650600228229401496703205376, 2)"
/// );
/// ```
///
/// # div_assign
/// ```
/// use core::str::FromStr;
/// use malachite_base::num::basic::traits::Two;
/// use malachite_nz::natural::Natural;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// let mut v = NaturalVector::from_str("(0, 7, 255)").unwrap();
/// v /= Natural::TWO;
/// assert_eq!(v.to_string(), "(0, 3, 127)");
/// ```
pub mod scalar_div;
/// Implementations of [`Mul`](core::ops::Mul) and [`MulAssign`](core::ops::MulAssign), for
/// multiplying a vector by a scalar, with the scalar on either side.
pub mod scalar_mul;
/// Left-shifting a vector (multiplying it by a power of 2), by implementations of
/// [`Shl`](core::ops::Shl) and [`ShlAssign`](core::ops::ShlAssign).
///
/// # shl
/// ```
/// use core::str::FromStr;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// assert_eq!(
///     (NaturalVector::from_str("()").unwrap() << 10u8).to_string(),
///     "()"
/// );
/// assert_eq!(
///     (NaturalVector::from_str("(1, 2, 3)").unwrap() << 0u16).to_string(),
///     "(1, 2, 3)"
/// );
/// assert_eq!(
///     (NaturalVector::from_str("(1, 2, 3)").unwrap() << 2u32).to_string(),
///     "(4, 8, 12)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(3, 0)").unwrap() << 100u64).to_string(),
///     "(3802951800684688204490109616128, 0)"
/// );
///
/// assert_eq!(
///     (NaturalVector::from_str("(1, 2, 3)").unwrap() << 2i8).to_string(),
///     "(4, 8, 12)"
/// );
///
/// assert_eq!(
///     (&NaturalVector::from_str("(1, 2, 3, 5)").unwrap() << -1i64).to_string(),
///     "(0, 1, 1, 2)"
/// );
/// ```
///
/// # shl_assign
/// ```
/// use core::str::FromStr;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// let mut v = NaturalVector::from_str("(1, 2, 3)").unwrap();
/// v <<= 2u32;
/// assert_eq!(v.to_string(), "(4, 8, 12)");
///
/// let mut v = NaturalVector::from_str("(1, 2, 3, 5)").unwrap();
/// v <<= -1i32;
/// assert_eq!(v.to_string(), "(0, 1, 1, 2)");
/// ```
pub mod shl;
/// 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_nz::natural_vector::NaturalVector;
///
/// assert_eq!(
///     (NaturalVector::from_str("()").unwrap() >> 10u8).to_string(),
///     "()"
/// );
/// assert_eq!(
///     (NaturalVector::from_str("(1, 2, 3)").unwrap() >> 0u16).to_string(),
///     "(1, 2, 3)"
/// );
/// assert_eq!(
///     (NaturalVector::from_str("(4, 8, 12)").unwrap() >> 2u32).to_string(),
///     "(1, 2, 3)"
/// );
/// assert_eq!(
///     (NaturalVector::from_str("(1, 2, 3, 5)").unwrap() >> 1u8).to_string(),
///     "(0, 1, 1, 2)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(3802951800684688204490109616128, 0)").unwrap() >> 100u64)
///         .to_string(),
///     "(3, 0)"
/// );
/// assert_eq!(
///     (NaturalVector::from_str("(1, 2, 3)").unwrap() >> -2i8).to_string(),
///     "(4, 8, 12)"
/// );
/// assert_eq!(
///     (&NaturalVector::from_str("(4, 8, 12)").unwrap() >> 2i64).to_string(),
///     "(1, 2, 3)"
/// );
/// ```
///
/// # shr_assign
/// ```
/// use core::str::FromStr;
/// use malachite_nz::natural_vector::NaturalVector;
///
/// let mut v = NaturalVector::from_str("(4, 8, 12)").unwrap();
/// v >>= 2u32;
/// assert_eq!(v.to_string(), "(1, 2, 3)");
/// let mut v = NaturalVector::from_str("(1, 2, 3)").unwrap();
/// v >>= -2i32;
/// assert_eq!(v.to_string(), "(4, 8, 12)");
/// ```
pub mod shr;
/// Implementations of [`Sum`](core::iter::Sum), for adding up vectors entry by entry.
pub mod sum;