[BACK]Return to help.k CVS log [TXT][DIR] Up to [local] / OpenXM / src / k097

Diff for /OpenXM/src/k097/help.k between version 1.1.1.1 and 1.10

version 1.1.1.1, 1999/10/08 02:12:15 version 1.10, 2001/05/27 12:48:02
Line 1 
Line 1 
   /* $OpenXM: OpenXM/src/k097/help.k,v 1.9 2001/01/08 05:26:48 takayama Exp $ */
 if (K00_verbose)  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) {  def help(x) {
   if (Length(Arglist) < 1) {    if (Length(Arglist) < 1) {
Line 23  def Help(key) {
Line 23  def Help(key) {
   }    }
   n = Length(Helplist);    n = Length(Helplist);
   PSfor (i=0; i<n; i++) {    PSfor (i=0; i<n; i++) {
     item = Helplist[i];      item = Helplist[i,1];
     if (item[0] == key) {      if (item[0] == key) {
        if (IsArray(item[1])) {         if (IsArray(item[1])) {
          item1 = item[1];           item1 = item[1];
Line 48  def ShowKeyWords(ss) {
Line 48  def ShowKeyWords(ss) {
   n = Length(Helplist);    n = Length(Helplist);
   keys = [" " ];  /* This is a gate keeper for shell. */    keys = [" " ];  /* This is a gate keeper for shell. */
   PSfor (i=0; i< n; i++ ) {    PSfor (i=0; i< n; i++ ) {
     keys = Append(keys,Helplist[i,0]);      keys = Append(keys,Helplist[i,1,0]);
   }    }
   keys = sm1(keys," shell ");    keys = sm1(keys," shell ");
   n = Length(keys);    n = Length(keys);
Line 92  def ShowKeyWords(ss) {
Line 92  def ShowKeyWords(ss) {
   }    }
   Ln();    Ln();
   Println("Type in Help(keyword);  to see a help message (string keyword).");    Println("Type in Help(keyword);  to see a help message (string keyword).");
     Println("A new help system can be used as man() or man(keyword).");
   
   /* Println(keys); */    /* Println(keys); */
 }  }
Line 152  def ShowKeyWordsOfSm1(ss) {
Line 153  def ShowKeyWordsOfSm1(ss) {
   /* Println(keys); */    /* Println(keys); */
 }  }
   
 HelpAdd(["Help", "Help(key) shows an explanation on the key (string key)."]);  /* Start of HelpAdd */
   HelpAdd(
   ["Map",
    ["Map(<<karg>>,<<func>>) applies the function <<func>> to the <<karg>> (string <<func>>).",
     " Ex. Map([82,83,85],\"AsciiToString\"):"],
    ["karg","func"],
    null,
    "apply a function to each element of a list."
   ]);
   HelpAdd(["Position",
    ["Position(<<list>>,<<elem>>) returns the position p of the element <<elem>> in",
     " the array <<list>>. If <<elem>> is not in <<list>>, it return -1",
     " (array <<list>>).",
     "Ex. Position([1,34,2],34): "],
    ["list","elem"],
    null,
    "find a position of an element in a list."
   ]);
   HelpAdd(["StringToAsciiArray",
    ["StringToAsciiArray(<<s>>) decomposes the string <<s>> into an array of ",
     "ascii codes of <<s>>.",
     "cf. AsciiToString."],
    ["s"],
    ["AsciiToString"],
    "translate a string to an array of ascii codes."
   ]);
   
   HelpAdd(["NewArray",
    ["NewArray(<<n>>) returns an array of size integer <<n>>."],
    ["n"],
    ["NewMatrix"],
    "it returns an array of a given size."
   ]);
   HelpAdd(["GetEnv",
    ["GetEnv(<<s>>) returns the value of the environmental variable string <<s>>."],
    ["s"],
    null,
    "value of an environmental variable."
   ]);
   HelpAdd(["Boundp",
    ["Boundp(<<s>>) checks if the symbol <<s>> is bounded to a value or not (string <<s>>)."],
    ["s"],
    null,
    "check if a symbol is assigned a value or not."
   ]);
   HelpAdd(["Rest",
    ["Rest(<<a>>) returns the rest (cdr) of  <<a>> (list <<a>>)."],
    ["a"],
    ["Append","Join"],
    "it returns the rest of a given list."
   ]);
   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>>)."],
    ["s"],
    ["GetEnv"],
    "find a file in the search path."
   ]);
   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>>)."],
    ["s","flag"],
    ["load"],
    "load a sm1 program"
   ]);
   HelpAdd(["ReParse",
    ["Reparse(<<obj>>): ",
    "It parses the given object <<obj>> in the current ring."],
    ["obj"],
    ["Mapto","RingD"],
    "parses a given object in the current ring."
   ]);
   HelpAdd(["Pmat",
    ["Pmat(<<m>>): ",
     "Print the array <<m>> in a pretty way."],
    ["m"],
    ["Println"],
    "print an given array in a pretty way."
   ]);
   HelpAdd(["Tag",
   ["Tag(<<f>>) returns the datatype tag of <<f>> where",
    "0: null, 5: string,  6: array, 9: polynomial, 15: integer(big-num),  ",
    "16: rational, 18:double, 257: Error ",
    "Ex. Tag([Poly(\"0\"), 0]):"],
    ["f"],
    ["Is*"],
    "return the tag of a given object."
   ]);
   HelpAdd(["Error",
    ["Error(<<s>>) causes an error and outputs a message <<s>>."],
    ["s"],
    null,
    "cause an error."
   ]);
   
   HelpAdd(["Help",
    ["Help(<<key>>) or help(<<key>>) shows an explanation on the <<key>> (string <<key>>)."],
    ["key"],
    ["HelpAdd","help","man"],
    "display a help message."
   ]);
 HelpAdd(["HelpAdd",  HelpAdd(["HelpAdd",
  ["HelpAdd([key,explanation]) (string key, string explanation)",   ["HelpAdd([<<key>>,<<explanation>>]) (string <<key>>, string <<explanation>>)",
   " or (string key, array explanation)."]]);    " or (string <<key>>, array <<explanation>>).",
     "   ",
     "HelpAdd([<<key>>,<<explanation>>,<<category>>]) is used to specify ",
     "the <<category>> of the topics."],
     ["key","explanation"],
     ["help","man"],
     "Add a help message in the system."
   ]);
   
 HelpAdd(["load",  HelpAdd(["load",
  ["load(fname) loads the file << fname >>(string fname).",   ["load(<<fname>>) loads the file << fname >>(string <<fname>>).",
   "load fname  loads the file << fname >>.",    "load <<fname>>  loads the file << fname >>.",
   "load[fname] loads the file << fname >> with the preprocessing by /lib/cpp."    "load[<<fname>>] loads the file << fname >> with the preprocessing by /lib/cpp."
 ]]);  ],
 HelpAdd(["Ln","Ln() newline."]);  ["fname"],
 HelpAdd(["Println","Println(f) prints f and goes to the new line."]);  ["Load_sm1"],
 HelpAdd(["Print","Print(f) prints f."]);  "load a given file."]);
   
   HelpAdd(["Ln","Print newline.",
   [ ],
   ["Print","Println"],
   "print newline."]);
   HelpAdd(["Println",
    ["Println(<<f>>) prints <<f>> and goes to the new line."],
    ["f"],
    ["Ln","Print","Stderr."],
    "display a given object with the newline."
   ]);
   HelpAdd(["Print",
    ["Print(<<f>>) prints <<f>> without the newline."],
    ["f"],
    ["Println"],
    "display a given object."
   ]);
 HelpAdd(["Poly",  HelpAdd(["Poly",
  "Poly(name) returns the polynomial name in the current ring   ["Poly(<<name>>) parses a given string <<name>> in the current ring ",
   (string name)."]);    "and returns a polynomial."
    ],
    ["name"],
    ["DC","PolyR","ReParse","RingD"],
    "translate a string to a polynomial."
   ]);
 HelpAdd(["PolyR",  HelpAdd(["PolyR",
  "PolyR(name,r) returns the polynomial name in the ring r   ["PolyR(<<name>>,<<r>>) parses a string <<name>> in the ring <<r>> ",
  (string name, ring r).   "Ex. r = RingD(\"x,y\"); y = PolyR(\"x+2*y\",r); "],
  Ex. r = RingD(\"x,y\"); y = PolyR(\"y\",r); "]);   ["name","r"],
    ["Poly"],
    "translate a string to a polynomial in a given ring."
   ]);
 HelpAdd(["RingD",  HelpAdd(["RingD",
  ["RingD(names) defines a new ring (string names).",   ["RingD(<<names>>) defines a new ring of differential operators (string <<names>>).",
   "RingD(names,weight_vector) defines a new ring with the weight vector",    "RingD(<<names>>,<<weight_vector>>) defines a new ring with the weight vector",
   "(string names, array weight_vector).",    "(string <<names>>, array <<weight_vector>>).",
   "RingD(names,weight_vector,characteristic)",    "RingD(<<names>>,<<weight_vector>>,<<characteristic>>)",
   " Ex. RingD(\"x,y\",[[\"x\",2,\"y\",1]]) "]]);    "Dx is the associated variable to x where Dx*x - x*Dx = 1 holds.",
 HelpAdd(["Reduction","Reduction(f,G) returns the remainder and sygygies when    " Ex. RingD(\"x,y\",[[\"x\",2,\"y\",1]]) "],
 f is devided by G (polynomial f, array G)."]);    ["names","weight_vector"],
 HelpAdd(["AddString","AddString(list) returns the concatnated string (array list)."]);    ["GetRing","PolyR","ReParse","SetRing"],
 HelpAdd(["AsciiToString","AsciiToString(ascii_code) returns the string of which    "define a new ring of differential operators."
 ascii code is ascii_code (integer ascii_code)."]);  ]);
 HelpAdd(["ToString","ToString(obj) transforms the <<obj>> to a string."]);  HelpAdd(["Reduction",
 HelpAdd(["Numerator","Numerator(f) returns the numerator of <<f>> (rational f)."]);   ["Reduction(<<f>>,<<G>>) returns the remainder and sygygies when
 HelpAdd(["Denominator","Denominator(f) returns the denominator of <<f>> (rational f)."]);     <<f>> is devided by <<G>> (polynomial <<f>>, array <<G>>)."],
 HelpAdd(["Replace","Replace(f,rule) (polynomial f, array rule).   ["f","g"],
            Ex. Replace( (x+y)^3, [[x,Poly(\"1\")]])"]);   ["Gb"],
    "get the remainder and the quotients."
   ]);
   HelpAdd(["AddString","AddString(<<list>>) returns the concatnated string (array <<list>>).",
    ["list"],
    null,
    "concatenate strings."
   ]);
   HelpAdd(["AsciiToString",
    "AsciiToString(<<ascii_code>>) returns the string of which
     ascii code is <<ascii_code>> (integer <<ascii_code>>).",
    ["ascii_code"],
    ["!ReservedNames","AddString","StringToAsciiArray"],
    "translate from ascii code to a string."
   ]);
   HelpAdd(["ToString",
    "ToString(<<obj>>) transforms the <<obj>> to a string.",
    ["obj"],
    ["DC"],
    "translate a given object to a string."
   ]);
   HelpAdd(["Numerator",
    "Numerator(<<f>>) returns the numerator of the rational <<f>>.",
    ["f"],
    ["Cancel","Denominator"],
    "numerator"
   ]);
   HelpAdd(["Denominator",
    "Denominator(<<f>>) returns the denominator of the rational <<f>>.",
    ["f"],
    ["Cancel","Numerator"],
    "denominator"
   ]);
   HelpAdd(["Replace",
     ["Replace(<<f>>,<<rule>>) rewrites <<f>> by the <<rule>> (polynomial <<f>>, array <<rule>>).  ",
      "Ex. RingD(\"x,y\"); Replace( (x+y)^3, [[x,Poly(\"1\")]])"],
     ["f","rule"],
     ["replace (sm1)"],
     "substitute variables by given values"
   ]);
 HelpAdd(["SetRingVariables",  HelpAdd(["SetRingVariables",
  "SetRingVariables()   "Set the generators of the current ring as global variables.
   Set the generators of the current ring as global variables.    You do not need explicitly call this function which is called from RingD.
   cf. RingD(), Poly(), PolyR()"]);    cf. RingD(), Poly(), PolyR()",
 HelpAdd(["Append","Append([f1,...,fn],g) returns the list [f1,...,fn,g]"]);    [ ],
     ["RingD"],
     "  "
   ]);
   HelpAdd(["Append",
    "Append([<<f1>>,...,<<fn>>],<<g>>) returns the list [<<f1>>,...,<<fn>>,<<g>>]",
    ["f1","fn","g"],
    ["Join","NewArray","Rest"],
    "append two lists or arrays."
   ]);
 HelpAdd(["Join",  HelpAdd(["Join",
  "Join([f1,...,fn],[g1,...,gm]) returns the list   "Join([<<f1>>,...,<<fn>>],[<<g1>>,...,<<gm>>]) returns the list
   [f1,...,fn,g1,...,gm]"]);    [<<f1>>,...,<<fn>>,<<g1>>,...,<<gm>>]",
 HelpAdd(["Indexed",    ["f1","fn","g1","gm"],
  "Indexed(name,i) returns the string name[i]    ["Append","NewArray","Rest"],
   (string name, integer i)"]);    "join two lists or arrays"
   ]);
   
 HelpAdd(["-ReservedName1",  HelpAdd(["!ReservedNames",
  ["The names k00*, K00*, sm1* , arg1,arg2,arg3,arg4,....," ,   ["The names k00*, K00*, sm1* , arg1,arg2,arg3,arg4,....," ,
   "Helplist, Arglist, FunctionValue,",    "Helplist, Arglist, FunctionValue,",
   "@@@*, db.*, k.*, tmp002*, tmp00* are used for system functions."]]);    "@@*, db.*, k.*, tmp002*, tmp00* are used for system functions.",
     "Percent, LeftBracket, RightBracket, Dollar, Newline are constants"],
     null,
     null,
     "reserved symbols."
   ]);
   
 HelpAdd(["IntegerToSm1Integer",  HelpAdd(["IntegerToSm1Integer",
  "IntegerToSm1Integer(i) translates integer i   "IntegerToSm1Integer(<<i>>) translates integer <<i>>
   to sm1.integer (integer i)."]);    to sm1 integer (integer <<i>>).",
 HelpAdd(["true","true returns sm1.integer 1."]);   ["i"],
 HelpAdd(["false","false returns sm1.integer 0."]);   null,
    "translates integer to 32 bit integer (sm1 integer)"
   ]);
   HelpAdd(["true","true returns sm1 integer 1.",null,null," "]);
   HelpAdd(["false","false returns sm1 integer 0.",null,null," "]);
 HelpAdd(["IsArray",  HelpAdd(["IsArray",
  ["If f is the array object, then IsArray(f) returns true,",   ["If <<f>> is an array (or list) object, then IsArray(<<f>>) returns true,",
   "else IsArray(f) returns false."]]);    "else IsArray(<<f>>) returns false."],
    ["f"],
    ["Is*","Tag"],
    "check if an given object is an array."
   ]);
   
   
   
 HelpAdd(["Init_w",  HelpAdd(["Init_w",
  ["Init_w(f,vars,w) returns the initial terms with respect to the",   ["Init_w(<<f>>,<<vars>>,<<w>>) returns the initial terms with respect to the",
   "weight vector <<w>> (array of integer) of the polynomial <<f>>",    "weight vector <<w>> (array of integer) of the polynomial <<f>>",
   "(polynomial).  Here, <<f>> is regarded as a polynomial with respect",    "(polynomial).  Here, <<f>> is regarded as a polynomial with respect",
   "to the variables <<vars>> (array of polynomials).",    "to the variables <<vars>> (array of polynomials).",
   "Example: Init_w(x^2+y^2+x,[x,y],[1,1]):"]]);    "Ex. RingD(\"x,y\"); Init_w(x^2+y^2+x,[x,y],[1,1]):"],
     ["f","vars","w"],
     ["Gb","Init"],
     "return the initial terms."
   ]);
   
 HelpAdd(["RingDonIndexedVariables",  
  ["RingDonIndexedVariables(name,n) defines and returns the ring of",  
   "homogenized differential operators",  
   "Q<h, name[0], ..., name[n-1], Dname[0], ..., Dname[n-1]>",  
   "where <<name>> is a string and <<n>> 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 <<w>> (array)",  
   "Example: RingDonIndexedVariables(\"x\",3,[[\"x[0]\",1,\"x[2]\",3]])."]]);  
   
 HelpAdd(["Groebner",  HelpAdd(["Groebner",
  ["Groebner(input) returns Groebner basis of the left module (or ideal)",   ["Groebner(<<input>>) returns Groebner basis of the left ideal or the submodule",
   "defined by <<input>> (array of polynomials)",    "defined by <<input>> (array of polynomials)",
   "The order is that of the ring to which each element of <<input>>",    "The order is that of the ring to which each element of <<input>>",
   "belongs.",    "belongs.",
   "The input is automatically homogenized.",    "The input is automatically homogenized.",
   "Example: RingD(\"x,y\",[[\"x\", 10, \"y\", 1]]);",    "Ex. RingD(\"x,y\",[[\"x\", 10, \"y\", 1]]);",
   "         Groebner([Poly(\" x^2+y^2-4\"),Poly(\" x*y-1 \")]):",    "          Groebner([Poly(\" x^2+y^2-4\"),Poly(\" x*y-1 \")]):",
   "cf. RingD, Homogenize"]]);    "cf. RingD, Homogenize"],
     ["input"],
     ["Gb","Init_w","RingD","groebner (sm1)"],
     "compute the Grobner basis."
   ]);
   
   
 HelpAdd(["RingPoly",  HelpAdd(["RingPoly",
  ["RingPoly(names) defines a Ring of Polyomials (string names).",   ["RingPoly(<<names>>) defines a ring of polyomials (string <<names>>).",
   "The names of variables of that ring are <<names>>  and ",    "The names of variables of that ring are <<names>>  and ",
   "the homogenization variable h.",    "the homogenization variable h.",
   "cf. SetRingVariables, RingD",    "cf. SetRingVariables, RingD",
   "Example: R=RingPoly(\"x,y\");",    "Ex. R=RingPoly(\"x,y\");",
   "  ",    "  ",
   "RingPoly(names,weight_vector) defines a Ring of Polynomials",    "RingPoly(<<names>>,<<weight_vector>>) defines a ring of polynomials",
   "with the order defined by the << weight_vector >>",    "with the order defined by the <<weight_vector>>",
   "(string names, array of array weight_vector).",    "(string <<names>>, array of array <<weight_vector>>).",
   "RingPoly(names,weight_vector,characteristic)",    "RingPoly(<<names>>,<<weight_vector>>,<<characteristic>>)",
   "Example: R=RingPoly(\"x,y\",[[\"x\",10,\"y\",1]]);",    "Example: R=RingPoly(\"x,y\",[[\"x\",10,\"y\",1]]);",
   "         (x+y)^10: "]]);    "         (x+y)^10: "],
     ["names","weight_vector"],
     ["GetRing","RingD","SetRing"],
     "define a ring of polynomials."
   ]);
   
   
 HelpAdd(["CancelNumber",  HelpAdd(["CancelNumber",
 ["CancelNumber(rn) reduces the rational number <<rn>>",  ["CancelNumber(<<rn>>) reduces the rational number <<rn>>",
  "(rational rn).",   "(rational <<rn>>).",
  "Example: CancelNumber( 2/6 ) : "]]);   "Ex. CancelNumber( 2/6 ) : "],
    ["rn"],
    ["Cancel"],
    "factor out the greatest common divisor."
   ]);
   
 HelpAdd(["IsString",  HelpAdd(["IsString",
 ["IsString(obj) returns true if << obj >> is a string (object obj).",  ["IsString(<<obj>>) returns true if << obj >> is a string (object <<obj>>).",
  "Example:  if (IsString(\"abc\")) Println(\"Hello\"); ;"]]);   "Ex.  if (IsString(\"abc\")) Println(\"Hello\"); ;"],
    ["obj"],
    ["DC","Is*","Tag"],
    "check if a given object is a string."
   ]);
   
   HelpAdd(["IsRing",
    ["IsRing(<<obj>>) returns true if << obj >> is a ring (object <<obj>>)."
    ],
    ["obj"],
    ["DC","Is*","Tag"],
    "check if a given object is a ring."
   ]);
   
   
 HelpAdd(["IsSm1Integer",  HelpAdd(["IsSm1Integer",
 ["IsSm1Integer(obj) returns true if << obj >> is an integer of sm1(object obj)."]]);  ["IsSm1Integer(<<obj>>) returns true if << obj >> is an integer of sm1(object <<obj>>)."],
    ["obj"],
    ["DC","Is*","Tag"],
    "check if a given object is a 32 bit integer."
   ]);
   
 HelpAdd(["sm1",  HelpAdd(["sm1",
 ["sm1(arg1,arg2,...) is used to embed sm1 native code in the kxx program.",  ["sm1(<<arg1>>,<<arg2>>,...) is used to embed sm1 native code in the kxx program.",
  "Example: sm1( 2, 2, \" add print \"); ",   "Ex. sm1( 2, 2, \" add print \"); ",
  "Example: def myadd(a,b) { sm1(a,b,\" add /FunctionValue set \"); }" ]]);   "Ex. def myadd(a,b) { sm1(\" a b add /FunctionValue set \"); }" ],
    ["arg1","arg2"],
    ["usage (sm1)"],
    "execute sm1 commands"
   ]);
   
 HelpAdd(["DC",  HelpAdd(["DC",
 ["DC(obj,key) converts << obj >> to a new object in the primitive",  ["DC(<<obj>>,<<key>>) converts << obj >> to a new object in the primitive",
  "class << key >> (object obj, string key)",   "class << key >> (object <<obj>>, string <<key>>)",
  "Example:  DC(\" (x+1)^10 \", \"polynomial\"): "]]);   "Ex.  DC(\" (x+1)^10 \", \"polynomial\"): "],
    ["obj","key"],
    ["ToString"],
    "translate data types."
   ]);
   
 HelpAdd(["Length",  HelpAdd(["Length",
 ["Length(vec) returns the length of the array << vec >>",  ["Length(<<vec>>) returns the length of the array << vec >>",
  "(array vec)"]]);   "(array <<vec>>)"],
    ["vec"],
    null,
    "length of a given array or a list."
   ]);
   
 HelpAdd(["Transpose",  HelpAdd(["Transpose",
 ["Transpose(m) return the transpose of the matrix << m >>",   ["Transpose(<<m>>.) return the transpose of the matrix << m >>",
  "(array of array m)."]]);    "(array of array <<m>>)."],
    ["m"],
    ["NewMatrix"],
    "transposition"
   ]);
   
 HelpAdd(["Save",  HelpAdd(["Save",
 ["Save(obj) appends << obj >> to the file sm1out.txt (object obj)."]]);   ["Save(<<obj>>) appends << obj >> to the file sm1out.txt (object <<obj>>)."],
    ["obj"],
    null,
    "write a given object to a file."
   ]);
   
 HelpAdd(["Coefficients",  HelpAdd(["Coefficients",
 ["Coefficients(f,v) returns [exponents, coefficients] of << f >>",  ["Coefficients(<<f>>,<<v>>) returns [exponents, coefficients] of << f >>",
  "with respect to the variable << v >>",   "with respect to the variable << v >>",
  "(polynomial f,v).",   "(polynomial <<f>>,<<v>>).",
  "Example: Coefficients(Poly(\"(x+1)^2\"),Poly(\"x\")): "]]);   "Ex.  Coefficients(Poly(\"(x+1)^2\"),Poly(\"x\")): "],
    ["f","v"],
    ["Exponent","Init","Init_w"],
    "get the exponents and coefficients."
   ]);
   
 HelpAdd(["System",  HelpAdd(["System",
 ["System(comm) executes the unix system command << comm >>",  ["System(<<comm>>) executes the unix system command << comm >>",
  "(string comm)",   "(string <<comm>>)",
  "Example: System(\"ls\");"]]);   "Ex. System(\"ls\");"],
    ["comm"],
    null,
    "call the unix shell."
   ]);
   
 HelpAdd(["Exponent",  HelpAdd(["Exponent",
  ["Expoent(f,vars) returns the vector of exponents of the polynomial f",   ["Expoent(<<f>>,<<vars>>) returns the vector of exponents of the polynomial <<f>>",
   "Ex. Exponent( x^2*y-1,[x,y])"]]);    "Ex. Exponent( x^2*y-1,[x,y])"],
    ["f","vars"],
    ["Coefficients"],
    "exponents of a given polynomial."
   ]);
   
 HelpAdd(["Protect",  HelpAdd(["Protect",
  ["Protect(name) protects the symbol <<name>> (string)",   ["Protect(<<name>>) protects the symbol <<name>> (string)",
   "Protect(name,level) protects the symbol <<name>> (string) with ",    "Protect(<<name>>,<<level>>) protects the symbol <<name>> (string) with ",
   "<<level>> "]]);    "<<level>> "],
    ["name","level"],
    ["extension (sm1)"],
    "add read-only property for a given variable."
   ]);
   
 HelpAdd(["IsPolynomial",  HelpAdd(["IsPolynomial",
  ["IsPolynomial(f) returns true if <<f>> (object) is a polynomial."]]);   ["IsPolynomial(<<f>>) returns true if <<f>> (object) is a polynomial."],
    ["obj"],
    ["DC","Is*","Tag"],
    "check if a given object is a polynomial."
   ]);
   
   
   
Line 331  def RingPoly(vList,weightMatrix,pp) {
Line 586  def RingPoly(vList,weightMatrix,pp) {
     sm1("[", vList,      sm1("[", vList,
         "ring_of_polynomials ( ) elimination_order 0 ] define_ring          "ring_of_polynomials ( ) elimination_order 0 ] define_ring
          /tmp set ");           /tmp set ");
       SetRingVariables();
     return(tmp);      return(tmp);
   } else ;    } else ;
   if (argsize == 2) {    if (argsize == 2) {
Line 351  def RingPoly(vList,weightMatrix,pp) {
Line 607  def RingPoly(vList,weightMatrix,pp) {
     }      }
     new0[i] = newtmp;      new0[i] = newtmp;
   }    }
     SetRingVariables();
   ringpp =    ringpp =
   sm1("[", vList,    sm1("[", vList,
       "ring_of_polynomials ", new0, " weight_vector", pp, " ] define_ring");        "ring_of_polynomials ", new0, " weight_vector", pp, " ] define_ring");
Line 366  def IsSm1Integer(ob) {
Line 623  def IsSm1Integer(ob) {
   sm1(ob , " isInteger /FunctionValue set ");    sm1(ob , " isInteger /FunctionValue set ");
 }  }
   
   def IsRing(ob) {
     sm1(ob , " isRing /FunctionValue set ");
   }
   
   
 def CancelNumber(rn) {  def CancelNumber(rn) {
   local tmp;    local tmp;
   sm1(" [(cancel) ",rn," ] mpzext /tmp set ");    sm1(" [(cancel) ",rn," ] mpzext /tmp set ");
Line 374  def CancelNumber(rn) {
Line 635  def CancelNumber(rn) {
   sm1(" tmp (denominator) dc (1).. eq { /FunctionValue tmp (numerator) dc def} { /FunctionValue tmp def } ifelse ");    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) {  def DC(obj,key) {
     if (IsArray(obj) && key=="polynomial") {
       return(Map(obj,"DC_polynomial"));
     }
   if (key == "string") { return(ToString(obj)); }    if (key == "string") { return(ToString(obj)); }
   else if (key == "integer") { key = "universalNumber"; }    else if (key == "integer") { key = "universalNumber"; }
   else if (key == "sm1integer") { key = "integer"; }    else if (key == "sm1integer") { key = "integer"; }
Line 446  def Init(f) {
Line 713  def Init(f) {
   }    }
 }  }
 HelpAdd(["Init",  HelpAdd(["Init",
  ["Init(f) returns the initial term of the polynomial <<f>> (polynomial)",   ["Init(<<f>>) returns the initial term of the polynomial <<f>> (polynomial)",
   "Init(list) returns the array of initial terms of the array of polynomials",    "Init(<<list>>) returns the array of initial terms of the array of polynomials",
   "<< list >> (array)"]]);    "<< list >> (array)"],
     ["f"],
     ["Init_w"],
     "return the initial term."
   ]);
   
 HelpAdd(["NewMatrix",  HelpAdd(["NewMatrix",
  ["NewMatrix(m,n) returns the (m,n)-matrix (array) with the entries 0."]]);   ["NewMatrix(<<m>>,<<n>>) returns the (<<m>>,<<n>>)-matrix (array) with the entries 0."],
    ["m","n"],
    ["NewArray"],
    "generate a matrix of a given size."
   ]);
   
 def Eliminatev(list,var)  /* [(x-y). (y-z).] [(z) ] */  def Eliminatev(list,var)  /* [(x-y). (y-z).] [(z) ] */
 {  {
    sm1(list, var, " eliminatev /FunctionValue set ");     sm1(list, var, " eliminatev /FunctionValue set ");
 }  }
 HelpAdd(["Eliminatev",  HelpAdd(["Eliminatev",
 ["Eliminatev(list,var) prunes polynomials in << list >>(array of polynomials)",  ["Eliminatev(<<list>>,<<var>>) prunes polynomials in << list >>(array of polynomials)",
  "which contains the variables in << var >> ( array of strings )",   "which contains the variables in << var >> ( array of strings )",
  "Example: Eliminatev([Poly(\" x+h \"),Poly(\" x \")],[ \"h\" ]): "]]);   "Ex. Eliminatev([Poly(\" x+h \"),Poly(\" x \")],[ \"h\" ]): "],
    ["list","var"],
    ["eliminatev (sm1)"],
    "  "
   ]);
   
 def ReducedBase(base) {  def ReducedBase(base) {
   sm1( base, " reducedBase /FunctionValue set ");    sm1( base, " reducedBase /FunctionValue set ");
 }  }
 HelpAdd(["ReducedBase",  HelpAdd(["ReducedBase",
  ["ReducedBase[base] prunes redundant elements in the Grobner basis <<base>> (array)."   ["ReducedBase(<<base>>) prunes redundant elements in the Grobner basis <<base>> (array)."
 ]]);  ],
    ["base"],
    ["Gb","Groebner"],
    "remove unnecessary elements."
   ]);
   
 def IndexedVariables(name,size) {  
   local result,i,result2;  
   result = [ ];  
   for (i=0; i<size-1; i++) {  
     result = Append(result,Indexed(name,i));  
     result = Append(result,",");  
   }  
   if (size-1 >= 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<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vList,k00_i));}  
     sm1(vList, " (literal) dc ", tmp, " def ");  
     tmp = NewArray(size);  
     for (k00_i=0; k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vListD,k00_i));}  
     sm1(vListD, " (literal) dc ", tmp, " def ");  
     if (SetRingVariables_Verbose) {  
       Print("Set the global variables ");  
       sm1("[(parse) ",vList," ] extension pop print ");  
       sm1("[(parse) ",vListD," ] extension pop print "); Ln();  
     }else {  
       sm1("[(parse) ",vList," ] extension pop  ");  
       sm1("[(parse) ",vListD," ] extension pop ");  
     }  
     return( myring );  
   }  
   if (argsize == 3 || argsize == 4) {  
    if (argsize == 3) { pp = 0; }  
    vListD = AddString(["D",vList]);  
    myring = RingD(IndexedVariables(vList,size),weightMatrix,pp);  
     SetRingVariables();  
     tmp = NewArray(size);  
     for (k00_i=0;k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vList,k00_i));}  
     sm1(vList, " (literal) dc ", tmp, " def ");  
     tmp = NewArray(size);  
     for (k00_i=0;k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vListD,k00_i));}  
     sm1(vListD, " (literal) dc ", tmp, " def ");  
     if (SetRingVariables_Verbose) {  
       Print("Set the global variables ");  
       sm1("[(parse) ",vList," ] extension pop print ");  
       sm1("[(parse) ",vListD," ] extension pop print "); Ln();  
     } else {  
       sm1("[(parse) ",vList," ] extension pop  ");  
       sm1("[(parse) ",vListD," ] extension pop ");  
     }  
     return( myring );  
   }  
   return(-1);  
 }  
   
 def Ringp(f) {  
   sm1(f, " (ring) dc /FunctionValue set ");  
 }  
 HelpAdd(["Ringp",  
  ["Ringp(f) ( polynomial f ) returns the ring to which the polynomial << f >>",  
   "belongs."]]);  
   
 def Coefficients(f,v) {  def Coefficients(f,v) {
   local ans,exp;    local ans,exp;
   ans = sm1(f,v, " coefficients ");    ans = sm1(f,v, " coefficients ");
Line 566  def IsInteger(a) {
Line 765  def IsInteger(a) {
   sm1(a , " isUniversalNumber /FunctionValue set ");    sm1(a , " isUniversalNumber /FunctionValue set ");
 }  }
 HelpAdd(["IsInteger",  HelpAdd(["IsInteger",
 ["IsInteger(a) returns true if << a >> is an integer (object a).",  ["IsInteger(<<a>>) returns true if << a >> is an integer (object <<a>>).",
  "It returns false if << a >> is not.",   "It returns false if << a >> is not.",
  "cf. IsSm1Integer"]]);   "cf. IsSm1Integer"],
    ["a"],
    ["DC","Is*","Tag"],
    "check if a given object is an integer."
   ]);
   
 def IsRational(a) {  def IsRational(a) {
   sm1(a , " isRational /FunctionValue set ");    sm1(a , " isRational /FunctionValue set ");
 }  }
 HelpAdd(["IsRational",  HelpAdd(["IsRational",
 ["IsRational(a) returns true if << a >> is a rational (object a).",  ["IsRational(<<a>>) returns true if << a >> is a rational (object <<a>>).",
  "It returns false if << a >> is not."]]);   "It returns false if << a >> is not."],
    ["a"],
    ["DC","Is*","Tag"],
    "check if a given object is a rational."
   ]);
   
   
 def IsDouble(a) {  def IsDouble(a) {
   sm1(a , " isDouble /FunctionValue set ");    sm1(a , " isDouble /FunctionValue set ");
 }  }
 HelpAdd(["IsDouble",  HelpAdd(["IsDouble",
 ["IsDouble(a) returns true if << a >> is a double (object a).",  ["IsDouble(<<a>>) returns true if << a >> is a double (object <<a>>).",
  "It returns false if << a >> is not."]]);   "It returns false if << a >> is not."],
    ["a"],
    ["DC","Is*","Tag"],
    "check if a given object is double."
   ]);
   
   
 sm1(" /cs { this  [ ] Cleards  } def ");  sm1(" /cs { this  [ ] Cleards  } def ");
Line 604  def Init_w(f,vars,weight) {
Line 815  def Init_w(f,vars,weight) {
 }  }
   
 HelpAdd(["Mapto",  HelpAdd(["Mapto",
  ["Mapto(obj,ring) parses << obj >> as elements of the << ring >>.",   ["Mapto(<<obj>>,<<ring>>) parses << obj >> as elements of the << ring >>.",
   "(ring << ring >>, polynomial << obj >> or array of polynomial << obj >>).",    "(ring << ring >>, polynomial << obj >> or array of polynomial << obj >>).",
   "Ex. R = RingD(\"x,y\"); SetRingVariables();",    "Ex. R = RingD(\"x,y\"); SetRingVariables();",
   "    f = (x+y)^2; R2 = RingD(\"x,y,z\",[[\"y\",1]]); ",    "    f = (x+y)^2; R2 = RingD(\"x,y,z\",[[\"y\",1]]); ",
   "    f2 = Mapto(f,R2); f2: "]]);    "    f2 = Mapto(f,R2); f2: "],
     ["obj","ring"],
     ["ReParse"],
     "parse a polynomial in a given ring."
   ]);
   
 def Mapto(obj,ring) {  def Mapto(obj,ring) {
    local ans,i,n;     local ans,i,n;
Line 627  def Mapto(obj,ring) {
Line 842  def Mapto(obj,ring) {
   
   
 HelpAdd(["ToDouble",  HelpAdd(["ToDouble",
  ["ToDouble(f) translates << f >> into double when it is possible",   ["ToDouble(<<f>>) translates << f >> into double when it is possible",
   "object << f >>.",    "object << f >>.",
   "Example: ToDouble([1,1/2,[5]]): "]]);    "Ex. ToDouble([1,1/2,[5]]): "],
    ["f"],
    ["DC","Is*","Tag"],
    "translate a given object to double."
   ]);
 def k00_toDouble(f) {   return(DC(f,"double")); }  def k00_toDouble(f) {   return(DC(f,"double")); }
 def ToDouble(f) {  def ToDouble(f) {
   if (IsArray(f)) return(Map(f,"ToDouble"));    if (IsArray(f)) return(Map(f,"ToDouble"));
Line 638  def ToDouble(f) {
Line 857  def ToDouble(f) {
 }  }
   
   
 def RingPonIndexedVariables(vList, size, weightMatrix) {  
   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 (RingPonIndexedVariables): ");  
     return(null);  
   }  
   if (argsize == 2) {  
     myring = RingPoly(IndexedVariables(vList,size));  
     SetRingVariables();  
     tmp = NewArray(size);  
     for (k00_i=0; k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vList,k00_i));}  
     sm1(vList, " (literal) dc ", tmp, " def ");  
     if (SetRingVariables_Verbose) {  
      Print("Set the global variables ");  
      sm1("[(parse) ",vList," ] extension pop print "); Ln();  
     }else {  
      sm1("[(parse) ",vList," ] extension pop  ");  
     }  
     return( myring );  
   }  
   if (argsize == 3) {  
     myring = RingPoly(IndexedVariables(vList,size),weightMatrix);  
     SetRingVariables();  
     tmp = NewArray(size);  
     for (k00_i=0;k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vList,k00_i));}  
     sm1(vList, " (literal) dc ", tmp, " def ");  
     if (SetRingVariables_Verbose) {  
       Print("Set the global variables ");  
       sm1("[(parse) ",vList," ] extension pop print "); Ln();  
     } else {  
       sm1("[(parse) ",vList," ] extension pop ");  
     }  
     return( myring );  
   }  
   return(-1);  
 }  
   
 HelpAdd(["RingPonIndexedVariables",  
  ["RingPonIndexedVariables(name,n) defines and returns the ring of",  
   "polynomials",  
   "Q<h, name[0], ..., name[n-1] >",  
   "where <<name>> is a string and <<n>> 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 <<w>> (array)",  
   "Example: RingPonIndexedVariables(\"x\",3,[[\"x[0]\",1,\"x[2]\",3]])."]]);  
   
   
 def Mod(f,n) {  def Mod(f,n) {
    if (IsPolynomial(f)) {     if (IsPolynomial(f)) {
      sm1("[(mod) ",f,n,"] gbext  /FunctionValue set ");       sm1("[(mod) ",f,n,"] gbext  /FunctionValue set ");
    } else if (IsInteger(f)) { return( Gmp.Mod(f,n) ); }     } else if (IsInteger(f)) { return( Gmp.Mod(f,n) ); }
 }  }
 HelpAdd(["Mod",  HelpAdd(["Mod",
  ["Mod(f,p) returns f modulo n  where << f >> (polynomial) and",   ["Mod(<<f>>,<<p>>) returns f modulo <<n>>  where << f >> (polynomial) and",
   " << p >> (integer). "]]);    " << p >> (integer). "],
    ["f","p"],
    ["gbext (sm1)"],
    "modulo"
   ]);
   
   
   
Line 713  def Characteristic(ringp) {
Line 883  def Characteristic(ringp) {
   return(p);    return(p);
 }  }
 HelpAdd(["Characteristic",  HelpAdd(["Characteristic",
 ["Characteristic(ring) returns the characteristic of the << ring >>."   ["Characteristic(<<ring>>) returns the characteristic of the << ring >>."],
 ]]);   ["ring"],
    ["GetRing","RingD","RingPoly","SetRing"],
    "get the characteristic of a given ring."
   ]);
   
 def IsConstant(f) {  def IsConstant(f) {
   if (Length(f) > 1) return(false);    if (Length(f) > 1) return(false);
   sm1("[(isConstant) ", f," ] gbext /FunctionValue set ");    sm1("[(isConstant) ", f," ] gbext /FunctionValue set ");
 }  }
 HelpAdd(["IsConstant",  HelpAdd(["IsConstant",
 ["IsConstant(f) returns true if the polynomial << f >> is a constant."  ["IsConstant(<<f>>) returns true if the polynomial << f >> is a constant."
 ]]);  ],
    ["f"],
    ["DC","Is*","Tag"],
    "check if a given object is a constant."
   ]);
   
 Println("Default ring is Z[x,h]."); x = Poly("x"); h = Poly("h");  Println("Default ring is Z[x,h]."); x = Poly("x"); h = Poly("h");
   
 def Substitute(f,xx,g) {  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 (IsInteger(f)) return(f);
     if (IsArray(f)) {
        n = Length(f);
        ans = NewVector(n);
        for (i=0; i<n; i++) {
          ans[i] = Substitute(f[i],xx,g);
        }
        return(ans);
     }
   if (! IsPolynomial(f)) {    if (! IsPolynomial(f)) {
     k00_error("Substitute","The first argument must be polynomial.");      k00_error("Substitute","The first argument must be polynomial.");
   }    }
Line 744  def Substitute(f,xx,g) {
Line 929  def Substitute(f,xx,g) {
   return(Cancel(coeff0*newex));    return(Cancel(coeff0*newex));
 }  }
 HelpAdd(["Substitute",  HelpAdd(["Substitute",
 ["Substitute(f,xx,g) replaces << xx >> in << f >> by << g >>.",  ["Substitute(<<f>>,<<xx>>,<<g>>) replaces << xx >> in << f >> by << g >>.",
   "This function takes coeffients of << f >> with respect to << xx >>",    "This function takes coeffients of << f >> with respect to << xx >>",
   "and returns the inner product of the vector of coefficients and the vector",    "and returns the inner product of the vector of coefficients and the vector",
   "of which elements are g^(corresponding exponent).",    "of which elements are g^(corresponding exponent).",
   "Note that it may cause an unexpected result in non-commutative rings."    "Note that it may cause an unexpected result in non-commutative rings."
 ]]);  ],
    ["f","xx","g"],
    ["Replace"],
    "  "
   ]);
   
 def Tag(f) {  
   local ans;  
   if (IsArray(f)) {  
     return(Map(f,"Tag"));  
   }else {  
     ans = sm1(f," tag (universalNumber) dc ");  
     return(ans);  
   }  
 }  
 HelpAdd(["Tag",  
 ["Tag(f) returns the datatype tags of f where",  
  "5: string,  9: polynomial, 15: integer(big-num), 16: rational, ",  
  "17: object, 18:double.",  
  "Ex. Tag([Poly(\"0\"), 0]):"  
 ]]);  
   
   HelpAdd(["OutputPrompt",
    ["Output the prompt. Files should end with this command."],
    null,
    null,
    "output the prompt."]);
   
   Protect("Percent");
   Protect("LeftBracket");
   Protect("RightBracket");
   Protect("Dollar");
   Protect("Newline");
   
 OutputPrompt ;  OutputPrompt ;

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.10

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>