Skip to main content

Module slice

Module slice 

Source
Expand description

Slice forms of rustymath’s functions. Each function object, such as [Pow], has a scalar form one and a slice form many. Both run code that rustymath compiles once for each item type, inside its own crate. A caller’s build settings can’t change that code, and rustymath’s speed test times what callers run. An edit to a function’s body rebuilds only rustymath.

Structs§

Flipped
K with its two arguments in the other order, as a Binary at each item type where K is one: Flipped(k).one(x, y) is k.one(y, x), and likewise for many and checked.
Wrapped
K with no result failing. Each result is K’s, wrapped to its type, as static kinds and NumPy keep integer results. LLVM removes K’s test of whether a result fits, because the loop never reads it. The adapter suits an object whose scalar form is its whole computation, as integer arithmetic’s is.

Enums§

Arg
One argument of a slice function: one item that every result pairs with, or one item for each result.

Constants§

CHUNK
How many items a caller handles at a time where it converts or expands arguments into buffers for a slice form. Buffers of this many items stay in cache.

Traits§

Binary
A function of two items as a value, as Unary is for one.
KernelItem
A type that function objects take or give: a float, a complex number, an integer, a Boolean, a character or an ordering. Pieces on several threads read and write items.
Results
The results of a function object of N items of type T: their type and whether any can fail. Unary, Binary and Ternary each require it, so code that takes a function object of any arity reads these through one bound.
Ternary
A function of three items as a value, as Unary is for one.
Unary
A function of one item as a value, with a scalar form and a slice form. rustymath’s function objects, such as Exp, implement it at each item type they take: every Float type for a float function, and complex numbers, integers or Booleans for others. Out is the type of each result, which is the item type unless the function gives another, as Abs gives the real magnitude of a complex number. Its methods take &self, so a function object can hold settings.

Functions§

appended⚠
Appends n items to out, which write writes into its spare capacity, never zeroed first, and gives write’s result. write must write every slot it gets. Each caller’s loop does, by its construction.
buffered⚠
f, a slice form writing n outputs of type O, run into a buffer, with each turning each output into the P that out takes. It gives f’s result.
judged
Whether valid holds for every result in out with the items of x that gave it, paired as mapped pairs them. These loops only judge: a loop that also computes each result stops vectorizing for some bodies, such as Ln’s. Failures gather as bits, with no branch.
mapped
Writes f for each of n results into out, for arguments x, and gives whether f said true for every result. One and two arguments run through [pairs_into], and three through triples_into, whose loops vectorize.
pairs
Appends f on each of n pairs of items to out, and gives whether f said true for every pair. An Arg::One pairs with every item of the other argument. The loops write straight into out’s spare capacity, which is never zeroed first. This is the loop that rustymath’s slice forms run, and a caller’s own kernels can run it too, as basedpl’s arithmetic does. A long call splits across threads, as parallel describes.
running
How many independent running values a loop keeps, each of size bytes: a fold’s partial results, or a block of items under Horner’s rule. 32 measured faster on the Mac than 8 or 16 for items of up to 8 bytes. A 16-byte item, such as a Complex<f64>, keeps 16, because 32 fill every vector register, and a complex sum then took 1.7 times as long. In wasm, LLVM leaves 32 values of 8 bytes, or 16 of 16 bytes, in linear memory, where each step loads and stores them. It keeps half as many in locals.
written⚠
out’s slots as items. Each caller passes only slots that its loop has just written.