Expand description
Evaluation and JIT code generation for oCAS.
This crate provides a stack-based virtual machine for numeric evaluation of symbolic expressions, an AST-to-instruction compiler, a Cranelift JIT backend, and SIMD vectorized evaluation.
§Architecture
The evaluation pipeline:
Atom (arena-backed)
→ EvalTree (owned intermediate)
→ Instr sequence (compile + optimize)
→ ExpressionEvaluator (stack VM)
→ or JitCompiledFunction (Cranelift, feature = "jit")
→ or VectorEvaluator (SIMD batch)§Example
ⓘ
use ocas_eval::{ExpressionEvaluator, EvaluationDomain};
use ocas_atom::AtomArena;
use ocas_core::arena::Arena;
let arena = Arena::new();
let ctx = AtomArena::new(&arena);
let expr = ctx.add(&[ctx.var("x"), ctx.num(1)]);
let eval: ExpressionEvaluator<f64> =
ExpressionEvaluator::compile(&expr).unwrap();
let result = eval.evaluate(&[2.0]).unwrap();
assert_eq!(result[0], 3.0);Re-exports§
pub use compile::compile_atom;pub use compile::compile_atom_with;pub use compile::compile_atoms_multi;pub use compile::compile_atoms_multi_with;pub use compile::compile_tree;pub use compile::compile_tree_with;pub use compile::compile_trees_multi;pub use domain::EvaluationDomain;pub use domain::PowfExtension;pub use error::EvaluationError;pub use evaluator::ExpressionEvaluator;pub use function_map::FunctionMap;pub use instruction::Instr;pub use instruction::Instruction;pub use instruction::Slot;pub use streaming::StreamingEvaluator;pub use tree::EvalTree;
Modules§
- compile
- AST-to-instruction compiler.
- domain
- Numeric evaluation domain trait.
- error
- Evaluation-specific error types.
- evaluator
- Stack-based expression evaluator.
- function_
map - Function registry for user-defined external functions.
- instruction
- Instruction set for the stack-based evaluation VM.
- numeric
- Numerical integration (adaptive Monte Carlo / Vegas) and deterministic quadrature bridges.
- streaming
- Streaming evaluation over large datasets.
- tree
- Owned intermediate representation for expression tree compilation.