001/* 002 * $Id$ 003 */ 004 005package edu.jas.poly; 006 007 008import java.util.Collection; 009import java.util.List; 010import java.util.Random; 011 012import edu.jas.arith.BigInteger; 013import edu.jas.structure.AbelianGroupElem; 014import edu.jas.structure.AbelianGroupFactory; 015import edu.jas.structure.RingElem; 016import edu.jas.structure.RingFactory; 017 018 019/** 020 * ExpVector implements exponent vectors for polynomials. Exponent vectors are 021 * implemented as arrays of Java elementary types, like long, int, short and 022 * byte. ExpVector provides also the familiar MAS static method names. The 023 * implementation is only tested for nonnegative exponents but should work also 024 * for negative exponents. Objects of this class are intended to be immutable, 025 * but exponents can be set (during construction); also the hash code is only 026 * computed once, when needed. The different storage unit implementations are 027 * <code>ExpVectorLong</code> <code>ExpVectorInteger</code>, 028 * <code>ExpVectorShort</code> and <code>ExpVectorByte</code>. The static 029 * factory methods <code>create()</code> of <code>ExpVector</code> select the 030 * respective storage unit. The selection of the desired storage unit is 031 * internally done via the static variable <code>storunit</code>. This varaible 032 * should not be changed dynamically. 033 * @author Heinz Kredel 034 */ 035 036public abstract class ExpVector implements AbelianGroupElem<ExpVector> { 037 038 039 /** 040 * Stored hash code. 041 */ 042 transient protected int hash = -1; 043 044 045 /** 046 * Stored bitLength. 047 */ 048 transient protected long blen = -1; 049 050 051 /** 052 * Random number generator. 053 */ 054 private final static Random random = new Random(); 055 056 057 /** 058 * Storage representation of exponent arrays. 059 */ 060 public static enum StorUnit { 061 LONG, INT, SHORT, BYTE 062 }; 063 064 065 /** 066 * Used storage representation of exponent arrays. <b>Note:</b> Set this 067 * only statically and not dynamically. 068 */ 069 public final static StorUnit storunit = StorUnit.LONG; 070 071 072 /** 073 * Constructor for ExpVector. 074 */ 075 public ExpVector() { 076 hash = 0; 077 } 078 079 080 /** 081 * Factory constructor for ExpVector. 082 * @param n length of exponent vector. 083 */ 084 public final static ExpVector create(int n) { 085 switch (storunit) { 086 case INT: 087 return new ExpVectorInteger(n); 088 case LONG: 089 return new ExpVectorLong(n); 090 case SHORT: 091 return new ExpVectorShort(n); 092 case BYTE: 093 return new ExpVectorByte(n); 094 default: 095 return new ExpVectorInteger(n); 096 } 097 } 098 099 100 /** 101 * Factory constructor for ExpVector. Sets exponent i to e. 102 * @param n length of exponent vector. 103 * @param i index of exponent to be set. 104 * @param e exponent to be set. 105 */ 106 public final static ExpVector create(int n, int i, long e) { 107 switch (storunit) { 108 case INT: 109 return new ExpVectorInteger(n, i, e); 110 case LONG: 111 return new ExpVectorLong(n, i, e); 112 case SHORT: 113 return new ExpVectorShort(n, i, e); 114 case BYTE: 115 return new ExpVectorByte(n, i, e); 116 default: 117 return new ExpVectorInteger(n, i, e); 118 } 119 } 120 121 122 /** 123 * Internal factory constructor for ExpVector. Sets val. 124 * @param v internal representation array. 125 */ 126 public final static ExpVector create(long[] v) { 127 switch (storunit) { 128 case INT: 129 return new ExpVectorInteger(v); 130 case LONG: 131 return new ExpVectorLong(v); 132 case SHORT: 133 return new ExpVectorShort(v); 134 case BYTE: 135 return new ExpVectorByte(v); 136 default: 137 return new ExpVectorInteger(v); 138 } 139 } 140 141 142 /** 143 * Factory constructor for ExpVector. Converts a String representation to an 144 * ExpVector. Accepted format = (1,2,3,4,5,6,7). 145 * @param s String representation. 146 */ 147 public final static ExpVector create(String s) { 148 switch (storunit) { 149 case INT: 150 return new ExpVectorInteger(s); 151 case LONG: 152 return new ExpVectorLong(s); 153 case SHORT: 154 return new ExpVectorShort(s); 155 case BYTE: 156 return new ExpVectorByte(s); 157 default: 158 return new ExpVectorInteger(s); 159 } 160 } 161 162 163 /** 164 * Factory constructor for ExpVector. Sets val. 165 * @param v collection of exponents. 166 */ 167 public final static ExpVector create(Collection<Long> v) { 168 long[] w = new long[v.size()]; 169 int i = 0; 170 for (Long k : v) { 171 w[i++] = k; 172 } 173 return create(w); 174 } 175 176 177 /** 178 * Get the corresponding element factory. 179 * @return factory for this Element. 180 * @see edu.jas.structure.Element#factory() 181 */ 182 public AbelianGroupFactory<ExpVector> factory() { 183 throw new UnsupportedOperationException("no factory implemented for ExpVector"); 184 } 185 186 187 /** 188 * Is this structure finite or infinite. 189 * @return true if this structure is finite, else false. 190 * @see edu.jas.structure.ElemFactory#isFinite() <b>Note: </b> returns true 191 * because of finite set of values in each index. 192 */ 193 public boolean isFinite() { 194 return true; 195 } 196 197 198 /** 199 * Clone this. 200 * @see java.lang.Object#clone() 201 */ 202 @Override 203 public abstract ExpVector copy(); 204 205 206 /** 207 * Get the exponent vector. 208 * @return val. 209 */ 210 public abstract long[] getVal(); 211 212 213 /** 214 * Get the exponent at position i. 215 * @param i position. 216 * @return val[i]. 217 */ 218 public abstract long getVal(int i); 219 220 221 /** 222 * Set the exponent at position i to e. 223 * @param i 224 * @param e 225 * @return old val[i]. 226 */ 227 protected abstract long setVal(int i, long e); 228 229 230 /** 231 * Get the length of this exponent vector. 232 * @return val.length. 233 */ 234 public abstract int length(); 235 236 237 /** 238 * Extend variables. Used e.g. in module embedding. Extend this by i 239 * elements and set val[j] to e. 240 * @param i number of elements to extend. 241 * @param j index of element to be set. 242 * @param e new exponent for val[j]. 243 * @return extended exponent vector. 244 */ 245 public abstract ExpVector extend(int i, int j, long e); 246 247 248 /** 249 * Extend lower variables. Extend this by i lower elements and set val[j] to 250 * e. 251 * @param i number of elements to extend. 252 * @param j index of element to be set. 253 * @param e new exponent for val[j]. 254 * @return extended exponent vector. 255 */ 256 public abstract ExpVector extendLower(int i, int j, long e); 257 258 259 /** 260 * Contract variables. Used e.g. in module embedding. Contract this to len 261 * elements. 262 * @param i position of first element to be copied. 263 * @param len new length. 264 * @return contracted exponent vector. 265 */ 266 public abstract ExpVector contract(int i, int len); 267 268 269 /** 270 * Reverse variables. Used e.g. in opposite rings. 271 * @return reversed exponent vector. 272 */ 273 public abstract ExpVector reverse(); 274 275 276 /** 277 * Reverse lower j variables. Used e.g. in opposite rings. Reverses the 278 * first j-1 variables, the rest is unchanged. 279 * @param j index of first variable reversed. 280 * @return reversed exponent vector. 281 */ 282 public abstract ExpVector reverse(int j); 283 284 285 /** 286 * Combine with ExpVector. Combine this with the other ExpVector V. 287 * @param V the other exponent vector. 288 * @return combined exponent vector. 289 */ 290 public abstract ExpVector combine(ExpVector V); 291 292 293 /** 294 * Permutation of exponent vector. 295 * @param P permutation. 296 * @return P(e). 297 */ 298 public abstract ExpVector permutation(List<Integer> P); 299 300 301 /** 302 * Get the string representation. 303 * @see java.lang.Object#toString() 304 */ 305 @Override 306 public String toString() { 307 StringBuffer s = new StringBuffer("("); 308 for (int i = 0; i < length(); i++) { 309 s.append(getVal(i)); 310 if (i < length() - 1) { 311 s.append(","); 312 } 313 } 314 s.append(")"); 315 return s.toString(); 316 } 317 318 319 /** 320 * Get the string representation with variable names. 321 * @param vars names of variables. 322 * @see java.lang.Object#toString() 323 */ 324 public String toString(String[] vars) { 325 StringBuffer s = new StringBuffer(); 326 boolean pit; 327 int r = length(); 328 if (r != vars.length) { 329 return toString(); 330 } 331 if (r == 0) { 332 return s.toString(); 333 } 334 long vi; 335 for (int i = r - 1; i > 0; i--) { 336 vi = getVal(i); 337 if (vi != 0) { 338 s.append(vars[r - 1 - i]); 339 if (vi != 1) { 340 s.append("^" + vi); 341 } 342 pit = false; 343 for (int j = i - 1; j >= 0; j--) { 344 if (getVal(j) != 0) { 345 pit = true; 346 } 347 } 348 if (pit) { 349 s.append(" * "); 350 } 351 } 352 } 353 vi = getVal(0); 354 if (vi != 0) { 355 s.append(vars[r - 1]); 356 if (vi != 1) { 357 s.append("^" + vi); 358 } 359 } 360 return s.toString(); 361 } 362 363 364 /** 365 * Get the string representation of the variables. 366 * @param vars names of variables. 367 * @return string representation of the variables. 368 * @see java.util.Arrays#toString() 369 */ 370 public final static String varsToString(String[] vars) { 371 if (vars == null) { 372 return "null"; 373 } 374 StringBuffer s = new StringBuffer(); 375 for (int i = 0; i < vars.length; i++) { 376 s.append(vars[i]); 377 if (i < vars.length - 1) { 378 s.append(","); 379 } 380 } 381 return s.toString(); 382 } 383 384 385 /** 386 * Get a scripting compatible string representation. 387 * @return script compatible representation for this Element. 388 * @see edu.jas.structure.Element#toScript() 389 */ 390 @Override 391 public String toScript() { 392 return toScript(stdVars()); 393 } 394 395 396 /** 397 * Get a scripting compatible string representation. 398 * @return script compatible representation for this Element. 399 * @see edu.jas.structure.Element#toScript() 400 */ 401 // @Override 402 public String toScript(String[] vars) { 403 // Python case 404 int r = length(); 405 if (r != vars.length) { 406 return toString(); 407 } 408 StringBuffer s = new StringBuffer(); 409 boolean pit; 410 long vi; 411 for (int i = r - 1; i > 0; i--) { 412 vi = getVal(i); 413 if (vi != 0) { 414 s.append(vars[r - 1 - i]); 415 if (vi != 1) { 416 s.append("**" + vi); 417 } 418 pit = false; 419 for (int j = i - 1; j >= 0; j--) { 420 if (getVal(j) != 0) { 421 pit = true; 422 } 423 } 424 if (pit) { 425 s.append(" * "); 426 } 427 } 428 } 429 vi = getVal(0); 430 if (vi != 0) { 431 s.append(vars[r - 1]); 432 if (vi != 1) { 433 s.append("**" + vi); 434 } 435 } 436 return s.toString(); 437 } 438 439 440 /** 441 * Get a scripting compatible string representation of the factory. 442 * @return script compatible representation for this ElemFactory. 443 * @see edu.jas.structure.Element#toScriptFactory() 444 */ 445 @Override 446 public String toScriptFactory() { 447 // Python case 448 return "ExpVector()"; 449 } 450 451 452 /** 453 * Get the variable name at index. 454 * @param idx index of the variable 455 * @param vars array of names of variables 456 * @return name of variable at the given index. 457 */ 458 public String indexVarName(int idx, String... vars) { 459 return vars[length() - idx - 1]; 460 } 461 462 463 /** 464 * Get the array index of a variable at index. 465 * @param idx index of the variable 466 * @return array index of the variable. 467 */ 468 public int varIndex(int idx) { 469 return length() - idx - 1; 470 } 471 472 473 /** 474 * Get the index of a variable. 475 * @param x variable name to be searched. 476 * @param vars array of names of variables 477 * @return index of x in vars. 478 */ 479 public int indexVar(String x, String... vars) { 480 for (int i = 0; i < length(); i++) { 481 if (x.equals(vars[i])) { 482 return length() - i - 1; 483 } 484 } 485 return -1; // not found 486 } 487 488 489 /** 490 * Evaluate. 491 * @param cf ring factory for elements of a. 492 * @param a list of values. 493 * @return a_1^{e_1} * ... * a_n^{e_n}. 494 */ 495 public <C extends RingElem<C>> C evaluate(RingFactory<C> cf, List<C> a) { 496 C c = cf.getONE(); 497 for (int i = 0; i < length(); i++) { 498 long ei = getVal(i); 499 if (ei == 0L) { 500 continue; 501 } 502 C ai = a.get(length() - 1 - i); 503 if (ai.isZERO()) { 504 return ai; 505 } 506 C pi = ai.power(ei); 507 c = c.multiply(pi); 508 } 509 return c; 510 } 511 512 513 /** 514 * Comparison with any other object. 515 * @see java.lang.Object#equals(java.lang.Object) 516 */ 517 @Override 518 public boolean equals(Object B) { 519 if (!(B instanceof ExpVector)) { 520 return false; 521 } 522 ExpVector b = (ExpVector) B; 523 int t = this.invLexCompareTo(b); 524 //System.out.println("equals: this = " + this + " B = " + B + " t = " + t); 525 return (0 == t); 526 } 527 528 529 /** 530 * hashCode. Optimized for small exponents, i.e. ≤ 2<sup>4</sup> and 531 * small number of variables, i.e. ≤ 8. 532 * @see java.lang.Object#hashCode() 533 */ 534 @Override 535 public int hashCode() { 536 if (hash < 0) { 537 int h = 0; 538 for (int i = 0; i < length(); i++) { 539 h = (h << 4) + (int) getVal(i); 540 } 541 hash = h; 542 } 543 return hash; 544 } 545 546 547 /** 548 * Returns the number of bits in the representation of this exponent vector. 549 * @return number of bits in the representation of this ExpVector, including 550 * sign bits. 551 */ 552 public long bitLength() { 553 if (blen < 0L) { 554 long n = 0L; 555 for (int i = 0; i < length(); i++) { 556 n += BigInteger.bitLength(getVal(i)); 557 } 558 blen = n; 559 //System.out.println("bitLength(ExpVector) = " + blen); 560 } 561 return blen; 562 } 563 564 565 /** 566 * Is ExpVector zero. 567 * @return If this has all elements 0 then true is returned, else false. 568 */ 569 public boolean isZERO() { 570 return (0 == this.signum()); 571 } 572 573 574 /** 575 * Standard variable names. Generate standard names for variables, i.e. x0 576 * to x(n-1). 577 * @return standard names. 578 */ 579 public String[] stdVars() { 580 return STDVARS("x", length()); 581 } 582 583 584 /** 585 * Generate variable names. Generate names for variables, i.e. prefix0 to 586 * prefix(n-1). 587 * @param prefix name prefix. 588 * @return standard names. 589 */ 590 public String[] stdVars(String prefix) { 591 return STDVARS(prefix, length()); 592 } 593 594 595 /** 596 * Standard variable names. Generate standard names for variables, i.e. x0 597 * to x(n-1). 598 * @param n size of names array 599 * @return standard names. 600 */ 601 public final static String[] STDVARS(int n) { 602 return STDVARS("x", n); 603 } 604 605 606 /** 607 * Generate variable names. Generate names for variables from given prefix. 608 * i.e. prefix0 to prefix(n-1). 609 * @param n size of names array. 610 * @param prefix name prefix. 611 * @return vatiable names. 612 */ 613 public final static String[] STDVARS(String prefix, int n) { 614 String[] vars = new String[n]; 615 if (prefix == null || prefix.length() == 0) { 616 prefix = "x"; 617 } 618 for (int i = 0; i < n; i++) { 619 vars[i] = prefix + i; //(n-1-i); 620 } 621 return vars; 622 } 623 624 625 /** 626 * ExpVector absolute value. 627 * @param U 628 * @return abs(U). 629 */ 630 public final static ExpVector EVABS(ExpVector U) { 631 return U.abs(); 632 } 633 634 635 /** 636 * ExpVector absolute value. 637 * @return abs(this). 638 */ 639 public abstract ExpVector abs(); 640 641 642 /** 643 * ExpVector negate. 644 * @param U 645 * @return -U. 646 */ 647 public final static ExpVector EVNEG(ExpVector U) { 648 return U.negate(); 649 } 650 651 652 /** 653 * ExpVector negate. 654 * @return -this. 655 */ 656 public abstract ExpVector negate(); 657 658 659 /** 660 * ExpVector summation. 661 * @param U 662 * @param V 663 * @return U+V. 664 */ 665 public final static ExpVector EVSUM(ExpVector U, ExpVector V) { 666 return U.sum(V); 667 } 668 669 670 /** 671 * ExpVector summation. 672 * @param V 673 * @return this+V. 674 */ 675 public abstract ExpVector sum(ExpVector V); 676 677 678 /** 679 * ExpVector difference. Result may have negative entries. 680 * @param U 681 * @param V 682 * @return U-V. 683 */ 684 public final static ExpVector EVDIF(ExpVector U, ExpVector V) { 685 return U.subtract(V); 686 } 687 688 689 /** 690 * ExpVector subtract. Result may have negative entries. 691 * @param V 692 * @return this-V. 693 */ 694 public abstract ExpVector subtract(ExpVector V); 695 696 697 /** 698 * ExpVector multiply by scalar. 699 * @param s scalar 700 * @return s*this. 701 */ 702 public abstract ExpVector scalarMultiply(long s); 703 704 705 /** 706 * ExpVector substitution. Clone and set exponent to d at position i. 707 * @param U 708 * @param i position. 709 * @param d new exponent. 710 * @return substituted ExpVector. 711 */ 712 public final static ExpVector EVSU(ExpVector U, int i, long d) { 713 return U.subst(i, d); 714 } 715 716 717 /** 718 * ExpVector substitution. Clone and set exponent to d at position i. 719 * @param i position. 720 * @param d new exponent. 721 * @return substituted ExpVector. 722 */ 723 public ExpVector subst(int i, long d) { 724 ExpVector V = this.copy(); 725 //long e = 726 V.setVal(i, d); 727 return V; 728 } 729 730 731 /** 732 * Generate a random ExpVector. 733 * @param r length of new ExpVector. 734 * @param k maximal degree in each exponent. 735 * @param q density of nozero exponents. 736 * @return random ExpVector. 737 */ 738 public final static ExpVector EVRAND(int r, long k, float q) { 739 return random(r, k, q, random); 740 } 741 742 743 /** 744 * Generate a random ExpVector. 745 * @param r length of new ExpVector. 746 * @param k maximal degree in each exponent. 747 * @param q density of nozero exponents. 748 * @param rnd is a source for random bits. 749 * @return random ExpVector. 750 */ 751 public final static ExpVector EVRAND(int r, long k, float q, Random rnd) { 752 return random(r, k, q, rnd); 753 } 754 755 756 /** 757 * Generate a random ExpVector. 758 * @param r length of new ExpVector. 759 * @param k maximal degree in each exponent. 760 * @param q density of nozero exponents. 761 * @return random ExpVector. 762 */ 763 public final static ExpVector random(int r, long k, float q) { 764 return random(r, k, q, random); 765 } 766 767 768 /** 769 * Generate a random ExpVector. 770 * @param r length of new ExpVector. 771 * @param k maximal degree in each exponent. 772 * @param q density of nozero exponents. 773 * @param rnd is a source for random bits. 774 * @return random ExpVector. 775 */ 776 public final static ExpVector random(int r, long k, float q, Random rnd) { 777 long[] w = new long[r]; 778 long e; 779 float f; 780 for (int i = 0; i < w.length; i++) { 781 f = rnd.nextFloat(); 782 if (f > q) { 783 e = 0; 784 } else { 785 e = rnd.nextLong() % k; 786 if (e < 0) { 787 e = -e; 788 } 789 } 790 w[i] = e; 791 } 792 return create(w); 793 } 794 795 796 /** 797 * ExpVector sign. 798 * @param U 799 * @return 0 if U is zero, -1 if some entry is negative, 1 if no entry is 800 * negativ and at least one entry is positive. 801 */ 802 public final static int EVSIGN(ExpVector U) { 803 return U.signum(); 804 } 805 806 807 /** 808 * ExpVector signum. 809 * @return 0 if this is zero, -1 if some entry is negative, 1 if no entry is 810 * negative and at least one entry is positive. 811 */ 812 public abstract int signum(); 813 814 815 /** 816 * ExpVector total degree. 817 * @param U 818 * @return sum of all exponents. 819 */ 820 public final static long EVTDEG(ExpVector U) { 821 return U.totalDeg(); 822 } 823 824 825 /** 826 * ExpVector degree. 827 * @return total degree of all exponents. 828 */ 829 public long degree() { 830 return totalDeg(); 831 } 832 833 834 /** 835 * ExpVector total degree. 836 * @return sum of all exponents. 837 */ 838 public abstract long totalDeg(); 839 840 841 /** 842 * ExpVector maximal degree. 843 * @param U 844 * @return maximal exponent. 845 */ 846 public final static long EVMDEG(ExpVector U) { 847 return U.maxDeg(); 848 } 849 850 851 /** 852 * ExpVector maximal degree. 853 * @return maximal exponent. 854 */ 855 public abstract long maxDeg(); 856 857 858 /** 859 * ExpVector minimal degree. 860 * @param U 861 * @return minimal exponent. 862 */ 863 public final static long EVMINDEG(ExpVector U) { 864 return U.minDeg(); 865 } 866 867 868 /** 869 * ExpVector minimal degree. 870 * @return minimal exponent. 871 */ 872 public abstract long minDeg(); 873 874 875 /** 876 * ExpVector weighted degree. 877 * @param w weights. 878 * @param U 879 * @return weighted sum of all exponents. 880 */ 881 public final static long EVWDEG(long[][] w, ExpVector U) { 882 return U.weightDeg(w); 883 } 884 885 886 /** 887 * ExpVector weighted degree. 888 * @param w weights. 889 * @return weighted sum of all exponents. 890 */ 891 public abstract long weightDeg(long[][] w); 892 893 894 /** 895 * ExpVector weighted degree. 896 * @param w weights. 897 * @return weighted sum of all exponents. 898 */ 899 public abstract long weightDeg(long[] w); 900 901 902 /** 903 * ExpVector least common multiple. 904 * @param U 905 * @param V 906 * @return component wise maximum of U and V. 907 */ 908 public final static ExpVector EVLCM(ExpVector U, ExpVector V) { 909 return U.lcm(V); 910 } 911 912 913 /** 914 * ExpVector least common multiple. 915 * @param V 916 * @return component wise maximum of this and V. 917 */ 918 public abstract ExpVector lcm(ExpVector V); 919 920 921 /** 922 * ExpVector greatest common divisor. 923 * @param U 924 * @param V 925 * @return component wise minimum of U and V. 926 */ 927 public final static ExpVector EVGCD(ExpVector U, ExpVector V) { 928 return U.gcd(V); 929 } 930 931 932 /** 933 * ExpVector greatest common divisor. 934 * @param V 935 * @return component wise minimum of this and V. 936 */ 937 public abstract ExpVector gcd(ExpVector V); 938 939 940 /** 941 * ExpVector dependency on variables. 942 * @param U 943 * @return array of indices where U has positive exponents. 944 */ 945 public final static int[] EVDOV(ExpVector U) { 946 return U.dependencyOnVariables(); 947 } 948 949 950 /** 951 * ExpVector dependent variables. 952 * @return number of indices where val has positive exponents. 953 */ 954 public abstract int dependentVariables(); 955 956 957 /** 958 * ExpVector dependency on variables. 959 * @return array of indices where val has positive exponents. 960 */ 961 public abstract int[] dependencyOnVariables(); 962 963 964 /** 965 * ExpVector multiple test. Test if U is component wise greater or equal to 966 * V. 967 * @param U 968 * @param V 969 * @return true if U is a multiple of V, else false. 970 */ 971 public final static boolean EVMT(ExpVector U, ExpVector V) { 972 return U.multipleOf(V); 973 } 974 975 976 /** 977 * ExpVector multiple test. Test if this is component wise greater or equal 978 * to V. 979 * @param V 980 * @return true if this is a multiple of V, else false. 981 */ 982 public abstract boolean multipleOf(ExpVector V); 983 984 985 /** 986 * ExpVector divides test. Test if V is component wise greater or equal to 987 * this. 988 * @param V 989 * @return true if this divides V, else false. 990 */ 991 public boolean divides(ExpVector V) { 992 return V.multipleOf(this); 993 } 994 995 996 /** 997 * ExpVector compareTo. 998 * @param V 999 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1000 */ 1001 @Override 1002 public int compareTo(ExpVector V) { 1003 return this.invLexCompareTo(V); 1004 } 1005 1006 1007 /** 1008 * Inverse lexicographical compare. 1009 * @param U 1010 * @param V 1011 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1012 */ 1013 public final static int EVILCP(ExpVector U, ExpVector V) { 1014 return U.invLexCompareTo(V); 1015 } 1016 1017 1018 /** 1019 * ExpVector inverse lexicographical compareTo. 1020 * @param V 1021 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1022 */ 1023 public abstract int invLexCompareTo(ExpVector V); 1024 1025 1026 /** 1027 * Inverse lexicographical compare part. Compare entries between begin and 1028 * end (-1). 1029 * @param U 1030 * @param V 1031 * @param begin 1032 * @param end 1033 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1034 */ 1035 public final static int EVILCP(ExpVector U, ExpVector V, int begin, int end) { 1036 return U.invLexCompareTo(V, begin, end); 1037 } 1038 1039 1040 /** 1041 * ExpVector inverse lexicographical compareTo. 1042 * @param V 1043 * @param begin 1044 * @param end 1045 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1046 */ 1047 public abstract int invLexCompareTo(ExpVector V, int begin, int end); 1048 1049 1050 /** 1051 * Inverse graded lexicographical compare. 1052 * @param U 1053 * @param V 1054 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1055 */ 1056 public final static int EVIGLC(ExpVector U, ExpVector V) { 1057 return U.invGradCompareTo(V); 1058 } 1059 1060 1061 /** 1062 * ExpVector inverse graded lexicographical compareTo. 1063 * @param V 1064 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1065 */ 1066 public abstract int invGradCompareTo(ExpVector V); 1067 1068 1069 /** 1070 * Inverse graded lexicographical compare part. Compare entries between 1071 * begin and end (-1). 1072 * @param U 1073 * @param V 1074 * @param begin 1075 * @param end 1076 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1077 */ 1078 public final static int EVIGLC(ExpVector U, ExpVector V, int begin, int end) { 1079 return U.invGradCompareTo(V, begin, end); 1080 } 1081 1082 1083 /** 1084 * ExpVector inverse graded lexicographical compareTo. 1085 * @param V 1086 * @param begin 1087 * @param end 1088 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1089 */ 1090 public abstract int invGradCompareTo(ExpVector V, int begin, int end); 1091 1092 1093 /** 1094 * Reverse inverse lexicographical compare. 1095 * @param U 1096 * @param V 1097 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1098 */ 1099 public final static int EVRILCP(ExpVector U, ExpVector V) { 1100 return U.revInvLexCompareTo(V); 1101 } 1102 1103 1104 /** 1105 * ExpVector reverse inverse lexicographical compareTo. 1106 * @param V 1107 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1108 */ 1109 public abstract int revInvLexCompareTo(ExpVector V); 1110 1111 1112 /** 1113 * Reverse inverse lexicographical compare part. Compare entries between 1114 * begin and end (-1). 1115 * @param U 1116 * @param V 1117 * @param begin 1118 * @param end 1119 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1120 */ 1121 public final static int EVRILCP(ExpVector U, ExpVector V, int begin, int end) { 1122 return U.revInvLexCompareTo(V, begin, end); 1123 } 1124 1125 1126 /** 1127 * ExpVector reverse inverse lexicographical compareTo. 1128 * @param V 1129 * @param begin 1130 * @param end 1131 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1132 */ 1133 public abstract int revInvLexCompareTo(ExpVector V, int begin, int end); 1134 1135 1136 /** 1137 * Reverse inverse graded lexicographical compare. 1138 * @param U 1139 * @param V 1140 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1141 */ 1142 public final static int EVRIGLC(ExpVector U, ExpVector V) { 1143 return U.revInvGradCompareTo(V); 1144 } 1145 1146 1147 /** 1148 * ExpVector reverse inverse graded compareTo. 1149 * @param V 1150 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1151 */ 1152 public abstract int revInvGradCompareTo(ExpVector V); 1153 1154 1155 /** 1156 * Reverse inverse graded lexicographical compare part. Compare entries 1157 * between begin and end (-1). 1158 * @param U 1159 * @param V 1160 * @param begin 1161 * @param end 1162 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1163 */ 1164 public final static int EVRIGLC(ExpVector U, ExpVector V, int begin, int end) { 1165 return U.revInvGradCompareTo(V, begin, end); 1166 } 1167 1168 1169 /** 1170 * ExpVector reverse inverse graded compareTo. 1171 * @param V 1172 * @param begin 1173 * @param end 1174 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1175 */ 1176 public abstract int revInvGradCompareTo(ExpVector V, int begin, int end); 1177 1178 1179 /** 1180 * Inverse total degree lexicographical compare. 1181 * @param U 1182 * @param V 1183 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1184 */ 1185 public final static int EVITDEGLC(ExpVector U, ExpVector V) { 1186 return U.invTdegCompareTo(V); 1187 } 1188 1189 1190 /** 1191 * ExpVector inverse total degree lexicographical compareTo. 1192 * @param V 1193 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1194 */ 1195 public abstract int invTdegCompareTo(ExpVector V); 1196 1197 1198 /** 1199 * Reverse lexicographical inverse total degree compare. 1200 * @param U 1201 * @param V 1202 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1203 */ 1204 public final static int EVRLITDEGC(ExpVector U, ExpVector V) { 1205 return U.revLexInvTdegCompareTo(V); 1206 } 1207 1208 1209 /** 1210 * ExpVector reverse lexicographical inverse total degree compareTo. 1211 * @param V 1212 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1213 */ 1214 public abstract int revLexInvTdegCompareTo(ExpVector V); 1215 1216 1217 /** 1218 * Inverse weighted lexicographical compare. 1219 * @param w weight array. 1220 * @param U 1221 * @param V 1222 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1223 */ 1224 public final static int EVIWLC(long[][] w, ExpVector U, ExpVector V) { 1225 return U.invWeightCompareTo(w, V); 1226 } 1227 1228 1229 /** 1230 * ExpVector inverse weighted lexicographical compareTo. 1231 * @param w weight array. 1232 * @param V 1233 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1234 */ 1235 public abstract int invWeightCompareTo(long[][] w, ExpVector V); 1236 1237 1238 /** 1239 * Inverse weighted lexicographical compare part. Compare entries between 1240 * begin and end (-1). 1241 * @param w weight array. 1242 * @param U 1243 * @param V 1244 * @param begin 1245 * @param end 1246 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1247 */ 1248 public final static int EVIWLC(long[][] w, ExpVector U, ExpVector V, int begin, int end) { 1249 return U.invWeightCompareTo(w, V, begin, end); 1250 } 1251 1252 1253 /** 1254 * ExpVector inverse weighted lexicographical compareTo. 1255 * @param w weight array. 1256 * @param V 1257 * @param begin 1258 * @param end 1259 * @return 0 if U == V, -1 if U < V, 1 if U > V. 1260 */ 1261 public abstract int invWeightCompareTo(long[][] w, ExpVector V, int begin, int end); 1262 1263}