Skip to content

Commit

Permalink
added lift and promote for IndexedVariable
Browse files Browse the repository at this point in the history
  • Loading branch information
mahrud committed Oct 6, 2024
1 parent 2e3fbd1 commit cc48ffd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions M2/Macaulay2/m2/monoids.m2
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ degree MonoidElement := m -> (
baseName MonoidElement := m -> if #(s := rawSparseListFormMonomial raw m) == 1 and s#0#1 == 1
then (class m).generatorSymbols#(s#0#0) else error "expected a generator"

promote(IndexedVariable, RingElement) := RingElement => (m, R) -> promote(value m, R)
promote(MonoidElement, RingElement) := RingElement => (m, R) -> (
k := coefficientRing first flattenRing R;
-- TODO: audit this code
Expand All @@ -89,6 +90,7 @@ promote(MonoidElement, RingElement) := RingElement => (m, R) -> (
then new R from rawTerm(R.RawRing, raw 1_k, m.RawMonomial)
else "expected monomial from same ring")

lift(IndexedVariable, MonoidElement) := MonoidElement => (m, M) -> lift(value m, M)
lift(RingElement, MonoidElement) := MonoidElement => (m, M) -> (
k := coefficientRing first flattenRing(R := ring m);
if instance(m, monoid k)
Expand Down

0 comments on commit cc48ffd

Please sign in to comment.