=================================================================== RCS file: /home/cvs/OpenXM/src/k097/slib.k,v retrieving revision 1.3 retrieving revision 1.9 diff -u -p -r1.3 -r1.9 --- OpenXM/src/k097/slib.k 2000/12/10 02:21:46 1.3 +++ OpenXM/src/k097/slib.k 2001/01/08 05:26:49 1.9 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/k097/slib.k,v 1.2 2000/01/21 03:01:26 takayama Exp $ */ +/* $OpenXM: OpenXM/src/k097/slib.k,v 1.8 2001/01/05 11:14:25 takayama Exp $ */ /* slib.sm1, standard library. */ /* April 26-- , 1996 */ /* Don't use function names that is already used as a postscipt macro names*/ @@ -8,11 +8,62 @@ 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) { +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"); } @@ -37,13 +88,6 @@ def Append(f,g) { return(Join(f,[g])); } def Length(f) { sm1(f," length (universalNumber) dc /FunctionValue set"); } -def Indexed(name,i) { - sm1(name,i," s.Indexed /FunctionValue set "); -} -/* Indexed2("a",2,3) ---> "a[2,3]" */ -def Indexed2(name,i,j) { - sm1(name,i,j," s.Indexed2 /FunctionValue set "); -} def Transpose(mat) { sm1(mat," transpose /FunctionValue set "); } @@ -78,12 +122,71 @@ def LiftStd(F) { /* Print("Input is "); Println(F); */ [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> to the <>(string func).", - " Ex. Map([82,83,85],\"AsciiToString\"):"]]); /* test Map def foo1(i) { return(i*2); } def foo() { @@ -297,32 +388,81 @@ def Position(list,elem) { sm1(" /k00.label0 "); return(pos); } -HelpAdd(["Position", - ["Position(list,elem) returns the position p of the element <> in", - " the array <>. If <> is not in <>, it return -1", - " (array list).", - "Ex. Position([1,34,2],34): "]]); -def StringToIntegerArray(s) { +def StringToAsciiArray(s) { sm1(s," (array) dc { (universalNumber) dc } map /FunctionValue set "); } -HelpAdd(["StringToIntegerArray", - ["StringToIntegerArray(s) decomposes the string <> into an array of", - "ascii codes of <> (string s).", - "cf. AsciiToString."]]); -def StringToAsciiArray(s) { return(StringToIntegerArray(s)); } -HelpAdd(["StringToAsciiArray", - ["StringToAsciiArray(s) is StringToIntegerArray(s)."]]); - def NewArray(n) { return(NewVector(n)); } -HelpAdd(["NewArray", -["NewArray(n) returns an array of size n (integer n)."]]); def GetEnv(s) { sm1(" [(getenv) s] extension /FunctionValue set "); } -HelpAdd(["GetEnv", -["GetEnv(s) returns the value of the environmental variable s (string s)."]]); +def Boundp(a) { + local b; + sm1("[(parse) [(/) ",a," ( load tag 0 eq + { /FunctionValue 0 def } + { /FunctionValue 1 def } ifelse )] cat ] extension"); +} +def Rest(a) { + sm1(a," rest /FunctionValue set "); +} +def GetPathName(s) { + local t,sss; + sss = s; + sm1(" [(stat) s] extension 0 get /t set "); + if (Tag(t) == 0) { + s=AddString([GetEnv("LOAD_K_PATH"),"/",s]); + sm1(" [(stat) s] extension 0 get /t set "); + if (Tag(t) == 0) { + return(null); + }else{ + return(s); + } + }else{ + return(s); + } +} + +def Load_sm1(fnames,flag) { + local ppp,n,i,cmd; + if (Boundp(flag)) { + }else{ + n = Length(fnames); + for (i=0; i