diff --git a/M2/Macaulay2/d/actors.d b/M2/Macaulay2/d/actors.d index efc6dfd42b..83f1b33264 100644 --- a/M2/Macaulay2/d/actors.d +++ b/M2/Macaulay2/d/actors.d @@ -331,7 +331,7 @@ export (lhs:Expr) * (rhs:Expr) : Expr := ( is null do buildErrorPacket(EngineError("monomial ideal multiplication failed")) ) else binarymethod(lhs,rhs,StarS)) - is x:RawMatrixCell do ( -- # typical value: symbol *, RawMatrix, RawRingElement, RawRingElement + is x:RawMatrixCell do ( -- # typical value: symbol *, RawMatrix, RawRingElement, RawMatrix when rhs is y:RawRingElementCell do ( when x.p*y.p diff --git a/M2/Macaulay2/d/parse.d b/M2/Macaulay2/d/parse.d index a5765f0acb..daf87278af 100644 --- a/M2/Macaulay2/d/parse.d +++ b/M2/Macaulay2/d/parse.d @@ -141,7 +141,6 @@ export LocalQuote := {+Operator:Token, rhs:Token, local:void}; export Binary := {+lhs:ParseTree, Operator:Token, rhs:ParseTree}; export Unary := {+Operator:Token, rhs:ParseTree}; export Postfix:= {+lhs:ParseTree, Operator:Token}; -export ArrayParseTree := array(ParseTree); export Parentheses := {+ left:Token, contents:ParseTree, right:Token }; export EmptyParentheses := {+ left:Token, right:Token }; export dummy := {+position:Position}; diff --git a/M2/Macaulay2/d/parser.d b/M2/Macaulay2/d/parser.d index ca1a23a7ca..98ca764320 100644 --- a/M2/Macaulay2/d/parser.d +++ b/M2/Macaulay2/d/parser.d @@ -273,30 +273,6 @@ matcher(left:string):string := ( ); "" ); -export varexprlist := { - list:array(ParseTree), - size:int - }; -export newvarexprlist(i:int):varexprlist := varexprlist( - new array(ParseTree) len i do provide dummyTree, - 0); -needatleast(i:int,v:varexprlist):void := ( - if length(v.list) < i then ( - v.list = new array(ParseTree) len 2*i do ( - foreach e in v.list do provide e; - while true do provide dummyTree; - ); - ); - ); -export (v:varexprlist) << (e:ParseTree) : varexprlist := ( - needatleast(v.size + 1,v); - v.list.(v.size) = e; - v.size = v.size + 1; - v - ); -export toexprlist(v:varexprlist):ArrayParseTree := ( - new array(ParseTree) len v.size do foreach e in v.list do provide e - ); export unaryparen(left:Token,file:TokenFile,prec:int,obeylines:bool):ParseTree := ( rightparen := matcher(left.word.name); if rightparen == peektoken(file,false).word.name diff --git a/M2/Macaulay2/m2/modules.m2 b/M2/Macaulay2/m2/modules.m2 index 3932f496b2..6c98e9b6d0 100644 --- a/M2/Macaulay2/m2/modules.m2 +++ b/M2/Macaulay2/m2/modules.m2 @@ -352,14 +352,6 @@ isSubset(Module, Module) := (M, N) -> ( ----------------------------------------------------------------------------- --- the key for issub hooks under GlobalHookStore -protect ContainmentHooks -issub = (f, g) -> f === g or ring f === ring g and tryHooks(ContainmentHooks, (f, g), - -- This is used by isSubset and for checking equality of ideals and modules. - -- Specialized strategies may be added as hooks, for instance for local rings. - -- TODO: how can do better in the homogeneous case? - (f, g) -> -1 === rawGBContains(raw gb g, raw f)) - -- used for sorting a list of modules Module ? Module := (M, N) -> if rank M != rank N then rank M ? rank N else degrees M ? degrees N diff --git a/M2/Macaulay2/m2/monideal.m2 b/M2/Macaulay2/m2/monideal.m2 index 59b5529583..35fb9fd780 100644 --- a/M2/Macaulay2/m2/monideal.m2 +++ b/M2/Macaulay2/m2/monideal.m2 @@ -34,7 +34,7 @@ monomialIdeal Sequence := v -> monomialIdeal toList v monomialIdeal RingElement := v -> monomialIdeal {v} MonomialIdeal#1 = I -> monomialIdeal 1_(ring I) -MonomialIdeal ^ ZZ := MonomialIdeal => (I, n) -> monomialIdeal (ideal I)^n +MonomialIdeal ^ ZZ := MonomialIdeal => BinaryPowerMethod MonomialIdeal ^ Array := MonomialIdeal => (I, e) -> monomialIdeal (ideal I)^e MonomialIdeal + MonomialIdeal := MonomialIdeal => ((I, J) -> newMonomialIdeal(ring I, raw I + raw J)) @@ samering diff --git a/M2/Macaulay2/m2/monoids.m2 b/M2/Macaulay2/m2/monoids.m2 index 72cc963ef2..64b3a0a7ad 100644 --- a/M2/Macaulay2/m2/monoids.m2 +++ b/M2/Macaulay2/m2/monoids.m2 @@ -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 @@ -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) diff --git a/M2/Macaulay2/packages/Macaulay2Doc/ov_language.m2 b/M2/Macaulay2/packages/Macaulay2Doc/ov_language.m2 index a74937d7a6..702f964dff 100644 --- a/M2/Macaulay2/packages/Macaulay2Doc/ov_language.m2 +++ b/M2/Macaulay2/packages/Macaulay2Doc/ov_language.m2 @@ -606,18 +606,17 @@ document { }, SeeAlso => {"if", "then"} } -document { Key => "catch", - Headline => "catch a thrown exception", SeeAlso => {"throw"}, - Usage => "catch c", - Outputs => {{"the value obtained by evaluating the code ", TT "c", ", or, if a ", TO "throw", " was executed during the evaluation of ", TT "c", ", - the argument given to ", TO "throw", "."}}, - EXAMPLE lines /// - catch scan(0..10, i -> if i == 5 then throw 18 else print i) - ///} -document { Key => "throw", - Headline => "throw an exception", SeeAlso => {"catch"}, - Usage => "throw x", - Consequences => {{"the flow of control is passed to the surrounding ", TO "catch", ", and ", TT "x", " is returned as its value"}}, +document { + Key => {"throw", "catch"}, + Headline => "throw and catch exceptions", + Usage => "catch c\nthrow x", + Outputs => {{ + TT "catch", " returns the value obtained by evaluating the code ", TT "c", + ", or, if a ", TT "throw", " was executed during the evaluation of ", TT "c", + ", the argument given to ", TT "throw", "."}}, + Consequences => {{ + TT "throw", " passes the flow of control to the surrounding ", TT "catch", + ", and ", TT "x", " is returned as its value"}}, EXAMPLE lines /// catch scan(0..10, i -> if i == 5 then throw 18 else print i) ///} diff --git a/M2/Macaulay2/tests/normal/monideal4.m2 b/M2/Macaulay2/tests/normal/monideal4.m2 index abf481ee14..94713fbb39 100644 --- a/M2/Macaulay2/tests/normal/monideal4.m2 +++ b/M2/Macaulay2/tests/normal/monideal4.m2 @@ -3,7 +3,12 @@ I = monomialIdeal(a^3,b^2*c,a*c*d) J = saturate(I,a) J1 = monomialIdeal(1_R) assert(J == monomialIdeal(1_R)) -end --- Local Variables: --- compile-command: "make -C $M2BUILDDIR/Macaulay2/packages/Macaulay2Doc/test monideal4.out" --- End: + +R = QQ[x_1..x_10] +I = monomialIdeal vars R +(t, J) = toSequence elapsedTiming I^6; +assert(t < 1 and instance(J, MonomialIdeal) and numgens J == 5005) +(t, K) = toSequence elapsedTiming saturate J; +assert(t < 1 and instance(K, MonomialIdeal) and K == 1) +(t, L) = toSequence elapsedTiming radical J; +assert(t < 1 and instance(L, MonomialIdeal) and L == I)