Real: Ignore doc tests if Float is disabled

This commit is contained in:
Yoan Lecoq 2019-02-03 16:51:04 +01:00 committed by Josh Stone
parent aaf3c267bd
commit c28e2fe062
1 changed files with 96 additions and 143 deletions

View File

@ -14,48 +14,45 @@ use Float;
/// See [this Wikipedia article](https://en.wikipedia.org/wiki/Real_data_type)
/// for a list of data types that could meaningfully implement this trait.
///
/// This trait is only available with the `std` feature, or with the `libm` feature otherwise.
#[doc(test(attr(cfg(any(feature = "std", feature = "libm")))))]
/// This trait is always available, however it requires either `std` or `libm`
/// in order for `f32` and `f64` to implement it.
pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// Returns the smallest finite value that this type can represent.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
/// let x: f64 = Real::min_value();
///
/// assert_eq!(x, f64::MIN);
/// # }
/// ```
fn min_value() -> Self;
/// Returns the smallest positive, normalized value that this type can represent.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
/// let x: f64 = Real::min_positive_value();
///
/// assert_eq!(x, f64::MIN_POSITIVE);
/// # }
/// ```
fn min_positive_value() -> Self;
/// Returns epsilon, a small positive value.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
/// let x: f64 = Real::epsilon();
///
/// assert_eq!(x, f64::EPSILON);
/// # }
/// ```
///
/// # Panics
@ -66,21 +63,20 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// Returns the largest finite value that this type can represent.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
/// let x: f64 = Real::max_value();
/// assert_eq!(x, f64::MAX);
/// # }
/// ```
fn max_value() -> Self;
/// Returns the largest integer less than or equal to a number.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let f = 3.99;
@ -88,14 +84,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// assert_eq!(f.floor(), 3.0);
/// assert_eq!(g.floor(), 3.0);
/// # }
/// ```
fn floor(self) -> Self;
/// Returns the smallest integer greater than or equal to a number.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let f = 3.01;
@ -103,15 +98,14 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// assert_eq!(f.ceil(), 4.0);
/// assert_eq!(g.ceil(), 4.0);
/// # }
/// ```
fn ceil(self) -> Self;
/// Returns the nearest integer to a number. Round half-way cases away from
/// `0.0`.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let f = 3.3;
@ -119,14 +113,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// assert_eq!(f.round(), 3.0);
/// assert_eq!(g.round(), -3.0);
/// # }
/// ```
fn round(self) -> Self;
/// Return the integer part of a number.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let f = 3.3;
@ -134,14 +127,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// assert_eq!(f.trunc(), 3.0);
/// assert_eq!(g.trunc(), -3.0);
/// # }
/// ```
fn trunc(self) -> Self;
/// Returns the fractional part of a number.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let x = 3.5;
@ -151,15 +143,14 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// assert!(abs_difference_x < 1e-10);
/// assert!(abs_difference_y < 1e-10);
/// # }
/// ```
fn fract(self) -> Self;
/// Computes the absolute value of `self`. Returns `Float::nan()` if the
/// number is `Float::nan()`.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -173,7 +164,6 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// assert!(abs_difference_y < 1e-10);
///
/// assert!(::num_traits::Float::is_nan(f64::NAN.abs()));
/// # }
/// ```
fn abs(self) -> Self;
@ -183,8 +173,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// - `-1.0` if the number is negative, `-0.0` or `Float::neg_infinity()`
/// - `Float::nan()` if the number is `Float::nan()`
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -194,15 +184,14 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// assert_eq!(f64::NEG_INFINITY.signum(), -1.0);
///
/// assert!(f64::NAN.signum().is_nan());
/// # }
/// ```
fn signum(self) -> Self;
/// Returns `true` if `self` is positive, including `+0.0`,
/// `Float::infinity()`, and with newer versions of Rust `f64::NAN`.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -214,15 +203,14 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// assert!(f.is_sign_positive());
/// assert!(!g.is_sign_positive());
/// assert!(!neg_nan.is_sign_positive());
/// # }
/// ```
fn is_sign_positive(self) -> bool;
/// Returns `true` if `self` is negative, including `-0.0`,
/// `Float::neg_infinity()`, and with newer versions of Rust `-f64::NAN`.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -234,7 +222,6 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// assert!(!f.is_sign_negative());
/// assert!(g.is_sign_negative());
/// assert!(!nan.is_sign_negative());
/// # }
/// ```
fn is_sign_negative(self) -> bool;
@ -244,8 +231,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// Using `mul_add` can be more performant than an unfused multiply-add if
/// the target architecture has a dedicated `fma` CPU instruction.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let m = 10.0;
@ -256,21 +243,19 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (m.mul_add(x, b) - (m*x + b)).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn mul_add(self, a: Self, b: Self) -> Self;
/// Take the reciprocal (inverse) of a number, `1/x`.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let x = 2.0;
/// let abs_difference = (x.recip() - (1.0/x)).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn recip(self) -> Self;
@ -278,29 +263,27 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// Using this function is generally faster than using `powf`
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let x = 2.0;
/// let abs_difference = (x.powi(2) - x*x).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn powi(self, n: i32) -> Self;
/// Raise a number to a real number power.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let x = 2.0;
/// let abs_difference = (x.powf(2.0) - x*x).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn powf(self, n: Self) -> Self;
@ -312,8 +295,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// If the implementing type doesn't support NaN, this method should panic if `self < 0`.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let positive = 4.0;
@ -323,14 +306,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// assert!(abs_difference < 1e-10);
/// assert!(::num_traits::Float::is_nan(negative.sqrt()));
/// # }
/// ```
fn sqrt(self) -> Self;
/// Returns `e^(self)`, (the exponential function).
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let one = 1.0;
@ -341,14 +323,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (e.ln() - 1.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn exp(self) -> Self;
/// Returns `2^(self)`.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let f = 2.0;
@ -357,7 +338,6 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (f.exp2() - 4.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn exp2(self) -> Self;
@ -367,8 +347,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// If `self <= 0` and this type does not support a NaN representation, this function should panic.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let one = 1.0;
@ -379,7 +359,6 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (e.ln() - 1.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn ln(self) -> Self;
@ -389,8 +368,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// If `self <= 0` and this type does not support a NaN representation, this function should panic.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let ten = 10.0;
@ -404,7 +383,6 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// assert!(abs_difference_10 < 1e-10);
/// assert!(abs_difference_2 < 1e-10);
/// # }
/// ```
fn log(self, base: Self) -> Self;
@ -414,8 +392,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// If `self <= 0` and this type does not support a NaN representation, this function should panic.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let two = 2.0;
@ -424,7 +402,6 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (two.log2() - 1.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn log2(self) -> Self;
@ -435,8 +412,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// If `self <= 0` and this type does not support a NaN representation, this function should panic.
///
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let ten = 10.0;
@ -445,14 +422,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (ten.log10() - 1.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn log10(self) -> Self;
/// Converts radians to degrees.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use std::f64::consts;
///
/// let angle = consts::PI;
@ -460,14 +436,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (angle.to_degrees() - 180.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn to_degrees(self) -> Self;
/// Converts degrees to radians.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use std::f64::consts;
///
/// let angle = 180.0_f64;
@ -475,35 +450,32 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (angle.to_radians() - consts::PI).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn to_radians(self) -> Self;
/// Returns the maximum of the two numbers.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let x = 1.0;
/// let y = 2.0;
///
/// assert_eq!(x.max(y), y);
/// # }
/// ```
fn max(self, other: Self) -> Self;
/// Returns the minimum of the two numbers.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let x = 1.0;
/// let y = 2.0;
///
/// assert_eq!(x.min(y), x);
/// # }
/// ```
fn min(self, other: Self) -> Self;
@ -512,8 +484,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// * If `self <= other`: `0:0`
/// * Else: `self - other`
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let x = 3.0;
@ -524,14 +496,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// assert!(abs_difference_x < 1e-10);
/// assert!(abs_difference_y < 1e-10);
/// # }
/// ```
fn abs_sub(self, other: Self) -> Self;
/// Take the cubic root of a number.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let x = 8.0;
@ -540,15 +511,14 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (x.cbrt() - 2.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn cbrt(self) -> Self;
/// Calculate the length of the hypotenuse of a right-angle triangle given
/// legs of length `x` and `y`.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let x = 2.0;
@ -558,14 +528,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (x.hypot(y) - (x.powi(2) + y.powi(2)).sqrt()).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn hypot(self, other: Self) -> Self;
/// Computes the sine of a number (in radians).
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -574,14 +543,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (x.sin() - 1.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn sin(self) -> Self;
/// Computes the cosine of a number (in radians).
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -590,14 +558,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (x.cos() - 1.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn cos(self) -> Self;
/// Computes the tangent of a number (in radians).
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -605,7 +572,6 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (x.tan() - 1.0).abs();
///
/// assert!(abs_difference < 1e-14);
/// # }
/// ```
fn tan(self) -> Self;
@ -618,8 +584,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// If this type does not support a NaN representation, this function should panic
/// if the number is outside the range [-1, 1].
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -629,7 +595,6 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (f.sin().asin() - f64::consts::PI / 2.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn asin(self) -> Self;
@ -642,8 +607,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// If this type does not support a NaN representation, this function should panic
/// if the number is outside the range [-1, 1].
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -653,15 +618,14 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (f.cos().acos() - f64::consts::PI / 4.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn acos(self) -> Self;
/// Computes the arctangent of a number. Return value is in radians in the
/// range [-pi/2, pi/2];
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let f = 1.0;
@ -670,7 +634,6 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (f.tan().atan() - 1.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn atan(self) -> Self;
@ -681,8 +644,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// * `y >= 0`: `arctan(y/x) + pi` -> `(pi/2, pi]`
/// * `y < 0`: `arctan(y/x) - pi` -> `(-pi, -pi/2)`
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -701,15 +664,14 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// assert!(abs_difference_1 < 1e-10);
/// assert!(abs_difference_2 < 1e-10);
/// # }
/// ```
fn atan2(self, other: Self) -> Self;
/// Simultaneously computes the sine and cosine of the number, `x`. Returns
/// `(sin(x), cos(x))`.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -721,15 +683,14 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// assert!(abs_difference_0 < 1e-10);
/// assert!(abs_difference_0 < 1e-10);
/// # }
/// ```
fn sin_cos(self) -> (Self, Self);
/// Returns `e^(self) - 1` in a way that is accurate even if the
/// number is close to zero.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let x = 7.0;
@ -738,7 +699,6 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (x.ln().exp_m1() - 6.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn exp_m1(self) -> Self;
@ -750,8 +710,8 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// If this type does not support a NaN representation, this function should panic
/// if `self-1 <= 0`.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -761,14 +721,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (x.ln_1p() - 1.0).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn ln_1p(self) -> Self;
/// Hyperbolic sine function.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -781,14 +740,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (f - g).abs();
///
/// assert!(abs_difference < 1e-10);
/// # }
/// ```
fn sinh(self) -> Self;
/// Hyperbolic cosine function.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -801,14 +759,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
///
/// // Same result
/// assert!(abs_difference < 1.0e-10);
/// # }
/// ```
fn cosh(self) -> Self;
/// Hyperbolic tangent function.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -821,14 +778,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (f - g).abs();
///
/// assert!(abs_difference < 1.0e-10);
/// # }
/// ```
fn tanh(self) -> Self;
/// Inverse hyperbolic sine function.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let x = 1.0;
@ -837,14 +793,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (f - x).abs();
///
/// assert!(abs_difference < 1.0e-10);
/// # }
/// ```
fn asinh(self) -> Self;
/// Inverse hyperbolic cosine function.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
///
/// let x = 1.0;
@ -853,14 +808,13 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (f - x).abs();
///
/// assert!(abs_difference < 1.0e-10);
/// # }
/// ```
fn acosh(self) -> Self;
/// Inverse hyperbolic tangent function.
///
/// ```
/// # #[cfg(any(feature = "std", feature = "libm"))] {
#[cfg_attr(any(feature = "std", feature = "libm"), doc="```")]
#[cfg_attr(not(any(feature = "std", feature = "libm")), doc="```ignore")]
/// use num_traits::real::Real;
/// use std::f64;
///
@ -870,7 +824,6 @@ pub trait Real: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
/// let abs_difference = (f - e).abs();
///
/// assert!(abs_difference < 1.0e-10);
/// # }
/// ```
fn atanh(self) -> Self;
}