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

◆ n_logical_terms()

int PolyRing::n_logical_terms ( int nvars0,
const ring_elem f ) const
virtual

Implements PolynomialRing.

Definition at line 1764 of file poly.cpp.

1765{
1766 // nvars0 is the number of variables in the outer monoid
1767 if (nvars0 == n_vars()) return n_terms(f);
1768 Nterm *t = f;
1769 if (t == nullptr) return 0;
1770 exponents_t exp1 = newarray_atomic(int, n_vars());
1772 M_->to_expvector(t->monom, exp1);
1773 int result = 1;
1774 for (; t != nullptr; t = t->next)
1775 {
1776 M_->to_expvector(t->monom, exp2);
1777 if (EQ == exponents::lex_compare(nvars0, exp1, exp2)) continue;
1778 // TODO: use std::swap?
1779 exponents_t temp = exp1;
1780 exp1 = exp2;
1781 exp2 = temp;
1782 result++;
1783 }
1784 freemem(exp1);
1785 freemem(exp2);
1786 return result;
1787}
exponents::Exponents exponents_t
static int lex_compare(int nvars, ConstExponents a, ConstExponents b)
int n_terms(const ring_elem f) const
Definition polyring.hpp:360
const Monoid * M_
Definition polyring.hpp:124
int n_vars() const
Definition polyring.hpp:196
void freemem(void *s)
Definition m2-mem.cpp:103
VALGRIND_MAKE_MEM_DEFINED & result(result)
const mpreal exp2(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
Definition mpreal.h:2299
#define newarray_atomic(T, len)
Definition newdelete.hpp:91
Nterm * next
Definition ringelem.hpp:157
int monom[1]
Definition ringelem.hpp:160
const int EQ
Definition style.hpp:40

References EQ, freemem(), ExponentVector< int, true >::lex_compare(), PolynomialRing::M_, Nterm::monom, PolynomialRing::n_terms(), PolynomialRing::n_vars(), newarray_atomic, Nterm::next, and result().

Referenced by get_terms(), lift(), and list_form().