Skip to content

Commit 0fc70b0

Browse files
Changed visibility
1 parent a2d7c81 commit 0fc70b0

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/internal_math.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::mem::swap;
66
/// # Returns
77
/// x mod m
88
/* const */
9-
fn safe_mod(mut x: i64, m: i64) -> i64 {
9+
pub(crate) fn safe_mod(mut x: i64, m: i64) -> i64 {
1010
x %= m;
1111
if x < 0 {
1212
x += m;
@@ -17,9 +17,9 @@ fn safe_mod(mut x: i64, m: i64) -> i64 {
1717
/// Fast modular by barrett reduction
1818
/// Reference: https://en.wikipedia.org/wiki/Barrett_reduction
1919
/// 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,
2323
}
2424

2525
impl Barrett {
@@ -28,7 +28,7 @@ impl Barrett {
2828
/// (Note: `m <= 2^31` should also hold, which is undocumented in the original library.
2929
/// See the [pull reqeust commment](https://github.com/rust-lang-ja/ac-library-rs/pull/3#discussion_r484661007)
3030
/// for more details.)
31-
fn new(m: u32) -> Barrett {
31+
pub(crate) fn new(m: u32) -> Barrett {
3232
Barrett {
3333
_m: m,
3434
im: (-1i64 as u64 / m as u64).wrapping_add(1),
@@ -37,7 +37,7 @@ impl Barrett {
3737

3838
/// # Returns
3939
/// `m`
40-
fn umod(&self) -> u32 {
40+
pub(crate) fn umod(&self) -> u32 {
4141
self._m
4242
}
4343

@@ -48,7 +48,7 @@ impl Barrett {
4848
/// # Returns
4949
/// a * b % m
5050
#[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 {
5252
// [1] m = 1
5353
// a = b = im = 0, so okay
5454

@@ -78,7 +78,7 @@ impl Barrett {
7878
/// `(x ** n) % m`
7979
/* const */
8080
#[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 {
8282
if m == 1 {
8383
return 0;
8484
}
@@ -102,7 +102,7 @@ fn pow_mod(x: i64, mut n: i64, m: i32) -> i64 {
102102
/// # Parameters
103103
/// * `n` `0 <= n`
104104
/* const */
105-
fn is_prime(n: i32) -> bool {
105+
pub(crate) fn is_prime(n: i32) -> bool {
106106
let n = n as i64;
107107
match n {
108108
_ if n <= 1 => return false,
@@ -138,7 +138,7 @@ fn is_prime(n: i32) -> bool {
138138
/// (g, x) s.t. g = gcd(a, b), xa = g (mod b), 0 <= x < b/g
139139
/* const */
140140
#[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) {
142142
let a = safe_mod(a, b);
143143
if a == 0 {
144144
return (b, 0);
@@ -178,7 +178,7 @@ fn inv_gcd(a: i64, b: i64) -> (i64, i64) {
178178
/// @param m must be prime
179179
/// @return primitive root (and minimum in now)
180180
/* const */
181-
fn primitive_root(m: i32) -> i32 {
181+
pub(crate) fn primitive_root(m: i32) -> i32 {
182182
match m {
183183
2 => return 1,
184184
167_772_161 => return 3,

0 commit comments

Comments
 (0)