Skip to content

Commit

Permalink
auto merge of rust-lang#12321 : bjz/rust/remove-real, r=alexcrichton
Browse files Browse the repository at this point in the history
This is part of the effort to simplify `std::num`, as tracked in issue rust-lang#10387. It is also a step towards a proper IEEE-754 trait (see rust-lang#12281).
  • Loading branch information
bors committed Feb 18, 2014
2 parents 62d7d00 + 876eb93 commit b0ce960
Show file tree
Hide file tree
Showing 9 changed files with 501 additions and 511 deletions.
2 changes: 1 addition & 1 deletion src/etc/vim/syntax/rust.vim
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ syn keyword rustTrait Iterator DoubleEndedIterator RandomAccessIterator Cloneabl
syn keyword rustTrait OrdIterator MutableDoubleEndedIterator ExactSize

syn keyword rustTrait Algebraic Trigonometric Exponential Hyperbolic
syn keyword rustTrait Bitwise Bounded Integer Fractional Real RealExt
syn keyword rustTrait Bitwise Bounded Integer
syn keyword rustTrait Num NumCast CheckedAdd CheckedSub CheckedMul CheckedDiv
syn keyword rustTrait Orderable Signed Unsigned Round
syn keyword rustTrait Primitive Int Float ToStrRadix ToPrimitive FromPrimitive
Expand Down
12 changes: 6 additions & 6 deletions src/libnum/complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ impl<T: Clone + Num> Cmplx<T> {
}
}

impl<T: Clone + Real> Cmplx<T> {
impl<T: Clone + Float> Cmplx<T> {
/// Calculate |self|
#[inline]
pub fn norm(&self) -> T {
self.re.hypot(&self.im)
}
}

impl<T: Clone + Real> Cmplx<T> {
impl<T: Clone + Float> Cmplx<T> {
/// Calculate the principal Arg of self.
#[inline]
pub fn arg(&self) -> T {
Expand Down Expand Up @@ -192,7 +192,7 @@ mod test {
#[allow(non_uppercase_statics)];

use super::{Complex64, Cmplx};
use std::num::{Zero,One,Real};
use std::num::{Zero,One,Float};

pub static _0_0i : Complex64 = Cmplx { re: 0.0, im: 0.0 };
pub static _1_0i : Complex64 = Cmplx { re: 1.0, im: 0.0 };
Expand Down Expand Up @@ -270,9 +270,9 @@ mod test {
assert!((c.arg() - arg).abs() < 1.0e-6)
}
test(_1_0i, 0.0);
test(_1_1i, 0.25 * Real::pi());
test(_neg1_1i, 0.75 * Real::pi());
test(_05_05i, 0.25 * Real::pi());
test(_1_1i, 0.25 * Float::pi());
test(_neg1_1i, 0.75 * Float::pi());
test(_05_05i, 0.25 * Float::pi());
}

#[test]
Expand Down
Loading

0 comments on commit b0ce960

Please sign in to comment.