Expand description
§pmath
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::{gcd, ord};
use pmath::primes::is_prime;
assert_eq!(gcd(48, 18), 6);
assert_eq!(ord(3, 7), 6);
assert!(is_prime(29).0);
§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§
- digits
- Functions for working with digits.
- factors
- Factors and divisors of integers.
- linalg
- Linear algebra structures and operations.
- primes
- Functions related to prime numbers.
- probability
- Probability calculations and distributions.
- sequences
- Iterators over mathematical sequences.
- statistics
- Statistics calculations.
Structs§
- Simple
Continued Fraction - Simple continued fraction.
Functions§
- factorial
- Factorial of an integer.
- factorial_
0_ to_ n - Factorials of integers from
0
ton
. - gcd
- The greatest common divisor of two integers.
- gcd_
multiple - The greatest common divisor of multiple integers.
- isqrt
- Integer square root.
- lcm
- The least common multiple of two integers.
- lcm_
multiple - The least common multiple of multiple integers.
- newtons_
method - Newton’s method for finding the zero of a function.
- ord
- Multiplicative order.
- partition_
p - Partition function.
- partition_
p_ 0_ to_ n - Partition function of integers from
0
ton
. - partition_
prime - Prime partition function.
- partition_
prime_ 0_ to_ n - Prime partition function of integers from
0
ton
. - phi
- Euler’s totient function.
- phi_
0_ to_ n - Euler’s totient function of integers from
0
ton
.