001 /*
002 * $Id: ExpVectorShort.java 3295 2010-08-26 17:01:10Z kredel $
003 */
004
005 package edu.jas.poly;
006
007
008 import java.util.Vector;
009
010
011 /**
012 * ExpVectorShort implements exponent vectors for polynomials using arrays of
013 * short as storage unit. This class is used by ExpVector internally, there is
014 * no need to use this class directly.
015 * @see ExpVector
016 * @author Heinz Kredel
017 */
018
019 public class ExpVectorShort extends ExpVector
020 /*implements AbelianGroupElem<ExpVectorShort>*/{
021
022
023 /**
024 * The data structure is an array of longs.
025 */
026 /*package*/final short[] val;
027
028
029 /**
030 * Largest short.
031 */
032 public static long maxShort = (long) Short.MAX_VALUE / 2;
033
034
035 /**
036 * Smallest short.
037 */
038 public static long minShort = (long) Short.MIN_VALUE / 2;
039
040
041 /**
042 * Constructor for ExpVector.
043 * @param n length of exponent vector.
044 */
045 public ExpVectorShort(int n) {
046 this(new short[n]);
047 }
048
049
050 /**
051 * Constructor for ExpVector. Sets exponent i to e.
052 * @param n length of exponent vector.
053 * @param i index of exponent to be set.
054 * @param e exponent to be set.
055 */
056 public ExpVectorShort(int n, int i, short e) {
057 this(n);
058 val[i] = e;
059 }
060
061
062 /**
063 * Constructor for ExpVector. Sets exponent i to e.
064 * @param n length of exponent vector.
065 * @param i index of exponent to be set.
066 * @param e exponent to be set.
067 */
068 public ExpVectorShort(int n, int i, long e) {
069 this(n);
070 if (e >= maxShort || e <= minShort) {
071 throw new IllegalArgumentException("exponent to large: " + e);
072 }
073 val[i] = (short) e;
074 }
075
076
077 /**
078 * Internal constructor for ExpVector. Sets val.
079 * @param v internal representation array.
080 */
081 protected ExpVectorShort(short[] v) {
082 super();
083 val = v;
084 }
085
086
087 /**
088 * Constructor for ExpVector. Sets val, converts from long array.
089 * @param v long representation array.
090 */
091 public ExpVectorShort(long[] v) {
092 this(v.length);
093 for (int i = 0; i < v.length; i++) {
094 if (v[i] >= maxShort || v[i] <= minShort) {
095 throw new IllegalArgumentException("exponent to large: " + v[i]);
096 }
097 val[i] = (short) v[i];
098 }
099 }
100
101
102 /**
103 * Constructor for ExpVector. Converts a String representation to an
104 * ExpVector. Accepted format = (1,2,3,4,5,6,7).
105 * @param s String representation.
106 */
107 public ExpVectorShort(String s) throws NumberFormatException {
108 super();
109 // first format = (1,2,3,4,5,6,7)
110 Vector<Short> exps = new Vector<Short>();
111 s = s.trim();
112 int b = s.indexOf('(');
113 int e = s.indexOf(')', b + 1);
114 String teil;
115 int k;
116 short a;
117 if (b >= 0 && e >= 0) {
118 b++;
119 while ((k = s.indexOf(',', b)) >= 0) {
120 teil = s.substring(b, k);
121 a = Short.parseShort(teil);
122 exps.add(new Short(a));
123 b = k + 1;
124 }
125 if (b <= e) {
126 teil = s.substring(b, e);
127 a = Short.parseShort(teil);
128 exps.add(new Short(a));
129 }
130 int length = exps.size();
131 val = new short[length];
132 for (int j = 0; j < length; j++) {
133 val[j] = exps.elementAt(j).shortValue();
134 }
135 } else {
136 // not implemented
137 val = null;
138 // length = -1;
139 //Vector names = new Vector();
140 //vars = s;
141 }
142 }
143
144
145 /**
146 * Clone this.
147 * @see java.lang.Object#clone()
148 */
149 @Override
150 public ExpVectorShort clone() {
151 short[] w = new short[val.length];
152 System.arraycopy(val, 0, w, 0, val.length);
153 return new ExpVectorShort(w);
154 }
155
156
157 /**
158 * Get the exponent vector.
159 * @return val as long.
160 */
161 @Override
162 /*package*/long[] getVal() {
163 long v[] = new long[val.length];
164 for (int i = 0; i < val.length; i++) {
165 v[i] = val[i];
166 }
167 return v;
168 }
169
170
171 /**
172 * Get the exponent at position i.
173 * @param i position.
174 * @return val[i].
175 */
176 @Override
177 public long getVal(int i) {
178 return val[i];
179 }
180
181
182 /**
183 * Set the exponent at position i to e.
184 * @param i
185 * @param e
186 * @return old val[i].
187 */
188 @Override
189 protected long setVal(int i, long e) {
190 short x = val[i];
191 if (e >= maxShort || e <= minShort) {
192 throw new IllegalArgumentException("exponent to large: " + e);
193 }
194 val[i] = (short) e;
195 hash = 0; // beware of race condition
196 return x;
197 }
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 short setVal(int i, short e) {
207 short x = val[i];
208 val[i] = e;
209 hash = 0; // beware of race condition
210 return x;
211 }
212
213
214 /**
215 * Get the length of this exponent vector.
216 * @return val.length.
217 */
218 @Override
219 public int length() {
220 return val.length;
221 }
222
223
224 /**
225 * Extend variables. Used e.g. in module embedding. Extend this by i
226 * elements and set val[j] to e.
227 * @param i number of elements to extend.
228 * @param j index of element to be set.
229 * @param e new exponent for val[j].
230 * @return extended exponent vector.
231 */
232 @Override
233 public ExpVectorShort extend(int i, int j, long e) {
234 short[] w = new short[val.length + i];
235 System.arraycopy(val, 0, w, i, val.length);
236 if (j >= i) {
237 throw new IllegalArgumentException("i " + i + " <= j " + j + " invalid");
238 }
239 if (e >= maxShort || e <= minShort) {
240 throw new IllegalArgumentException("exponent to large: " + e);
241 }
242 w[j] = (short) e;
243 return new ExpVectorShort(w);
244 }
245
246
247 /**
248 * Extend lower variables. Extend this by i lower elements and set val[j] to
249 * e.
250 * @param i number of elements to extend.
251 * @param j index of element to be set.
252 * @param e new exponent for val[j].
253 * @return extended exponent vector.
254 */
255 @Override
256 public ExpVectorShort extendLower(int i, int j, long e) {
257 short[] w = new short[val.length + i];
258 System.arraycopy(val, 0, w, 0, val.length);
259 if (j >= i) {
260 throw new IllegalArgumentException("i " + i + " <= j " + j + " invalid");
261 }
262 w[val.length + j] = (short) e;
263 return new ExpVectorShort(w);
264 }
265
266
267 /**
268 * Contract variables. Used e.g. in module embedding. Contract this to len
269 * elements.
270 * @param i position of first element to be copied.
271 * @param len new length.
272 * @return contracted exponent vector.
273 */
274 @Override
275 public ExpVectorShort contract(int i, int len) {
276 if (i + len > val.length) {
277 throw new IllegalArgumentException("len " + len + " > val.len " + val.length);
278 }
279 short[] w = new short[len];
280 System.arraycopy(val, i, w, 0, len);
281 return new ExpVectorShort(w);
282 }
283
284
285 /**
286 * Reverse variables. Used e.g. in opposite rings.
287 * @return reversed exponent vector.
288 */
289 @Override
290 public ExpVectorShort reverse() {
291 short[] w = new short[val.length];
292 for (int i = 0; i < val.length; i++) {
293 w[i] = val[val.length - 1 - i];
294 }
295 return new ExpVectorShort(w);
296 }
297
298
299 /**
300 * Reverse j variables. Used e.g. in opposite rings. Reverses the first j-1
301 * variables, the rest is unchanged.
302 * @param j index of first variable not reversed.
303 * @return reversed exponent vector.
304 */
305 @Override
306 public ExpVectorShort reverse(int j) {
307 if (j <= 0 || j > val.length) {
308 return this;
309 }
310 short[] w = new short[val.length];
311 for (int i = 0; i < j; i++) {
312 w[i] = val[j - 1 - i];
313 }
314 // copy rest
315 for (int i = j; i < val.length; i++) {
316 w[i] = val[i];
317 }
318 return new ExpVectorShort(w);
319 }
320
321
322 /**
323 * Combine with ExpVector. Combine this with the other ExpVector V.
324 * @param V the other exponent vector.
325 * @return combined exponent vector.
326 */
327 @Override
328 public ExpVectorShort combine(ExpVector V) {
329 if (V == null || V.length() == 0) {
330 return this;
331 }
332 ExpVectorShort Vi = (ExpVectorShort) V;
333 if (val.length == 0) {
334 return Vi;
335 }
336 short[] w = new short[val.length + Vi.val.length];
337 System.arraycopy(val, 0, w, 0, val.length);
338 System.arraycopy(Vi.val, 0, w, val.length, Vi.val.length);
339 return new ExpVectorShort(w);
340 }
341
342
343 /**
344 * Get the string representation.
345 * @see java.lang.Object#toString()
346 */
347 @Override
348 public String toString() {
349 return super.toString() + ":short";
350 }
351
352
353 /**
354 * Comparison with any other object.
355 * @see java.lang.Object#equals(java.lang.Object)
356 */
357 @Override
358 public boolean equals(Object B) {
359 if (!(B instanceof ExpVectorShort)) {
360 return false;
361 }
362 ExpVectorShort b = (ExpVectorShort) B;
363 int t = this.invLexCompareTo(b);
364 //System.out.println("equals: this = " + this + " B = " + B + " t = " + t);
365 return (0 == t);
366 }
367
368
369 /**
370 * ExpVector absolute value.
371 * @return abs(this).
372 */
373 @Override
374 public ExpVectorShort abs() {
375 short[] u = val;
376 short[] w = new short[u.length];
377 for (int i = 0; i < u.length; i++) {
378 if (u[i] >= 0L) {
379 w[i] = u[i];
380 } else {
381 w[i] = (short) (-u[i]);
382 }
383 }
384 return new ExpVectorShort(w);
385 //return EVABS(this);
386 }
387
388
389 /**
390 * ExpVector negate.
391 * @return -this.
392 */
393 @Override
394 public ExpVectorShort negate() {
395 short[] u = val;
396 short[] w = new short[u.length];
397 for (int i = 0; i < u.length; i++) {
398 w[i] = (short) (-u[i]);
399 }
400 return new ExpVectorShort(w);
401 // return EVNEG(this);
402 }
403
404
405 /**
406 * ExpVector summation.
407 * @param V
408 * @return this+V.
409 */
410 @Override
411 public ExpVectorShort sum(ExpVector V) {
412 short[] u = val;
413 short[] v = ((ExpVectorShort) V).val;
414 short[] w = new short[u.length];
415 for (int i = 0; i < u.length; i++) {
416 w[i] = (short) (u[i] + v[i]);
417 }
418 return new ExpVectorShort(w);
419 // return EVSUM(this, V);
420 }
421
422
423 /**
424 * ExpVector subtract. Result may have negative entries.
425 * @param V
426 * @return this-V.
427 */
428 @Override
429 public ExpVectorShort subtract(ExpVector V) {
430 short[] u = val;
431 short[] v = ((ExpVectorShort) V).val;
432 short[] w = new short[u.length];
433 for (int i = 0; i < u.length; i++) {
434 w[i] = (short) (u[i] - v[i]);
435 }
436 return new ExpVectorShort(w);
437 //return EVDIF(this, V);
438 }
439
440
441 /**
442 * ExpVector substitution. Clone and set exponent to d at position i.
443 * @param i position.
444 * @param d new exponent.
445 * @return substituted ExpVector.
446 */
447 public ExpVectorShort subst(int i, short d) {
448 ExpVectorShort V = (ExpVectorShort) this.clone();
449 long e = V.setVal(i, d);
450 return V;
451 //return EVSU(this, i, d);
452 }
453
454
455 /**
456 * ExpVector substitution. Clone and set exponent to d at position i.
457 * @param i position.
458 * @param d new exponent.
459 * @return substituted ExpVector.
460 */
461 @Override
462 public ExpVectorShort subst(int i, long d) {
463 ExpVectorShort V = (ExpVectorShort) this.clone();
464 long e = V.setVal(i, d);
465 return V;
466 //return EVSU(this, i, d);
467 }
468
469
470 /**
471 * ExpVector signum.
472 * @return 0 if this is zero, -1 if some entry is negative, 1 if no entry is
473 * negative and at least one entry is positive.
474 */
475 @Override
476 public int signum() {
477 int t = 0;
478 short[] u = val;
479 for (int i = 0; i < u.length; i++) {
480 if (u[i] < 0) {
481 return -1;
482 }
483 if (u[i] > 0) {
484 t = 1;
485 }
486 }
487 return t;
488 //return EVSIGN(this);
489 }
490
491
492 /**
493 * ExpVector total degree.
494 * @return sum of all exponents.
495 */
496 @Override
497 public long totalDeg() {
498 long t = 0;
499 short[] u = val; // U.val;
500 for (int i = 0; i < u.length; i++) {
501 t += u[i];
502 }
503 return t;
504 //return EVTDEG(this);
505 }
506
507
508 /**
509 * ExpVector maximal degree.
510 * @return maximal exponent.
511 */
512 @Override
513 public long maxDeg() {
514 long t = 0;
515 short[] u = val;
516 for (int i = 0; i < u.length; i++) {
517 if (u[i] > t) {
518 t = u[i];
519 }
520 }
521 return t;
522 //return EVMDEG(this);
523 }
524
525
526 /**
527 * ExpVector weighted degree.
528 * @param w weights.
529 * @return weighted sum of all exponents.
530 */
531 @Override
532 public long weightDeg(long[][] w) {
533 if (w == null || w.length == 0) {
534 return totalDeg(); // assume weight 1
535 }
536 long t = 0;
537 short[] u = val;
538 for (int j = 0; j < w.length; j++) {
539 long[] wj = w[j];
540 for (int i = 0; i < u.length; i++) {
541 t += wj[i] * u[i];
542 }
543 }
544 return t;
545 //return EVWDEG( w, this );
546 }
547
548
549 /**
550 * ExpVector least common multiple.
551 * @param V
552 * @return component wise maximum of this and V.
553 */
554 @Override
555 public ExpVectorShort lcm(ExpVector V) {
556 short[] u = val;
557 short[] v = ((ExpVectorShort) V).val;
558 short[] w = new short[u.length];
559 for (int i = 0; i < u.length; i++) {
560 w[i] = (u[i] >= v[i] ? u[i] : v[i]);
561 }
562 return new ExpVectorShort(w);
563 //return EVLCM(this, V);
564 }
565
566
567 /**
568 * ExpVector greatest common divisor.
569 * @param V
570 * @return component wise minimum of this and V.
571 */
572 @Override
573 public ExpVectorShort gcd(ExpVector V) {
574 short[] u = val;
575 short[] v = ((ExpVectorShort) V).val;
576 short[] w = new short[u.length];
577 for (int i = 0; i < u.length; i++) {
578 w[i] = (u[i] <= v[i] ? u[i] : v[i]);
579 }
580 return new ExpVectorShort(w);
581 //return EVGCD(this, V);
582 }
583
584
585 /**
586 * ExpVector dependency on variables.
587 * @return array of indices where val has positive exponents.
588 */
589 @Override
590 public int[] dependencyOnVariables() {
591 short[] u = val;
592 int l = 0;
593 for (int i = 0; i < u.length; i++) {
594 if (u[i] > 0) {
595 l++;
596 }
597 }
598 int[] dep = new int[l];
599 if (l == 0) {
600 return dep;
601 }
602 int j = 0;
603 for (int i = 0; i < u.length; i++) {
604 if (u[i] > 0) {
605 dep[j] = i;
606 j++;
607 }
608 }
609 return dep;
610 }
611
612
613 /**
614 * ExpVector multiple test. Test if this is component wise greater or equal
615 * to V.
616 * @param V
617 * @return true if this is a multiple of V, else false.
618 */
619 @Override
620 public boolean multipleOf(ExpVector V) {
621 short[] u = val;
622 short[] v = ((ExpVectorShort) V).val;
623 boolean t = true;
624 for (int i = 0; i < u.length; i++) {
625 if (u[i] < v[i]) {
626 return false;
627 }
628 }
629 return t;
630 //return EVMT(this, V);
631 }
632
633
634 /**
635 * ExpVector compareTo.
636 * @param V
637 * @return 0 if U == V, -1 if U < V, 1 if U > V.
638 */
639 //@Override
640 @Override
641 public int compareTo(ExpVector V) {
642 return this.invLexCompareTo(V);
643 }
644
645
646 /**
647 * ExpVector inverse lexicographical compareTo.
648 * @param V
649 * @return 0 if U == V, -1 if U < V, 1 if U > V.
650 */
651 @Override
652 public int invLexCompareTo(ExpVector V) {
653 short[] u = val;
654 short[] v = ((ExpVectorShort) V).val;
655 int t = 0;
656 for (int i = 0; i < u.length; i++) {
657 if (u[i] > v[i])
658 return 1;
659 if (u[i] < v[i])
660 return -1;
661 }
662 return t;
663 //return EVILCP(this, V);
664 }
665
666
667 /**
668 * ExpVector inverse lexicographical compareTo.
669 * @param V
670 * @param begin
671 * @param end
672 * @return 0 if U == V, -1 if U < V, 1 if U > V.
673 */
674 @Override
675 public int invLexCompareTo(ExpVector V, int begin, int end) {
676 short[] u = val;
677 short[] v = ((ExpVectorShort) V).val;
678 int t = 0;
679 for (int i = begin; i < end; i++) {
680 if (u[i] > v[i])
681 return 1;
682 if (u[i] < v[i])
683 return -1;
684 }
685 return t;
686 //return EVILCP(this, V, begin, end);
687 }
688
689
690 /**
691 * ExpVector inverse graded lexicographical compareTo.
692 * @param V
693 * @return 0 if U == V, -1 if U < V, 1 if U > V.
694 */
695 @Override
696 public int invGradCompareTo(ExpVector V) {
697 short[] u = val;
698 short[] v = ((ExpVectorShort) V).val;
699 int t = 0;
700 int i;
701 for (i = 0; i < u.length; i++) {
702 if (u[i] > v[i]) {
703 t = 1;
704 break;
705 }
706 if (u[i] < v[i]) {
707 t = -1;
708 break;
709 }
710 }
711 if (t == 0) {
712 return t;
713 }
714 long up = 0;
715 long vp = 0;
716 for (int j = i; j < u.length; j++) {
717 up += u[j];
718 vp += v[j];
719 }
720 if (up > vp) {
721 t = 1;
722 } else {
723 if (up < vp) {
724 t = -1;
725 }
726 }
727 return t;
728 //return EVIGLC(this, V);
729 }
730
731
732 /**
733 * ExpVector inverse graded lexicographical compareTo.
734 * @param V
735 * @param begin
736 * @param end
737 * @return 0 if U == V, -1 if U < V, 1 if U > V.
738 */
739 @Override
740 public int invGradCompareTo(ExpVector V, int begin, int end) {
741 short[] u = val;
742 short[] v = ((ExpVectorShort) V).val;
743 int t = 0;
744 int i;
745 for (i = begin; i < end; i++) {
746 if (u[i] > v[i]) {
747 t = 1;
748 break;
749 }
750 if (u[i] < v[i]) {
751 t = -1;
752 break;
753 }
754 }
755 if (t == 0) {
756 return t;
757 }
758 long up = 0;
759 long vp = 0;
760 for (int j = i; j < end; j++) {
761 up += u[j];
762 vp += v[j];
763 }
764 if (up > vp) {
765 t = 1;
766 } else {
767 if (up < vp) {
768 t = -1;
769 }
770 }
771 return t;
772 //return EVIGLC(this, V, begin, end);
773 }
774
775
776 /**
777 * ExpVector reverse inverse lexicographical compareTo.
778 * @param V
779 * @return 0 if U == V, -1 if U < V, 1 if U > V.
780 */
781 @Override
782 public int revInvLexCompareTo(ExpVector V) {
783 short[] u = val;
784 short[] v = ((ExpVectorShort) V).val;
785 int t = 0;
786 for (int i = u.length - 1; i >= 0; i--) {
787 if (u[i] > v[i])
788 return 1;
789 if (u[i] < v[i])
790 return -1;
791 }
792 return t;
793 //return EVRILCP(this, V);
794 }
795
796
797 /**
798 * ExpVector reverse inverse lexicographical compareTo.
799 * @param V
800 * @param begin
801 * @param end
802 * @return 0 if U == V, -1 if U < V, 1 if U > V.
803 */
804 @Override
805 public int revInvLexCompareTo(ExpVector V, int begin, int end) {
806 short[] u = val;
807 short[] v = ((ExpVectorShort) V).val;
808 int t = 0;
809 for (int i = end - 1; i >= begin; i--) {
810 if (u[i] > v[i])
811 return 1;
812 if (u[i] < v[i])
813 return -1;
814 }
815 return t;
816 //return EVRILCP(this, V, begin, end);
817 }
818
819
820 /**
821 * ExpVector reverse inverse graded compareTo.
822 * @param V
823 * @return 0 if U == V, -1 if U < V, 1 if U > V.
824 */
825 @Override
826 public int revInvGradCompareTo(ExpVector V) {
827 short[] u = val;
828 short[] v = ((ExpVectorShort) V).val;
829 int t = 0;
830 int i;
831 for (i = u.length - 1; i >= 0; i--) {
832 if (u[i] > v[i]) {
833 t = 1;
834 break;
835 }
836 if (u[i] < v[i]) {
837 t = -1;
838 break;
839 }
840 }
841 if (t == 0) {
842 return t;
843 }
844 long up = 0;
845 long vp = 0;
846 for (int j = i; j >= 0; j--) {
847 up += u[j];
848 vp += v[j];
849 }
850 if (up > vp) {
851 t = 1;
852 } else {
853 if (up < vp) {
854 t = -1;
855 }
856 }
857 return t;
858 //return EVRIGLC(this, V);
859 }
860
861
862 /**
863 * ExpVector reverse inverse graded compareTo.
864 * @param V
865 * @param begin
866 * @param end
867 * @return 0 if U == V, -1 if U < V, 1 if U > V.
868 */
869 @Override
870 public int revInvGradCompareTo(ExpVector V, int begin, int end) {
871 short[] u = val;
872 short[] v = ((ExpVectorShort) V).val;
873 int t = 0;
874 int i;
875 for (i = end - 1; i >= begin; i--) {
876 if (u[i] > v[i]) {
877 t = 1;
878 break;
879 }
880 if (u[i] < v[i]) {
881 t = -1;
882 break;
883 }
884 }
885 if (t == 0) {
886 return t;
887 }
888 long up = 0;
889 long vp = 0;
890 for (int j = i; j >= begin; j--) {
891 up += u[j];
892 vp += v[j];
893 }
894 if (up > vp) {
895 t = 1;
896 } else {
897 if (up < vp) {
898 t = -1;
899 }
900 }
901 return t;
902 //return EVRIGLC(this, V, begin, end);
903 }
904
905
906 /**
907 * ExpVector inverse weighted lexicographical compareTo.
908 * @param w weight array.
909 * @param V
910 * @return 0 if U == V, -1 if U < V, 1 if U > V.
911 */
912 @Override
913 public int invWeightCompareTo(long[][] w, ExpVector V) {
914 short[] u = val;
915 short[] v = ((ExpVectorShort) V).val;
916 int t = 0;
917 int i;
918 for (i = 0; i < u.length; i++) {
919 if (u[i] > v[i]) {
920 t = 1;
921 break;
922 }
923 if (u[i] < v[i]) {
924 t = -1;
925 break;
926 }
927 }
928 if (t == 0) {
929 return t;
930 }
931 for (int k = 0; k < w.length; k++) {
932 long[] wk = w[k];
933 long up = 0;
934 long vp = 0;
935 for (int j = i; j < u.length; j++) {
936 up += wk[j] * u[j];
937 vp += wk[j] * v[j];
938 }
939 if (up > vp) {
940 return 1;
941 } else if (up < vp) {
942 return -1;
943 }
944 }
945 return t;
946 //return EVIWLC(w, this, V);
947 }
948
949
950 /**
951 * ExpVector inverse weighted lexicographical compareTo.
952 * @param w weight array.
953 * @param V
954 * @param begin
955 * @param end
956 * @return 0 if U == V, -1 if U < V, 1 if U > V.
957 */
958 @Override
959 public int invWeightCompareTo(long[][] w, ExpVector V, int begin, int end) {
960 short[] u = val;
961 short[] v = ((ExpVectorShort) V).val;
962 int t = 0;
963 int i;
964 for (i = begin; i < end; i++) {
965 if (u[i] > v[i]) {
966 t = 1;
967 break;
968 }
969 if (u[i] < v[i]) {
970 t = -1;
971 break;
972 }
973 }
974 if (t == 0) {
975 return t;
976 }
977 for (int k = 0; k < w.length; k++) {
978 long[] wk = w[k];
979 long up = 0;
980 long vp = 0;
981 for (int j = i; j < end; j++) {
982 up += wk[j] * u[j];
983 vp += wk[j] * v[j];
984 }
985 if (up > vp) {
986 return 1;
987 } else if (up < vp) {
988 return -1;
989 }
990 }
991 return t;
992 //return EVIWLC(w, this, V, begin, end);
993 }
994
995 }