pub struct EmlTree {
pub root: Arc<EmlNode>,
/* private fields */
}Expand description
EML tree with metadata.
Fields§
§root: Arc<EmlNode>Root node of the tree.
Implementations§
Source§impl EmlTree
impl EmlTree
Sourcepub fn eval_real(&self, ctx: &EvalCtx) -> Result<f64, EmlError>
pub fn eval_real(&self, ctx: &EvalCtx) -> Result<f64, EmlError>
Evaluate the tree with real-valued inputs.
Internally uses complex arithmetic when needed (e.g., ln of negative
numbers). Returns the real part if the imaginary part is below threshold,
otherwise returns Err(EmlError::ComplexResult).
Sourcepub fn eval_complex(
&self,
vars: &[Complex<f64>],
) -> Result<Complex<f64>, EmlError>
pub fn eval_complex( &self, vars: &[Complex<f64>], ) -> Result<Complex<f64>, EmlError>
Evaluate the tree with complex-valued inputs.
Uses a stack-machine post-order traversal for numerical stability and to avoid stack overflow on deeply nested trees.
Sourcepub fn eval_batch(&self, data: &[Vec<f64>]) -> Result<Vec<f64>, EmlError>
pub fn eval_batch(&self, data: &[Vec<f64>]) -> Result<Vec<f64>, EmlError>
Evaluate the tree on a batch of data points.
Each element of data is a vector of variable values for one data point.
Returns a vector of results, one per data point.
When the parallel feature is enabled and data.len() >= 128,
evaluation is distributed across rayon threads.
Source§impl EmlTree
impl EmlTree
Sourcepub fn lower(&self) -> LoweredOp
pub fn lower(&self) -> LoweredOp
Lower an EML tree to a conventional operation tree.
Recognizes common EML patterns (exp, ln, arithmetic) and
converts them to their standard equivalents. Unrecognized
subtrees are lowered as literal exp(left) - ln(right).
Sourcepub fn eval_real_lowered(&self, ctx: &EvalCtx) -> Result<f64, EmlError>
pub fn eval_real_lowered(&self, ctx: &EvalCtx) -> Result<f64, EmlError>
Evaluate the tree at real-valued variables via the lowered IR.
Unlike EmlTree::eval_real, which walks the raw EML tree through
complex arithmetic (and accumulates ~1e-2 precision drift on deep
constructions such as Canonical::sin(x)), this method first lowers
the tree (recognising sin/cos/arithmetic patterns), simplifies
the lowered IR, and evaluates through the OxiOp stack machine.
Because the stack machine dispatches directly to f64::sin/f64::cos
when the lowering recognised a trig pattern, the result attains
full f64 precision (~1e-15).
§Errors
Returns Err(EmlError::NanEncountered) if the IR evaluates to NaN.
Source§impl EmlTree
impl EmlTree
Sourcepub fn eml(left: &EmlTree, right: &EmlTree) -> EmlTree
pub fn eml(left: &EmlTree, right: &EmlTree) -> EmlTree
Create a tree representing eml(left, right) = exp(left) - ln(right).
Sourcepub fn const_val(v: f64) -> EmlTree
pub fn const_val(v: f64) -> EmlTree
Create a tree with a free constant leaf (active only when SymRegConfig.enable_const_leaf = true).
Sourcepub fn count_const_leaves(&self) -> usize
pub fn count_const_leaves(&self) -> usize
Count Const leaves in the tree.
Sourcepub fn iter_postorder(&self) -> PostOrderIter<'_>
pub fn iter_postorder(&self) -> PostOrderIter<'_>
Iterate over all nodes in post-order (left, right, parent).
Source§impl EmlTree
impl EmlTree
Sourcepub fn to_json_pretty(&self) -> Result<String, Error>
pub fn to_json_pretty(&self) -> Result<String, Error>
Serialize to a pretty-printed JSON string.
Sourcepub fn from_binary(bytes: &[u8]) -> Result<EmlTree, Error>
pub fn from_binary(bytes: &[u8]) -> Result<EmlTree, Error>
Deserialize from binary bytes encoded with Self::to_binary.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for EmlTree
impl<'de> Deserialize<'de> for EmlTree
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<EmlTree, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<EmlTree, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for EmlTree
impl Serialize for EmlTree
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for EmlTree
impl RefUnwindSafe for EmlTree
impl Send for EmlTree
impl Sync for EmlTree
impl Unpin for EmlTree
impl UnsafeUnpin for EmlTree
impl UnwindSafe for EmlTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.