competitive/num/mint/
mod.rs

1//! modint
2
3use crate::{
4    num::{BarrettReduction, One, Zero},
5    tools::{IterScan, SerdeByteStr},
6};
7
8#[codesnip::entry("MIntBase", include("scanner", "zero_one", "coding"))]
9pub use mint_base::{MInt, MIntBase, MIntConvert};
10
11#[cfg_attr(nightly, codesnip::entry("MIntBase"))]
12mod mint_base;
13
14#[cfg_attr(
15    nightly,
16    codesnip::entry("MInt", include("MIntBase", "BarrettReduction"))
17)]
18pub mod mint_basic;
19
20#[cfg_attr(nightly, codesnip::entry("montgomery", include("MIntBase")))]
21pub mod montgomery;
22
23mod random_spec {
24    use super::*;
25    use crate::tools::{RandomSpec, Xorshift};
26    use std::ops::{RangeFull, RangeTo};
27
28    impl<M> RandomSpec<MInt<M>> for RangeFull
29    where
30        M: MIntBase,
31        RangeTo<M::Inner>: RandomSpec<M::Inner>,
32    {
33        fn rand(&self, rng: &mut Xorshift) -> MInt<M> {
34            MInt::<M>::new_unchecked(rng.random(..M::get_mod()))
35        }
36    }
37}