pub struct Kernel { /* private fields */ }Expand description
One resolved mathematical definition and its captured numerical policies.
Implementations§
Source§impl Kernel
impl Kernel
pub fn resolve<K: Formula<N>, const N: usize>( object: K, variant: Variant, types: [DType; N], ) -> Result<Self, Error>
pub fn circle( code: i64, inverse: bool, real_part: bool, variant: Variant, types: [DType; 1], ) -> Result<Option<Self>, Error>
pub fn new<K: Formula<N>, const N: usize>(object: K, variant: Variant) -> Self
pub fn try_resolve<K: Formula<N>, const N: usize>( object: K, variant: Variant, types: [DType; N], ) -> Result<Option<Self>, Error>
Sourcepub fn of(
op: Op,
variant: Variant,
types: &[DType],
) -> Result<Option<Self>, Error>
pub fn of( op: Op, variant: Variant, types: &[DType], ) -> Result<Option<Self>, Error>
op resolved for arguments of types types in variant, as Kernel::try_resolve resolves its object: Ok(None) where it has no body for them, or types doesn’t hold one type per argument. Non-generic, so every formula’s kernel code compiles in rustymath alone.
Sourcepub fn slope(
op: Op,
side: usize,
variant: Variant,
types: &[DType],
) -> Result<Option<Self>, Error>
pub fn slope( op: Op, side: usize, variant: Variant, types: &[DType], ) -> Result<Option<Self>, Error>
The kernel of op’s partial in its argument side (derivative::Slope), whose arguments are op’s and then op’s result, one type each in types, resolved as Kernel::of resolves op. Ok(None) also where op takes three arguments.
pub fn arity(&self) -> usize
pub fn result_dtype(&self) -> DType
Sourcepub fn with_checked(self, checked: bool) -> Self
pub fn with_checked(self, checked: bool) -> Self
Select whether this operation reports item errors.
pub fn input_policy(&self) -> Option<Policy>
pub fn selected_input(&self) -> Option<usize>
Sourcepub fn ordered(self, classes: &[Option<i32>], types: &[DType]) -> Self
pub fn ordered(self, classes: &[Option<i32>], types: &[DType]) -> Self
Resolve an order-only operation on disjoint logical domains, before numeric promotion.
pub fn exact(&self, args: &[BigRational]) -> Result<Option<BigRational>, Error>
pub fn has_exact(&self) -> bool
Sourcepub fn integers(&self, args: &[i64]) -> Result<i64, Error>
pub fn integers(&self, args: &[i64]) -> Result<i64, Error>
The formula on one item of each integer argument, at the kernel’s integer computing width, with its checked or wrapping variant. A Boolean computing kind reads 0 and 1.
pub fn real(&self, args: &[f64], settings: Settings) -> Result<f64, Error>
pub fn complex( &self, args: &[Complex64], settings: Settings, ) -> Result<Complex64, Error>
Sourcepub fn may_raise(&self) -> bool
pub fn may_raise(&self) -> bool
Whether checked execution can record a numeric data error, for arguments that hold any values of their types.
Sourcepub fn may_raise_on(&self, narrowed: &[Range]) -> bool
pub fn may_raise_on(&self, narrowed: &[Range]) -> bool
Whether checked execution can record a numeric data error where each argument holds values of its type within its range in narrowed, such as a constant’s own value or the nonnegative numbers.
Sourcepub fn range_on(&self, narrowed: &[Range], same: bool) -> Range
pub fn range_on(&self, narrowed: &[Range], same: bool) -> Range
The result bound on arguments within narrowed. same says both arguments denote one value, enabling the formula’s same-input fact.
pub fn partials( &self, ops: &dyn Ops<f64, V = Slot, B = Slot, I = Slot, W = Slot>, x: &[Slot], result: Slot, needed: &[bool], output: &mut [Option<Slot>], )
pub fn range(&self, x: &[Range]) -> Range
pub fn identity(&self) -> Option<f64>
Sourcepub fn kept(&self, constants: &[Option<f64>]) -> Option<usize>
pub fn kept(&self, constants: &[Option<f64>]) -> Option<usize>
The argument that a dyadic call returns unchanged where constants gives the arguments that are one number, 0 for the left and 1 for the right, from the formula’s identities: x+0 and 0+x keep x, x-0 keeps x, and 0-x keeps nothing.
Sourcepub fn fold(&self) -> Option<Reduce>
pub fn fold(&self) -> Option<Reduce>
The reduction by which a fold through this kernel combines its items, as reduction gives it at the kernel’s variant.
Sourcepub fn inverse_fold(&self) -> Option<Reduce>
pub fn inverse_fold(&self) -> Option<Reduce>
The reduction that an unseeded right fold by this formula runs as an alternating one, as - runs as an alternating +.
pub fn truth_table(&self) -> Option<u8>
pub fn total_dtype(&self) -> Option<DType>
pub fn fold_dtype(&self, input: DType, len: usize, seed: Option<DType>) -> DType
Sourcepub fn scan_dtype(&self, seeded: bool) -> DType
pub fn scan_dtype(&self, seeded: bool) -> DType
The scan’s result dtype. A seeded comparison stores only Boolean results; without a seed, each lane retains its original first item. Native reductions can accumulate at a wider type.
Sourcepub fn product_dtype(&self, fold: &Kernel, plan: &ProductPlan) -> DType
pub fn product_dtype(&self, fold: &Kernel, plan: &ProductPlan) -> DType
The dtype of this map kernel’s product with fold over plan: its native product’s result where one runs (product_for), and otherwise fold’s total of this kernel’s results along the contracted axes (fold_dtype), as a fold of them gives.
pub fn map( &self, inputs: &[Read<'_>], range: Range<usize>, settings: Settings, output: &mut Buffer, ) -> Result<(), Error>
Sourcepub fn map_in<'a, 'b>(
&self,
inputs: &[Read<'_>],
range: Range<usize>,
settings: Settings,
scratch: &'a mut Scratch,
output: MapOutput<'a, 'b>,
) -> Result<(), Error>
pub fn map_in<'a, 'b>( &self, inputs: &[Read<'_>], range: Range<usize>, settings: Settings, scratch: &'a mut Scratch, output: MapOutput<'a, 'b>, ) -> Result<(), Error>
Appends a mapped range using the caller’s execution-local conversion buffers.
pub fn fold_pieces( &self, dims: [usize; 3], seed: Seed<'_>, direction: Direction, settings: Settings, pieces: &Pieces<'_>, output: &mut Buffer, ) -> Result<(), Error>
pub fn scan( &self, dims: [usize; 3], seed: Seed<'_>, direction: Direction, settings: Settings, input: Read<'_>, output: &mut Buffer, ) -> Result<(), Error>
Sourcepub fn adjacent(
&self,
dims: [usize; 3],
seed: Option<Read<'_>>,
flip: bool,
settings: Settings,
input: Read<'_>,
output: &mut Buffer,
) -> Result<(), Error>
pub fn adjacent( &self, dims: [usize; 3], seed: Option<Read<'_>>, flip: bool, settings: Settings, input: Read<'_>, output: &mut Buffer, ) -> Result<(), Error>
Each item of input, an array of shape dims, combined with the item a row before it along the middle axis, and each lane’s first row with seed, or kept as it is without one, as an inverse scan runs: flip swaps the arguments, so the earlier item comes second. The results take output‘s dtype, so a comparison’s 0s and 1s and an unseeded first row keep the items’ type where the caller asks for it.
Sourcepub fn fold_read(
&self,
shape: &[usize],
axis: Option<usize>,
seed: Seed<'_>,
direction: Direction,
settings: Settings,
input: Read<'_>,
output: &mut Buffer,
) -> Result<Option<Vec<Steps>>, Error>
pub fn fold_read( &self, shape: &[usize], axis: Option<usize>, seed: Seed<'_>, direction: Direction, settings: Settings, input: Read<'_>, output: &mut Buffer, ) -> Result<Option<Vec<Steps>>, Error>
Folds along axis of input, an array of shape, or all its items for None, into output. Whole-array commutative folds may read a contiguous block in storage order; ordered folds retain logical order. A returned order reads output in the result’s order, for folds that stay in their source’s order (Buffer::ordered).
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Kernel
impl !UnwindSafe for Kernel
impl Forget for Kernel
impl Freeze for Kernel
impl Send for Kernel
impl Sync for Kernel
impl Unpin for Kernel
impl UnsafeUnpin for Kernel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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