Struct dual_num::DualNumber
[−]
[src]
pub struct DualNumber<T>(_, _);
Dual Number structure
Although DualNumber
does implement PartialEq
and PartialOrd
,
it only compares the real part.
Additionally, min
and max
only compare the real parts, and keep the dual parts.
Lastly, the Rem
remainder operator is not correctly or fully defined for DualNumber
, and will panic.
Methods
impl<T> DualNumber<T>
[src]
pub fn new(real: T, dual: T) -> DualNumber<T>
[src]
Create a new dual number from its real and dual parts.
pub fn from_real(real: T) -> DualNumber<T> where
T: Zero,
[src]
T: Zero,
Create a new dual number from a real number.
The dual part is set to zero.
pub fn into_tuple(self) -> (T, T)
[src]
Returns both real and dual parts as a tuple
ⓘImportant traits for &'a mut Wpub fn real_ref(&self) -> &T
[src]
Returns a reference to the real part
ⓘImportant traits for &'a mut Wpub fn dual_ref(&self) -> &T
[src]
Returns a reference to the dual part
ⓘImportant traits for &'a mut Wpub fn real_mut(&mut self) -> &mut T
[src]
Returns a mutable reference to the real part
ⓘImportant traits for &'a mut Wpub fn dual_mut(&mut self) -> &mut T
[src]
Returns a mutable reference to the dual part
pub fn map<F>(self, mapper: F) -> Self where
F: Fn(DualNumber<T>) -> DualNumber<T>,
[src]
F: Fn(DualNumber<T>) -> DualNumber<T>,
Convenience method to take a closure (or any function) that can operate on the dual number in place
pub fn map_parts<F>(self, mapper: F) -> Self where
F: Fn(T, T) -> DualNumber<T>,
[src]
F: Fn(T, T) -> DualNumber<T>,
Convenience method to take a closure (or any function) that can operate on the dual number parts in place
impl<T: Copy> DualNumber<T>
[src]
pub fn real(&self) -> T
[src]
Returns the real part
pub fn dual(&self) -> T
[src]
Returns the dual part
impl<T: Float> DualNumber<T>
[src]
Trait Implementations
impl<T: Debug> Debug for DualNumber<T>
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<T: Clone> Clone for DualNumber<T>
[src]
fn clone(&self) -> DualNumber<T>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Copy> Copy for DualNumber<T>
[src]
impl<T: Zero> From<T> for DualNumber<T>
[src]
fn from(real: T) -> DualNumber<T>
[src]
Performs the conversion.
impl<T: Display> Display for DualNumber<T>
[src]
fn fmt(&self, f: &mut Formatter) -> FmtResult
[src]
Formats the value using the given formatter. Read more
impl<T: PartialEq> PartialEq<Self> for DualNumber<T>
[src]
fn eq(&self, rhs: &Self) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T: PartialOrd> PartialOrd<Self> for DualNumber<T>
[src]
fn partial_cmp(&self, rhs: &Self) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, rhs: &Self) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, rhs: &Self) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, rhs: &Self) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, rhs: &Self) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: PartialEq> PartialEq<T> for DualNumber<T>
[src]
fn eq(&self, rhs: &T) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T: PartialOrd> PartialOrd<T> for DualNumber<T>
[src]
fn partial_cmp(&self, rhs: &T) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, rhs: &T) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, rhs: &T) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, rhs: &T) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, rhs: &T) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<T: ToPrimitive> ToPrimitive for DualNumber<T>
[src]
fn to_isize(&self) -> Option<isize>
[src]
Converts the value of self
to an isize
.
fn to_i8(&self) -> Option<i8>
[src]
Converts the value of self
to an i8
.
fn to_i16(&self) -> Option<i16>
[src]
Converts the value of self
to an i16
.
fn to_i32(&self) -> Option<i32>
[src]
Converts the value of self
to an i32
.
fn to_i64(&self) -> Option<i64>
[src]
Converts the value of self
to an i64
.
fn to_usize(&self) -> Option<usize>
[src]
Converts the value of self
to a usize
.
fn to_u8(&self) -> Option<u8>
[src]
Converts the value of self
to an u8
.
fn to_u16(&self) -> Option<u16>
[src]
Converts the value of self
to an u16
.
fn to_u32(&self) -> Option<u32>
[src]
Converts the value of self
to an u32
.
fn to_u64(&self) -> Option<u64>
[src]
Converts the value of self
to an u64
.
fn to_f32(&self) -> Option<f32>
[src]
Converts the value of self
to an f32
.
fn to_f64(&self) -> Option<f64>
[src]
Converts the value of self
to an f64
.
impl<T: FromPrimitive> FromPrimitive for DualNumber<T> where
T: Zero,
[src]
T: Zero,
fn from_isize(n: isize) -> Option<DualNumber<T>>
[src]
Convert an isize
to return an optional value of this type. If the value cannot be represented by this value, the None
is returned. Read more
fn from_i8(n: i8) -> Option<DualNumber<T>>
[src]
Convert an i8
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_i16(n: i16) -> Option<DualNumber<T>>
[src]
Convert an i16
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_i32(n: i32) -> Option<DualNumber<T>>
[src]
Convert an i32
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_i64(n: i64) -> Option<DualNumber<T>>
[src]
Convert an i64
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_usize(n: usize) -> Option<DualNumber<T>>
[src]
Convert a usize
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_u8(n: u8) -> Option<DualNumber<T>>
[src]
Convert an u8
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_u16(n: u16) -> Option<DualNumber<T>>
[src]
Convert an u16
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_u32(n: u32) -> Option<DualNumber<T>>
[src]
Convert an u32
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_u64(n: u64) -> Option<DualNumber<T>>
[src]
Convert an u64
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_f32(n: f32) -> Option<DualNumber<T>>
[src]
Convert a f32
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
fn from_f64(n: f64) -> Option<DualNumber<T>>
[src]
Convert a f64
to return an optional value of this type. If the type cannot be represented by this value, the None
is returned. Read more
impl<T: Num + Copy> Add<T> for DualNumber<T>
[src]
type Output = DualNumber<T>
The resulting type after applying the +
operator.
fn add(self, rhs: T) -> DualNumber<T>
[src]
Performs the +
operation.
impl<T: Num + Copy> Sub<T> for DualNumber<T>
[src]
type Output = DualNumber<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: T) -> DualNumber<T>
[src]
Performs the -
operation.
impl<T: Num + Copy> Mul<T> for DualNumber<T>
[src]
type Output = DualNumber<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: T) -> DualNumber<T>
[src]
Performs the *
operation.
impl<T: Num + Copy> Div<T> for DualNumber<T>
[src]
type Output = DualNumber<T>
The resulting type after applying the /
operator.
fn div(self, rhs: T) -> DualNumber<T>
[src]
Performs the /
operation.
impl<T: Signed + Copy> Neg for DualNumber<T>
[src]
type Output = Self
The resulting type after applying the -
operator.
fn neg(self) -> Self
[src]
Performs the unary -
operation.
impl<T: Num + Copy> Add<Self> for DualNumber<T>
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self
[src]
Performs the +
operation.
impl<T: Num + Copy> Sub<Self> for DualNumber<T>
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self
[src]
Performs the -
operation.
impl<T: Num + Copy> Mul<Self> for DualNumber<T>
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: Self) -> Self
[src]
Performs the *
operation.
impl<T: Num + Copy> Div<Self> for DualNumber<T>
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: Self) -> Self
[src]
Performs the /
operation.
impl<T: Num + Copy> Rem<Self> for DualNumber<T>
[src]
type Output = Self
The resulting type after applying the %
operator.
fn rem(self, _: Self) -> Self
[src]
UNIMPLEMENTED!!!
As far as I know, remainder is not a valid operation on dual numbers,
but is required for the Float
trait to be implemented.
impl<T> Signed for DualNumber<T> where
T: Signed + Copy + PartialOrd,
[src]
T: Signed + Copy + PartialOrd,
fn abs(&self) -> Self
[src]
Computes the absolute value. Read more
fn abs_sub(&self, rhs: &Self) -> Self
[src]
The positive difference of two numbers. Read more
fn signum(&self) -> Self
[src]
Returns the sign of the number. Read more
fn is_positive(&self) -> bool
[src]
Returns true if the number is positive and false if the number is zero or negative.
fn is_negative(&self) -> bool
[src]
Returns true if the number is negative and false if the number is zero or positive.
impl<T: Unsigned> Unsigned for DualNumber<T> where
Self: Num,
[src]
Self: Num,
impl<T: Num + Zero + Copy> Zero for DualNumber<T>
[src]
fn zero() -> DualNumber<T>
[src]
Returns the additive identity element of Self
, 0
. Read more
fn is_zero(&self) -> bool
[src]
Returns true
if self
is equal to the additive identity.
impl<T: Num + One + Copy> One for DualNumber<T>
[src]
fn one() -> DualNumber<T>
[src]
Returns the multiplicative identity element of Self
, 1
. Read more
fn is_one(&self) -> bool where
Self: PartialEq<Self>,
[src]
Self: PartialEq<Self>,
Returns true
if self
is equal to the multiplicative identity. Read more
impl<T: Num + Copy> Num for DualNumber<T>
[src]
type FromStrRadixErr = <T as Num>::FromStrRadixErr
fn from_str_radix(
str: &str,
radix: u32
) -> Result<DualNumber<T>, Self::FromStrRadixErr>
[src]
str: &str,
radix: u32
) -> Result<DualNumber<T>, Self::FromStrRadixErr>
Convert from a string and radix <= 36. Read more
impl<T: Float> NumCast for DualNumber<T>
[src]
fn from<N: ToPrimitive>(n: N) -> Option<DualNumber<T>>
[src]
Creates a number from another value that can be converted into a primitive via the ToPrimitive
trait. Read more
impl<T: FloatConst + Zero> FloatConst for DualNumber<T>
[src]
fn E() -> DualNumber<T>
[src]
Return Euler’s number.
fn FRAC_1_PI() -> DualNumber<T>
[src]
Return 1.0 / π
.
fn FRAC_1_SQRT_2() -> DualNumber<T>
[src]
Return 1.0 / sqrt(2.0)
.
fn FRAC_2_PI() -> DualNumber<T>
[src]
Return 2.0 / π
.
fn FRAC_2_SQRT_PI() -> DualNumber<T>
[src]
Return 2.0 / sqrt(π)
.
fn FRAC_PI_2() -> DualNumber<T>
[src]
Return π / 2.0
.
fn FRAC_PI_3() -> DualNumber<T>
[src]
Return π / 3.0
.
fn FRAC_PI_4() -> DualNumber<T>
[src]
Return π / 4.0
.
fn FRAC_PI_6() -> DualNumber<T>
[src]
Return π / 6.0
.
fn FRAC_PI_8() -> DualNumber<T>
[src]
Return π / 8.0
.
fn LN_10() -> DualNumber<T>
[src]
Return ln(10.0)
.
fn LN_2() -> DualNumber<T>
[src]
Return ln(2.0)
.
fn LOG10_E() -> DualNumber<T>
[src]
Return log10(e)
.
fn LOG2_E() -> DualNumber<T>
[src]
Return log2(e)
.
fn PI() -> DualNumber<T>
[src]
Return Archimedes’ constant.
fn SQRT_2() -> DualNumber<T>
[src]
Return sqrt(2.0)
.
impl<T> Float for DualNumber<T> where
T: Float + Signed + FloatConst,
[src]
T: Float + Signed + FloatConst,
fn nan() -> Self
[src]
Returns the NaN
value. Read more
fn infinity() -> Self
[src]
Returns the infinite value. Read more
fn neg_infinity() -> Self
[src]
Returns the negative infinite value. Read more
fn neg_zero() -> Self
[src]
Returns -0.0
. Read more
fn min_positive_value() -> Self
[src]
Returns the smallest positive, normalized value that this type can represent. Read more
fn epsilon() -> Self
[src]
Returns epsilon, a small positive value. Read more
fn min_value() -> Self
[src]
Returns the smallest finite value that this type can represent. Read more
fn max_value() -> Self
[src]
Returns the largest finite value that this type can represent. Read more
fn is_nan(self) -> bool
[src]
Returns true
if this value is NaN
and false otherwise. Read more
fn is_infinite(self) -> bool
[src]
Returns true
if this value is positive infinity or negative infinity and false otherwise. Read more
fn is_finite(self) -> bool
[src]
Returns true
if this number is neither infinite nor NaN
. Read more
fn is_normal(self) -> bool
[src]
Returns true
if the number is neither zero, infinite, [subnormal][subnormal], or NaN
. Read more
fn is_sign_positive(self) -> bool
[src]
Returns true
if self
is positive, including +0.0
, Float::infinity()
, and since Rust 1.20 also Float::nan()
. Read more
fn is_sign_negative(self) -> bool
[src]
Returns true
if self
is negative, including -0.0
, Float::neg_infinity()
, and since Rust 1.20 also -Float::nan()
. Read more
fn classify(self) -> FpCategory
[src]
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. Read more
fn floor(self) -> Self
[src]
Returns the largest integer less than or equal to a number. Read more
fn ceil(self) -> Self
[src]
Returns the smallest integer greater than or equal to a number. Read more
fn round(self) -> Self
[src]
Returns the nearest integer to a number. Round half-way cases away from 0.0
. Read more
fn trunc(self) -> Self
[src]
Return the integer part of a number. Read more
fn fract(self) -> Self
[src]
Returns the fractional part of a number. Read more
fn signum(self) -> Self
[src]
Returns a number that represents the sign of self
. Read more
fn abs(self) -> Self
[src]
Computes the absolute value of self
. Returns Float::nan()
if the number is Float::nan()
. Read more
fn max(self, other: Self) -> Self
[src]
Returns the maximum of the two numbers. Read more
fn min(self, other: Self) -> Self
[src]
Returns the minimum of the two numbers. Read more
fn abs_sub(self, rhs: Self) -> Self
[src]
The positive difference of two numbers. Read more
fn mul_add(self, a: Self, b: Self) -> Self
[src]
Fused multiply-add. Computes (self * a) + b
with only one rounding error. This produces a more accurate result with better performance than a separate multiplication operation followed by an add. Read more
fn recip(self) -> Self
[src]
Take the reciprocal (inverse) of a number, 1/x
. Read more
fn powi(self, n: i32) -> Self
[src]
Raise a number to an integer power. Read more
fn powf(self, n: Self) -> Self
[src]
Raise a number to a floating point power. Read more
fn exp(self) -> Self
[src]
Returns e^(self)
, (the exponential function). Read more
fn exp2(self) -> Self
[src]
Returns 2^(self)
. Read more
fn ln(self) -> Self
[src]
Returns the natural logarithm of the number. Read more
fn log(self, base: Self) -> Self
[src]
Returns the logarithm of the number with respect to an arbitrary base. Read more
fn log2(self) -> Self
[src]
Returns the base 2 logarithm of the number. Read more
fn log10(self) -> Self
[src]
Returns the base 10 logarithm of the number. Read more
fn sqrt(self) -> Self
[src]
Take the square root of a number. Read more
fn cbrt(self) -> Self
[src]
Take the cubic root of a number. Read more
fn hypot(self, other: Self) -> Self
[src]
Calculate the length of the hypotenuse of a right-angle triangle given legs of length x
and y
. Read more
fn sin(self) -> Self
[src]
Computes the sine of a number (in radians). Read more
fn cos(self) -> Self
[src]
Computes the cosine of a number (in radians). Read more
fn tan(self) -> Self
[src]
Computes the tangent of a number (in radians). Read more
fn asin(self) -> Self
[src]
Computes the arcsine of a number. Return value is in radians in the range [-pi/2, pi/2] or NaN if the number is outside the range [-1, 1]. Read more
fn acos(self) -> Self
[src]
Computes the arccosine of a number. Return value is in radians in the range [0, pi] or NaN if the number is outside the range [-1, 1]. Read more
fn atan(self) -> Self
[src]
Computes the arctangent of a number. Return value is in radians in the range [-pi/2, pi/2]; Read more
fn atan2(self, other: Self) -> Self
[src]
Computes the four quadrant arctangent of self
(y
) and other
(x
). Read more
fn sin_cos(self) -> (Self, Self)
[src]
Simultaneously computes the sine and cosine of the number, x
. Returns (sin(x), cos(x))
. Read more
fn exp_m1(self) -> Self
[src]
Returns e^(self) - 1
in a way that is accurate even if the number is close to zero. Read more
fn ln_1p(self) -> Self
[src]
Returns ln(1+n)
(natural logarithm) more accurately than if the operations were performed separately. Read more
fn sinh(self) -> Self
[src]
Hyperbolic sine function. Read more
fn cosh(self) -> Self
[src]
Hyperbolic cosine function. Read more
fn tanh(self) -> Self
[src]
Hyperbolic tangent function. Read more
fn asinh(self) -> Self
[src]
Inverse hyperbolic sine function. Read more
fn acosh(self) -> Self
[src]
Inverse hyperbolic cosine function. Read more
fn atanh(self) -> Self
[src]
Inverse hyperbolic tangent function. Read more
fn integer_decode(self) -> (u64, i16, i8)
[src]
Returns the mantissa, base 2 exponent, and sign as integers, respectively. The original number can be recovered by sign * mantissa * 2 ^ exponent
. Read more
fn to_degrees(self) -> Self
[src]
Converts radians to degrees. Read more
fn to_radians(self) -> Self
[src]
Converts degrees to radians. Read more
Auto Trait Implementations
impl<T> Send for DualNumber<T> where
T: Send,
T: Send,
impl<T> Sync for DualNumber<T> where
T: Sync,
T: Sync,