Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge Exponential and Hyperbolic traits
The Hyperbolic Functions are trivially implemented in terms of `exp`, so it's  simpler to group them the Exponential trait. In the future these would have default implementations.
  • Loading branch information
brendanzab committed Apr 29, 2013
commit d3f494f5c3ce96da2e0c8090fc17a8738e4396c1
2 changes: 1 addition & 1 deletion src/libcore/core.rc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub use iter::{ExtendedMutableIter};

pub use num::{Num, NumCast};
pub use num::{Orderable, Signed, Unsigned, Round};
pub use num::{Algebraic, Trigonometric, Exponential, Hyperbolic};
pub use num::{Algebraic, Trigonometric, Exponential};
pub use num::{Integer, Fractional, Real, RealExt};
pub use num::{Bitwise, BitCount, Bounded};
pub use num::{Primitive, Int, Float};
Expand Down
2 changes: 0 additions & 2 deletions src/libcore/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,7 @@ impl Exponential for f32 {

#[inline(always)]
fn log10(&self) -> f32 { log10(*self) }
}

impl Hyperbolic for f32 {
#[inline(always)]
fn sinh(&self) -> f32 { sinh(*self) }

Expand Down
2 changes: 0 additions & 2 deletions src/libcore/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,7 @@ impl Exponential for f64 {

#[inline(always)]
fn log10(&self) -> f64 { log10(*self) }
}

impl Hyperbolic for f64 {
#[inline(always)]
fn sinh(&self) -> f64 { sinh(*self) }

Expand Down
2 changes: 0 additions & 2 deletions src/libcore/num/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,9 +547,7 @@ impl Exponential for float {
fn log10(&self) -> float {
(*self as f64).log10() as float
}
}

impl Hyperbolic for float {
#[inline(always)]
fn sinh(&self) -> float {
(*self as f64).sinh() as float
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/num/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ pub trait Exponential {
fn log(&self) -> Self;
fn log2(&self) -> Self;
fn log10(&self) -> Self;
}

pub trait Hyperbolic: Exponential {
// The Hyperbolic Functions are trivially implemented in terms of `exp`, so it's simpler
// to group them within this trait. In the future these would have default implementations.
fn sinh(&self) -> Self;
fn cosh(&self) -> Self;
fn tanh(&self) -> Self;
Expand All @@ -146,7 +146,7 @@ pub trait Real: Signed
+ Fractional
+ Algebraic
+ Trigonometric
+ Hyperbolic {
+ Exponential {
// Common Constants
// FIXME (#5527): These should be associated constants
fn pi() -> Self;
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub use iter::{CopyableIter, CopyableOrderedIter, CopyableNonstrictIter};
pub use iter::{Times, ExtendedMutableIter};
pub use num::{Num, NumCast};
pub use num::{Orderable, Signed, Unsigned, Round};
pub use num::{Algebraic, Trigonometric, Exponential, Hyperbolic};
pub use num::{Algebraic, Trigonometric, Exponential};
pub use num::{Integer, Fractional, Real, RealExt};
pub use num::{Bitwise, BitCount, Bounded};
pub use num::{Primitive, Int, Float};
Expand Down