fix: Fix incorrect degree calculation

This commit is contained in:
Alivecow 2024-11-27 14:06:40 +01:00
parent 4a2b0ab014
commit 6532c576c6
2 changed files with 3 additions and 2 deletions

View file

@ -19,7 +19,7 @@ pub fn ddf(f: Polynomial) -> Vec<(Polynomial, u128)> {
let mut f_star = f.clone(); let mut f_star = f.clone();
let one_cmp = Polynomial::one(); let one_cmp = Polynomial::one();
while f_star.degree() as u128 >= (d) { while f_star.degree() as u128 >= (2 * d) {
let h = Polynomial::x().bpow_mod(q.clone().pow(d), f_star.clone()) + Polynomial::x(); let h = Polynomial::x().bpow_mod(q.clone().pow(d), f_star.clone()) + Polynomial::x();
let g = gcd(&h, &f_star); let g = gcd(&h, &f_star);
@ -35,6 +35,7 @@ pub fn ddf(f: Polynomial) -> Vec<(Polynomial, u128)> {
d += 1; d += 1;
} }
if f_star != one_cmp { if f_star != one_cmp {
eprintln!("fstar not one"); eprintln!("fstar not one");
z.push((f_star.clone(), f_star.degree() as u128)); z.push((f_star.clone(), f_star.degree() as u128));

View file

@ -25,7 +25,7 @@ impl Polynomial {
} }
pub fn degree(&self) -> usize { pub fn degree(&self) -> usize {
self.polynomial.len() self.polynomial.len() - 1
} }
pub fn one() -> Self { pub fn one() -> Self {