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.
This commit is contained in:
@@ -105,7 +105,7 @@ pub use iter::{ExtendedMutableIter};
|
|||||||
|
|
||||||
pub use num::{Num, NumCast};
|
pub use num::{Num, NumCast};
|
||||||
pub use num::{Orderable, Signed, Unsigned, Round};
|
pub use num::{Orderable, Signed, Unsigned, Round};
|
||||||
pub use num::{Algebraic, Trigonometric, Exponential};
|
pub use num::{Algebraic, Trigonometric, Exponential, Hyperbolic};
|
||||||
pub use num::{Integer, Fractional, Real, RealExt};
|
pub use num::{Integer, Fractional, Real, RealExt};
|
||||||
pub use num::{Bitwise, BitCount, Bounded};
|
pub use num::{Bitwise, BitCount, Bounded};
|
||||||
pub use num::{Primitive, Int, Float};
|
pub use num::{Primitive, Int, Float};
|
||||||
|
|||||||
@@ -425,7 +425,9 @@ impl Exponential for f32 {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn log10(&self) -> f32 { log10(*self) }
|
fn log10(&self) -> f32 { log10(*self) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Hyperbolic for f32 {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn sinh(&self) -> f32 { sinh(*self) }
|
fn sinh(&self) -> f32 { sinh(*self) }
|
||||||
|
|
||||||
|
|||||||
@@ -437,7 +437,9 @@ impl Exponential for f64 {
|
|||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn log10(&self) -> f64 { log10(*self) }
|
fn log10(&self) -> f64 { log10(*self) }
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Hyperbolic for f64 {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn sinh(&self) -> f64 { sinh(*self) }
|
fn sinh(&self) -> f64 { sinh(*self) }
|
||||||
|
|
||||||
|
|||||||
@@ -547,7 +547,9 @@ impl Exponential for float {
|
|||||||
fn log10(&self) -> float {
|
fn log10(&self) -> float {
|
||||||
(*self as f64).log10() as float
|
(*self as f64).log10() as float
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Hyperbolic for float {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn sinh(&self) -> float {
|
fn sinh(&self) -> float {
|
||||||
(*self as f64).sinh() as float
|
(*self as f64).sinh() as float
|
||||||
|
|||||||
@@ -131,9 +131,9 @@ pub trait Exponential {
|
|||||||
fn log(&self) -> Self;
|
fn log(&self) -> Self;
|
||||||
fn log2(&self) -> Self;
|
fn log2(&self) -> Self;
|
||||||
fn log10(&self) -> Self;
|
fn log10(&self) -> Self;
|
||||||
|
}
|
||||||
|
|
||||||
// The Hyperbolic Functions are trivially implemented in terms of `exp`, so it's simpler
|
pub trait Hyperbolic: Exponential {
|
||||||
// to group them within this trait. In the future these would have default implementations.
|
|
||||||
fn sinh(&self) -> Self;
|
fn sinh(&self) -> Self;
|
||||||
fn cosh(&self) -> Self;
|
fn cosh(&self) -> Self;
|
||||||
fn tanh(&self) -> Self;
|
fn tanh(&self) -> Self;
|
||||||
@@ -146,7 +146,7 @@ pub trait Real: Signed
|
|||||||
+ Fractional
|
+ Fractional
|
||||||
+ Algebraic
|
+ Algebraic
|
||||||
+ Trigonometric
|
+ Trigonometric
|
||||||
+ Exponential {
|
+ Hyperbolic {
|
||||||
// Common Constants
|
// Common Constants
|
||||||
// FIXME (#5527): These should be associated constants
|
// FIXME (#5527): These should be associated constants
|
||||||
fn pi() -> Self;
|
fn pi() -> Self;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ pub use iter::{CopyableIter, CopyableOrderedIter, CopyableNonstrictIter};
|
|||||||
pub use iter::{Times, ExtendedMutableIter};
|
pub use iter::{Times, ExtendedMutableIter};
|
||||||
pub use num::{Num, NumCast};
|
pub use num::{Num, NumCast};
|
||||||
pub use num::{Orderable, Signed, Unsigned, Round};
|
pub use num::{Orderable, Signed, Unsigned, Round};
|
||||||
pub use num::{Algebraic, Trigonometric, Exponential};
|
pub use num::{Algebraic, Trigonometric, Exponential, Hyperbolic};
|
||||||
pub use num::{Integer, Fractional, Real, RealExt};
|
pub use num::{Integer, Fractional, Real, RealExt};
|
||||||
pub use num::{Bitwise, BitCount, Bounded};
|
pub use num::{Bitwise, BitCount, Bounded};
|
||||||
pub use num::{Primitive, Int, Float};
|
pub use num::{Primitive, Int, Float};
|
||||||
|
|||||||
Reference in New Issue
Block a user