Skip to content

Commit

Permalink
put vecs more prominent into readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bertiqwerty committed May 11, 2024
1 parent 9ebad5b commit 3b058e2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ let result = dddexpr_dxyx_iter.eval(&[f64::MAX, f64::MAX])?;
assert!((result - 2.0).abs() < 1e-12);
```

## Mixing Data Types in one Expression with the Feature `value`
## Mixing Scalar Data Types and Float Vectors in one Expression with the Feature `value`

After activating the Exmex-feature `value` one can use expressions with data of type [`Val`](https://docs.rs/exmex/latest/exmex/enum.Val.html), inspired by the type `Value` from the crate [Evalexpr](https://crates.io/crates/evalexpr). An instance of `Val` can contain a boolean, an int, or a float. This way, it is possible to use booleans, ints, and floats in the same expression. Further, Exmex provides in terms of [`ValOpsFactory`](https://docs.rs/exmex/latest/exmex/struct.ValOpsFactory.html) a pre-defined set of operators for `Val`. See the following example of a Python-like `if`-`else`-operator.
After activating the Exmex-feature `value` one can use expressions with data of type [`Val`](https://docs.rs/exmex/latest/exmex/enum.Val.html), inspired by the type `Value` from the crate [Evalexpr](https://crates.io/crates/evalexpr). An instance of `Val` can contain a boolean, an int, a float, or a vector of floats. This way, it is possible to use booleans, ints, floats, and vectors in the same expression. Further, Exmex provides in terms of [`ValOpsFactory`](https://docs.rs/exmex/latest/exmex/struct.ValOpsFactory.html) a pre-defined set of operators for `Val`. See the following example of a Python-like `if`-`else`-operator.
```rust
use exmex::{Express, Val};
let expr = exmex::parse_val::<i32, f64>("0 if b < c else 1.2")?;
let res = expr.eval(&[Val::Float(34.0), Val::Int(21)])?.to_float()?;
assert!((res - 1.2).abs() < 1e-12);
```

The [`Val`](https://docs.rs/exmex/latest/exmex/enum.Val.html) type also supports vectors with, e.g., dot-product and cross-product.
See the [`Val`-docs](https://docs.rs/exmex/latest/exmex/enum.Val.html) for an example containing vectors.

If both `partial` and `value` are activated, partial derivatives can be computed for expressions of types such
as `FlatExVal<i32, f64>`. This is currently not supported for vectors.
Expand Down

0 comments on commit 3b058e2

Please sign in to comment.