pub trait Ops<F>where
F: Float,{
type V: Copy;
type B: Copy;
type I: Copy;
type W: Copy;
Show 62 methods
// Required methods
fn width(&self) -> FloatWidth;
fn fused(&self) -> bool;
fn widen(&self, x: Self::V) -> Self::W;
fn wide_number(&self, x: f64) -> Self::W;
fn wide_multiply_add(&self, x: Self::W, y: Self::W, z: Self::W) -> Self::W;
fn narrow(&self, x: Self::W) -> Self::V;
fn integer(&self, x: i64) -> Self::I;
fn integer_op(&self, op: Integer, x: Self::I, y: Self::I) -> Self::I;
fn integer_compare(&self, op: Cmp, x: Self::I, y: Self::I) -> Self::B;
fn integer_select(&self, test: Self::B, x: Self::I, y: Self::I) -> Self::I;
fn to_integer(&self, x: Self::V) -> Self::I;
fn from_integer(&self, x: Self::I) -> Self::V;
fn to_bits(&self, x: Self::V) -> Self::I;
fn from_bits(&self, x: Self::I) -> Self::V;
fn number(&self, x: F) -> Self::V;
fn unary(&self, op: Unary, x: Self::V) -> Self::V;
fn binary(&self, op: Binary, x: Self::V, y: Self::V) -> Self::V;
fn compare(&self, c: Cmp, x: Self::V, y: Self::V) -> Self::B;
fn multiply_add(&self, x: Self::V, y: Self::V, z: Self::V) -> Self::V;
fn overflow(&self, op: Binary, x: Self::V, y: Self::V) -> Self::B;
fn and(&self, x: Self::B, y: Self::B) -> Self::B;
fn or(&self, x: Self::B, y: Self::B) -> Self::B;
fn not(&self, x: Self::B) -> Self::B;
fn select(&self, m: Self::B, x: Self::V, y: Self::V) -> Self::V;
// Provided methods
fn one_where(&self, m: Self::B) -> Self::V { ... }
fn constant(&self, _v: Self::V) -> Option<F> { ... }
fn integral(&self) -> bool { ... }
fn tolerance(&self, fallback: F) -> Self::V { ... }
fn sign(&self, x: Self::V) -> Self::V { ... }
fn reciprocal(&self, x: Self::V) -> Self::V { ... }
fn power(&self, k: F, x: Self::V) -> Self::V { ... }
fn real_power(&self, x: Self::V, y: Self::V) -> Self::V { ... }
fn power_slope(
&self,
x: Self::V,
y: Self::V,
r: Self::V,
halves: bool,
) -> Self::V { ... }
fn negate(&self, x: Self::V) -> Self::V { ... }
fn magnitude(&self, x: Self::V) -> Self::V { ... }
fn sqrt(&self, x: Self::V) -> Self::V { ... }
fn floor(&self, x: Self::V) -> Self::V { ... }
fn ln(&self, x: Self::V) -> Self::V { ... }
fn sin(&self, x: Self::V) -> Self::V { ... }
fn cos(&self, x: Self::V) -> Self::V { ... }
fn sinh(&self, x: Self::V) -> Self::V { ... }
fn cosh(&self, x: Self::V) -> Self::V { ... }
fn sqrt1mx2(&self, x: Self::V) -> Self::V { ... }
fn sqrt1px2(&self, x: Self::V) -> Self::V { ... }
fn digamma(&self, x: Self::V) -> Self::V { ... }
fn exp(&self, x: Self::V) -> Self::V { ... }
fn lgamma(&self, x: Self::V) -> Self::V { ... }
fn complement(&self, x: Self::V) -> Self::V { ... }
fn add(&self, x: Self::V, y: Self::V) -> Self::V { ... }
fn subtract(&self, x: Self::V, y: Self::V) -> Self::V { ... }
fn multiply(&self, x: Self::V, y: Self::V) -> Self::V { ... }
fn divide(&self, x: Self::V, y: Self::V) -> Self::V { ... }
fn larger(&self, x: Self::V, y: Self::V) -> Self::V { ... }
fn smaller(&self, x: Self::V, y: Self::V) -> Self::V { ... }
fn binom(&self, x: Self::V, y: Self::V) -> Self::V { ... }
fn binom_dn(&self, x: Self::V, y: Self::V) -> Self::V { ... }
fn binom_dk(&self, x: Self::V, y: Self::V) -> Self::V { ... }
fn polygamma(&self, x: Self::V, y: Self::V) -> Self::V { ... }
fn bit_and(&self, x: Self::V, y: Self::V) -> Self::V { ... }
fn less(&self, x: Self::V, y: Self::V) -> Self::B { ... }
fn less_equal(&self, x: Self::V, y: Self::V) -> Self::B { ... }
fn equal(&self, x: Self::V, y: Self::V) -> Self::B { ... }
}Expand description
The operations that a recipe uses, on values V and truth values B, at float type F. Each rounds as IEEE’s operation, or rustymath’s function of its name, does at F’s width. An implementor computes the operations by id, in unary, binary and compare, and recipes call them by their names.
Required Associated Types§
Required Methods§
fn width(&self) -> FloatWidth
fn fused(&self) -> bool
fn widen(&self, x: Self::V) -> Self::W
fn wide_number(&self, x: f64) -> Self::W
fn wide_multiply_add(&self, x: Self::W, y: Self::W, z: Self::W) -> Self::W
fn narrow(&self, x: Self::W) -> Self::V
fn integer(&self, x: i64) -> Self::I
fn integer_op(&self, op: Integer, x: Self::I, y: Self::I) -> Self::I
fn integer_compare(&self, op: Cmp, x: Self::I, y: Self::I) -> Self::B
fn integer_select(&self, test: Self::B, x: Self::I, y: Self::I) -> Self::I
fn to_integer(&self, x: Self::V) -> Self::I
fn from_integer(&self, x: Self::I) -> Self::V
fn to_bits(&self, x: Self::V) -> Self::I
fn from_bits(&self, x: Self::I) -> Self::V
fn unary(&self, op: Unary, x: Self::V) -> Self::V
fn binary(&self, op: Binary, x: Self::V, y: Self::V) -> Self::V
fn compare(&self, c: Cmp, x: Self::V, y: Self::V) -> Self::B
Sourcefn multiply_add(&self, x: Self::V, y: Self::V, z: Self::V) -> Self::V
fn multiply_add(&self, x: Self::V, y: Self::V, z: Self::V) -> Self::V
x·y + z, rounded once where the target fuses multiply-add (FUSED), as rustymath’s mla gives it.
fn overflow(&self, op: Binary, x: Self::V, y: Self::V) -> Self::B
fn and(&self, x: Self::B, y: Self::B) -> Self::B
fn or(&self, x: Self::B, y: Self::B) -> Self::B
fn not(&self, x: Self::B) -> Self::B
Provided Methods§
Sourcefn constant(&self, _v: Self::V) -> Option<F>
fn constant(&self, _v: Self::V) -> Option<F>
v where it’s one number that every item shares, known before any item is read, such as the 3 of x^3. A recipe can pick a cheaper formula by it. None where v varies by item.
Sourcefn integral(&self) -> bool
fn integral(&self) -> bool
Whether values are integers, as a compiler’s values at an integer type are. A recipe for an integer object asks before taking an integer-only step (Binary::BitAnd). Floats never are.
Sourcefn tolerance(&self, fallback: F) -> Self::V
fn tolerance(&self, fallback: F) -> Self::V
Captured tolerance; recording backends return its runtime setting slot.
Sourcefn reciprocal(&self, x: Self::V) -> Self::V
fn reciprocal(&self, x: Self::V) -> Self::V
1 ÷ x, as reciprocal gives it.
Sourcefn power(&self, k: F, x: Self::V) -> Self::V
fn power(&self, k: F, x: Self::V) -> Self::V
x raised to k, a constant that Exponent::of routes off the general route, as power gives it.
Sourcefn real_power(&self, x: Self::V, y: Self::V) -> Self::V
fn real_power(&self, x: Self::V, y: Self::V) -> Self::V
The real part of x^y through the existing power formula.
Sourcefn power_slope(
&self,
x: Self::V,
y: Self::V,
r: Self::V,
halves: bool,
) -> Self::V
fn power_slope( &self, x: Self::V, y: Self::V, r: Self::V, halves: bool, ) -> Self::V
The partial in x of x^y = r; halves permits constant half-integer powers.
fn negate(&self, x: Self::V) -> Self::V
fn magnitude(&self, x: Self::V) -> Self::V
fn sqrt(&self, x: Self::V) -> Self::V
fn floor(&self, x: Self::V) -> Self::V
fn ln(&self, x: Self::V) -> Self::V
fn sin(&self, x: Self::V) -> Self::V
fn cos(&self, x: Self::V) -> Self::V
fn sinh(&self, x: Self::V) -> Self::V
fn cosh(&self, x: Self::V) -> Self::V
fn sqrt1mx2(&self, x: Self::V) -> Self::V
fn sqrt1px2(&self, x: Self::V) -> Self::V
fn digamma(&self, x: Self::V) -> Self::V
fn exp(&self, x: Self::V) -> Self::V
fn lgamma(&self, x: Self::V) -> Self::V
fn complement(&self, x: Self::V) -> Self::V
fn add(&self, x: Self::V, y: Self::V) -> Self::V
fn subtract(&self, x: Self::V, y: Self::V) -> Self::V
fn multiply(&self, x: Self::V, y: Self::V) -> Self::V
fn divide(&self, x: Self::V, y: Self::V) -> Self::V
fn larger(&self, x: Self::V, y: Self::V) -> Self::V
fn smaller(&self, x: Self::V, y: Self::V) -> Self::V
fn binom(&self, x: Self::V, y: Self::V) -> Self::V
fn binom_dn(&self, x: Self::V, y: Self::V) -> Self::V
fn binom_dk(&self, x: Self::V, y: Self::V) -> Self::V
fn polygamma(&self, x: Self::V, y: Self::V) -> Self::V
fn bit_and(&self, x: Self::V, y: Self::V) -> Self::V
fn less(&self, x: Self::V, y: Self::V) -> Self::B
fn less_equal(&self, x: Self::V, y: Self::V) -> Self::B
fn equal(&self, x: Self::V, y: Self::V) -> Self::B
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".