Skip to main content

Crate numerica

Crate numerica 

Source
Expand description

Numerica is an open-source mathematics library for Rust, that provides high-performance number types, such as error-tracking floats and finite field elements.

It provides

  • Abstractions over rings, Euclidean domains, fields and floats
  • High-performance Integer with automatic up-and-downgrading to arbitrary precision types
  • Rational numbers with reconstruction algorithms
  • Fast finite field arithmetic
  • Error-tracking floating point types
  • Generic dual numbers for automatic differentiation
  • Matrix operations and linear system solving
  • Numerical integration using Vegas algorithm with discrete layer support

For operations on symbols, check out the sister project Symbolica.

§Example

Solve a linear system over the rationals:

let a = Matrix::from_linear(
    vec![
        1.into(), 2.into(), 3.into(),
        4.into(), 5.into(), 16.into(),
        7.into(), 8.into(), 9.into(),
    ],
    3, 3, Q,
)
.unwrap();

let b = Matrix::from_linear(vec![1.into(), 2.into(), 3.into()], 3, 1, Q).unwrap();

let r = a.solve(&b).unwrap();
assert_eq!(r.into_vec(), [(-1, 3), (2, 3), (0, 1)]);

Solution: $(-1/3, 2/3, 0)$.

Modules§

combinatorics
Provides combinatorial utilities for generating combinations, permutations, and partitions of sets.
domains
Defines core algebraic traits and data structures.
numerical_integration
Methods for numerical integration of black-box functions.
printer
Methods for printing rings.
tensors
Methods for tensor manipulation and linear algebra.
utils
Utility traits and structures.

Macros§

create_hyperdual_from_components
Create a new hyperdual number, from a specification of the components. The first components must be the real value and the single derivatives of the variables in order.
create_hyperdual_from_depths
Create a new hyperdual number, with a given derivative depth per variable.
create_hyperdual_single_derivative
Create a new hyperdual number, with only single derivatives and with $var variables.