void CharPolyMod(zz_pX& g, const zz_pX& a, const zz_pX& ff) { zz_pX f = ff; MakeMonic(f); long n = deg(f); if (n <= 0 || deg(a) >= n) Error("CharPoly: bad args"); if (IsZero(a)) { clear(g); SetCoeff(g, n); return; } if (n > 90 || (zz_p::PrimeCnt() <= 1 && n > 45)) { zz_pX h; MinPolyMod(h, a, f); if (deg(h) == n) { g = h; return; } } if (zz_p::modulus() < n+1) { HessCharPoly(g, a, f); return; } vec_zz_p u(INIT_SIZE, n+1), v(INIT_SIZE, n+1); zz_pX h, h1; negate(h, a); long i; for (i = 0; i <= n; i++) { u[i] = i; add(h1, h, u[i]); resultant(v[i], f, h1); } interpolate(g, u, v); }
void NormMod(zz_p& x, const zz_pX& a, const zz_pX& f) { if (deg(f) <= 0 || deg(a) >= deg(f)) Error("norm: bad args"); if (IsZero(a)) { clear(x); return; } zz_p t; resultant(t, f, a); if (!IsOne(LeadCoeff(f))) { zz_p t1; power(t1, LeadCoeff(f), deg(a)); inv(t1, t1); mul(t, t, t1); } x = t; }
static CYTHON_INLINE struct ZZ* ZZX_resultant(struct ZZX* x, struct ZZX* y, int proof) { ZZ* res = new ZZ(); resultant(*res, *x, *y, proof); return res; }
double TwoVector::angle(void) const { double r = resultant(); if(r <= 0.) return 0.; return std::acos(m_x/r); // angle in radians }