Expand description
tang-expr — RISC expression graph for symbolic computation.
Builds computation graphs from generic Scalar code via a thread-local
graph. Enables symbolic differentiation, sparsity detection, simplification,
and multi-backend compilation (CPU closures, WGSL shaders).
§Quick start
use tang::Vec3;
use tang_expr::{trace, ExprId};
let (mut g, dot) = trace(|| {
let a = Vec3::new(ExprId::var(0), ExprId::var(1), ExprId::var(2));
let b = Vec3::new(ExprId::var(3), ExprId::var(4), ExprId::var(5));
a.dot(b)
});
// Evaluate with concrete values
let result: f64 = g.eval(dot, &[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]);
assert!((result - 32.0).abs() < 1e-10);
// Symbolic differentiation
let ddot_dx0 = g.diff(dot, 0);
let ddot_dx0 = g.simplify(ddot_dx0);Re-exports§
Modules§
- codegen
- Multi-dialect compute shader code generation.
- compile
- Compile expression graphs to optimized Rust closures.
- diff
- Symbolic differentiation.
- display
- Pretty-printing for expressions.
- eval
- Generic evaluation of expression graphs.
- graph
- Expression graph with structural interning (automatic CSE).
- node
- Expression node types and ExprId handle.
- simplify
- Pattern-matched simplification rules.
- sparsity
- Sparsity analysis via dependency bitmasks.
- wgsl
- WGSL compute shader code generation.
Functions§
- trace
- Run a closure with a fresh graph, returning the graph and result.
- with_
graph - Access the thread-local graph.