@@ -6,7 +6,7 @@ use std::mem::swap;
6
6
/// # Returns
7
7
/// x mod m
8
8
/* const */
9
- fn safe_mod ( mut x : i64 , m : i64 ) -> i64 {
9
+ pub ( crate ) fn safe_mod ( mut x : i64 , m : i64 ) -> i64 {
10
10
x %= m;
11
11
if x < 0 {
12
12
x += m;
@@ -17,9 +17,9 @@ fn safe_mod(mut x: i64, m: i64) -> i64 {
17
17
/// Fast modular by barrett reduction
18
18
/// Reference: https://en.wikipedia.org/wiki/Barrett_reduction
19
19
/// NOTE: reconsider after Ice Lake
20
- struct Barrett {
21
- _m : u32 ,
22
- im : u64 ,
20
+ pub ( crate ) struct Barrett {
21
+ pub ( crate ) _m : u32 ,
22
+ pub ( crate ) im : u64 ,
23
23
}
24
24
25
25
impl Barrett {
@@ -28,7 +28,7 @@ impl Barrett {
28
28
/// (Note: `m <= 2^31` should also hold, which is undocumented in the original library.
29
29
/// See the [pull reqeust commment](https://github.com/rust-lang-ja/ac-library-rs/pull/3#discussion_r484661007)
30
30
/// for more details.)
31
- fn new ( m : u32 ) -> Barrett {
31
+ pub ( crate ) fn new ( m : u32 ) -> Barrett {
32
32
Barrett {
33
33
_m : m,
34
34
im : ( -1i64 as u64 / m as u64 ) . wrapping_add ( 1 ) ,
@@ -37,7 +37,7 @@ impl Barrett {
37
37
38
38
/// # Returns
39
39
/// `m`
40
- fn umod ( & self ) -> u32 {
40
+ pub ( crate ) fn umod ( & self ) -> u32 {
41
41
self . _m
42
42
}
43
43
@@ -48,7 +48,7 @@ impl Barrett {
48
48
/// # Returns
49
49
/// a * b % m
50
50
#[ allow( clippy:: many_single_char_names) ]
51
- fn mul ( & self , a : u32 , b : u32 ) -> u32 {
51
+ pub ( crate ) fn mul ( & self , a : u32 , b : u32 ) -> u32 {
52
52
// [1] m = 1
53
53
// a = b = im = 0, so okay
54
54
@@ -78,7 +78,7 @@ impl Barrett {
78
78
/// `(x ** n) % m`
79
79
/* const */
80
80
#[ allow( clippy:: many_single_char_names) ]
81
- fn pow_mod ( x : i64 , mut n : i64 , m : i32 ) -> i64 {
81
+ pub ( crate ) fn pow_mod ( x : i64 , mut n : i64 , m : i32 ) -> i64 {
82
82
if m == 1 {
83
83
return 0 ;
84
84
}
@@ -102,7 +102,7 @@ fn pow_mod(x: i64, mut n: i64, m: i32) -> i64 {
102
102
/// # Parameters
103
103
/// * `n` `0 <= n`
104
104
/* const */
105
- fn is_prime ( n : i32 ) -> bool {
105
+ pub ( crate ) fn is_prime ( n : i32 ) -> bool {
106
106
let n = n as i64 ;
107
107
match n {
108
108
_ if n <= 1 => return false ,
@@ -138,7 +138,7 @@ fn is_prime(n: i32) -> bool {
138
138
/// (g, x) s.t. g = gcd(a, b), xa = g (mod b), 0 <= x < b/g
139
139
/* const */
140
140
#[ allow( clippy:: many_single_char_names) ]
141
- fn inv_gcd ( a : i64 , b : i64 ) -> ( i64 , i64 ) {
141
+ pub ( crate ) fn inv_gcd ( a : i64 , b : i64 ) -> ( i64 , i64 ) {
142
142
let a = safe_mod ( a, b) ;
143
143
if a == 0 {
144
144
return ( b, 0 ) ;
@@ -178,7 +178,7 @@ fn inv_gcd(a: i64, b: i64) -> (i64, i64) {
178
178
/// @param m must be prime
179
179
/// @return primitive root (and minimum in now)
180
180
/* const */
181
- fn primitive_root ( m : i32 ) -> i32 {
181
+ pub ( crate ) fn primitive_root ( m : i32 ) -> i32 {
182
182
match m {
183
183
2 => return 1 ,
184
184
167_772_161 => return 3 ,
0 commit comments