Skip to content

Commit

Permalink
lift between fraction fields
Browse files Browse the repository at this point in the history
  • Loading branch information
pzinn committed Sep 23, 2024
1 parent 10e9339 commit 514efd9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion M2/Macaulay2/m2/enginering.m2
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,15 @@ frac EngineRing := R -> if isField R then R else if R.?frac then R.frac else (
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));
promote(List,S.frac,F) := (m,G,F) -> apply(m, d -> splice ( d | toList(degreeLength F-#d:0) )); -- TODO check
promote(List,S.frac,F) := (m,G,F) -> apply(m, d -> splice ( d | toList(degreeLength F-#d:0) ));
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));
lift(F,S.frac) := opts -> (a,G) -> fraction(lift(numerator a,S),lift(denominator a,S));
lift(List,F,S.frac) := opts -> (m,F,G) -> apply(m, d -> take(d,degreeLength S.frac));
lift(Module,F,S.frac) := opts -> (M,F,G) -> S.frac ** M;
lift(Matrix,F,S.frac) := opts -> (m,F,G) -> map(lift(target m,S.frac),lift(source m,S.frac),applyTable(entries m,x->lift(x,S.frac)));
lift(MutableMatrix,F,S.frac) := opts -> (m,F,G) -> mutableMatrix applyTable(entries m,x->lift(x,S.frac));
));
F)

Expand Down
1 change: 1 addition & 0 deletions M2/Macaulay2/m2/rings.m2
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ toExternalString Ring := toString @@ describe
-- promote, lift, liftable, and isConstant
-----------------------------------------------------------------------------

-- TODO rename isLiftable; add test that lift method exists
-- some remnants from lift and promote, version 2
liftable = method(TypicalValue => Boolean, Dispatch => {Thing, Type, Type})
liftable(Number, Number) :=
Expand Down

0 comments on commit 514efd9

Please sign in to comment.