Macaulay2 Engine
Loading...
Searching...
No Matches

◆ list_form()

engine_RawArrayPairOrNull PolyRing::list_form ( const Ring * coeffR,
const ring_elem f ) const
virtual

Implements PolynomialRing.

Definition at line 1789 of file poly.cpp.

1791{
1792 // Either coeffR should be the actual coefficient ring (possible a "toField"ed
1793 // ring)
1794 // or a polynomial ring. If not, NULL is returned and an error given
1795 // In the latter case, the last set of variables are part of
1796 // the coefficients.
1797 int nvars0 = check_coeff_ring(coeffR, this);
1798 if (nvars0 < 0) return nullptr;
1799 int n = n_logical_terms(nvars0, f);
1800 engine_RawMonomialArray monoms =
1801 GETMEM(engine_RawMonomialArray, sizeofarray(monoms, n));
1802 engine_RawRingElementArray coeffs =
1803 GETMEM(engine_RawRingElementArray, sizeofarray(coeffs, n));
1804 monoms->len = n;
1805 coeffs->len = n;
1806 engine_RawArrayPair result = newitem(struct engine_RawArrayPair_struct);
1807 result->monoms = monoms;
1808 result->coeffs = coeffs;
1809
1811 gc_vector<int> resultvp;
1812 const Nterm *t = f;
1813 for (int next = 0; next < n; next++)
1814 {
1815 getMonoid()->to_expvector(t->monom, exp);
1816 ring_elem c =
1817 get_logical_coeff(coeffR, t); // increments t to the next term of f.
1818 varpower::from_expvector(nvars0, exp, resultvp);
1819 monoms->array[next] = EngineMonomial::make(resultvp.data());
1820 coeffs->array[next] = RingElement::make_raw(coeffR, c);
1821 resultvp.resize(0);
1822
1823 assert(monoms->array[next] != NULL);
1824 assert(coeffs->array[next] != NULL);
1825 }
1826 freemem(exp);
1827 return result;
1828}
exponents::Exponents exponents_t
static EngineMonomial * make(int v, int e)
Definition monomial.cpp:26
static void from_expvector(int n, exponents::ConstExponents a, Vector &result)
void to_expvector(const_monomial m, exponents_t result_exp) const
Definition monoid.cpp:747
ring_elem get_logical_coeff(const Ring *coeffR, const Nterm *&f) const
Definition poly.cpp:1701
virtual int n_logical_terms(int nvars0, const ring_elem f) const
Definition poly.cpp:1764
virtual const Monoid * getMonoid() const
Definition polyring.hpp:282
int n_vars() const
Definition polyring.hpp:196
static RingElement * make_raw(const Ring *R, ring_elem f)
Definition relem.cpp:20
void freemem(void *s)
Definition m2-mem.cpp:103
VALGRIND_MAKE_MEM_DEFINED & result(result)
#define sizeofarray(s, len)
Definition m2-mem.h:129
struct engine_RawArrayPair_struct * engine_RawArrayPair
Definition m2-types.h:183
const mpreal exp(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
Definition mpreal.h:2298
#define newitem(T)
Definition newdelete.hpp:86
#define GETMEM(T, size)
#define newarray_atomic(T, len)
Definition newdelete.hpp:91
int check_coeff_ring(const Ring *coeffR, const PolyRing *P)
Definition poly.cpp:359
int monom[1]
Definition ringelem.hpp:160

References check_coeff_ring(), freemem(), ExponentList< int, true >::from_expvector(), get_logical_coeff(), GETMEM, PolynomialRing::getMonoid(), EngineMonomial::make(), RingElement::make_raw(), Nterm::monom, n_logical_terms(), PolynomialRing::n_vars(), newarray_atomic, newitem, result(), Ring::Ring(), sizeofarray, and Monoid::to_expvector().