Skip to main content

Ops

Trait Ops 

Source
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§

Source

type V: Copy

A value.

Source

type B: Copy

A truth value.

Source

type I: Copy

Integer bits at the resolved working width.

Source

type W: Copy

A binary64 temporary for short mixed-width reductions.

Required Methods§

Source

fn width(&self) -> FloatWidth

Source

fn fused(&self) -> bool

Source

fn widen(&self, x: Self::V) -> Self::W

Source

fn wide_number(&self, x: f64) -> Self::W

Source

fn wide_multiply_add(&self, x: Self::W, y: Self::W, z: Self::W) -> Self::W

Source

fn narrow(&self, x: Self::W) -> Self::V

Source

fn integer(&self, x: i64) -> Self::I

Source

fn integer_op(&self, op: Integer, x: Self::I, y: Self::I) -> Self::I

Source

fn integer_compare(&self, op: Cmp, x: Self::I, y: Self::I) -> Self::B

Source

fn integer_select(&self, test: Self::B, x: Self::I, y: Self::I) -> Self::I

Source

fn to_integer(&self, x: Self::V) -> Self::I

Source

fn from_integer(&self, x: Self::I) -> Self::V

Source

fn to_bits(&self, x: Self::V) -> Self::I

Source

fn from_bits(&self, x: Self::I) -> Self::V

Source

fn number(&self, x: F) -> Self::V

The number x.

Source

fn unary(&self, op: Unary, x: Self::V) -> Self::V

Source

fn binary(&self, op: Binary, x: Self::V, y: Self::V) -> Self::V

Source

fn compare(&self, c: Cmp, x: Self::V, y: Self::V) -> Self::B

Source

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.

Source

fn overflow(&self, op: Binary, x: Self::V, y: Self::V) -> Self::B

Source

fn and(&self, x: Self::B, y: Self::B) -> Self::B

Source

fn or(&self, x: Self::B, y: Self::B) -> Self::B

Source

fn not(&self, x: Self::B) -> Self::B

Source

fn select(&self, m: Self::B, x: Self::V, y: Self::V) -> Self::V

x where m holds, otherwise y. ∂’s recorder runs a recipe on whole values, where m and each array case must have one layout: build them from the same arguments.

Provided Methods§

Source

fn one_where(&self, m: Self::B) -> Self::V

1 where m holds, otherwise 0.

Source

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.

Source

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.

Source

fn tolerance(&self, fallback: F) -> Self::V

Captured tolerance; recording backends return its runtime setting slot.

Source

fn sign(&self, x: Self::V) -> Self::V

The sign of x, as sign gives it.

Source

fn reciprocal(&self, x: Self::V) -> Self::V

1 ÷ x, as reciprocal gives it.

Source

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.

Source

fn real_power(&self, x: Self::V, y: Self::V) -> Self::V

The real part of x^y through the existing power formula.

Source

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.

Source

fn negate(&self, x: Self::V) -> Self::V

Source

fn magnitude(&self, x: Self::V) -> Self::V

Source

fn sqrt(&self, x: Self::V) -> Self::V

Source

fn floor(&self, x: Self::V) -> Self::V

Source

fn ln(&self, x: Self::V) -> Self::V

Source

fn sin(&self, x: Self::V) -> Self::V

Source

fn cos(&self, x: Self::V) -> Self::V

Source

fn sinh(&self, x: Self::V) -> Self::V

Source

fn cosh(&self, x: Self::V) -> Self::V

Source

fn sqrt1mx2(&self, x: Self::V) -> Self::V

Source

fn sqrt1px2(&self, x: Self::V) -> Self::V

Source

fn digamma(&self, x: Self::V) -> Self::V

Source

fn exp(&self, x: Self::V) -> Self::V

Source

fn lgamma(&self, x: Self::V) -> Self::V

Source

fn complement(&self, x: Self::V) -> Self::V

Source

fn add(&self, x: Self::V, y: Self::V) -> Self::V

Source

fn subtract(&self, x: Self::V, y: Self::V) -> Self::V

Source

fn multiply(&self, x: Self::V, y: Self::V) -> Self::V

Source

fn divide(&self, x: Self::V, y: Self::V) -> Self::V

Source

fn larger(&self, x: Self::V, y: Self::V) -> Self::V

Source

fn smaller(&self, x: Self::V, y: Self::V) -> Self::V

Source

fn binom(&self, x: Self::V, y: Self::V) -> Self::V

Source

fn binom_dn(&self, x: Self::V, y: Self::V) -> Self::V

Source

fn binom_dk(&self, x: Self::V, y: Self::V) -> Self::V

Source

fn polygamma(&self, x: Self::V, y: Self::V) -> Self::V

Source

fn bit_and(&self, x: Self::V, y: Self::V) -> Self::V

Source

fn less(&self, x: Self::V, y: Self::V) -> Self::B

Source

fn less_equal(&self, x: Self::V, y: Self::V) -> Self::B

Source

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".

Implementors§

Source§

impl<F, const FUSED: bool> Ops<F> for NativeOps<FUSED>
where F: Float,

Source§

type V = F

Source§

type B = bool

Source§

type I = u64

Source§

type W = f64

Source§

impl<F> Ops<F> for RangeOps
where F: Float,

Source§

impl<T> Ops<f64> for IntegerOps<T>
where T: Overflowing,

Source§

type V = T

Source§

type B = bool

Source§

type I = u64

Source§

type W = f64