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