/* $OpenXM: OpenXM/src/k097/slib.k,v 1.9 2001/01/08 05:26:49 takayama Exp $ */ /* slib.sm1, standard library. */ /* April 26-- , 1996 */ /* Don't use function names that is already used as a postscipt macro names*/ /* You may encounter operand stack overflow. */ /* sm1("(incmac.sm1) run (slib.sm1) run "); */ if (K00_verbose) sm1(" ( slib.k (slib.ccc): 8/17,1996, 3/4 -- 3/10,1997 ) message "); /* Each Helplist[i] has the format [ category, [ key, explanations, ( args ,) (refs ,) (short descriptions)]] category : null or string key : string explanations : string or array of string (Ex. and << >> are key words) args : null or list of strings refs : null or list of strings short descriptions : string */ Helplist = [ ]; def void HelpAdd(s,category) { local n; n = Length(Arglist); if (n <= 1) { category = null; } if (true) { /* Assert the args */ /* You can use functions only defined before using HelpAdd */ if (!(n == 1 || n == 2)) { Println(s); Error("HelpAdd: wrong argument length."); } if (!(Tag(category) == 0 || Tag(category) == 5)) { Println(category); Error("HelpAdd: wrong category."); } if (!(Tag(s) == 6)) { Println(s); Error("HelpAdd: s must be an array."); } if (! (Tag(s[0]) == 5)) { Println(s); Error("HelpAdd: s[0] must be a string."); } if (! (Tag(s[1]) == 5 || Tag(s[1]) == 6)) { Println(s); Error("HelpAdd: s[1] must be a string or an array."); } /* End of assert */ } s = [category,s]; Helplist = Append(Helplist,s); } def Tag(f) { local ans; ans = sm1(f," etag (universalNumber) dc "); return(ans); } def Error(s) { sm1(" s error "); } def Print(a) { /* print object without new line */ sm1(a," messagen"); } def Println(a) { /* print object with new line */ sm1(a," message"); } def Ln() { sm1(" ( ) message"); } /* newline */ /* Warning!! When use sm1 as f = sm1(...), Never set /FunctionValue. Example: f = sm1(" 1 1 add /FunctionValue set ") causes error. */ def Poly(f) { sm1(f," (poly) data_conversion /FunctionValue set"); } def PolyR(f,r) { /* parse the polynomial in R */ sm1(f,r," ,, /FunctionValue set"); } def Degree(f,v) { sm1(f,v," degree (universalNumber) dc /FunctionValue set"); } def Append(f,g) { return(Join(f,[g])); } def Length(f) { sm1(f," length (universalNumber) dc /FunctionValue set"); } def Transpose(mat) { sm1(mat," transpose /FunctionValue set "); } sm1(" /s.Indexed { (integer) dc /arg2 set /arg1 set arg1 ([) arg2 (dollar) dc (]) 4 cat_n } def /s.Indexed2 { (integer) dc /arg3 set (integer) dc /arg2 set /arg1 set arg1 ([) arg2 (dollar) dc (,) arg3 (dollar) dc (]) 6 cat_n } def "); def Groebner(F) { /* Print("Input is "); Println(F); */ sm1(F," {[[(h). (1).]] replace homogenize} map /arg1 set [arg1] groebner 0 get /FunctionValue set "); } def GroebnerTime(F) { /* Print("Input is "); Println(F); */ sm1(F," {[[(h). (1).]] replace homogenize} map /arg1 set { [arg1] groebner 0 get } timer /FunctionValue set "); } def LiftStd(F) { /* Print("Input is "); Println(F); */ sm1(F," {[[(h). (1).]] replace homogenize} map /arg1 set [arg1 [(needBack)]] groebner /FunctionValue set "); } /* def Reduction(f,G) { sm1(f,G," reduction /FunctionValue set "); } */ def Reduction(f,myset) { local n, indexTable, set2, i, j, tmp, t_syz,r,rng, vsize,tt; vsize = null; r = GetRing(Poly("1")); /* Save the current ring */ rng = GetRing(f); if (Tag(rng) == 0) { rng = GetRing(myset); } if (Tag(rng) != 0) {SetRing(rng);} if (IsArray(f)) { vsize = Length(f); sm1(" [f] fromVectors 0 get /f set "); } n = Length(myset); if (n > 0) { if (IsArray(myset[0])) { if (vsize != Length(myset[0])) { Error("Reduction: size mismatch."); } sm1(" myset fromVectors /myset set "); } } indexTable = NewArray(n); set2 = [ ]; j = 0; for (i=0; i