=================================================================== RCS file: /home/cvs/OpenXM/src/k097/help.k,v retrieving revision 1.1.1.1 retrieving revision 1.8 diff -u -p -r1.1.1.1 -r1.8 --- OpenXM/src/k097/help.k 1999/10/08 02:12:15 1.1.1.1 +++ OpenXM/src/k097/help.k 2001/01/05 11:14:25 1.8 @@ -1,6 +1,6 @@ - +/* $OpenXM: OpenXM/src/k097/help.k,v 1.7 2001/01/04 12:29:31 takayama Exp $ */ if (K00_verbose) - Println("help.k (help.ccc). 8/6, 1996 --- 8/7, 1996. 3/6, 1997 --- 12/21, 1997."); + Println("help.k: 8/6, 1996 --- 8/7, 1996. 3/6, 1997 --- 12/21, 1997."); def help(x) { if (Length(Arglist) < 1) { @@ -168,9 +168,9 @@ HelpAdd(["Poly", "Poly(name) returns the polynomial name in the current ring (string name)."]); HelpAdd(["PolyR", - "PolyR(name,r) returns the polynomial name in the ring r - (string name, ring r). - Ex. r = RingD(\"x,y\"); y = PolyR(\"y\",r); "]); + ["PolyR(name,r) returns the polynomial name in the ring r + (string name, ring r).", + "Ex. r = RingD(\"x,y\"); y = PolyR(\"y\",r); "]]); HelpAdd(["RingD", ["RingD(names) defines a new ring (string names).", "RingD(names,weight_vector) defines a new ring with the weight vector", @@ -185,8 +185,9 @@ ascii code is ascii_code (integer ascii_code)."]); HelpAdd(["ToString","ToString(obj) transforms the <> to a string."]); HelpAdd(["Numerator","Numerator(f) returns the numerator of <> (rational f)."]); HelpAdd(["Denominator","Denominator(f) returns the denominator of <> (rational f)."]); -HelpAdd(["Replace","Replace(f,rule) (polynomial f, array rule). - Ex. Replace( (x+y)^3, [[x,Poly(\"1\")]])"]); +HelpAdd(["Replace", + ["Replace(f,rule) (polynomial f, array rule). ", + "Ex. Replace( (x+y)^3, [[x,Poly(\"1\")]])"]]); HelpAdd(["SetRingVariables", "SetRingVariables() Set the generators of the current ring as global variables. @@ -195,11 +196,8 @@ HelpAdd(["Append","Append([f1,...,fn],g) returns the l HelpAdd(["Join", "Join([f1,...,fn],[g1,...,gm]) returns the list [f1,...,fn,g1,...,gm]"]); -HelpAdd(["Indexed", - "Indexed(name,i) returns the string name[i] - (string name, integer i)"]); -HelpAdd(["-ReservedName1", +HelpAdd(["!ReservedNames", ["The names k00*, K00*, sm1* , arg1,arg2,arg3,arg4,....," , "Helplist, Arglist, FunctionValue,", "@@@*, db.*, k.*, tmp002*, tmp00* are used for system functions."]]); @@ -222,18 +220,6 @@ HelpAdd(["Init_w", "to the variables <> (array of polynomials).", "Example: Init_w(x^2+y^2+x,[x,y],[1,1]):"]]); -HelpAdd(["RingDonIndexedVariables", - ["RingDonIndexedVariables(name,n) defines and returns the ring of", - "homogenized differential operators", - "Q", - "where <> is a string and <> is an integer.", - "Note that this function defines global variables", - "h, name[0], ..., name[n-1], Dname[0], ..., Dname[n-1].", - "Example: RingDonIndexedVariables(\"x\",3).", - "RingDonIndexedVariables(name,n,w) defines and returns the ring of", - "homogenized differential operators with the ordering defined by ", - "the weight vector <> (array)", - "Example: RingDonIndexedVariables(\"x\",3,[[\"x[0]\",1,\"x[2]\",3]])."]]); HelpAdd(["Groebner", ["Groebner(input) returns Groebner basis of the left module (or ideal)", @@ -270,7 +256,11 @@ HelpAdd(["IsString", ["IsString(obj) returns true if << obj >> is a string (object obj).", "Example: if (IsString(\"abc\")) Println(\"Hello\"); ;"]]); +HelpAdd(["IsRing", +["IsRing(obj) returns true if << obj >> is a ring (object obj)." +]]); + HelpAdd(["IsSm1Integer", ["IsSm1Integer(obj) returns true if << obj >> is an integer of sm1(object obj)."]]); @@ -331,6 +321,7 @@ def RingPoly(vList,weightMatrix,pp) { sm1("[", vList, "ring_of_polynomials ( ) elimination_order 0 ] define_ring /tmp set "); + SetRingVariables(); return(tmp); } else ; if (argsize == 2) { @@ -351,6 +342,7 @@ def RingPoly(vList,weightMatrix,pp) { } new0[i] = newtmp; } + SetRingVariables(); ringpp = sm1("[", vList, "ring_of_polynomials ", new0, " weight_vector", pp, " ] define_ring"); @@ -366,7 +358,11 @@ def IsSm1Integer(ob) { sm1(ob , " isInteger /FunctionValue set "); } +def IsRing(ob) { + sm1(ob , " isRing /FunctionValue set "); +} + def CancelNumber(rn) { local tmp; sm1(" [(cancel) ",rn," ] mpzext /tmp set "); @@ -374,7 +370,13 @@ def CancelNumber(rn) { sm1(" tmp (denominator) dc (1).. eq { /FunctionValue tmp (numerator) dc def} { /FunctionValue tmp def } ifelse "); } +def DC_polynomial(obj) { + return(DC(obj,"polynomial")); +} def DC(obj,key) { + if (IsArray(obj) && key=="polynomial") { + return(Map(obj,"DC_polynomial")); + } if (key == "string") { return(ToString(obj)); } else if (key == "integer") { key = "universalNumber"; } else if (key == "sm1integer") { key = "integer"; } @@ -469,84 +471,7 @@ HelpAdd(["ReducedBase", ["ReducedBase[base] prunes redundant elements in the Grobner basis <> (array)." ]]); -def IndexedVariables(name,size) { - local result,i,result2; - result = [ ]; - for (i=0; i= 0) { - result = Append(result,Indexed(name,size-1)); - } - result2 = Join(["{"],result); - result2 = Join(result2,["}"]); - return(AddString(result2)); -} -HelpAdd(["IndexedVariables", -["IndexedVariables(name,size) returns the string ", - " {name[0],name[1],...,name[size-1]} which can be used as inputs to ", - " the function RingD (string name, integer size).", - " cf. RingDonIndexedVariables.", - " Ex. R = RingD(IndexedVariables(\"a\",3)); ", - " h = Poly(\"h\");", - " a = NewArray(3);", - " for (i=0; i<3; i++) {a[i] = Poly(Indexed(\"a\",i));} ;"]]); - -def RingDonIndexedVariables(vList, size, weightMatrix,pp) { - local myring,tmp,k00_i,argsize,vListD; - /* You cannot use these local varialbes as a name of global ring - variables. Change these names to names that start with k00_ */ - argsize = Length(Arglist); - if (argsize == 1) { - Println("Error (IndexedRingD): "); - return(null); - } - if (argsize == 2) { - vListD = AddString(["D",vList]); - myring = RingD(IndexedVariables(vList,size)); - SetRingVariables(); - tmp = NewArray(size); - for (k00_i=0; k00_i", - "where <> is a string and <> is an integer.", - "Note that this function defines global variables", - "h, name[0], ..., name[n-1].", - "Example: RingPonIndexedVariables(\"x\",3).", - "RingPonIndexedVariables(name,n,w) defines and returns the ring of", - "polynomials with the ordering defined by ", - "the weight vector <> (array)", - "Example: RingPonIndexedVariables(\"x\",3,[[\"x[0]\",1,\"x[2]\",3]])."]]); - - def Mod(f,n) { if (IsPolynomial(f)) { sm1("[(mod) ",f,n,"] gbext /FunctionValue set "); @@ -727,8 +599,16 @@ HelpAdd(["IsConstant", Println("Default ring is Z[x,h]."); x = Poly("x"); h = Poly("h"); def Substitute(f,xx,g) { - local tmp, coeff0,ex,i,n,newex; + local tmp, coeff0,ex,i,n,newex,ans; if (IsInteger(f)) return(f); + if (IsArray(f)) { + n = Length(f); + ans = NewVector(n); + for (i=0; i