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