pub trait Kernel<N>: Kernel{
type Host;
type Pre;
const FIDELITY: Fidelity;
const RATE: Rate;
// Required methods
fn advance<'t>(
host: &'t mut Self::Host,
deps: <<N as Wired>::Deps as DepSet>::Outs<'t>,
) -> <N as Cell>::Out<'t>;
fn pre<'d>(
host: &Self::Host,
want: Want,
deps: <<N as Wired>::Deps as DepSet>::Outs<'d>,
) -> Self::Pre;
fn formula(pre: &Self::Pre) -> Option<&Ast>;
fn jac<'d>(
pre: &Self::Pre,
j: Jac<'_, <<N as Wired>::Deps as DepSet>::Outs<'d>>,
) -> bool
where <N as Wired>::Deps: DepFlat,
<<N as Wired>::Deps as DepSet>::Outs<'d>: Copy,
<N as Cell>::Out<'x>: for<'x> Flat;
// Provided methods
fn trace(_: &Self::Pre, _: &[f64]) -> Option<Trace> { ... }
fn exact<'d>(
_: &Self::Pre,
_: Exact<'_, <<N as Wired>::Deps as DepSet>::Outs<'d>>,
) -> bool
where <N as Wired>::Deps: DepFlat,
<<N as Wired>::Deps as DepSet>::Outs<'d>: Copy,
<N as Cell>::Out<'x>: for<'x> Flat { ... }
}Expand description
How a node computes, and therefore what can be read off it. Sealed: the kernel set is the framework’s, so a node’s only choice is which one it names and there is no way to supply a body the engine cannot also read.
Each kernel demands its own body trait, so naming one without the body does not compile. The
split into pre and jac is what lets the two readings cost their
own price: Pure captures one grad pass and nothing else, where Opaque captures the
pre-advance clone its finite differences re-advance.
One trait for both node shapes. What used to be a second, run-shaped copy of it was the level
side read against a different owner of the out — so Host names the owner and
the rest is one declaration.
Required Associated Constants§
Required Associated Types§
Sourcetype Host
type Host
What the sweep advances. A level node is its own host; a run node’s is the [Emitter] beside
it, which owns the buffer the run is filled into and the last_period its rate is enforced
against. That the storage sits here rather than in a second argument is the whole of why one
trait can serve both: an out borrowed from the node and an out borrowed from the engine differ
in who is lent for the tick, and naming the lender is enough to say it.
Required Methods§
fn advance<'t>( host: &'t mut Self::Host, deps: <<N as Wired>::Deps as DepSet>::Outs<'t>, ) -> <N as Cell>::Out<'t>
fn pre<'d>( host: &Self::Host, want: Want, deps: <<N as Wired>::Deps as DepSet>::Outs<'d>, ) -> Self::Pre
Sourcefn jac<'d>(
pre: &Self::Pre,
j: Jac<'_, <<N as Wired>::Deps as DepSet>::Outs<'d>>,
) -> bool
fn jac<'d>( pre: &Self::Pre, j: Jac<'_, <<N as Wired>::Deps as DepSet>::Outs<'d>>, ) -> bool
Fills the Jacobian and reports whether it is exact. Called once, for a node that fired at
Want::Jac. What it fills is the one-step reading — each dep’s last element perturbed,
prior state held fixed — however the kernel arrived there; the derivative over a dep’s whole
reach is a different quantity and is not this one (r[kernels.jac.two-quantities]).
The observation bounds sit here rather than on the trait, so a bare step — which never asks
for a derivative — carries none of them.
Provided Methods§
Sourcefn trace(_: &Self::Pre, _: &[f64]) -> Option<Trace>
fn trace(_: &Self::Pre, _: &[f64]) -> Option<Trace>
The value-annotated reading of the body over this tick’s dep flattening, where that flattening
is the env the body was read over. The default declines, which is the honest answer for a
per-element kernel: its env is filled by read — wider than the deps’ own slots, and in the
order the body asked for them — so a trace taken over the flattening would be evaluating the
body against an env that is not the one it read (Ast::Var indexes, so it would not even be
wrong quietly).
A reading rather than a flag, because every other reading the engine offers comes off this one
declaration and a bool here would leave the last one being reconstructed outside.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".