FFElement FiniteField::makeElement(const Polynomial& p) const { assert(p.getMod() == getP()); if (p.getDomain() == domain) return FFElement(p, this); std::vector<FieldElement> coeffs; for (auto& c : p.getCoeffs()) coeffs.push_back(domain->getField()->makeElement(c.getVal())); return FFElement(domain->makeElement(coeffs), this); }
FiniteField::FiniteField(const Polynomial& irred) : p(irred.getMod()), k(irred.degree()), domain(irred.getDomain()), modulus(irred) { //assert(k > 1 && "Use PrimeField if k==1"); assert(irred.isIrreducible()); }