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

◆ promote()

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

Implements Ring.

Definition at line 431 of file schur2.cpp.

434{
435 // Cases:
436 // 1. Rf is ZZ
437 // 2. Rf is coefficientRing
438 // 3. Rf is another SchurRing2
439
440 if (Rf == globalZZ)
441 {
442 from_coeff(Rf->promote(globalZZ, f, result));
443 return true;
444 }
445 else if (Rf == coefficientRing)
446 {
447 result = from_coeff(f);
448 return true;
449 }
450 else
451 {
452 const SchurRing2 *Sf = Rf->cast_to_SchurRing2();
453 if (Sf != nullptr)
454 {
456 {
457 result = truncate(f);
458 return true;
459 }
460
461 return promote_coeffs(Sf, f, result);
462 }
463 }
464 return false;
465}
ring_elem from_coeff(ring_elem a) const
Definition schur2.cpp:281
ring_elem truncate(const ring_elem f) const
Definition schur2.cpp:512
bool promote_coeffs(const SchurRing2 *Sf, const ring_elem f, ring_elem &resultRE) const
Definition schur2.cpp:383
const Ring * getCoefficientRing() const
Definition schur2.hpp:175
const Ring * coefficientRing
Definition schur2.hpp:154
RingZZ * globalZZ
Definition relem.cpp:13
VALGRIND_MAKE_MEM_DEFINED & result(result)

References Ring::cast_to_SchurRing2(), coefficientRing, from_coeff(), getCoefficientRing(), globalZZ, Ring::promote(), promote_coeffs(), result(), Ring::Ring(), SchurRing2(), and truncate().