From 04b5a893fe86b5e3023e2252496cd78a54571360 Mon Sep 17 00:00:00 2001 From: pzinn Date: Mon, 7 Oct 2024 16:53:22 +1100 Subject: [PATCH] doc and tests for promote update --- M2/Macaulay2/packages/Macaulay2Doc/doc5.m2 | 8 +++--- .../functions/setupPromote-doc.m2 | 26 +++++++++++++++++++ M2/Macaulay2/tests/normal/testpromote.m2 | 19 ++++++++++++++ 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 M2/Macaulay2/packages/Macaulay2Doc/functions/setupPromote-doc.m2 diff --git a/M2/Macaulay2/packages/Macaulay2Doc/doc5.m2 b/M2/Macaulay2/packages/Macaulay2Doc/doc5.m2 index 740f0ed96eb..163de20ea29 100644 --- a/M2/Macaulay2/packages/Macaulay2Doc/doc5.m2 +++ b/M2/Macaulay2/packages/Macaulay2Doc/doc5.m2 @@ -360,7 +360,7 @@ document { Key => {(eagonNorthcott,Matrix),eagonNorthcott}, document { Key => {(selectVariables,List,PolynomialRing),selectVariables}, Headline => "make a subring of a polynomial ring generated by selected variables", - Usage => "(S,f) = selectVariables(v,R)", + Usage => "(S,F) = selectVariables(v,R)", Inputs => { "v" => {"a sorted list of numbers specifying which variables to select"}, "R" @@ -369,13 +369,13 @@ document { Key => {(selectVariables,List,PolynomialRing),selectVariables}, "S" => PolynomialRing => {"a polynomial ring generated as a subring of R by the variables whose indices occur in the list v, together with the induced monomial ordering" }, - "f" => RingMap => {"the inclusion map from S to R"} + "F" => RingMap => {"the inclusion map from S to R"} }, EXAMPLE lines /// - (S,f) = selectVariables({2,4}, QQ[a..h,Weights=>1..8]); + (S,F) = selectVariables({2,4}, QQ[a..h,Weights=>1..8]); describe S options S - f + F /// } diff --git a/M2/Macaulay2/packages/Macaulay2Doc/functions/setupPromote-doc.m2 b/M2/Macaulay2/packages/Macaulay2Doc/functions/setupPromote-doc.m2 new file mode 100644 index 00000000000..bc8caca25e1 --- /dev/null +++ b/M2/Macaulay2/packages/Macaulay2Doc/functions/setupPromote-doc.m2 @@ -0,0 +1,26 @@ +--- status: DRAFT +--- author(s): PZJ +--- notes: + +undocumented {(setupPromote,Ring,Ring)} + +doc /// + Key + setupPromote + Headline + automatic promotion from one ring to another + Usage + setupPromote f + Inputs + f: RingMap + Description + Text + After calling @TT "setupPromote"@, any operation that is given an element of the source of @TT "f"@ but + expects an elements of the target of @TT "f"@ will automatically apply @TT "f"@. + Example + R=QQ[x_1,x_2] + R'=QQ[e_1,e_2] + setupPromote map(R,R',{x_1+x_2,x_1*x_2}) + e_1*x_1 + e_2==x_1*x_2 +/// diff --git a/M2/Macaulay2/tests/normal/testpromote.m2 b/M2/Macaulay2/tests/normal/testpromote.m2 index fcd727de9ba..e2884dc4497 100644 --- a/M2/Macaulay2/tests/normal/testpromote.m2 +++ b/M2/Macaulay2/tests/normal/testpromote.m2 @@ -63,6 +63,25 @@ assert( rawLift(raw C, f) == raw C_0 ) --E = frac D --F = GF(2,5) +-- more sophisticated, m2 level, promotes +R=QQ[x]; S=R[y]; +a=promote(1/x,frac S) +assert(lift(a,frac R) == 1/x) +assert(1/x + 1/y == a + 1/y) +assert(y/x == a * y) +assert(promote((frac R)^{1,2},frac S)==(frac S)^{{1,0},{2,0}}) +T=R**QQ[z]; +assert(promote(x_R,T) == x_T) +assert(lift(x_T,R) == x_R) +assert(lift(z,R,Verify=>false) === null) + +R=QQ[x_1,x_2] +R'=QQ[e_1,e_2] +f=map(R,R',{x_1+x_2,x_1*x_2}) +setupPromote f +assert(e_2==x_1*x_2) +assert(map(R,R') === f) + end -- Local Variables: