diff options
| author | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2013-04-29 23:38:58 +1000 |
|---|---|---|
| committer | Brendan Zabarauskas <bjzaba@yahoo.com.au> | 2013-04-29 23:50:34 +1000 |
| commit | 500078e147e1e5f5cf9bd57459ebbdda652d97ed (patch) | |
| tree | 4be175281d008a2aa63175a663630929ae5fbccd /src/libcore/num | |
| parent | d3f494f5c3ce96da2e0c8090fc17a8738e4396c1 (diff) | |
| download | rust-500078e147e1e5f5cf9bd57459ebbdda652d97ed.tar.gz rust-500078e147e1e5f5cf9bd57459ebbdda652d97ed.zip | |
Revert "Merge Exponential and Hyperbolic traits"
After discussions on IRC and #4819, we have decided to revert this change. This is due to the traits expressing different ideas and because hyperbolic functions are not trivially implementable from exponential functions for floating-point types.
Diffstat (limited to 'src/libcore/num')
| -rw-r--r-- | src/libcore/num/f32.rs | 2 | ||||
| -rw-r--r-- | src/libcore/num/f64.rs | 2 | ||||
| -rw-r--r-- | src/libcore/num/float.rs | 2 | ||||
| -rw-r--r-- | src/libcore/num/num.rs | 6 |
4 files changed, 9 insertions, 3 deletions
diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 8c34219ae21..e687f482fa9 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -425,7 +425,9 @@ impl Exponential for f32 { #[inline(always)] fn log10(&self) -> f32 { log10(*self) } +} +impl Hyperbolic for f32 { #[inline(always)] fn sinh(&self) -> f32 { sinh(*self) } diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 19951ad7cff..d00e6ae2c0d 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -437,7 +437,9 @@ impl Exponential for f64 { #[inline(always)] fn log10(&self) -> f64 { log10(*self) } +} +impl Hyperbolic for f64 { #[inline(always)] fn sinh(&self) -> f64 { sinh(*self) } diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index c64f36f065f..3aa8848cdbe 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -547,7 +547,9 @@ 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 diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index 30a1213f7ff..3e43ebfef12 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -131,9 +131,9 @@ pub trait Exponential { fn log(&self) -> Self; fn log2(&self) -> Self; fn log10(&self) -> Self; +} - // 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. +pub trait Hyperbolic: Exponential { fn sinh(&self) -> Self; fn cosh(&self) -> Self; fn tanh(&self) -> Self; @@ -146,7 +146,7 @@ pub trait Real: Signed + Fractional + Algebraic + Trigonometric - + Exponential { + + Hyperbolic { // Common Constants // FIXME (#5527): These should be associated constants fn pi() -> Self; |
