001/* 002 * $Id: TermOrderByName.java 5377 2015-12-31 17:43:16Z kredel $ 003 */ 004 005package edu.jas.poly; 006 007 008 009 010// import org.apache.log4j.Logger; 011 012 013/** 014 * Term order names for ordered polynomials. Defines names for the most used 015 * term orders: graded and lexicographical orders. For the definitions see for 016 * example the articles <a href="http://doi.acm.org/10.1145/43882.43887">Kredel, 017 * "Admissible term orderings used in computer algebra systems"</a> and <a 018 * href="http://doi.acm.org/10.1145/70936.70941">Sit, 019 * "Some comments on term-ordering in Gröbner basis computations"</a>. Not 020 * all algorithms may work with all term orders since not all are well-founded, 021 * so watch your step. 022 * 023 * <b>Note:</b> Variables in printed JAS polynomial <b>(low, ..., medium, ..., 024 * high)</b> Variables in other CAS polynomial <b>(high, ..., medium, ..., 025 * low)</b> with <b>low</b> < <b>medium</b> < <b>high</b>. Example: for 026 * variables x<sub>1</sub>, ..., x<sub>r</sub> it is assumed in JAS that 027 * x<sub>1</sub> < ... < x<sub>r</sub> in other CAS it means x<sub>1</sub> 028 * > ... > x<sub>r</sub>. 029 * 030 * @author Heinz Kredel 031 */ 032 033public class TermOrderByName { 034 035 036 //private static final Logger logger = Logger.getLogger(TermOrderByName.class); 037 038 039 /** 040 * TermOrder named LEX. 041 */ 042 public static final TermOrder LEX = new TermOrder(TermOrder.LEX); 043 044 045 /** 046 * TermOrder named INVLEX. 047 */ 048 public static final TermOrder INVLEX = new TermOrder(TermOrder.INVLEX); 049 050 051 /** 052 * TermOrder named GRLEX. 053 */ 054 public static final TermOrder GRLEX = new TermOrder(TermOrder.GRLEX); 055 056 057 /** 058 * TermOrder named IGRLEX. 059 */ 060 public static final TermOrder IGRLEX = new TermOrder(TermOrder.IGRLEX); 061 062 063 /** 064 * TermOrder named REVLEX. 065 */ 066 public static final TermOrder REVLEX = new TermOrder(TermOrder.REVLEX); 067 068 069 /** 070 * TermOrder named REVILEX. 071 */ 072 public static final TermOrder REVILEX = new TermOrder(TermOrder.REVILEX); 073 074 075 /** 076 * TermOrder named REVTDEG. 077 */ 078 public static final TermOrder REVTDEG = new TermOrder(TermOrder.REVTDEG); 079 080 081 /** 082 * TermOrder named REVITDG. 083 */ 084 public static final TermOrder REVITDG = new TermOrder(TermOrder.REVITDG); 085 086 087 /** 088 * Default TermOrder. 089 */ 090 public final static TermOrder DEFAULT = new TermOrder(TermOrder.DEFAULT_EVORD); 091 092 093 // Math like term orders: 094 095 /** 096 * TermOrder name Lexicographic of Math like CAS. 097 */ 098 public final static TermOrder Lexicographic = REVILEX; 099 100 101 /** 102 * TermOrder name NegativeLexicographic of Math like CAS. 103 */ 104 public final static TermOrder NegativeLexicographic = REVLEX; 105 106 107 /** 108 * TermOrder name DegreeLexicographic of Math like CAS. 109 */ 110 public final static TermOrder DegreeLexicographic = REVITDG; 111 112 113 /** 114 * TermOrder name NegativeDegreeLexicographic of Math like CAS. 115 */ 116 public final static TermOrder NegativeDegreeLexicographic = REVTDEG; 117 118 119 /** 120 * TermOrder name ReverseLexicographic of Math like CAS. 121 */ 122 public final static TermOrder ReverseLexicographic = INVLEX; 123 124 125 /** 126 * TermOrder name DegreeReverseLexicographic of Math like CAS. 127 */ 128 public final static TermOrder DegreeReverseLexicographic = IGRLEX; 129 130 131 /** 132 * TermOrder name NegativeReverseLexicographic of Math like CAS. 133 */ 134 public final static TermOrder NegativeReverseLexicographic = LEX; 135 136 137 /** 138 * TermOrder name NegativeDegreeReverseLexicographic of Math like CAS. 139 */ 140 public final static TermOrder NegativeDegreeReverseLexicographic = GRLEX; 141 142 143 // Sage term orders: 144 145 /** 146 * TermOrder name lex of Sage. 147 */ 148 public final static TermOrder lex = Lexicographic; // = REVILEX; 149 150 151 /** 152 * TermOrder name degrevlex of Sage. 153 */ 154 public final static TermOrder degrevlex = DegreeReverseLexicographic; // = IGRLEX; 155 156 157 /** 158 * TermOrder name deglex of Sage. 159 */ 160 public final static TermOrder deglex = DegreeLexicographic; // = REVITDG; 161 162 163 /** 164 * TermOrder name invlex of Sage. 165 */ 166 public final static TermOrder invlex = INVLEX; //ReverseLexicographic 167 168 169 /** 170 * TermOrder name neglex of Sage. 171 */ 172 public final static TermOrder neglex = NegativeLexicographic; // = REVLEX; 173 174 175 /** 176 * TermOrder name negdegrevlex of Sage. 177 */ 178 public final static TermOrder negdegrevlex = NegativeDegreeReverseLexicographic; // = GRLEX; 179 180 181 /** 182 * TermOrder name negdeglex of Sage. 183 */ 184 public final static TermOrder negdeglex = NegativeDegreeLexicographic; // = REVTDEG; 185 186 187 /** 188 * TermOrder name negrevlex of Sage. 189 */ 190 public final static TermOrder negrevlex = NegativeReverseLexicographic; // = LEX; 191 192 193 // Singular term orders: 194 195 /** 196 * TermOrder name lp of Singular. 197 */ 198 public final static TermOrder lp = lex; // = REVILEX; 199 200 201 /** 202 * TermOrder name dp of Singular. 203 */ 204 public final static TermOrder dp = degrevlex; // = IGRLEX; 205 206 207 /** 208 * TermOrder name Dp of Singular. 209 */ 210 public final static TermOrder Dp = deglex; // = REVITDG; 211 212 213 /** 214 * TermOrder name rp of Singular. 215 */ 216 public final static TermOrder rp = invlex; // = INVLEX; 217 218 219 /** 220 * TermOrder name ls of Singular. 221 */ 222 public final static TermOrder ls = neglex; // = REVLEX; 223 224 225 /** 226 * TermOrder name ds of Singular. 227 */ 228 public final static TermOrder ds = negdegrevlex; // = GRLEX; 229 230 231 /** 232 * TermOrder name Ds of Singular. 233 */ 234 public final static TermOrder Ds = negdeglex; // = REVTDEG; 235 236 237 // missing: public final static TermOrder negrevlex; // = LEX; 238 239 240 /** 241 * Construct elimination block TermOrder. Variables {x<sub>1</sub>, ..., 242 * x<sub>s-1</sub>} < {x<sub>s</sub>, ..., x<sub>r</sub>} 243 * 244 * @param t1 term order for both blocks 245 * @param s split index 246 * @return constructed term order 247 */ 248 public final static TermOrder blockOrder(TermOrder t1, int s) { 249 return t1.blockOrder(s); 250 } 251 252 253 /** 254 * Construct elimination block TermOrder. Variables {x<sub>1</sub>, ..., 255 * x<sub>s-1</sub>} < {x<sub>s</sub>, ..., x<sub>r</sub>} 256 * 257 * @param t1 term order for both blocks 258 * @param e exponent vector of desired length, r = length(e) 259 * @param s split index 260 * @return constructed term order 261 */ 262 public final static TermOrder blockOrder(TermOrder t1, ExpVector e, int s) { 263 return t1.blockOrder(s, e.length()); 264 } 265 266 267 /** 268 * Construct elimination block TermOrder. Variables {x<sub>1</sub>, ..., 269 * x<sub>s-1</sub>} < {x<sub>s</sub>, ..., x<sub>r</sub>} 270 * 271 * @param t1 term order for lower valiables 272 * @param t2 term order for higher variables 273 * @param s split index 274 * @return constructed term order 275 */ 276 public final static TermOrder blockOrder(TermOrder t1, TermOrder t2, int s) { 277 return new TermOrder(t1.getEvord(), t2.getEvord(), Integer.MAX_VALUE, s); 278 } 279 280 281 /** 282 * Construct elimination block TermOrder. Variables {x<sub>1</sub>, ..., 283 * x<sub>s-1</sub>} < {x<sub>s</sub>, ..., x<sub>r</sub>} 284 * 285 * @param t1 term order for lower valiables 286 * @param t2 term order for higher variables 287 * @param e exponent vector of desired length, r = length(e) 288 * @param s split index 289 * @return constructed term order 290 */ 291 public final static TermOrder blockOrder(TermOrder t1, TermOrder t2, ExpVector e, int s) { 292 return new TermOrder(t1.getEvord(), t2.getEvord(), e.length(), s); 293 } 294 295 296 /** 297 * Construct weight TermOrder. 298 * 299 * @param v weight vector 300 * @return constructed term order 301 */ 302 public final static TermOrder weightOrder(long[] v) { 303 return TermOrder.reverseWeight(new long[][] { v }); 304 } 305 306 307 /** 308 * 309 * Construct weight TermOrder. 310 * @param w weight matrix 311 * @return constructed term order 312 */ 313 public final static TermOrder weightOrder(long[][] w) { 314 return TermOrder.reverseWeight(w); 315 } 316 317 318 /** 319 * 320 * Construct weight for INVLEX. 321 * @return weight matrix 322 */ 323 public final static long[][] weightForOrder(int to, int n) { 324 long[][] w = new long[n][]; 325 switch (to) { 326 case TermOrder.INVLEX: 327 default: 328 for (int i = 0; i < n; i++ ) { 329 w[i] = new long[n]; 330 long[] wi = w[i]; 331 for( int j = 0; j < n; j++ ) { 332 if ((n-1-i) == j) { 333 wi[j] = 1L; 334 } else { 335 wi[j] = 0L; 336 } 337 } 338 } 339 break; 340 case TermOrder.REVILEX: 341 for (int i = 0; i < n; i++ ) { 342 w[i] = new long[n]; 343 long[] wi = w[i]; 344 for( int j = 0; j < n; j++ ) { 345 if (i == j) { 346 wi[j] = 1L; 347 } else { 348 wi[j] = 0L; 349 } 350 } 351 } 352 break; 353 } 354 return w; 355 } 356 357}