parent
d3ef15195e
commit
5fe8a5fbdf
@ -301,7 +301,7 @@ fn pow_bench(b: &mut Bencher) {
|
||||
for i in 2..upper + 1 {
|
||||
for j in 2..upper + 1 {
|
||||
let i_big = BigUint::from_usize(i).unwrap();
|
||||
num_traits::pow(i_big, j);
|
||||
i_big.pow(j);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -19,7 +19,7 @@ use serde;
|
||||
|
||||
use integer::{Integer, Roots};
|
||||
use traits::{ToPrimitive, FromPrimitive, Float, Num, Unsigned, CheckedAdd, CheckedSub, CheckedMul,
|
||||
CheckedDiv, Zero, One, pow};
|
||||
CheckedDiv, Zero, One, Pow};
|
||||
|
||||
use big_digit::{self, BigDigit, DoubleBigDigit};
|
||||
|
||||
@ -436,7 +436,7 @@ impl Unsigned for BigUint {}
|
||||
|
||||
macro_rules! pow_impl {
|
||||
($unsigned:ty) => {
|
||||
impl<'a> pow::Pow<$unsigned> for &'a BigUint {
|
||||
impl<'a> Pow<$unsigned> for &'a BigUint {
|
||||
type Output = BigUint;
|
||||
|
||||
#[inline]
|
||||
@ -464,7 +464,7 @@ macro_rules! pow_impl {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> pow::Pow<&'b $unsigned> for &'a BigUint {
|
||||
impl<'a, 'b> Pow<&'b $unsigned> for &'a BigUint {
|
||||
type Output = BigUint;
|
||||
|
||||
#[inline]
|
||||
@ -1105,7 +1105,7 @@ impl Roots for BigUint {
|
||||
|
||||
loop {
|
||||
s = u;
|
||||
let q = self / pow(s.clone(), n_min_1);
|
||||
let q = self / s.pow(n_min_1);
|
||||
let t: BigUint = n_min_1 * &s + q;
|
||||
|
||||
u = t / n;
|
||||
|
@ -4,7 +4,7 @@ extern crate num_traits;
|
||||
|
||||
mod biguint {
|
||||
use num_bigint::BigUint;
|
||||
use num_traits::pow;
|
||||
use num_traits::Pow;
|
||||
use std::str::FromStr;
|
||||
|
||||
fn check(x: u64, n: u32) {
|
||||
@ -17,8 +17,8 @@ mod biguint {
|
||||
assert_eq!(&res, &big_x.cbrt())
|
||||
}
|
||||
|
||||
assert!(pow(res.clone(), n as usize) <= big_x);
|
||||
assert!(pow(res.clone() + 1u32, n as usize) > big_x);
|
||||
assert!(res.pow(n) <= big_x);
|
||||
assert!((res + 1u32).pow(n) > big_x);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -58,7 +58,7 @@ mod biguint {
|
||||
|
||||
mod bigint {
|
||||
use num_bigint::BigInt;
|
||||
use num_traits::{Signed, pow};
|
||||
use num_traits::{Signed, Pow};
|
||||
|
||||
fn check(x: i64, n: u32) {
|
||||
let big_x = BigInt::from(x);
|
||||
@ -71,11 +71,11 @@ mod bigint {
|
||||
}
|
||||
|
||||
if big_x.is_negative() {
|
||||
assert!(pow(res.clone() - 1u32, n as usize) < big_x);
|
||||
assert!(pow(res.clone(), n as usize) >= big_x);
|
||||
assert!(res.pow(n) >= big_x);
|
||||
assert!((res - 1u32).pow(n) < big_x);
|
||||
} else {
|
||||
assert!(pow(res.clone(), n as usize) <= big_x);
|
||||
assert!(pow(res.clone() + 1u32, n as usize) > big_x);
|
||||
assert!(res.pow(n) <= big_x);
|
||||
assert!((res + 1u32).pow(n) > big_x);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user