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
Kwith its two arguments in the other order, as aBinaryat each item type whereKis one:Flipped(k).one(x, y)isk.one(y, x), and likewise formanyandchecked.- Wrapped
Kwith no result failing. Each result isK’s, wrapped to its type, as static kinds and NumPy keep integer results. LLVM removesK’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
Unaryis for one. - Kernel
Item - 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
Nitems of typeT: their type and whether any can fail.Unary,BinaryandTernaryeach 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
Unaryis 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: everyFloattype for a float function, and complex numbers, integers or Booleans for others.Outis the type of each result, which is the item type unless the function gives another, asAbsgives the real magnitude of a complex number. Its methods take&self, so a function object can hold settings.
Functions§
- appended⚠
- Appends
nitems toout, whichwritewrites into its spare capacity, never zeroed first, and giveswrite’s result.writemust write every slot it gets. Each caller’s loop does, by its construction. - buffered⚠
f, a slice form writingnoutputs of typeO, run into a buffer, witheachturning each output into thePthatouttakes. It givesf’s result.- judged
- Whether
validholds for every result inoutwith the items ofxthat gave it, paired asmappedpairs them. These loops only judge: a loop that also computes each result stops vectorizing for some bodies, such asLn’s. Failures gather as bits, with no branch. - mapped
- Writes
ffor each ofnresults intoout, for argumentsx, and gives whetherfsaidtruefor every result. One and two arguments run through [pairs_into], and three throughtriples_into, whose loops vectorize. - pairs
- Appends
fon each ofnpairs of items toout, and gives whetherfsaidtruefor every pair. AnArg::Onepairs with every item of the other argument. The loops write straight intoout’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, asparalleldescribes. - running
- How many independent running values a loop keeps, each of
sizebytes: 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 aComplex<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.