Expand description
Pure Rust implementation of DACE, the Differential Algebra Computational Toolbox.
DACE computes with truncated multivariate Taylor polynomials (“differential algebra”): it propagates high-order expansions of arbitrary multivariate functions through arithmetic and elementary-function composition, with a configurable cut-off epsilon and truncation order. This crate is a full rewrite of DACE 2.1 in pure Rust.
§Quickstart
dace_rs::init(20, 2).unwrap();
let x = dace_rs::Da::variable(1);
let y = dace_rs::Da::variable(2);
let f = (x.clone() * x.clone() + y).sin();
// coefficient of x^2 in sin(x^2+y) at the origin is cos(0) = 1
assert!((f.get_coefficient(&[2, 0]) - 1.0).abs() < 1e-14);§Multithreading
Da and CompiledDa are Send + Sync: sharing them across threads
(e.g. Rayon, or PyO3’s allow_threads) is supported. New threads need
no explicit initialization — computation settings (epsilon cutoff,
truncation order) and scratch buffers are lazily derived from the active
context on each thread’s first use.
After init is called again, every thread re-derives its settings on
next use, as if the thread had never been used; user-set epsilon and
truncation order therefore do not survive re-initialization on any
thread. Values keep operating on their original context, and mixing
values from different contexts in one operation panics (existing
semantics, enforced by Da::assert_same_context).
Da::random uses a per-thread LCG seeded with a fixed identical value
on every thread: parallel draws produce the same sequence on each thread,
not distinct streams.
dace_rs::init(20, 2).unwrap();
let x = dace_rs::Da::variable(1);
let c = std::thread::spawn(move || {
let y = dace_rs::Da::variable(2);
(x * y).get_coefficient(&[1, 1])
})
.join()
.unwrap();
assert_eq!(c, 1.0);Re-exports§
pub use ads::AdsConfig;pub use ads::AdsLeaf;pub use ads::AdsResult;pub use ads::ToleranceKind;pub use context::epsilon;pub use context::init;pub use context::initialized;pub use context::machine_epsilon;pub use context::max_monomials;pub use context::max_order;pub use context::max_variables;pub use context::pop_truncation_order;pub use context::push_truncation_order;pub use context::set_epsilon;pub use context::set_truncation_order;pub use context::truncation_order;pub use context::version;pub use elementary::acos;pub use elementary::acosh;pub use elementary::asin;pub use elementary::asinh;pub use elementary::atan;pub use elementary::atan2;pub use elementary::atanh;pub use elementary::cbrt;pub use elementary::cos;pub use elementary::cosh;pub use elementary::erf;pub use elementary::erfc;pub use elementary::exp;pub use elementary::hypot;pub use elementary::icrt;pub use elementary::isrt;pub use elementary::log;pub use elementary::log_base;pub use elementary::log2;pub use elementary::log10;pub use elementary::modulo;pub use elementary::powf;pub use elementary::powi;pub use elementary::root;pub use elementary::round;pub use elementary::sin;pub use elementary::sinh;pub use elementary::sqrt;pub use elementary::tan;pub use elementary::tanh;pub use elementary::trunc;pub use error::DaceError;pub use eval::CompiledDa;pub use norm::Interval;pub use norm::NormType;pub use special::bessel_i;pub use special::bessel_j;pub use special::bessel_k;pub use special::bessel_y;pub use special::gamma;pub use special::log_gamma;pub use special::psi;
Modules§
- ads
- Automatic domain splitting (ADS): recursive bisection and re-expansion of a DA map over a large uncertainty box.
- context
- DACE computation context: initialization, monomial index encoding, and thread-local computation settings.
- elementary
- Elementary functions of DA values.
- error
- Error type for DACE operations.
- eval
- Polynomial evaluation: compiled evaluation trees, partial evaluation, and variable substitution.
- io
- Text and binary I/O of
Davalues: thedaceWritedisplay format and its parser (daceRead), the binary blob format (daceExportBlob/daceImportBlob), and the code-generation formatter (DASimpleFormatter). - monomial
- A decoded monomial: exponent vector plus coefficient.
- norm
- Norms, order-sorted norms, estimates, and interval bounds of DA values.
- special
- Special functions of DA values: Bessel functions, gamma, and polygamma.
- vector
- Vector-of-DA operations: the
DaVectorextension trait, inverse maps, and scalar-vector helpers.
Structs§
- Da
- A truncated multivariate Taylor polynomial (“differential algebra” value).
Functions§
- fma
- The weighted sum
afac * a + bfac * b(daceWeightedSum).