Numerical and symbolic evaluation for CalcScript.
This crate provides an evaluator for CalcScript. It is split into two main
submodules, numerical and symbolic, which handle numerical and symbolic
evaluation respectively. Currently, symbolic manipulation is limited to
simplification, but this will be extended in the future.
Usage
Numerical evaluation
The numerical module implements an evaluator for CalcScript expressions.
Expressions are evaluated using the Eval trait,
optionally with a custom Ctxt context, used to
specify the variables and functions in scope, and the trigonometric mode to use
for trigonometric functions.
The default Ctxt::default() includes some
useful constants in the [consts] module and every builtin function in the
[funcs] module.
See its module-level documentation for more information.
use Eval;
use ;
let mut parser = new;
let ast_expr = parser..unwrap;
let result = ast_expr.eval_default.unwrap;
// 5sin(pi/2) * 6!
// = 5 * 1 * 720 = 3600
assert_eq!;
Simplification
The symbolic module currently provides simplify to
simplify expressions symbolically.
See its module-level documentation for more information.
use int;
use ;
use ;
let mut parser = new;
let ast_expr = parser..unwrap;
let simplified = simplify;
// `x + x + x = 3x`
assert_eq!;
Feature flags
mysql: Derivesmysql_commontraits for various types provided by this crate.serde: DerivesSerializeandDeserializefor various types provided by this crate.