Skip to content

Commit b1e6ca2

Browse files
update to PyO3 0.16, num-bigint 0.4, num-rational 0.4
1 parent 73ad7c6 commit b1e6ca2

File tree

6 files changed

+144
-231
lines changed

6 files changed

+144
-231
lines changed

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ crate-type = ["rlib", "cdylib"]
2323

2424
[dependencies]
2525
num-traits = "0.2"
26-
num-bigint = "0.2"
26+
num-bigint = "0.4"
2727
num-integer = "0.1"
28-
num-rational = "0.2"
28+
num-rational = "0.4"
2929
rand = "0.5"
3030
rand_pcg = "0.1.1"
3131
lazy_static = "1.4"
3232

3333
[dependencies.pyo3]
34-
version = "0.9.0"
34+
version = "0.16"
3535
optional = true
3636
features = ["num-bigint"]

src/lattice.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ where
181181
mod tests {
182182
use super::*;
183183
use num_bigint::BigInt;
184-
use num_traits::{One, Pow};
184+
use num_traits::One;
185185

186186
#[test]
187187
fn test_gram_schmidt() {
@@ -281,16 +281,6 @@ mod tests {
281281
assert!(output == expected);
282282
}
283283

284-
// workaround for https://github.com/rust-num/num-bigint/issues/106
285-
fn pow<'a, T>(base: &'a Ratio<BigInt>, exponent: &'a T) -> Ratio<BigInt>
286-
where
287-
&'a BigInt: Pow<&'a T, Output = BigInt>,
288-
{
289-
let numer = base.numer().pow(exponent);
290-
let denom = base.denom().pow(exponent);
291-
Ratio::new(numer, denom)
292-
}
293-
294284
#[test]
295285
fn test_lll_reduce() {
296286
let ints = |v: &[i64]| -> Vec<BigInt> { v.iter().copied().map(BigInt::from).collect() };
@@ -324,7 +314,7 @@ mod tests {
324314
assert!(output == expected);
325315

326316
// find the minimal polynomial of sin(pi / 7)
327-
let multiplier = BigInt::from(1) << 48;
317+
let multiplier = BigInt::one() << 48i32;
328318
// approximation to 1024 fractional bits
329319
let sin_pi_7_approximation: Ratio<BigInt> =
330320
"97498727392503287796421964844598099607650972550809391824625445149289352\
@@ -348,7 +338,8 @@ mod tests {
348338
BigInt::zero()
349339
}
350340
} else {
351-
-pow(&sin_pi_7_approximation, &x)
341+
-(&sin_pi_7_approximation)
342+
.pow(x as i32)
352343
.mul(&multiplier)
353344
.round()
354345
.to_integer()

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub use algebraic_numbers::RealAlgebraicNumber;
2121
macro_rules! doctest {
2222
($x:expr) => {
2323
#[doc = $x]
24-
extern {}
24+
extern "C" {}
2525
};
2626
}
2727

0 commit comments

Comments
 (0)