Skip to main content

ExpressionEvaluator

Struct ExpressionEvaluator 

Source
pub struct ExpressionEvaluator<T: EvaluationDomain> { /* private fields */ }
Expand description

A compiled expression ready for numeric evaluation.

The evaluator holds a sequence of Instrs and a pre-allocated stack. Call evaluate with parameter values to compute the result.

Implementations§

Source§

impl<T: EvaluationDomain + PowfExtension> ExpressionEvaluator<T>

Source

pub fn param_count(&self) -> usize

Return the number of parameters expected by this evaluator.

Source

pub fn result_count(&self) -> usize

Return the number of results produced by this evaluator.

Source

pub fn stack_size(&self) -> usize

Return the stack size required to evaluate this expression.

Callers reusing a stack buffer across evaluations should pre-allocate a Vec with this capacity.

Source

pub fn evaluate(&self, params: &[T]) -> Result<Vec<T>>

Evaluate the expression with the given parameter values.

Returns a vector of result values. The number of results equals result_indices.len().

§Errors

Returns EvaluationError if the number of parameters does not match, or if an arithmetic error occurs (e.g. division by zero).

§Example
let result = evaluator.evaluate(&[2.0_f64])?;
assert_eq!(result.len(), 1);
Source

pub fn evaluate_with_stack( &self, params: &[T], stack: &mut Vec<T>, results: &mut Vec<T>, ) -> Result<()>

Evaluate the expression, reusing caller-provided buffers.

stack must have capacity for at least stack_size elements (it is resized as needed); results is filled with the result values. Reusing buffers across calls avoids per-evaluation heap allocation, which matters for streaming and batch workloads.

§Errors

Returns EvaluationError if the number of parameters does not match, or if an arithmetic error occurs.

Source§

impl<T: EvaluationDomain + PowfExtension> ExpressionEvaluator<T>

Source

pub fn compile(atom: Atom<'_>) -> Result<Self>

Compile an Atom into an executable evaluator.

Source

pub fn compile_with(atom: Atom<'_>, map: FunctionMap<T>) -> Result<Self>

Compile an Atom with a FunctionMap for user-defined functions.

Source

pub fn compile_multi(atoms: &[Atom<'_>]) -> Result<Self>

Compile multiple Atoms into one multi-output evaluator, sharing common subexpressions across all outputs.

Source

pub fn compile_multi_with( atoms: &[Atom<'_>], map: FunctionMap<T>, ) -> Result<Self>

Compile multiple Atoms with a FunctionMap into one multi-output evaluator.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for ExpressionEvaluator<T>

§

impl<T> !UnwindSafe for ExpressionEvaluator<T>

§

impl<T> Freeze for ExpressionEvaluator<T>

§

impl<T> Send for ExpressionEvaluator<T>
where T: Send,

§

impl<T> Sync for ExpressionEvaluator<T>
where T: Sync,

§

impl<T> Unpin for ExpressionEvaluator<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for ExpressionEvaluator<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V