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

Annotation of OpenXM/src/k097/debug/indexed.k, Revision 1.1

1.1     ! takayama    1: /* $OpenXM$ */
        !             2: /* These were moved from slib.k and help.k */
        !             3:
        !             4: def Indexed(name,i) {
        !             5:   sm1(name,i," s.Indexed /FunctionValue set ");
        !             6: }
        !             7: /* Indexed2("a",2,3) ---> "a[2,3]" */
        !             8: def Indexed2(name,i,j) {
        !             9:   sm1(name,i,j," s.Indexed2 /FunctionValue set ");
        !            10: }
        !            11: HelpAdd(["Indexed",
        !            12:  "Indexed(name,i) returns the string name[i]
        !            13:   (string name, integer i)"]);
        !            14: HelpAdd(["RingDonIndexedVariables",
        !            15:  ["RingDonIndexedVariables(name,n) defines and returns the ring of",
        !            16:   "homogenized differential operators",
        !            17:   "Q<h, name[0], ..., name[n-1], Dname[0], ..., Dname[n-1]>",
        !            18:   "where <<name>> is a string and <<n>> is an integer.",
        !            19:   "Note that this function defines global variables",
        !            20:   "h, name[0], ..., name[n-1], Dname[0], ..., Dname[n-1].",
        !            21:   "Example: RingDonIndexedVariables(\"x\",3).",
        !            22:   "RingDonIndexedVariables(name,n,w) defines and returns the ring of",
        !            23:   "homogenized differential operators with the ordering defined by ",
        !            24:   "the weight vector <<w>> (array)",
        !            25:   "Example: RingDonIndexedVariables(\"x\",3,[[\"x[0]\",1,\"x[2]\",3]])."]]);
        !            26: def IndexedVariables(name,size) {
        !            27:   local result,i,result2;
        !            28:   result = [ ];
        !            29:   for (i=0; i<size-1; i++) {
        !            30:     result = Append(result,Indexed(name,i));
        !            31:     result = Append(result,",");
        !            32:   }
        !            33:   if (size-1 >= 0) {
        !            34:     result = Append(result,Indexed(name,size-1));
        !            35:   }
        !            36:   result2 = Join(["{"],result);
        !            37:   result2 = Join(result2,["}"]);
        !            38:   return(AddString(result2));
        !            39: }
        !            40: HelpAdd(["IndexedVariables",
        !            41: ["IndexedVariables(name,size) returns the string ",
        !            42:  " {name[0],name[1],...,name[size-1]} which can be used as inputs to ",
        !            43:  " the function RingD  (string name, integer size).",
        !            44:  " cf. RingDonIndexedVariables.",
        !            45:  " Ex. R = RingD(IndexedVariables(\"a\",3)); ",
        !            46:  "     h = Poly(\"h\");",
        !            47:  "     a = NewArray(3);",
        !            48:  "     for (i=0; i<3; i++) {a[i] = Poly(Indexed(\"a\",i));} ;"]]);
        !            49:
        !            50:
        !            51: def RingDonIndexedVariables(vList, size, weightMatrix,pp) {
        !            52:   local myring,tmp,k00_i,argsize,vListD;
        !            53:   /* You cannot use these local varialbes as a name of global ring
        !            54:      variables. Change these names to names that start with k00_ */
        !            55:   argsize = Length(Arglist);
        !            56:   if (argsize == 1) {
        !            57:     Println("Error (IndexedRingD): ");
        !            58:     return(null);
        !            59:   }
        !            60:   if (argsize == 2) {
        !            61:     vListD = AddString(["D",vList]);
        !            62:     myring = RingD(IndexedVariables(vList,size));
        !            63:     tmp = NewArray(size);
        !            64:     for (k00_i=0; k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vList,k00_i));}
        !            65:     sm1(vList, " (literal) dc ", tmp, " def ");
        !            66:     tmp = NewArray(size);
        !            67:     for (k00_i=0; k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vListD,k00_i));}
        !            68:     sm1(vListD, " (literal) dc ", tmp, " def ");
        !            69:     if (SetRingVariables_Verbose) {
        !            70:       Print("Set the global variables ");
        !            71:       sm1("[(parse) ",vList," ] extension pop print ");
        !            72:       sm1("[(parse) ",vListD," ] extension pop print "); Ln();
        !            73:     }else {
        !            74:       sm1("[(parse) ",vList," ] extension pop  ");
        !            75:       sm1("[(parse) ",vListD," ] extension pop ");
        !            76:     }
        !            77:     return( myring );
        !            78:   }
        !            79:   if (argsize == 3 || argsize == 4) {
        !            80:    if (argsize == 3) { pp = 0; }
        !            81:    vListD = AddString(["D",vList]);
        !            82:    myring = RingD(IndexedVariables(vList,size),weightMatrix,pp);
        !            83:     SetRingVariables();
        !            84:     tmp = NewArray(size);
        !            85:     for (k00_i=0;k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vList,k00_i));}
        !            86:     sm1(vList, " (literal) dc ", tmp, " def ");
        !            87:     tmp = NewArray(size);
        !            88:     for (k00_i=0;k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vListD,k00_i));}
        !            89:     sm1(vListD, " (literal) dc ", tmp, " def ");
        !            90:     if (SetRingVariables_Verbose) {
        !            91:       Print("Set the global variables ");
        !            92:       sm1("[(parse) ",vList," ] extension pop print ");
        !            93:       sm1("[(parse) ",vListD," ] extension pop print "); Ln();
        !            94:     } else {
        !            95:       sm1("[(parse) ",vList," ] extension pop  ");
        !            96:       sm1("[(parse) ",vListD," ] extension pop ");
        !            97:     }
        !            98:     return( myring );
        !            99:   }
        !           100:   return(-1);
        !           101: }
        !           102: def RingPonIndexedVariables(vList, size, weightMatrix) {
        !           103:   local myring,tmp,k00_i,argsize,vListD;
        !           104:   /* You cannot use these local varialbes as a name of global ring
        !           105:      variables. Change these names to names that start with k00_ */
        !           106:   argsize = Length(Arglist);
        !           107:   if (argsize == 1) {
        !           108:     Println("Error (RingPonIndexedVariables): ");
        !           109:     return(null);
        !           110:   }
        !           111:   if (argsize == 2) {
        !           112:     myring = RingPoly(IndexedVariables(vList,size));
        !           113:     SetRingVariables();
        !           114:     tmp = NewArray(size);
        !           115:     for (k00_i=0; k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vList,k00_i));}
        !           116:     sm1(vList, " (literal) dc ", tmp, " def ");
        !           117:     if (SetRingVariables_Verbose) {
        !           118:      Print("Set the global variables ");
        !           119:      sm1("[(parse) ",vList," ] extension pop print "); Ln();
        !           120:     }else {
        !           121:      sm1("[(parse) ",vList," ] extension pop  ");
        !           122:     }
        !           123:     return( myring );
        !           124:   }
        !           125:   if (argsize == 3) {
        !           126:     myring = RingPoly(IndexedVariables(vList,size),weightMatrix);
        !           127:     SetRingVariables();
        !           128:     tmp = NewArray(size);
        !           129:     for (k00_i=0;k00_i<size; k00_i++) {tmp[k00_i]=Poly(Indexed(vList,k00_i));}
        !           130:     sm1(vList, " (literal) dc ", tmp, " def ");
        !           131:     if (SetRingVariables_Verbose) {
        !           132:       Print("Set the global variables ");
        !           133:       sm1("[(parse) ",vList," ] extension pop print "); Ln();
        !           134:     } else {
        !           135:       sm1("[(parse) ",vList," ] extension pop ");
        !           136:     }
        !           137:     return( myring );
        !           138:   }
        !           139:   return(-1);
        !           140: }
        !           141:
        !           142: HelpAdd(["RingPonIndexedVariables",
        !           143:  ["RingPonIndexedVariables(name,n) defines and returns the ring of",
        !           144:   "polynomials",
        !           145:   "Q<h, name[0], ..., name[n-1] >",
        !           146:   "where <<name>> is a string and <<n>> is an integer.",
        !           147:   "Note that this function defines global variables",
        !           148:   "h, name[0], ..., name[n-1].",
        !           149:   "Example: RingPonIndexedVariables(\"x\",3).",
        !           150:   "RingPonIndexedVariables(name,n,w) defines and returns the ring of",
        !           151:   "polynomials with the ordering defined by ",
        !           152:   "the weight vector <<w>> (array)",
        !           153:   "Example: RingPonIndexedVariables(\"x\",3,[[\"x[0]\",1,\"x[2]\",3]])."]]);
        !           154:

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