#polynomial #algebra #ring #rational64

polynomial-ring

A polynomial implementation

21 releases

new 0.5.1 Apr 11, 2025
0.5.0 Nov 26, 2022
0.4.7 Jul 18, 2022
0.4.3 Feb 13, 2022
0.1.1 Apr 5, 2020

#154 in Math

Download history 86/week @ 2024-12-24 64/week @ 2024-12-31 79/week @ 2025-01-07 103/week @ 2025-01-14 101/week @ 2025-01-21 135/week @ 2025-01-28 185/week @ 2025-02-04 198/week @ 2025-02-11 140/week @ 2025-02-18 112/week @ 2025-02-25 78/week @ 2025-03-04 93/week @ 2025-03-11 93/week @ 2025-03-18 102/week @ 2025-03-25 83/week @ 2025-04-01 244/week @ 2025-04-08

535 downloads per month
Used in 7 crates

AGPL-3.0-or-later

25KB
519 lines

Polynomial Ring

A polynomial implementation.

use num::Rational64;
use polynomial_ring::Polynomial;

let f = Polynomial::new(vec![3, 1, 4, 1, 5].into_iter().map(|x| Rational64::from_integer(x)).collect());
let g = Polynomial::new(vec![2, 7, 1].into_iter().map(|x| Rational64::from_integer(x)).collect());
let mut r = f.clone();
let q = r.division(&g);
assert_eq!(f, q * g + r);
let f = Polynomial::new(vec![3, 1, 4, 1, 5].into_iter().map(|x| rug::Rational::from(x)).collect());
let g = Polynomial::new(vec![2, 7, 1].into_iter().map(|x| rug::Rational::from(x)).collect());
let mut r = f.clone();
let q = r.division(&g);
assert_eq!(f, q * g + r);

The Add, Sub, Mul, Div, and Rem traits are implemented for polynomials. Polynomials also support computing derivative, square free, pseudo division, and resultant.

Licence

AGPL-3.0-or-later

Dependencies

~2MB
~44K SLoC