Skip to main content

ExactRange

Struct ExactRange 

Source
pub struct ExactRange {
    pub min: f64,
    pub max: f64,
}
Expand description

The magnitudes of leaves for which an exact stage is valid: every nonzero leaf x must satisfy min <= |x| <= max. Both are powers of two.

A leaf is an input coordinate for the raw form, the computed difference for a difference form with Leaves::One, and each of the two coordinates that are subtracted for a difference form with Leaves::Two.

§Why the range is sufficient

Write m = min, M = max and u = 2^-53.

Grid. A nonzero f64 of magnitude at least m, a normal power of two, is an integer multiple of q = m 2^-52; so is zero. For a power of two g, the rounding of a multiple of g to f64 is a multiple of g: where the spacing of f64 near the value is at least g, every f64 there is a multiple of g; where it is smaller, the value is representable and rounds to itself. Every error-free transformation returns a rounded value and the exact difference between the true result and it, so with multiples of g as inputs (of g_a g_b for a product of multiples of g_a and g_b) both outputs are multiples of g. Hence every value an evaluation handles, every component of the expansion of a node included, is a multiple of the node’s grid: q for a leaf (also for both components of a difference two_diff(a, b), which can be far below m after cancellation but are still multiples of q), the smaller grid of the operands for a sum, and the product of the grids for a product. A nonzero component is at least its grid in magnitude; for a node of degree g in the leaves, the grid is q^g.

Magnitude. Each error-free transformation turns inputs a, b into x + y = r, where r is a + b or a b, with |y| <= u |x|; then |x| <= |r| / (1 - u) and |x| + |y| <= (1 + 3u)(|a| + |b|), or (1 + 3u) |a| |b| for a product. Follow the multiset of values an evaluation holds (pending inputs, with the factor of a scaling applied, and outputs): its sum of magnitudes grows by at most a factor 1 + 3u per transformation, and the output expansion is part of it. So the sum of the magnitudes of the components of a node, and every value handled on the way, is at most (1 + 3u)^T S <= (1 + 6uT) S, where T <= 2^51 is the number of transformations the node depends on, counted with multiplicity (see the operation counts below), and S follows the structure: M for a coordinate or a computed difference, 2M for the two components of a difference of coordinates, |n| for a constant n, the sum of the operands’ S for a sum or difference, their product for a product.

Rule. The range is the widest pair of powers of two within [operand_min, operand_max] such that, for every operand of every product, the grid is at least operand_min and (1 + 6uT) S is at most operand_max, and (1 + 6uT) S < 2^1020 at every node. Every factor of every exact product is then zero or in the product domain, and no value overflows. The grid condition depends only on m and the magnitude conditions only on M, and both are monotone, so the two ends are found separately.

The operation counts, with l_x the worst-case length of x: a difference of two coordinates is one transformation; a sum or difference at most 2 (l_x + l_y); a product at most 3 l_x l_y for the exact products of the scalings plus 4 l_x l_y (l_x + l_y) for merging them, whichever operand is scaled and in whatever order the scalings are merged.

Fields§

§min: f64

The smallest admissible magnitude of a nonzero leaf.

§max: f64

The largest admissible magnitude of a leaf.

Trait Implementations§

Source§

impl Clone for ExactRange

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ExactRange

Source§

impl Debug for ExactRange

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ExactRange

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ExactRange

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.