diff options
Diffstat (limited to 'src/libextra/num')
| -rw-r--r-- | src/libextra/num/complex.rs | 5 | ||||
| -rw-r--r-- | src/libextra/num/rational.rs | 13 |
2 files changed, 8 insertions, 10 deletions
diff --git a/src/libextra/num/complex.rs b/src/libextra/num/complex.rs index 58af80fefb7..b1b4bb57d98 100644 --- a/src/libextra/num/complex.rs +++ b/src/libextra/num/complex.rs @@ -11,7 +11,6 @@ //! Complex numbers. - use std::num::{Zero,One,ToStrRadix}; // FIXME #1284: handle complex NaN & infinity etc. This @@ -78,7 +77,7 @@ impl<T: Clone + Num> Cmplx<T> { } } -impl<T: Clone + Algebraic + Num> Cmplx<T> { +impl<T: Clone + Real> Cmplx<T> { /// Calculate |self| #[inline] pub fn norm(&self) -> T { @@ -86,7 +85,7 @@ impl<T: Clone + Algebraic + Num> Cmplx<T> { } } -impl<T: Clone + Trigonometric + Algebraic + Num> Cmplx<T> { +impl<T: Clone + Real> Cmplx<T> { /// Calculate the principal Arg of self. #[inline] pub fn arg(&self) -> T { diff --git a/src/libextra/num/rational.rs b/src/libextra/num/rational.rs index 3ab9f99d5cf..4edccf685e2 100644 --- a/src/libextra/num/rational.rs +++ b/src/libextra/num/rational.rs @@ -105,6 +105,12 @@ impl<T: Clone + Integer + Ord> ret.reduce(); ret } + + /// Return the reciprocal + #[inline] + pub fn recip(&self) -> Ratio<T> { + Ratio::new_raw(self.denom.clone(), self.numer.clone()) + } } impl Ratio<BigInt> { @@ -288,13 +294,6 @@ impl<T: Clone + Integer + Ord> } } -impl<T: Clone + Integer + Ord> Fractional for Ratio<T> { - #[inline] - fn recip(&self) -> Ratio<T> { - Ratio::new_raw(self.denom.clone(), self.numer.clone()) - } -} - /* String conversions */ impl<T: ToStr> ToStr for Ratio<T> { /// Renders as `numer/denom`. |
