3个不稳定版本
0.2.0 | 2021年8月4日 |
---|---|
0.1.1 | 2021年5月1日 |
0.1.0 | 2021年3月27日 |
#1095 in 数学
每月396次下载
用于 2 crates
13KB
287 行
modulo_tools
在模数、Montgomery乘法中进行加、减、乘、幂运算。
use modulo_n_tools::*;
use modulo_n_tools::montgomery::*;
let a = add_mod(&3, &4, &5);
assert_eq!(a, 2);
let b = mul_mod(&3, &a, &5);
assert_eq!(b, 1);
let c = pow_mod(2, 6, &7);
assert_eq!(c, 1);
let m = Montgomery64::new(57);
let d = m.powmod(5, 42);
assert_eq!(d, 7);
许可证
AGPL-3.0-or-later
lib.rs
:
modulo_tools
use modulo_n_tools::*;
use modulo_n_tools::montgomery::*;
let a = add_mod(&3, &4, &5);
assert_eq!(a, 2);
let b = mul_mod(&3, &a, &5);
assert_eq!(b, 1);
let c = pow_mod(2, 6, &7);
assert_eq!(c, 1);
let m = Montgomery64::new(57);
let d = m.powmod(5, 42);
assert_eq!(d, 7);