Trait aegir::Function

source ·
pub trait Function<C: Context>: Node {
    type Value: Buffer;
    type Error: Error;

    fn evaluate<CR: AsRef<C>>(&self, ctx: CR) -> AegirResult<Self, C>;

    fn evaluate_spec<CR: AsRef<C>>(
        &self,
        ctx: CR
    ) -> Result<Spec<Self::Value>, Self::Error> { ... } fn evaluate_shape<CR: AsRef<C>>(
        &self,
        ctx: CR
    ) -> Result<ShapeOf<Self::Value>, Self::Error> { ... } }
Expand description

Trait for operator Nodes that can be evaluated against a Context.

Required Associated Types§

The codomain of the function.

The error type of the function.

Required Methods§

Evaluate the function and return its Value.

Examples
let x = X.into_var();

assert_eq!(x.evaluate(ctx!{X = 1.0}).unwrap(), 1.0);

Provided Methods§

Evaluate the function and return its lifted Value.

Examples
let x = X.into_var().adjoint(X);
let jx = X.into_var().adjoint(X);

assert_eq!(jx.evaluate_spec(ctx!{X = [1.0, 2.0]}).unwrap(), Spec::Diagonal(S2, 1.0));

Evaluate the function and return the shape of the Value.

Note: by default, this method performs a full evaluation and calls the shape method on the buffer. This should be overridden in your implementation for better efficiency.

Implementors§