Skip to content

Commit

Permalink
doc and tests for promote update
Browse files Browse the repository at this point in the history
  • Loading branch information
pzinn committed Oct 7, 2024
1 parent bf82740 commit 53983f1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 4 deletions.
8 changes: 4 additions & 4 deletions M2/Macaulay2/packages/Macaulay2Doc/doc5.m2
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
///
}

Expand Down
26 changes: 26 additions & 0 deletions M2/Macaulay2/packages/Macaulay2Doc/functions/setupPromote-doc.m2
Original file line number Diff line number Diff line change
@@ -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,Degrees=>{1,2}]
setupPromote map(R,R',{x_1+x_2,x_1*x_2})
e_1*x_1
e_2==x_1*x_2
///
23 changes: 23 additions & 0 deletions M2/Macaulay2/tests/normal/testpromote.m2
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,29 @@ 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,Degrees=>{1,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)

R=QQ[a]; S=QQ[b];
setupPromote map(R,S,{a^2},DegreeMap=>i->2*i)
assert(isHomogeneous map(R,S))
assert(promote(S^{1,2},R)==R^{2,4})

end
-- Local Variables:
Expand Down

0 comments on commit 53983f1

Please sign in to comment.