669{
670 bool inExtension = mipo != nullptr;
671 try
672 {
674 *result_factors = nullptr;
675 *result_powers = nullptr;
676 if (P == nullptr)
677 {
678 ERROR(
"expected polynomial ring");
679 return;
680 }
683
684 CFFList q;
686
688 {
689 inExtension = true;
690 Variable a = set_GF_minimal_poly(P);
691 CanonicalForm h = convertToFactory(*g, notInExtension);
692 q = factorize(h, a);
693 }
694 else if (mipo != nullptr)
695 {
697 Variable a = rootOf(mipocf, 'a');
700
701 q = factorize(h, a);
704
705
706 }
707 else
708 {
710
711 q = factorize(h);
713 }
714
715 int nfactors = q.length();
716
717 *result_factors =
getmemarraytype(engine_RawRingElementArray, nfactors);
718 (*result_factors)->len = nfactors;
719
721
722 int next = 0;
723 for (CFFListIterator i = q; i.hasItem(); i++)
724 {
725 (*result_factors)->array[next] =
convertToM2(P, i.getItem().factor());
726 (*result_powers)->array[next++] = i.getItem().exp();
727 }
729 if (
error()) *result_factors =
nullptr, *result_powers =
nullptr;
731 {
733 return;
734 }
735}
virtual ring_elem var(int v) const =0
Abstract base for the engine's polynomial-ring hierarchy.
virtual const PolynomialRing * cast_to_PolynomialRing() const
static RingElement * make_raw(const Ring *R, ring_elem f)
const Ring * get_ring() const
static const RingElement * convertToM2(const PolynomialRing *R, CanonicalForm h)
const bool notInExtension
static CanonicalForm convertToFactory(mpz_srcptr p)
CanonicalForm algebraicElement_Fac
const RingElement * algebraicElement_M2
#define getmemarraytype(S, len)
M2_arrayint M2_makearrayint(int n)