fix: Fix dff algorithm attempt
This commit is contained in:
parent
b54753fe7e
commit
d599292d3a
3 changed files with 9 additions and 19 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use std::usize;
|
||||
|
||||
use num::{pow::Pow, traits::ToBytes, BigUint, FromPrimitive};
|
||||
use num::{cast::AsPrimitive, pow::Pow, traits::ToBytes, BigUint, FromPrimitive};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::poly::{gcd, Polynomial};
|
||||
|
|
@ -13,25 +13,30 @@ pub struct Factors {
|
|||
|
||||
pub fn ddf(f: Polynomial) -> Vec<(Polynomial, u128)> {
|
||||
let q = BigUint::pow(&BigUint::from_u8(2).unwrap(), 128);
|
||||
eprintln!("q: {:?}", q);
|
||||
|
||||
let mut z: Vec<(Polynomial, u128)> = vec![];
|
||||
let mut d: u128 = 1;
|
||||
let mut f_star = f.clone();
|
||||
|
||||
let one_cmp = Polynomial::one();
|
||||
while f_star.degree() >= (2 * d) as usize {
|
||||
while f_star.degree() as u128 >= (d) {
|
||||
let h = Polynomial::x().bpow_mod(q.clone().pow(d), f_star.clone()) + Polynomial::x();
|
||||
|
||||
let g = gcd(&h, &f_star);
|
||||
if g != one_cmp {
|
||||
eprintln!("d is: {}", d);
|
||||
eprintln!("g is: {:?}", &g.clone().to_c_array());
|
||||
|
||||
z.push((g.clone(), d));
|
||||
f_star = f_star.div(&g).0;
|
||||
}
|
||||
eprintln!("d outer is: {}", d);
|
||||
eprintln!("F star degree is {:?}", &f_star.degree());
|
||||
|
||||
d += 1;
|
||||
}
|
||||
if f_star != one_cmp {
|
||||
eprintln!("fstar not one");
|
||||
z.push((f_star.clone(), f_star.degree() as u128));
|
||||
} else if z.len() == 0 {
|
||||
z.push((f.clone(), 1));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue