1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//! # mathlex-eval
//!
//! Numerical evaluator for mathematical expression ASTs produced by
//! [`mathlex`](https://crates.io/crates/mathlex).
//!
//! Compiles a mathlex `Expression` AST into an efficient internal representation,
//! then evaluates it with variable substitution and N-dimensional broadcasting.
//!
//! ## Two-phase architecture
//!
//! 1. **Compile** — [`compile()`] validates the AST, substitutes constants, resolves
//! variables, and folds constant subexpressions into an optimized [`CompiledExpr`].
//! 2. **Evaluate** — [`eval()`] creates a lazy [`EvalHandle`] that computes output
//! shape from input shapes but defers computation until consumed via
//! [`scalar()`](EvalHandle::scalar), [`to_array()`](EvalHandle::to_array), or
//! [`iter()`](EvalHandle::iter).
//!
//! ## Quick start
//!
//! ```rust
//! use std::collections::HashMap;
//! use mathlex::{BinaryOp, Expression};
//! use mathlex_eval::{compile, eval, EvalInput};
//!
//! // Build AST for: 2*x + 3
//! let ast = Expression::Binary {
//! op: BinaryOp::Add,
//! left: Box::new(Expression::Binary {
//! op: BinaryOp::Mul,
//! left: Box::new(Expression::Integer(2)),
//! right: Box::new(Expression::Variable("x".into())),
//! }),
//! right: Box::new(Expression::Integer(3)),
//! };
//!
//! let compiled = compile(&ast, &HashMap::new()).unwrap();
//!
//! let mut args = HashMap::new();
//! args.insert("x", EvalInput::Scalar(5.0));
//! let result = eval(&compiled, args).unwrap().scalar().unwrap();
//! assert_eq!(result.to_f64(), Some(13.0));
//! ```
//!
//! ## Feature flags
//!
//! | Flag | Default | Description |
//! |------|---------|-------------|
//! | `serde` | yes | Serialize/Deserialize for [`CompiledExpr`] and [`NumericResult`] |
//! | `parallel` | no | Rayon-based parallel broadcasting in [`EvalHandle::to_array()`] |
//! | `ffi` | no | Swift FFI bridge via swift-bridge |
pub
pub use compile;
pub use CompiledExpr;
pub use ;
pub use ;