=================================================================== RCS file: /home/cvs/OpenXM/src/k097/slib.k,v retrieving revision 1.5 retrieving revision 1.11 diff -u -p -r1.5 -r1.11 --- OpenXM/src/k097/slib.k 2000/12/10 09:34:27 1.5 +++ OpenXM/src/k097/slib.k 2003/11/20 09:20:36 1.11 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/k097/slib.k,v 1.4 2000/12/10 03:12:19 takayama Exp $ */ +/* $OpenXM: OpenXM/src/k097/slib.k,v 1.10 2001/01/13 01:17:36 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,18 +122,80 @@ 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() { @@ -288,48 +391,27 @@ 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"); } -HelpAdd(["Boundp", -["Boundp(s) checks if the symbol s is bounded to a value or not (string s)."]]); def Rest(a) { sm1(a," rest /FunctionValue set "); } -HelpAdd(["Rest", -["Rest(a) returns the rest (cdr) of a (list a)."]]); def GetPathName(s) { local t,sss; sss = s; @@ -346,9 +428,6 @@ def GetPathName(s) { return(s); } } -HelpAdd(["GetPathName", -["GetPathName(s) checks if the file s exists in the current directory or", - "in LOAD_K_PATH. If there exists, it returns the path name (string s)."]]); def Load_sm1(fnames,flag) { local ppp,n,i,cmd; @@ -367,7 +446,33 @@ def Load_sm1(fnames,flag) { } } -HelpAdd(["Load_sm1", -["Load_sm1(s,flag) loads a sm1 program from s[0], s[1], ....", - "If loading is succeeded, the already-loaded flag is set to true.", - "(list s, string flag)."]]); + +def GetRing(f) { + sm1(" f getRing /FunctionValue set "); +} + +def SetRing(r) { + sm1(" r ring_def "); +} + +def ReParse(a) { + local c; + if (IsArray(a)) { + c = Map(a,"ReParse"); + }else{ + sm1(a," toString . /c set"); + } + return(c); +} + +def void Pmat(a) { + sm1(" a pmat "); +} + +def void QuoteMode(a) { + if ( a == 0) { + sm1("[(QuoteMode) 0] system_variable "); + }else{ + sm1("[(QuoteMode) 1] system_variable "); + } +} \ No newline at end of file