Expand description
§RSSN: Rust Symbolic, Scientific and Numerical Computing Library
rssn is a high-performance, modern library for symbolic mathematics and scientific
computing in Rust. It leverages a Directed Acyclic Graph (DAG) based model for
efficient, canonical representation of mathematical expressions.
§Key Features
-
Efficient DAG-based Expression Model: Expressions are stored as a Directed Acyclic Graph, ensuring that identical subexpressions are represented by a single node in memory. This provides automatic canonicalization and significant performance gains.
-
Advanced Symbolic Algebra: A powerful Computer Algebra System (CAS) for manipulating expressions. It goes beyond simple simplification by supporting:
- Polynomial algebra including Gröbner basis computation.
- Simplification and normalization of expressions with respect to polynomial side-relations.
-
Symbolic Calculus: Functions for differentiation, integration, limits, and series expansion.
-
Numerical Methods: A rich collection of algorithms for numerical integration, solving differential equations (ODEs and PDEs), optimization, and more.
-
Versatile Output: Render expressions as pretty-printed text, LaTeX, or plots.
§Crate Structure
The rssn crate is organized into the following main modules:
symbolic: The core of the CAS. It defines theExprandDagNoderepresentations and provides all functionality for symbolic manipulation, including thesimplify_dagengine and advanced algebraic tools incas_foundationsandgrobner.numerical: Contains implementations of various numerical algorithms.physics: Implements numerical methods specifically for physics simulations.input: Provides tools for parsing and formatting expressions.output: Provides tools for formatting and displaying expressions.jit: Just-in-time compilation of expressions and commands.compute: Provides tools for numerical and symbolic computation commands.plugins: Provides tools for loading and managing plugins.nightly: Provides tools with nightly features such as with AVX512.prelude: Re-exports the most common types and functions for convenient use.
§Example: Simplification with Relations
rssn can simplify expressions within the context of an algebraic variety. For example,
simplifying x^2 given the side-relation that x^2 + y^2 - 1 = 0 (the unit circle).
use rssn::symbolic::cas_foundations::simplify_with_relations;
use rssn::symbolic::core::Expr;
use rssn::symbolic::grobner::MonomialOrder;
// Define variables x and y
let x = Expr::new_variable("x");
let y = Expr::new_variable("y");
// Expression to simplify: 2*x^2
let two = Expr::new_bigint(2.into());
let x_sq = Expr::new_pow(
x.clone(),
Expr::new_bigint(2.into()),
);
let expr_to_simplify = Expr::new_mul(two, x_sq);
// Define the side-relation: x^2 + y^2 - 1 = 0
let y_sq = Expr::new_pow(
y.clone(),
Expr::new_bigint(2.into()),
);
let one = Expr::new_bigint(1.into());
let relation = Expr::new_sub(
Expr::new_add(x.clone(), y.clone()),
one,
);
// Simplify the expression with respect to the relation
let simplified_expr = simplify_with_relations(
&expr_to_simplify,
&[relation],
&["x", "y"],
MonomialOrder::Lexicographical,
);
// The result will be 2 - 4y + 2y^2
// Note: The exact output format and canonical form may vary between versions.
println!(
"Original expression: {}",
expr_to_simplify
);
println!(
"Simplified expression: {}",
simplified_expr
);
This library is in active development. The API may change, and community
contributions are welcome.
Re-exports§
pub use crate::input::parser::*;pub use crate::numerical::matrix::*;pub use crate::symbolic::calculus::*;pub use crate::symbolic::core::*;pub use crate::symbolic::matrix::*;pub use crate::symbolic::simplify_dag::*;
Modules§
- compute
- Computation engine and task management. Computation engine and related infrastructure.
- constant
- System and physical constants.
- ffi_
apis - FFI APIs for the ‘rssn’ Library. FFI API for the rssn library.
- ffi_
blindings - FFI blinding and security utilities. FFI blindings for the RSSN Library. Will be avalible at v0.3.0 release.
- input
- Input parsing and handling.
- jit
- Just-In-Time (JIT) compilation for expressions. The JIT compiler for RSSN
- nightly
- Features requiring nightly Rust.
- numerical
- Numerical computation and optimization.
- output
- Output formatting and handling.
- physics
- Physics-related functionality.
- plugins
- Plugin system for extending functionality.
- prelude
- Prelude for common imports.
- symbolic
- The symbolic computation engine.
Macros§
- bincode_
ffi_ binary - Creates a FFI-compatible function that takes two bincode buffers as input, deserializes them to two arguments, applies a body of logic, and returns the result as a bincode buffer.
- bincode_
ffi_ unary - Creates a FFI-compatible function that takes a bincode buffer as input, deserializes it to a single argument, applies a body of logic, and returns the result as a bincode buffer.
- handle_
ffi_ binary - Creates a FFI-compatible function that takes raw pointers to two arguments, dereferences them, applies a body of logic, and returns a raw pointer to the result.
- handle_
ffi_ unary - Creates a FFI-compatible function that takes a raw pointer to a single argument, dereferences it, applies a body of logic, and returns a raw pointer to the result.
- json_
ffi_ binary - Creates a FFI-compatible function that takes two JSON strings as input, deserializes them to two arguments, applies a body of logic, and returns the result as a JSON string.
- json_
ffi_ unary - Creates a FFI-compatible function that takes a JSON string as input, deserializes it to a single argument, applies a body of logic, and returns the result as a JSON string.
Functions§
- is_
exclusive - Checks if an
Archas exclusive ownership (strong count is 1).