mod_to_fractor replaced by more general ext_euclid

This commit is contained in:
Mirek Kratochvil 2012-11-08 12:52:07 +01:00
parent fc209d3345
commit 3e41ebdfe9
3 changed files with 1 additions and 31 deletions

View file

@ -253,7 +253,6 @@ public:
void sqrt (vector<polynomial>&, gf2m&); void sqrt (vector<polynomial>&, gf2m&);
polynomial gcd (polynomial, gf2m&); polynomial gcd (polynomial, gf2m&);
void mod_to_fracton (polynomial&, polynomial&, polynomial&, gf2m&);
void ext_euclid (polynomial&, polynomial&, polynomial&, gf2m&, int); void ext_euclid (polynomial&, polynomial&, polynomial&, gf2m&, int);
bool is_irreducible (gf2m&) const; bool is_irreducible (gf2m&) const;

View file

@ -38,7 +38,7 @@ void compute_goppa_error_locator (polynomial&syndrome, gf2m&fld,
v.sqrt (sqInv, fld); //v = sqrt((1/s)+x) mod goppa v.sqrt (sqInv, fld); //v = sqrt((1/s)+x) mod goppa
polynomial a, b; polynomial a, b;
v.mod_to_fracton (a, b, goppa, fld); v.ext_euclid (a, b, goppa, fld, goppa.degree()/2);
a.square (fld); a.square (fld);
b.square (fld); b.square (fld);

View file

@ -391,32 +391,3 @@ void polynomial::ext_euclid (polynomial&a_out, polynomial&b_out,
b.swap (b_out); b.swap (b_out);
} }
void polynomial::mod_to_fracton (polynomial&a, polynomial&b,
polynomial&m, gf2m&fld)
{
//TODO: replace with ext_euclid
int deg = m.degree() / 2;
polynomial a0, a1, b0, b1, q, r;
a0 = m;
a1 = *this;
a1.mod (m, fld);
b0.clear();
b1.clear();
b1.resize (1, 1);
while (a1.degree() > deg) {
a0.divmod (a1, q, r, fld);
a0.swap (a1);
a1.swap (r);
q.mult (b1, fld);
q.mod (m, fld);
q.add (b0, fld);
b0.swap (b1);
b1.swap (q);
}
a.swap (a1);
b.swap (b1);
}