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

◆ promote()

bool PolyRing::promote ( const Ring * R,
const ring_elem f,
ring_elem & result ) const
virtual

Implements Ring.

Definition at line 379 of file poly.cpp.

382{
383 // case 1: Rf = A[x]/J ---> A[x]/I is one of the 'base_ring's of 'this'.
384 // case 2: Rf = A ---> A[x]/I is the ring of scalars
385
386 // Cases:
387 // Rf is a poly ring (or quotient of one), with the same coeff ring as this.
388 // Rf is a poly ring (or quotient) with the same monoid as this (but coeffs
389 // are maybe different).
390 // Rf is the coeff ring of this
391 // Rf is not the coeff ring K of this, but is a base ring of K (e.g. ZZ -->
392 // QQ, A --> frac(A), any others?)
393 // Rf is a poly ring in a smaller number of variables
394
395 int nvars0 = n_vars();
396 if (Rf != K_)
397 {
398 const PolynomialRing *Rf1 = Rf->cast_to_PolynomialRing();
399 if (Rf1 != nullptr)
400 nvars0 -= Rf1->n_vars();
401 else
402 return false;
403 if (Rf1 && nvars0 == 0)
404 {
405 result = copy(f);
406 return true;
407 }
408 }
409
411 result = make_logical_term(Rf, f, exp);
412 return true;
413}
exponents::Exponents exponents_t
virtual ring_elem copy(const ring_elem f) const
Definition poly.cpp:653
virtual ring_elem make_logical_term(const Ring *coeffR, const ring_elem a, const_exponents exp) const
Definition poly.cpp:1882
const Ring * K_
Definition polyring.hpp:123
int n_vars() const
Definition polyring.hpp:196
VALGRIND_MAKE_MEM_DEFINED & result(result)
const mpreal exp(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
Definition mpreal.h:2298
#define newarray_atomic_clear(T, len)
Definition newdelete.hpp:93

References Ring::cast_to_PolynomialRing(), copy(), PolynomialRing::K_, make_logical_term(), PolynomialRing::n_vars(), newarray_atomic_clear, PolynomialRing::PolynomialRing(), result(), and Ring::Ring().