Skip to main content

Squares

Struct Squares 

Source
pub struct Squares;
Expand description

The sum of the squares of floats’ or complex numbers’ magnitudes as a Reduction, with each square computed and totalled in f64, where an f32’s square neither overflows nor underflows. It folds the items themselves, with no buffer of squares.

Trait Implementations§

Source§

impl Clone for Squares

Source§

fn clone(&self) -> Squares

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 Squares

Source§

impl Debug for Squares

Source§

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

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

impl<T> Reduction<T> for Squares
where T: Scalar,

Source§

const COMMUTATIVE: bool = true

Whether disjoint subsequences may be merged in any order.
Source§

type Total = f64

The type of a fold: the item type, i64 for a sum or product of integers narrower than 64 bits, f32 for a sum or product of f16s, i16 for an XNOR of bytes, the C of SumAs, f64 for Squares, a Scaled product for ScaledProduct, or a total with the parity of its count for Alternated.
Source§

fn unit() -> f64

The fold of no items: 0, 1, -∞ or ∞, the integer type’s least or greatest value, all ones, or false or true.
Source§

fn step(acc: f64, x: T) -> f64

acc combined with one more item.
Source§

fn merge(a: f64, b: f64) -> (f64, bool)

The folds of two neighbouring runs of items combined into the fold of both, and whether it fits.
Source§

fn slice(x: &[T]) -> (f64, bool)

The fold of x, which is unit() where x is empty, and whether it fits. The default takes each item in turn by checked.
Source§

fn scan(x: &[T], start: Option<f64>, out: &mut Vec<f64>) -> bool

Appends the running folds of x to out, the first combining start where it is given, and gives whether every one fits. The default takes each item in turn by checked (checked_steps).
Source§

fn identity() -> Self::Total

The exact identity of step, which leaves every total unchanged. For float sums it’s -0.0, because adding unit(), 0.0, turns a total of -0.0 into 0.0. For every other reduction it’s unit().
Source§

fn checked(acc: Self::Total, x: T) -> (Self::Total, bool)

step, and whether its result fits. An integer sum or product wraps where it doesn’t.
Source§

fn one(x: T) -> (Self::Total, bool)

The fold of the one item x, checked(identity(), x), and whether it fits.
Source§

fn chain(a: Self::Total, b: Self::Total) -> (Self::Total, bool)

merge, for a chain of folds whose every step waits for the one before, as van Herk-Gil-Werman’s suffixes and prefixes do. As in merge, a folds the earlier items. Float maximums and minimums override it with Folds::step_max and step_min, which use AArch64’s one-instruction fmaxnm and fminnm. LLVM can’t vectorize those, so they stay out of merge.
Source§

fn rows(data: &[T], columns: usize, out: &mut [Self::Total]) -> bool
where Self: Sized, T: Copy,

Folds each row of data, a matrix with columns items in each row, into the matching item of out, and gives whether every fold fits. The default is fold_rows, which folds each row of 16 items or more by slice. Float sums and products, integer maximums and minimums, and bitwise folds fold rows of 16 to 63 items by checked instead, eight rows side by side (rows_side_by_side). Each of their steps is one instruction, so keeping several rows’ steps in flight costs less than a call of slice for each row. Other reductions keep fold_rows, where slice vectorizes within the row: an integer sum’s step checks for overflow, and a float maximum’s or minimum’s slice runs Folds’ vector kernels. Nobody has timed float maximums side by side since their step became one select on x86.
Source§

fn short_lanes( _data: &[T], _len: usize, _start: Option<Self::Total>, _out: &mut Vec<Self::Total>, ) -> Option<bool>
where Self: Sized,

Appends the running folds of data’s lanes of len consecutive items to out, each lane from start, through a route that runs many short lanes at once, and gives whether every fold fits. A reduction without such a route gives None and appends nothing, as the default does. scan_along then runs the lanes itself. The Boolean reductions run lanes of 1 to 64 items through Logical, 64 items to a word.
Source§

const SPLIT: usize = 8

The most classes for which crate::search::ClassNumbers folds each class into four totals by position. Each step of a class’s total waits on the last through memory, so a reduction whose step takes longer gains from the split over more classes.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.