Skip to main content

Crate pmath

Crate pmath 

Source
Expand description

§pmath

GitHub Repository Static Badge Crates.io Version docs.rs GitHub Actions Workflow Status GitHub License

pmath is a general-purpose mathematics crate for Rust.

It provides a wide range of mathematical functions and algorithms which heavily use Rust’s idiomatic features such as traits, generics, and iterators.

This crate started as a mathematical backend for the peuler crate, but has since evolved into a standalone crate.

§Example

use pmath::core::gcd;
use pmath::numth::modular::ord;
use pmath::numth::prime::is_prime;

assert_eq!(gcd(48, 18), 6);
assert_eq!(ord(3, 7), 6);
assert!(is_prime(29).0);

§Performance

The goal is to provide efficient, but reasonably simple and readable implementations. Many algorithms are textbook implementations, with some optimizations where appropriate.

§Floating-point type

While many functions in this crate are generic over numeric types, some use floating-point arithmetic, either internally or as a part of their interface. In such cases, the f64 type is used since most targets have hardware support for it, and the precision it provides is often needed over f32 for mathematical computations.

§No-std support

There is currently no support for no-std environments.

§WebAssembly support

wasm32-unknown-unknown target is supported, but requires --cfg getrandom_backend="wasm_js" flag to be passed to the compiler. See getrandom crate’s documentation for more details.

Other WASM targets should work out of the box.

§License

This project is licensed under the MIT License.

§Contributing

Contributions are welcome!

Please open an issue or a pull request in the GitHub repository.

Modules§

algebra
Algebra.
analysis
Analysis.
core
Core mathematical functions.
digit
Utilities for working with digits.
discrete
Discrete mathematics.
geometry
Geometry.
numth
Number theory.
probability
Probability.
sequence
Iterators over mathematical sequences.
statistics
Statistics.