pub struct CompiledExprRef<K = String> { /* private fields */ }Expand description
A compiled, executable expression that is evaluated via references or pointers.
Created by Tabula::compile_ref.
This version is optimized for evaluation methods that use pointers (eval and eval_ptrs),
which can be slightly more efficient if the underlying data is not contiguous.
Implementations§
Source§impl<K> CompiledExprRef<K>
impl<K> CompiledExprRef<K>
Sourcepub fn vars(&self) -> &[K]
pub fn vars(&self) -> &[K]
Returns a slice of variable keys in the order they must be supplied for evaluation.
Sourcepub fn eval(&self, values: &[&f64]) -> Result<f64, JitError>
pub fn eval(&self, values: &[&f64]) -> Result<f64, JitError>
Evaluates the compiled expression with the given values (as references).
The values slice must provide &f64 references in the exact order specified by vars().
§Examples
use tabulon::Tabula;
let mut engine = Tabula::new();
let expr = engine.compile_ref("a * b").unwrap();
let a = 10.0;
let b = 5.5;
// Pass values as a slice of references
let result = expr.eval(&[&a, &b]).unwrap();
assert_eq!(result, 55.0);§Errors
JitError::ValuesLenifvalues.len()is less thanself.vars().len().JitError::Invalidatedif the expression was invalidated byTabula::free_memory.
Sourcepub fn eval_ptrs(&self, ptrs: &[*const f64]) -> Result<f64, JitError>
pub fn eval_ptrs(&self, ptrs: &[*const f64]) -> Result<f64, JitError>
Evaluates this compiled expression using raw pointers to f64 inputs.
This is an advanced, unsafe API for integrations (e.g., FFI) where holding references
is not feasible. Pointers must be valid and point to live f64 data.
§Safety
The caller must ensure that each pointer in ptrs is valid, aligned, and points to
memory that outlives the duration of this call. Misuse can lead to undefined behavior.
Trait Implementations§
Source§impl<K: Clone> Clone for CompiledExprRef<K>
impl<K: Clone> Clone for CompiledExprRef<K>
Source§fn clone(&self) -> CompiledExprRef<K>
fn clone(&self) -> CompiledExprRef<K>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more