From 70546d2fac89efbbc68b1596d9ac6c8320f41e6f Mon Sep 17 00:00:00 2001 From: Michael DeBellevue Date: Fri, 29 Sep 2023 14:53:38 -0500 Subject: [PATCH] Attempted fix of #2907 by ringmap.cpp change Tried adding block to ringmap code to detect the weyl algebra and change how ring maps are computed. Changed the order of multiplication for weyl algebras. This did not seem to alter the behavior in the reference issue. --- M2/Macaulay2/e/ringmap.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/M2/Macaulay2/e/ringmap.cpp b/M2/Macaulay2/e/ringmap.cpp index 4822dfc4a8d..cdfa482d296 100644 --- a/M2/Macaulay2/e/ringmap.cpp +++ b/M2/Macaulay2/e/ringmap.cpp @@ -165,8 +165,27 @@ ring_elem RingMap::eval_term(const Ring *sourceK, // source coeff ring result_monom = M->make_one(); temp_monom = M->make_one(); } - - if (!R->is_commutative_ring() || R->cast_to_SchurRing()) + if (R->is_weyl_algebra()) + { + for (index_varpower i = vp; i.valid(); ++i) + { + int v = first_var + i.var(); + int e = i.exponent(); + ring_elem g; + if (e >= 0) + g = _elem[v].bigelem; + else + g = R->invert(_elem[v].bigelem); + for (int j = 0; j < e; j++) + { + assert(v < nvars); + ring_elem tmp = R->mult(result, g); + R->remove(result); + result = tmp; + } + } + } + else if (!R->is_commutative_ring() || R->cast_to_SchurRing()) { // This is the only non-commutative case so far for (index_varpower i = vp; i.valid(); ++i)