MCPcopy Create free account
hub / github.com/Singular/Singular / minpoly

Function minpoly

factory/cf_map_ext.cc:599–635  ·  view source on GitHub ↗

g is in Fp[x] F is in Fp[t] h is in Fp[t] In the finite field Fp[t]/h(t), find g(x) in Fp[x] such that g(F(t)) = 0 mod h(t) i.e. g is the minpoly of the element F(t) of the finite field. */

Source from the content-addressed store, hash-verified

597 i.e. g is the minpoly of the element F(t) of the finite field.
598*/
599static void minpoly(nmod_poly_t g, const nmod_poly_t F, const nmod_poly_t h)
600{
601 slong i;
602 slong d = nmod_poly_degree(h);
603 mp_limb_t p = h->mod.n;
604 nmod_poly_t Fpow;
605 nmod_berlekamp_massey_t bma;
606
607 nmod_poly_init(Fpow, p);
608 nmod_berlekamp_massey_init(bma, p);
609
610 nmod_poly_one(Fpow);
611 for (i = 0; i < 2*d; i++)
612 {
613 nmod_berlekamp_massey_add_point(bma, nmod_poly_get_coeff_ui(Fpow, 0));
614 nmod_poly_mulmod(Fpow, Fpow, F, h);
615 }
616
617 nmod_berlekamp_massey_reduce(bma);
618
619 /* something went horribly wrong if V does not kill the whole sequence */
620 FLINT_ASSERT(nmod_poly_degree(nmod_berlekamp_massey_R_poly(bma)) <
621 nmod_poly_degree(nmod_berlekamp_massey_V_poly(bma)));
622
623 nmod_poly_make_monic(g, nmod_berlekamp_massey_V_poly(bma));
624#if WANT_ASSERT
625 {
626 nmod_poly_t z;
627 nmod_poly_init(z, p);
628 nmod_poly_compose_mod(z, g, F, h);
629 FLINT_ASSERT(nmod_poly_is_zero(z));
630 nmod_poly_clear(z);
631 }
632#endif
633 nmod_poly_clear(Fpow);
634 nmod_berlekamp_massey_clear(bma);
635}
636#endif
637
638

Callers 2

findMinPolyFunction · 0.85
printMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected