#algebra #polynomial

polynomial-ring

A polynomial implementation

20 releases

0.5.0 Nov 26, 2022
0.4.7 Jul 18, 2022
0.4.4 Jun 25, 2022
0.4.3 Feb 13, 2022
0.1.1 Apr 5, 2020

#328 in Math

Download history 141/week @ 2023-01-26 94/week @ 2023-02-02 124/week @ 2023-02-09 160/week @ 2023-02-16 107/week @ 2023-02-23 91/week @ 2023-03-02 143/week @ 2023-03-09 84/week @ 2023-03-16 120/week @ 2023-03-23 83/week @ 2023-03-30 103/week @ 2023-04-06 89/week @ 2023-04-13 100/week @ 2023-04-20 82/week @ 2023-04-27 128/week @ 2023-05-04 81/week @ 2023-05-11

402 downloads per month
Used in 2 crates

AGPL-3.0-or-later

23KB
514 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

~1–1.4MB
~34K SLoC