Skip to content

Commit a76845c

Browse files
Fixed typo & function name
Remove "_constexpr" from function name that are not const fn
1 parent b284f6d commit a76845c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/internal_math.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn safe_mod(mut x: i64, m: i64) -> i64 {
1414
x
1515
}
1616

17-
/// Fast moduler by barrett reduction
17+
/// Fast modular by barrett reduction
1818
/// Reference: https://en.wikipedia.org/wiki/Barrett_reduction
1919
/// NOTE: reconsider after Ice Lake
2020
struct Barrett {
@@ -76,7 +76,7 @@ impl Barrett {
7676
/// # Returns
7777
/// `(x ** n) % m`
7878
/* const */
79-
fn pow_mod_constexpr(x: i64, mut n: i64, m: i32) -> i64 {
79+
fn pow_mod(x: i64, mut n: i64, m: i32) -> i64 {
8080
if m == 1 {
8181
return 0;
8282
}
@@ -100,7 +100,7 @@ fn pow_mod_constexpr(x: i64, mut n: i64, m: i32) -> i64 {
100100
/// # Parameters
101101
/// * `n` `0 <= n`
102102
/* const */
103-
fn is_prime_constexpr(n: i32) -> bool {
103+
fn is_prime(n: i32) -> bool {
104104
let n = n as i64;
105105
match n {
106106
_ if n <= 1 => return false,
@@ -114,7 +114,7 @@ fn is_prime_constexpr(n: i32) -> bool {
114114
}
115115
for &a in &[2, 7, 61] {
116116
let mut t = d;
117-
let mut y = pow_mod_constexpr(a, t, n as i32);
117+
let mut y = pow_mod(a, t, n as i32);
118118
while t != n - 1 && y != 1 && y != n - 1 {
119119
y = y * y % n;
120120
t <<= 1;
@@ -175,7 +175,7 @@ fn inv_gcd(a: i64, b: i64) -> (i64, i64) {
175175
/// @param m must be prime
176176
/// @return primitive root (and minimum in now)
177177
/* const */
178-
fn primitive_root_constexpr(m: i32) -> i32 {
178+
fn primitive_root(m: i32) -> i32 {
179179
match m {
180180
2 => return 1,
181181
167_772_161 => return 3,
@@ -210,7 +210,7 @@ fn primitive_root_constexpr(m: i32) -> i32 {
210210
}
211211
let mut g = 2;
212212
loop {
213-
if (0..cnt).any(|i| pow_mod_constexpr(g, ((m - 1) / divs[i]) as i64, m) == 1) {
213+
if (0..cnt).any(|i| pow_mod(g, ((m - 1) / divs[i]) as i64, m) == 1) {
214214
break g as i32;
215215
}
216216
g += 1;

0 commit comments

Comments
 (0)