Skip to content

Commit

Permalink
promoteFromMap, promote for tensor products
Browse files Browse the repository at this point in the history
  • Loading branch information
pzinn committed Sep 23, 2024
1 parent 9ed1024 commit 10e9339
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
10 changes: 7 additions & 3 deletions M2/Macaulay2/m2/enginering.m2
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,13 @@ frac EngineRing := R -> if isField R then R else if R.?frac then R.frac else (
if R.?indexSymbols then F.indexSymbols = applyValues(R.indexSymbols, r -> promote(r,F));
if R.?indexStrings then F.indexStrings = applyValues(R.indexStrings, r -> promote(r,F));
if R.?numallvars then F.numallvars=R.numallvars;
scan(R.baseRings, S -> if S.?frac and not isPromotable(S.frac,F) then
promote(S.frac,F) := (a,F) -> fraction(promote(numerator a,R),promote(denominator a,R))
);
scan(R.baseRings, S -> if S.?frac and not isPromotable(S.frac,F) then (
promote(S.frac,F) := (a,F) -> fraction(promote(numerator a,R),promote(denominator a,R));
promote(List,S.frac,F) := (m,G,F) -> apply(m, d -> splice ( d | toList(degreeLength F-#d:0) )); -- TODO check
promote(Module,S.frac,F) := (M,G,F) -> F ** M;
promote(Matrix,S.frac,F) := (m,G,F) -> map(promote(target m,F),promote(source m,F),applyTable(entries m,x->promote(x,F)));
promote(MutableMatrix,S.frac,F) := (m,G,F) -> mutableMatrix applyTable(entries m,x->promote(x,F));
));
F)

-- methods for all ring elements
Expand Down
1 change: 1 addition & 0 deletions M2/Macaulay2/m2/exports.m2
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@ export {
"projectiveHilbertPolynomial",
"programPaths",
"promote",
"promoteFromMap",
"protect",
"prune",
"pruningMap",
Expand Down
6 changes: 3 additions & 3 deletions M2/Macaulay2/m2/matrix.m2
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ Matrix * Matrix := Matrix => (m,n) -> (
else (
R := ring m;
S := ring target n;
if R =!= S then (
try m = m ** S else
try n = n ** R else
if R =!= S then ( -- use toSameRing?
try m = promote(m,S) else
try n = promote(n,R) else
error "maps over incompatible rings";
);
M = target m;
Expand Down
18 changes: 17 additions & 1 deletion M2/Macaulay2/m2/newring.m2
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ needs "matrix2.m2" -- for lift
-- new polynomial ring or quotient ring from old --
----------------------------------

-- automate promotion
promoteFromMap = method()
promoteFromMap (Ring,Ring,RingMap) := (R,S,f) -> (
promote(R,S) := (a,S1) -> f a;
promote(Matrix,R,S) :=
promote(MutableMatrix,R,S) := -- doesn't work, cf https://github.com/Macaulay2/M2/issues/2192
promote(Module,R,S) := (M,R1,S1) -> f M; -- TODO rethink carefully
-- promote(List,R,S) := (L,R1,S1) -> f\L; -- TODO put back!!!!!!!!!!
)
promoteFromMap (Ring,Ring) := (R,S) -> promoteFromMap(R,S,map(S,R))


-- TODO: rewrite this to be easier to manage with degree group
nothing := symbol nothing
newRing = method( Options => applyValues(monoidDefaults, x -> nothing), TypicalValue => Ring )
Expand Down Expand Up @@ -77,7 +89,11 @@ tensor(QuotientRing, QuotientRing) := monoidTensorDefaults >> optns -> (R, S)
fg := substitute(f,(vars AB)_{0 .. m-1}) | substitute(g,(vars AB)_{m .. m+n-1});
-- forceGB fg; -- if the monomial order chosen doesn't restrict, then this
-- is an error!! MES
AB/image fg)
RS := AB/image fg;
promoteFromMap(R,RS,map(RS,R,(vars AB)_{0 .. m-1}));
promoteFromMap(S,RS,map(RS,S,(vars AB)_{m .. m+n-1}));
RS
)

-------------------------
-- Graph of a ring map --
Expand Down
12 changes: 0 additions & 12 deletions M2/Macaulay2/packages/CotangentSchubert/cotangent.m2
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,6 @@ expandElem := (P,vrs,els) -> (
sub(C,ring first els) * product(#vrs, i -> (els#i)^(ee#i)) + expandElem(Q,vrs,els)
)

-- automate promotion
promoteFromMap = method()
promoteFromMap (Ring,Ring,RingMap) := (R,S,f) -> (
promote(R,S) := (a,S1) -> f a;
promote(Matrix,R,S) :=
promote(MutableMatrix,R,S) := -- doesn't work, cf https://github.com/Macaulay2/M2/issues/2192
promote(Module,R,S) := (M,R1,S1) -> f M;
-- promote(List,R,S) := (L,R1,S1) -> f\L; -- TODO put back!!!!!!!!!!
S.baseRings = prepend(R,S.baseRings); -- temporary -- until promotability test improved in enginering.m2
)
promoteFromMap (Ring,Ring) := (R,S) -> promoteFromMap(R,S,map(S,R))

tautoClass = method(Dispatch=>{Thing,Thing,Type},Options=>true); -- "Chern classes" -- renamed tautoClass to avoid confusion with motivic classes
zeroSection = method(Dispatch=>{Type},Options=>true) -- note the {}
dualZeroSection = method(Dispatch=>{Type},Options=>true) -- note the {}
Expand Down

0 comments on commit 10e9339

Please sign in to comment.