pub struct Native64;Expand description
Numerical kernel specifier to be used as generic argument (or associated type) in order to indicate
that the floating point values that must be used are the Rust’s native f64 and/or Complex<f64>.
Trait Implementations§
Source§impl FunctionsComplexType<Native64> for Complex<f64>
Implement the FunctionsComplexType trait for the Complex<f64> type.
impl FunctionsComplexType<Native64> for Complex<f64>
Implement the FunctionsComplexType trait for the Complex<f64> type.
Source§fn new_(real_part: f64, imag_part: f64) -> Self
fn new_(real_part: f64, imag_part: f64) -> Self
Creates a complex number of type T::ComplexType from its real and imaginary parts.
§Panics
In debug mode a panic! will be emitted if the real_part or the imag_part is not finite.
Source§fn set_real_(&mut self, real_part: f64)
fn set_real_(&mut self, real_part: f64)
Set the value of the real part.
§Panics
In debug mode a panic! will be emitted if real_part is not finite.
Source§fn set_imag_(&mut self, imag_part: f64)
fn set_imag_(&mut self, imag_part: f64)
Set the value of the imaginary part.
§Panics
In debug mode a panic! will be emitted if imaginary_part is not finite.
Source§fn add_real_(&mut self, c: &f64)
fn add_real_(&mut self, c: &f64)
Add the value of the the real coefficient c to real part of self.
Source§fn add_imag_(&mut self, c: &f64)
fn add_imag_(&mut self, c: &f64)
Add the value of the the real coefficient c to imaginary part of self.
Source§fn multiply_real_(&mut self, c: &f64)
fn multiply_real_(&mut self, c: &f64)
Multiply the value of the real part by the real coefficient c.
Source§fn multiply_imag_(&mut self, c: &f64)
fn multiply_imag_(&mut self, c: &f64)
Multiply the value of the imaginary part by the real coefficient c.
Source§fn try_from_f64_(
real_part: f64,
imag_part: f64,
) -> Result<Self, TryFromf64Errors>
fn try_from_f64_( real_part: f64, imag_part: f64, ) -> Result<Self, TryFromf64Errors>
Try to build a Self from real and imaginary parts as f64 values.
The returned value is Ok if the input real_part and imag_part are finite and can be exactly represented by T::RealType,
otherwise the returned value is TryFromf64Errors.
Source§impl FunctionsRealType<Native64> for f64
impl FunctionsRealType<Native64> for f64
Source§fn atan2_(self, other: &Self) -> Self
fn atan2_(self, other: &Self) -> Self
Computes the four quadrant arctangent of self (y) and other (x) in radians.
x = 0,y = 0:0x >= 0:arctan(y/x)->[-pi/2, pi/2]y >= 0:arctan(y/x) + pi->(pi/2, pi]y < 0:arctan(y/x) - pi->(-pi, -pi/2)
use ftl_numkernel::{FunctionsGeneralType, FunctionsRealType};
let y = 3.0_f64;
let x = -4.0_f64;
let atan2 = y.atan2_(&x);
let expected = 2.4981_f64;
assert!((atan2 - expected).abs() < 0.0001);Source§fn clamp_(self, min: &Self, max: &Self) -> Self
fn clamp_(self, min: &Self, max: &Self) -> Self
Clamp the value within the specified bounds.
Returns max if self is greater than max, and min if self is less than min.
Otherwise this returns self.
Note that this function returns NaN if the initial value was NaN as well.
§Panics
Panics if min > max, min is NaN, or max is NaN.
use ftl_numkernel::{FunctionsRealType, IsNaN};
assert!((-3.0f64).clamp_(&-2.0, &1.0) == -2.0);
assert!((0.0f64).clamp_(&-2.0, &1.0) == 0.0);
assert!((2.0f64).clamp_(&-2.0, &1.0) == 1.0);
assert!((f64::NAN).clamp_(&-2.0, &1.0).is_nan_());Source§fn classify_(&self) -> FpCategory
fn classify_(&self) -> FpCategory
Returns the floating point category of the number. If only one property is going to be tested, it is generally faster to use the specific predicate instead.
use ftl_numkernel::FunctionsRealType;
use std::num::FpCategory;
let num = 12.4_f64;
let inf = f64::INFINITY;
assert_eq!(num.classify_(), FpCategory::Normal);
assert_eq!(inf.classify_(), FpCategory::Infinite);Source§fn copysign_(self, sign: &Self) -> Self
fn copysign_(self, sign: &Self) -> Self
Returns a number with the magnitude of self and the sign of sign.
Source§fn epsilon_() -> Self
fn epsilon_() -> Self
Machine epsilon value for f64.
This is the difference between 1.0 and the next larger representable number.
Source§fn exp_m1_(self) -> Self
fn exp_m1_(self) -> Self
Returns `e^(self) - 1`` in a way that is accurate even if the number is close to zero.
Source§fn hypot_(self, other: &Self) -> Self
fn hypot_(self, other: &Self) -> Self
Compute the distance between the origin and a point (self, other) on the Euclidean plane.
Equivalently, compute the length of the hypotenuse of a right-angle triangle with other sides having length self.abs() and other.abs().
Source§fn is_sign_negative_(&self) -> bool
fn is_sign_negative_(&self) -> bool
Returns true if the value is negative, −0 or NaN with a negative sign.
Source§fn is_sign_positive_(&self) -> bool
fn is_sign_positive_(&self) -> bool
Returns true if the value is positive, +0 or NaN with a positive sign.
Source§fn ln_1p_(self) -> Self
fn ln_1p_(self) -> Self
Returns ln(1. + self) (natural logarithm) more accurately than if the operations were performed separately.
Source§fn neg_infinity_() -> Self
fn neg_infinity_() -> Self
Returns the special value representing the negative infinity.
Source§fn mul_add_mul_mut_(&mut self, mul: &Self, add_mul1: &Self, add_mul2: &Self)
fn mul_add_mul_mut_(&mut self, mul: &Self, add_mul1: &Self, add_mul2: &Self)
Multiplies two products and adds them in one fused operation, rounding to the nearest with only one rounding error.
a.mul_add_mul_mut_(&b, &c, &d) produces a result like &a * &b + &c * &d, but stores the result in a using its precision.
Source§fn mul_sub_mul_mut_(&mut self, mul: &Self, sub_mul1: &Self, sub_mul2: &Self)
fn mul_sub_mul_mut_(&mut self, mul: &Self, sub_mul1: &Self, sub_mul2: &Self)
Multiplies two products and subtracts them in one fused operation, rounding to the nearest with only one rounding error.
a.mul_sub_mul_mut_(&b, &c, &d) produces a result like &a * &b - &c * &d, but stores the result in a using its precision.
Source§fn negative_one_() -> Self
fn negative_one_() -> Self
Build and return the (floating point) value -1. represented by a f64.
Source§fn one_div_2_() -> Self
fn one_div_2_() -> Self
Build and return the (floating point) value 0.5 represented by the proper type.
Source§fn round_(self) -> Self
fn round_(self) -> Self
Rounds self to the nearest integer, rounding half-way cases away from zero.
Source§fn round_ties_even_(self) -> Self
fn round_ties_even_(self) -> Self
Returns the nearest integer to a number. Rounds half-way cases to the number with an even least significant digit.
This function always returns the precise result.
§Examples
use ftl_numkernel::FunctionsRealType;
let f = 3.3_f64;
let g = -3.3_f64;
let h = 3.5_f64;
let i = 4.5_f64;
assert_eq!(f.round_ties_even_(), 3.0);
assert_eq!(g.round_ties_even_(), -3.0);
assert_eq!(h.round_ties_even_(), 4.0);
assert_eq!(i.round_ties_even_(), 4.0);Source§fn signum_(self) -> Self
fn signum_(self) -> Self
Computes the signum.
The returned value is:
1.0if the value is positive, +0.0 or +∞−1.0if the value is negative, −0.0 or −∞NaNif the value is NaN
Source§fn try_from_f64_(value: f64) -> Result<Self, TryFromf64Errors>
fn try_from_f64_(value: f64) -> Result<Self, TryFromf64Errors>
Source§fn trunc_(self) -> Self
fn trunc_(self) -> Self
Returns the integer part of self. This means that non-integer numbers are always truncated towards zero.
§Examples
use ftl_numkernel::FunctionsRealType;
let f = 3.7_f64;
let g = 3.0_f64;
let h = -3.7_f64;
assert_eq!(f.trunc_(), 3.0);
assert_eq!(g.trunc_(), 3.0);
assert_eq!(h.trunc_(), -3.0);