@@ -1,1464 +0,0 @@
1−/*
2− */
3−package org.idris.rts;
4−
5−import java.io.IOException;
6−import java.io.InputStream;
7−import java.io.OutputStream;
8−import java.math.BigInteger;
9−
10−public class PrimFn {
11− public static byte LPlus(byte x, byte y) {
12− return (byte)(x + y);
13− }
14− public static char LPlus(char x, char y) {
15− return (char)(x + y);
16− }
17− public static short LPlus(short x, short y) {
18− return (short)(x + y);
19− }
20− public static int LPlus(int x, int y) {
21− return x + y;
22− }
23− public static long LPlus(long x, long y) {
24− return x + y;
25− }
26− public static double LPlus(double x, double y) {
27− return x + y;
28− }
29− public static BigInteger LPlus(BigInteger x, BigInteger y) {
30− return x.add(y);
31− }
32− public static byte[] LPlus(byte[] x, byte[] y) {
33− byte[] res = x.clone();
34− for (int i = 0; i < res.length; ++i) {
35− res[i] += y[i];
36− }
37− return res;
38− }
39− public static short[] LPlus(short[] x, short[] y) {
40− short[] res = x.clone();
41− for (int i = 0; i < res.length; ++i) {
42− res[i] += y[i];
43− }
44− return res;
45− }
46− public static int[] LPlus(int[] x, int[] y) {
47− int[] res = x.clone();
48− for (int i = 0; i < res.length; ++i) {
49− res[i] += y[i];
50− }
51− return res;
52− }
53− public static long[] LPlus(long[] x, long[] y) {
54− long[] res = x.clone();
55− for (int i = 0; i < res.length; ++i) {
56− res[i] += y[i];
57− }
58− return res;
59− }
60−
61− public static byte LMinus(byte x, byte y) {
62− return (byte)(x - y);
63− }
64− public static char LMinus(char x, char y) {
65− return (char)(x - y);
66− }
67− public static short LMinus(short x, short y) {
68− return (short)(x - y);
69− }
70− public static int LMinus(int x, int y) {
71− return x - y;
72− }
73− public static long LMinus(long x, long y) {
74− return x - y;
75− }
76− public static double LMinus(double x, double y) {
77− return x - y;
78− }
79− public static BigInteger LMinus(BigInteger x, BigInteger y) {
80− return x.subtract(y);
81− }
82− public static byte[] LMinus(byte[] x, byte[] y) {
83− byte[] res = x.clone();
84− for (int i = 0; i < res.length; ++i) {
85− res[i] -= y[i];
86− }
87− return res;
88− }
89− public static short[] LMinus(short[] x, short[] y) {
90− short[] res = x.clone();
91− for (int i = 0; i < res.length; ++i) {
92− res[i] -= y[i];
93− }
94− return res;
95− }
96− public static int[] LMinus(int[] x, int[] y) {
97− int[] res = x.clone();
98− for (int i = 0; i < res.length; ++i) {
99− res[i] -= y[i];
100− }
101− return res;
102− }
103− public static long[] LMinus(long[] x, long[] y) {
104− long[] res = x.clone();
105− for (int i = 0; i < res.length; ++i) {
106− res[i] -= y[i];
107− }
108− return res;
109− }
110−
111− public static byte LTimes(byte x, byte y) {
112− return (byte)(x * y);
113− }
114− public static char LTimes(char x, char y) {
115− return (char)(x * y);
116− }
117− public static short LTimes(short x, short y) {
118− return (short)(x * y);
119− }
120− public static int LTimes(int x, int y) {
121− return x * y;
122− }
123− public static long LTimes(long x, long y) {
124− return x * y;
125− }
126− public static double LTimes(double x, double y) {
127− return x * y;
128− }
129− public static BigInteger LTimes(BigInteger x, BigInteger y) {
130− return x.multiply(y);
131− }
132− public static byte[] LTimes(byte[] x, byte[] y) {
133− byte[] res = x.clone();
134− for (int i = 0; i < res.length; ++i) {
135− res[i] *= y[i];
136− }
137− return res;
138− }
139− public static short[] LTimes(short[] x, short[] y) {
140− short[] res = x.clone();
141− for (int i = 0; i < res.length; ++i) {
142− res[i] *= y[i];
143− }
144− return res;
145− }
146− public static int[] LTimes(int[] x, int[] y) {
147− int[] res = x.clone();
148− for (int i = 0; i < res.length; ++i) {
149− res[i] *= y[i];
150− }
151− return res;
152− }
153− public static long[] LTimes(long[] x, long[] y) {
154− long[] res = x.clone();
155− for (int i = 0; i < res.length; ++i) {
156− res[i] *= y[i];
157− }
158− return res;
159− }
160−
161− public static byte LUDiv(byte x, byte y) {
162− return (byte)(((short)x) / ((short)y));
163− }
164− public static char LUDiv(char x, char y) {
165− return (char)(((long)x) / ((long)y));
166− }
167− public static short LUDiv(short x, short y) {
168− return (short)(((int)x) / ((int)y));
169− }
170− public static int LUDiv(int x, int y) {
171− return (int)(((long)x) / ((long)y));
172− }
173− public static long LUDiv(long x, long y) {
174− return BigInteger.valueOf(x).divide(BigInteger.valueOf(y)).longValue();
175− }
176− public static byte[] LUDiv(byte[] x, byte[] y) {
177− byte[] res = x.clone();
178− for (int i = 0; i < res.length; ++i) {
179− res[i] = (byte)(((short)res[i]) / ((short)y[i]));
180− }
181− return res;
182− }
183− public static short[] LUDiv(short[] x, short[] y) {
184− short[] res = x.clone();
185− for (int i = 0; i < res.length; ++i) {
186− res[i] = (short)(((int)res[i]) / ((int)y[i]));
187− }
188− return res;
189− }
190− public static int[] LUDiv(int[] x, int[] y) {
191− int[] res = x.clone();
192− for (int i = 0; i < res.length; ++i) {
193− res[i] = (int)(((long)res[i]) / ((long)y[i]));
194− }
195− return res;
196− }
197− public static long[] LUDiv(long[] x, long[] y) {
198− long[] res = x.clone();
199− for (int i = 0; i < res.length; ++i) {
200− res[i] = BigInteger.valueOf(res[i]).divide(BigInteger.valueOf(y[i])).longValue();
201− }
202− return res;
203− }
204−
205− public static byte LSDiv(byte x, byte y) {
206− return (byte)(x / y);
207− }
208− public static char LSDiv(char x, char y) {
209− return (char)(x / y);
210− }
211− public static short LSDiv(short x, short y) {
212− return (short)(x / y);
213− }
214− public static int LSDiv(int x, int y) {
215− return x / y;
216− }
217− public static long LSDiv(long x, long y) {
218− return x / y;
219− }
220− public static double LSDiv(double x, double y) {
221− return x / y;
222− }
223− public static BigInteger LSDiv(BigInteger x, BigInteger y) {
224− return x.divide(y);
225− }
226− public static byte[] LSDiv(byte[] x, byte[] y) {
227− byte[] res = x.clone();
228− for (int i = 0; i < res.length; ++i) {
229− res[i] /= y[i];
230− }
231− return res;
232− }
233− public static short[] LSDiv(short[] x, short[] y) {
234− short[] res = x.clone();
235− for (int i = 0; i < res.length; ++i) {
236− res[i] /= y[i];
237− }
238− return res;
239− }
240− public static int[] LSDiv(int[] x, int[] y) {
241− int[] res = x.clone();
242− for (int i = 0; i < res.length; ++i) {
243− res[i] /= y[i];
244− }
245− return res;
246− }
247− public static long[] LSDiv(long[] x, long[] y) {
248− long[] res = x.clone();
249− for (int i = 0; i < res.length; ++i) {
250− res[i] /= y[i];
251− }
252− return res;
253− }
254−
255− public static byte LURem(byte x, byte y) {
256− return (byte)(((short)x) % ((short)y));
257− }
258− public static char LURem(char x, char y) {
259− return (char)(((long)x) % ((long)y));
260− }
261− public static short LURem(short x, short y) {
262− return (short)(((int)x) % ((int)y));
263− }
264− public static int LURem(int x, int y) {
265− return (int)(((long)x) % ((long)y));
266− }
267− public static long LURem(long x, long y) {
268− return BigInteger.valueOf(x).divide(BigInteger.valueOf(y)).longValue();
269− }
270− public static byte[] LURem(byte[] x, byte[] y) {
271− byte[] res = x.clone();
272− for (int i = 0; i < res.length; ++i) {
273− res[i] = (byte)(((short)res[i]) % ((short)y[i]));
274− }
275− return res;
276− }
277− public static short[] LURem(short[] x, short[] y) {
278− short[] res = x.clone();
279− for (int i = 0; i < res.length; ++i) {
280− res[i] = (short)(((int)res[i]) % ((int)y[i]));
281− }
282− return res;
283− }
284− public static int[] LURem(int[] x, int[] y) {
285− int[] res = x.clone();
286− for (int i = 0; i < res.length; ++i) {
287− res[i] = (int)(((long)res[i]) % ((long)y[i]));
288− }
289− return res;
290− }
291− public static long[] LURem(long[] x, long[] y) {
292− long[] res = x.clone();
293− for (int i = 0; i < res.length; ++i) {
294− res[i] = BigInteger.valueOf(res[i]).divide(BigInteger.valueOf(y[i])).longValue();
295− }
296− return res;
297− }
298−
299− public static byte LSRem(byte x, byte y) {
300− return (byte)(x % y);
301− }
302− public static char LSRem(char x, char y) {
303− return (char)(x % y);
304− }
305− public static short LSRem(short x, short y) {
306− return (short)(x % y);
307− }
308− public static int LSRem(int x, int y) {
309− return x % y;
310− }
311− public static long LSRem(long x, long y) {
312− return x % y;
313− }
314− public static double LSRem(double x, double y) {
315− return x % y;
316− }
317− public static BigInteger LSRem(BigInteger x, BigInteger y) {
318− return x.remainder(y);
319− }
320− public static byte[] LSRem(byte[] x, byte[] y) {
321− byte[] res = x.clone();
322− for (int i = 0; i < res.length; ++i) {
323− res[i] %= y[i];
324− }
325− return res;
326− }
327− public static short[] LSRem(short[] x, short[] y) {
328− short[] res = x.clone();
329− for (int i = 0; i < res.length; ++i) {
330− res[i] %= y[i];
331− }
332− return res;
333− }
334− public static int[] LSRem(int[] x, int[] y) {
335− int[] res = x.clone();
336− for (int i = 0; i < res.length; ++i) {
337− res[i] %= y[i];
338− }
339− return res;
340− }
341− public static long[] LSRem(long[] x, long[] y) {
342− long[] res = x.clone();
343− for (int i = 0; i < res.length; ++i) {
344− res[i] %= y[i];
345− }
346− return res;
347− }
348−
349−
350− public static byte LAnd(byte x, byte y) {
351− return (byte)(x & y);
352− }
353− public static char LAnd(char x, char y) {
354− return (char)(x & y);
355− }
356− public static short LAnd(short x, short y) {
357− return (short)(x & y);
358− }
359− public static int LAnd(int x, int y) {
360− return x & y;
361− }
362− public static long LAnd(long x, long y) {
363− return x & y;
364− }
365− public static BigInteger LAnd(BigInteger x, BigInteger y) {
366− return x.and(y);
367− }
368− public static byte[] LAnd(byte[] x, byte[] y) {
369− byte[] res = x.clone();
370− for (int i = 0; i < res.length; ++i) {
371− res[i] &= y[i];
372− }
373− return res;
374− }
375− public static short[] LAnd(short[] x, short[] y) {
376− short[] res = x.clone();
377− for (int i = 0; i < res.length; ++i) {
378− res[i] &= y[i];
379− }
380− return res;
381− }
382− public static int[] LAnd(int[] x, int[] y) {
383− int[] res = x.clone();
384− for (int i = 0; i < res.length; ++i) {
385− res[i] &= y[i];
386− }
387− return res;
388− }
389− public static long[] LAnd(long[] x, long[] y) {
390− long[] res = x.clone();
391− for (int i = 0; i < res.length; ++i) {
392− res[i] &= y[i];
393− }
394− return res;
395− }
396−
397− public static byte LOr(byte x, byte y) {
398− return (byte)(x | y);
399− }
400− public static char LOr(char x, char y) {
401− return (char)(x | y);
402− }
403− public static short LOr(short x, short y) {
404− return (short)(x | y);
405− }
406− public static int LOr(int x, int y) {
407− return x | y;
408− }
409− public static long LOr(long x, long y) {
410− return x | y;
411− }
412− public static BigInteger LOr(BigInteger x, BigInteger y) {
413− return x.or(y);
414− }
415− public static byte[] LOr(byte[] x, byte[] y) {
416− byte[] res = x.clone();
417− for (int i = 0; i < res.length; ++i) {
418− res[i] |= y[i];
419− }
420− return res;
421− }
422− public static short[] LOr(short[] x, short[] y) {
423− short[] res = x.clone();
424− for (int i = 0; i < res.length; ++i) {
425− res[i] |= y[i];
426− }
427− return res;
428− }
429− public static int[] LOr(int[] x, int[] y) {
430− int[] res = x.clone();
431− for (int i = 0; i < res.length; ++i) {
432− res[i] |= y[i];
433− }
434− return res;
435− }
436− public static long[] LOr(long[] x, long[] y) {
437− long[] res = x.clone();
438− for (int i = 0; i < res.length; ++i) {
439− res[i] |= y[i];
440− }
441− return res;
442− }
443−
444− public static byte LXOr(byte x, byte y) {
445− return (byte)(x ^ y);
446− }
447− public static char LXOr(char x, char y) {
448− return (char)(x ^ y);
449− }
450− public static short LXOr(short x, short y) {
451− return (short)(x ^ y);
452− }
453− public static int LXOr(int x, int y) {
454− return x ^ y;
455− }
456− public static long LXOr(long x, long y) {
457− return x ^ y;
458− }
459− public static BigInteger LXOr(BigInteger x, BigInteger y) {
460− return x.xor(y);
461− }
462− public static byte[] LXOr(byte[] x, byte[] y) {
463− byte[] res = x.clone();
464− for (int i = 0; i < res.length; ++i) {
465− res[i] ^= y[i];
466− }
467− return res;
468− }
469− public static short[] LXOr(short[] x, short[] y) {
470− short[] res = x.clone();
471− for (int i = 0; i < res.length; ++i) {
472− res[i] ^= y[i];
473− }
474− return res;
475− }
476− public static int[] LXOr(int[] x, int[] y) {
477− int[] res = x.clone();
478− for (int i = 0; i < res.length; ++i) {
479− res[i] ^= y[i];
480− }
481− return res;
482− }
483− public static long[] LXOr(long[] x, long[] y) {
484− long[] res = x.clone();
485− for (int i = 0; i < res.length; ++i) {
486− res[i] ^= y[i];
487− }
488− return res;
489− }
490−
491− public static byte LCompl(byte x) {
492− return (byte)~x;
493− }
494− public static char LCompl(char x) {
495− return (char)~x;
496− }
497− public static short LCompl(short x) {
498− return (short)(~x);
499− }
500− public static int LCompl(int x) {
501− return ~x;
502− }
503− public static long LCompl(long x) {
504− return ~x;
505− }
506− public static BigInteger LCompl(BigInteger x) {
507− return x.not();
508− }
509− public static byte[] LCompl(byte[] x) {
510− byte[] res = new byte[x.length];
511− for (int i = 0; i < res.length; ++i) {
512− res[i] = (byte)~(x[i]);
513− }
514− return res;
515− }
516− public static short[] LCompl(short[] x) {
517− short[] res = new short[x.length];
518− for (int i = 0; i < res.length; ++i) {
519− res[i] = (short)~(x[i]);
520− }
521− return res;
522− }
523− public static int[] LCompl(int[] x) {
524− int[] res = new int[x.length];
525− for (int i = 0; i < res.length; ++i) {
526− res[i] = (int)~(x[i]);
527− }
528− return res;
529− }
530− public static long[] LCompl(long[] x) {
531− long[] res = new long[x.length];
532− for (int i = 0; i < res.length; ++i) {
533− res[i] = (long)~(x[i]);
534− }
535− return res;
536− }
537−
538− public static byte LSHL(byte x, byte y) {
539− return (byte)(x << y);
540− }
541− public static char LSHL(char x, char y) {
542− return (char)(x << y);
543− }
544− public static short LSHL(short x, short y) {
545− return (short)(x << y);
546− }
547− public static int LSHL(int x, int y) {
548− return x << y;
549− }
550− public static long LSHL(long x, long y) {
551− return x << y;
552− }
553− public static BigInteger LSHL(BigInteger x, BigInteger y) {
554− return x.shiftLeft(y.intValue());
555− }
556− public static byte[] LSHL(byte[] x, byte[] y) {
557− byte[] res = x.clone();
558− for (int i = 0; i < res.length; ++i) {
559− res[i] <<= y[i];
560− }
561− return res;
562− }
563− public static short[] LSHL(short[] x, short[] y) {
564− short[] res = x.clone();
565− for (int i = 0; i < res.length; ++i) {
566− res[i] <<= y[i];
567− }
568− return res;
569− }
570− public static int[] LSHL(int[] x, int[] y) {
571− int[] res = x.clone();
572− for (int i = 0; i < res.length; ++i) {
573− res[i] <<= y[i];
574− }
575− return res;
576− }
577− public static long[] LSHL(long[] x, long[] y) {
578− long[] res = x.clone();
579− for (int i = 0; i < res.length; ++i) {
580− res[i] <<= y[i];
581− }
582− return res;
583− }
584−
585− public static byte LLSHR(byte x, byte y) {
586− return (byte)(x >>> y);
587− }
588− public static char LLSHR(char x, char y) {
589− return (char)(x >>> y);
590− }
591− public static short LLSHR(short x, short y) {
592− return (short)(x >>> y);
593− }
594− public static int LLSHR(int x, int y) {
595− return x >>> y;
596− }
597− public static long LLSHR(long x, long y) {
598− return x >>> y;
599− }
600− public static byte[] LLSHR(byte[] x, byte[] y) {
601− byte[] res = x.clone();
602− for (int i = 0; i < res.length; ++i) {
603− res[i] >>>= y[i];
604− }
605− return res;
606− }
607− public static short[] LLSHR(short[] x, short[] y) {
608− short[] res = x.clone();
609− for (int i = 0; i < res.length; ++i) {
610− res[i] >>>= y[i];
611− }
612− return res;
613− }
614− public static int[] LLSHR(int[] x, int[] y) {
615− int[] res = x.clone();
616− for (int i = 0; i < res.length; ++i) {
617− res[i] >>>= y[i];
618− }
619− return res;
620− }
621− public static long[] LLSHR(long[] x, long[] y) {
622− long[] res = x.clone();
623− for (int i = 0; i < res.length; ++i) {
624− res[i] >>>= y[i];
625− }
626− return res;
627− }
628−
629− public static byte LASHR(byte x, byte y) {
630− return (byte)(x >> y);
631− }
632− public static char LASHR(char x, char y) {
633− return (char)(x >> y);
634− }
635− public static short LASHR(short x, short y) {
636− return (short)(x >> y);
637− }
638− public static int LASHR(int x, int y) {
639− return x >> y;
640− }
641− public static long LASHR(long x, long y) {
642− return x >> y;
643− }
644− public static BigInteger LASHR(BigInteger x, BigInteger y) {
645− return x.shiftRight(y.intValue());
646− }
647− public static byte[] LASHR(byte[] x, byte[] y) {
648− byte[] res = x.clone();
649− for (int i = 0; i < res.length; ++i) {
650− res[i] >>= y[i];
651− }
652− return res;
653− }
654− public static short[] LASHR(short[] x, short[] y) {
655− short[] res = x.clone();
656− for (int i = 0; i < res.length; ++i) {
657− res[i] >>= y[i];
658− }
659− return res;
660− }
661− public static int[] LASHR(int[] x, int[] y) {
662− int[] res = x.clone();
663− for (int i = 0; i < res.length; ++i) {
664− res[i] >>= y[i];
665− }
666− return res;
667− }
668− public static long[] LASHR(long[] x, long[] y) {
669− long[] res = x.clone();
670− for (int i = 0; i < res.length; ++i) {
671− res[i] >>= y[i];
672− }
673− return res;
674− }
675−
676− public static int LEq(byte x, byte y) {
677− return (x == y ? 1 : 0);
678− }
679− public static int LEq(char x, char y) {
680− return (x == y ? 1 : 0);
681− }
682− public static int LEq(short x, short y) {
683− return (x == y ? 1 : 0);
684− }
685− public static int LEq(int x, int y) {
686− return (x == y ? 1 : 0);
687− }
688− public static int LEq(long x, long y) {
689− return (x == y ? 1 : 0);
690− }
691− public static int LEq(double x, double y) {
692− return (x == y ? 1 : 0);
693− }
694− public static int LEq(BigInteger x, BigInteger y) {
695− return (x.equals(y) ? 1 : 0);
696− }
697− public static byte[] LEq(byte[] x, byte[] y) {
698− byte[] res = new byte[x.length];
699− for (int i = 0; i < x.length; ++i) {
700− res[i] = (byte)(x[i] == y[i] ? -1 : 0);
701− }
702− return res;
703− }
704− public static short[] LEq(short[] x, short[] y) {
705− short[] res = new short[x.length];
706− for (int i = 0; i < x.length; ++i) {
707− res[i] = (short)(x[i] == y[i] ? -1 : 0);
708− }
709− return res;
710− }
711− public static int[] LEq(int[] x, int[] y) {
712− int[] res = new int[x.length];
713− for (int i = 0; i < x.length; ++i) {
714− res[i] = (x[i] == y[i] ? -1 : 0);
715− }
716− return res;
717− }
718− public static long[] LEq(long[] x, long[] y) {
719− long[] res = new long[x.length];
720− for (int i = 0; i < x.length; ++i) {
721− res[i] = (x[i] == y[i] ? -1 : 0);
722− }
723− return res;
724− }
725−
726− public static int LLt(byte x, byte y) {
727− return (x < y ? 1 : 0);
728− }
729− public static int LLt(char x, char y) {
730− return (x < y ? 1 : 0);
731− }
732− public static int LLt(short x, short y) {
733− return (x < y ? 1 : 0);
734− }
735− public static int LLt(int x, int y) {
736− return (x < y ? 1 : 0);
737− }
738− public static int LLt(long x, long y) {
739− return (x < y ? 1 : 0);
740− }
741− public static double LLt(double x, double y) {
742− return (x < y ? 1 : 0);
743− }
744− public static int LLt(BigInteger x, BigInteger y) {
745− return (x.compareTo(y) < 0 ? 1 : 0);
746− }
747− public static byte[] LLt(byte[] x, byte[] y) {
748− byte[] res = new byte[x.length];
749− for (int i = 0; i < x.length; ++i) {
750− res[i] = (byte)(x[i] < y[i] ? -1 : 0);
751− }
752− return res;
753− }
754− public static short[] LLt(short[] x, short[] y) {
755− short[] res = new short[x.length];
756− for (int i = 0; i < x.length; ++i) {
757− res[i] = (short)(x[i] < y[i] ? -1 : 0);
758− }
759− return res;
760− }
761− public static int[] LLt(int[] x, int[] y) {
762− int[] res = new int[x.length];
763− for (int i = 0; i < x.length; ++i) {
764− res[i] = (x[i] < y[i] ? -1 : 0);
765− }
766− return res;
767− }
768− public static long[] LLt(long[] x, long[] y) {
769− long[] res = new long[x.length];
770− for (int i = 0; i < x.length; ++i) {
771− res[i] = (x[i] < y[i] ? -1 : 0);
772− }
773− return res;
774− }
775−
776− public static int LLe(byte x, byte y) {
777− return (x <= y ? 1 : 0);
778− }
779− public static int LLe(char x, char y) {
780− return (x <= y ? 1 : 0);
781− }
782− public static int LLe(short x, short y) {
783− return (x <= y ? 1 : 0);
784− }
785− public static int LLe(int x, int y) {
786− return (x <= y ? 1 : 0);
787− }
788− public static int LLe(long x, long y) {
789− return (x <= y ? 1 : 0);
790− }
791− public static double LLe(double x, double y) {
792− return (x <= y ? 1 : 0);
793− }
794− public static int LLe(BigInteger x, BigInteger y) {
795− return (x.compareTo(y) <= 0 ? 1 : 0);
796− }
797− public static byte[] LLe(byte[] x, byte[] y) {
798− byte[] res = new byte[x.length];
799− for (int i = 0; i < x.length; ++i) {
800− res[i] = (byte)(x[i] <= y[i] ? -1 : 0);
801− }
802− return res;
803− }
804− public static short[] LLe(short[] x, short[] y) {
805− short[] res = new short[x.length];
806− for (int i = 0; i < x.length; ++i) {
807− res[i] = (short)(x[i] <= y[i] ? -1 : 0);
808− }
809− return res;
810− }
811− public static int[] LLe(int[] x, int[] y) {
812− int[] res = new int[x.length];
813− for (int i = 0; i < x.length; ++i) {
814− res[i] = (x[i] <= y[i] ? -1 : 0);
815− }
816− return res;
817− }
818− public static long[] LLe(long[] x, long[] y) {
819− long[] res = new long[x.length];
820− for (int i = 0; i < x.length; ++i) {
821− res[i] = (x[i] <= y[i] ? -1 : 0);
822− }
823− return res;
824− }
825−
826− public static int LGt(byte x, byte y) {
827− return (x > y ? 1 : 0);
828− }
829− public static int LGt(char x, char y) {
830− return (x > y ? 1 : 0);
831− }
832− public static int LGt(short x, short y) {
833− return (x > y ? 1 : 0);
834− }
835− public static int LGt(int x, int y) {
836− return (x > y ? 1 : 0);
837− }
838− public static int LGt(long x, long y) {
839− return (x > y ? 1 : 0);
840− }
841− public static double LGt(double x, double y) {
842− return (x > y ? 1 : 0);
843− }
844− public static int LGt(BigInteger x, BigInteger y) {
845− return (x.compareTo(y) > 0 ? 1 : 0);
846− }
847− public static byte[] LGt(byte[] x, byte[] y) {
848− byte[] res = new byte[x.length];
849− for (int i = 0; i < x.length; ++i) {
850− res[i] = (byte)(x[i] > y[i] ? -1 : 0);
851− }
852− return res;
853− }
854− public static short[] LGt(short[] x, short[] y) {
855− short[] res = new short[x.length];
856− for (int i = 0; i < x.length; ++i) {
857− res[i] = (short)(x[i] > y[i] ? -1 : 0);
858− }
859− return res;
860− }
861− public static int[] LGt(int[] x, int[] y) {
862− int[] res = new int[x.length];
863− for (int i = 0; i < x.length; ++i) {
864− res[i] = (x[i] > y[i] ? -1 : 0);
865− }
866− return res;
867− }
868− public static long[] LGt(long[] x, long[] y) {
869− long[] res = new long[x.length];
870− for (int i = 0; i < x.length; ++i) {
871− res[i] = (x[i] > y[i] ? -1 : 0);
872− }
873− return res;
874− }
875−
876− public static int LGe(byte x, byte y) {
877− return (x >= y ? 1 : 0);
878− }
879− public static int LGe(char x, char y) {
880− return (x >= y ? 1 : 0);
881− }
882− public static int LGe(short x, short y) {
883− return (x >= y ? 1 : 0);
884− }
885− public static int LGe(int x, int y) {
886− return (x >= y ? 1 : 0);
887− }
888− public static int LGe(long x, long y) {
889− return (x >= y ? 1 : 0);
890− }
891− public static double LGe(double x, double y) {
892− return (x >= y ? 1 : 0);
893− }
894− public static int LGe(BigInteger x, BigInteger y) {
895− return (x.compareTo(y) >= 0 ? 1 : 0);
896− }
897− public static byte[] LGe(byte[] x, byte[] y) {
898− byte[] res = new byte[x.length];
899− for (int i = 0; i < x.length; ++i) {
900− res[i] = (byte)(x[i] >= y[i] ? -1 : 0);
901− }
902− return res;
903− }
904− public static short[] LGe(short[] x, short[] y) {
905− short[] res = new short[x.length];
906− for (int i = 0; i < x.length; ++i) {
907− res[i] = (short)(x[i] >= y[i] ? -1 : 0);
908− }
909− return res;
910− }
911− public static int[] LGe(int[] x, int[] y) {
912− int[] res = new int[x.length];
913− for (int i = 0; i < x.length; ++i) {
914− res[i] = (x[i] >= y[i] ? -1 : 0);
915− }
916− return res;
917− }
918− public static long[] LGe(long[] x, long[] y) {
919− long[] res = new long[x.length];
920− for (int i = 0; i < x.length; ++i) {
921− res[i] = (x[i] >= y[i] ? -1 : 0);
922− }
923− return res;
924− }
925−
926−
927− public static short LSExtIT16(byte x) {
928− return (short)x;
929− }
930− public static int LSExtIT32(byte x) {
931− return (int)x;
932− }
933− public static long LSExtIT64(byte x) {
934− return (long)x;
935− }
936− public static BigInteger LSExtITBig(byte x) {
937− return BigInteger.valueOf(x);
938− }
939− public static short[] LSExtITVec16(byte[] x) {
940− short[] res = new short[x.length];
941− for (int i = 0; i < res.length; ++i) {
942− res[i] = (short)x[i];
943− }
944− return res;
945− }
946− public static int[] LSExtITVec32(byte[] x) {
947− int[] res = new int[x.length];
948− for (int i = 0; i < res.length; ++i) {
949− res[i] = (int)x[i];
950− }
951− return res;
952− }
953− public static long[] LSExtITVec64(byte[] x) {
954− long[] res = new long[x.length];
955− for (int i = 0; i < res.length; ++i) {
956− res[i] = (long)x[i];
957− }
958− return res;
959− }
960−
961− public static short LSExtIT16(char x) {
962− return (short)x;
963− }
964− public static int LSExtIT32(char x) {
965− return (int)x;
966− }
967− public static long LSExtIT64(char x) {
968− return (long)x;
969− }
970− public static BigInteger LSExtITBig(char x) {
971− return BigInteger.valueOf(x);
972− }
973−
974− public static int LSExtIT32(short x) {
975− return (int)x;
976− }
977− public static long LSExtIT64(short x) {
978− return (long)x;
979− }
980− public static BigInteger LSExtITBig(short x) {
981− return BigInteger.valueOf(x);
982− }
983− public static int[] LSExtITVec32(short[] x) {
984− int[] res = new int[x.length];
985− for (int i = 0; i < res.length; ++i) {
986− res[i] = (int)x[i];
987− }
988− return res;
989− }
990− public static long[] LSExtITVec64(short[] x) {
991− long[] res = new long[x.length];
992− for (int i = 0; i < res.length; ++i) {
993− res[i] = (long)x[i];
994− }
995− return res;
996− }
997−
998− public static long LSExtIT64(int x) {
999− return (long)x;
1000− }
1001− public static BigInteger LSExtITBig(int x) {
1002− return BigInteger.valueOf(x);
1003− }
1004− public static long[] LSExtITVec64(int[] x) {
1005− long[] res = new long[x.length];
1006− for (int i = 0; i < res.length; ++i) {
1007− res[i] = (long)x[i];
1008− }
1009− return res;
1010− }
1011− public static BigInteger LSExtITBig(long x) {
1012− return BigInteger.valueOf(x);
1013− }
1014−
1015−
1016− public static short LZExtIT16(byte x) {
1017− return (short)(x < 0 ? x + (2 << 7) : x);
1018− }
1019− public static int LZExtIT32(byte x) {
1020− return (int)(x < 0 ? x + (2 << 7) : x);
1021− }
1022− public static long LZExtIT64(byte x) {
1023− return (long)(x < 0 ? x + (2 << 7) : x);
1024− }
1025− public static BigInteger LZExtITBig(byte x) {
1026− return BigInteger.valueOf(x < 0 ? x + (2 << 7) : x);
1027− }
1028− public static char LZExtITChar(byte x) {
1029− return (char)(x < 0 ? x + (2 << 7) : x);
1030− }
1031− public static short[] LZExtITVec16(byte[] x) {
1032− short[] res = new short[x.length];
1033− for (int i = 0; i < res.length; ++i) {
1034− res[i] = (short)(x[i] < 0 ? x[i] + (2 << 7) : x[i]);
1035− }
1036− return res;
1037− }
1038− public static int[] LZExtITVec32(byte[] x) {
1039− int[] res = new int[x.length];
1040− for (int i = 0; i < res.length; ++i) {
1041− res[i] = (int)(x[i] < 0 ? x[i] + (2 << 7) : x[i]);
1042− }
1043− return res;
1044− }
1045− public static long[] LZExtITVec64(byte[] x) {
1046− long[] res = new long[x.length];
1047− for (int i = 0; i < res.length; ++i) {
1048− res[i] = (long)(x[i] < 0 ? x[i] + (2 << 7) : x[i]);
1049− }
1050− return res;
1051− }
1052−
1053− public static int LZExtIT32(short x) {
1054− return (int)(x < 0 ? x + (2 << 15) : x);
1055− }
1056− public static long LZExtIT64(short x) {
1057− return (long)(x < 0 ? x + (2 << 15) : x);
1058− }
1059− public static BigInteger LZExtITBig(short x) {
1060− return BigInteger.valueOf(x < 0 ? x + (2 << 15) : x);
1061− }
1062− public static char LZExtITChar(short x) {
1063− return (char)(x < 0 ? x + (2 << 15) : x);
1064− }
1065− public static int[] LZExtITVec32(short[] x) {
1066− int[] res = new int[x.length];
1067− for (int i = 0; i < res.length; ++i) {
1068− res[i] = (int)(x[i] < 0 ? x[i] + (2 << 15) : x[i]);
1069− }
1070− return res;
1071− }
1072− public static long[] LZExtITVec64(short[] x) {
1073− long[] res = new long[x.length];
1074− for (int i = 0; i < res.length; ++i) {
1075− res[i] = (long)(x[i] < 0 ? x[i] + (2 << 15) : x[i]);
1076− }
1077− return res;
1078− }
1079−
1080− public static long LZExtIT64(int x) {
1081− return (long)(x < 0 ? ((long)x) + (2l << 31) : x);
1082− }
1083− public static BigInteger LZExtITBig(int x) {
1084− return BigInteger.valueOf(x < 0 ? ((long)x) + (2l << 31) : x);
1085− }
1086− public static char LZExtITChar(int x) {
1087− return (char)(x < 0 ? ((long)x) + (2l << 31) : x);
1088− }
1089− public static long[] LZExtITVec64(int[] x) {
1090− long[] res = new long[x.length];
1091− for (int i = 0; i < res.length; ++i) {
1092− res[i] = (long)(((long)x[i]) < 0 ? x[i] + (2l << 31) : x[i]);
1093− }
1094− return res;
1095− }
1096−
1097− public static BigInteger LZExtITBig(long x) {
1098− return (x < 0 ? BigInteger.valueOf(x).add(BigInteger.valueOf(2).shiftLeft(61)) : BigInteger.valueOf(x));
1099− }
1100− public static char LZExtITChar(long x) {
1101− return (char)((x < 0 ? BigInteger.valueOf(x).add(BigInteger.valueOf(2).shiftLeft(61)) : BigInteger.valueOf(x)).intValue());
1102− }
1103−
1104− public static byte LTruncIT8(short x) {
1105− return (byte)x;
1106− }
1107− public static byte[] LTruncITVec8(short[] x) {
1108− byte[] res = new byte[x.length];
1109− for (int i = 0; i < res.length; ++i) {
1110− res[i] = (byte)x[i];
1111− }
1112− return res;
1113− }
1114− public static char LTruncITChar(short x) {
1115− return (char)x;
1116− }
1117−
1118− public static byte LTruncIT8(int x) {
1119− return (byte)x;
1120− }
1121− public static short LTruncIT16(int x) {
1122− return (short)x;
1123− }
1124− public static byte[] LTruncITVec8(int[] x) {
1125− byte[] res = new byte[x.length];
1126− for (int i = 0; i < res.length; ++i) {
1127− res[i] = (byte)x[i];
1128− }
1129− return res;
1130− }
1131− public static short[] LTruncITVec16(int[] x) {
1132− short[] res = new short[x.length];
1133− for (int i = 0; i < res.length; ++i) {
1134− res[i] = (short)x[i];
1135− }
1136− return res;
1137− }
1138− public static char LTruncITChar(int x) {
1139− return (char)x;
1140− }
1141−
1142− public static byte LTruncIT8(long x) {
1143− return (byte)x;
1144− }
1145− public static short LTruncIT16(long x) {
1146− return (short)x;
1147− }
1148− public static int LTruncIT32(long x) {
1149− return (int)x;
1150− }
1151− public static byte[] LTruncITVec8(long[] x) {
1152− byte[] res = new byte[x.length];
1153− for (int i = 0; i < res.length; ++i) {
1154− res[i] = (byte)x[i];
1155− }
1156− return res;
1157− }
1158− public static short[] LTruncITVec16(long[] x) {
1159− short[] res = new short[x.length];
1160− for (int i = 0; i < res.length; ++i) {
1161− res[i] = (short)x[i];
1162− }
1163− return res;
1164− }
1165− public static int[] LTruncITVec32(long[] x) {
1166− int[] res = new int[x.length];
1167− for (int i = 0; i < res.length; ++i) {
1168− res[i] = (int)x[i];
1169− }
1170− return res;
1171− }
1172− public static char LTruncITChar(long x) {
1173− return (char)x;
1174− }
1175−
1176− public static byte LTruncIT8(BigInteger x) {
1177− return x.byteValue();
1178− }
1179− public static short LTruncIT16(BigInteger x) {
1180− return x.shortValue();
1181− }
1182− public static int LTruncIT32(BigInteger x) {
1183− return x.intValue();
1184− }
1185− public static long LTruncIT64(BigInteger x) {
1186− return x.longValue();
1187− }
1188− public static char LTruncITChar(BigInteger x) {
1189− return (char)x.intValue();
1190− }
1191−
1192− public static byte LTruncIT8(char x) {
1193− return (byte)x;
1194− }
1195− public static short LTruncIT16(char x) {
1196− return (short)x;
1197− }
1198− public static int LTruncIT32(char x) {
1199− return (int)x;
1200− }
1201− public static long LTruncIT64(char x) {
1202− return (int)x;
1203− }
1204− public static BigInteger LTruncITBig(char x) {
1205− return BigInteger.valueOf(x);
1206− }
1207−
1208−
1209− public static double LFExp(double x) {
1210− return Math.exp(x);
1211− }
1212− public static double LFLog(double x) {
1213− return Math.log(x);
1214− }
1215− public static double LFSin(double x) {
1216− return Math.sin(x);
1217− }
1218− public static double LFCos(double x) {
1219− return Math.cos(x);
1220− }
1221− public static double LFTan(double x) {
1222− return Math.tan(x);
1223− }
1224− public static double LFASin(double x) {
1225− return Math.asin(x);
1226− }
1227− public static double LFACos(double x) {
1228− return Math.acos(x);
1229− }
1230− public static double LFATan(double x) {
1231− return Math.atan(x);
1232− }
1233− public static double LFSqrt(double x) {
1234− return Math.sqrt(x);
1235− }
1236− public static double LFFloor(double x) {
1237− return Math.floor(x);
1238− }
1239− public static double LFCeil(double x) {
1240− return Math.ceil(x);
1241− }
1242−
1243− public static byte[] LMkVec(byte ... x) {
1244− return x;
1245− }
1246− public static short[] LMkVec(short ... x) {
1247− return x;
1248− }
1249− public static int[] LMKVec(int ... x) {
1250− return x;
1251− }
1252− public static long[] LMKVec(long ... x) {
1253− return x;
1254− }
1255−
1256− public static byte LIdxVec(byte[] x, int y) {
1257− return x[y];
1258− }
1259− public static short LIdxVec(short[] x, int y) {
1260− return x[y];
1261− }
1262− public static int LIdxVec(int[] x, int y) {
1263− return x[y];
1264− }
1265− public long LIdxVec(long[] x, int y) {
1266− return x[y];
1267− }
1268−
1269− public static byte[] LUpdateVec(byte[] x, int y, byte z) {
1270− x[y] = z;
1271− return x;
1272− }
1273− public static short[] LUpdateVec(short[] x, int y, short z) {
1274− x[y] = z;
1275− return x;
1276− }
1277− public static int[] LUpdateVec(int[] x, int y, int z) {
1278− x[y] = z;
1279− return x;
1280− }
1281− public long[] LUpdateVec(long[] x, int y, long z) {
1282− x[y] = z;
1283− return x;
1284− }
1285−
1286− public static String LStrConcat(String ... args) {
1287− StringBuilder builder = new StringBuilder();
1288− for (String arg : args) {
1289− builder.append(arg);
1290− }
1291− return builder.toString();
1292− }
1293−
1294− public static int LStrLt(String x, String y) {
1295− return (x.compareTo(y) < 0 ? 1 : 0);
1296− }
1297−
1298− public static int LStrEq(String x, String y) {
1299− return (x.equals(y) ? 1 : 0);
1300− }
1301−
1302− public static int LStrLen(String x) {
1303− return x.length();
1304− }
1305−
1306− public static double LIntFloat(byte x) {
1307− return (double)x;
1308− }
1309− public static double LIntFloat(char x) {
1310− return (double)x;
1311− }
1312− public static double LIntFloat(short x) {
1313− return (double)x;
1314− }
1315− public static double LIntFloat(int x) {
1316− return (double)x;
1317− }
1318− public static double LIntFloat(long x) {
1319− return (double)x;
1320− }
1321− public static double LIntFloat(BigInteger x) {
1322− return x.doubleValue();
1323− }
1324−
1325− public static byte LFloatIntIT8(double x) {
1326− return (byte)x;
1327− }
1328− public static short LFloatIntIT16(double x) {
1329− return (short)x;
1330− }
1331− public static int LFloatIntIT32(double x) {
1332− return (int)x;
1333− }
1334− public static long LFloatIntIT64(double x) {
1335− return (long)x;
1336− }
1337− public static BigInteger LFloatIntITBig(double x) {
1338− return BigInteger.valueOf((long)x);
1339− }
1340− public static char LFloatIntITChar(double x) {
1341− return (char)x;
1342− }
1343−
1344− public static String LIntStr(byte x) {
1345− return Byte.toString(x);
1346− }
1347− public static String LIntStr(char x) {
1348− return Character.toString(x);
1349− }
1350− public static String LIntStr(short x) {
1351− return Short.toString(x);
1352− }
1353− public static String LIntStr(int x) {
1354− return Integer.toString(x);
1355− }
1356− public static String LIntStr(long x) {
1357− return Long.toString(x);
1358− }
1359− public static String LIntStr(BigInteger x) {
1360− return x.toString();
1361− }
1362− public static byte LStrIntIT8(String x) {
1363− return Byte.parseByte(x);
1364− }
1365− public static short LStrIntIT16(String x) {
1366− return Short.parseShort(x);
1367− }
1368− public static int LStrIntIT32(String x) {
1369− return Integer.parseInt(x);
1370− }
1371− public static long LStrIntIT64(String x) {
1372− return Long.parseLong(x);
1373− }
1374− public static BigInteger LStrIntITBig(String x) {
1375− return new BigInteger(x);
1376− }
1377− public static char LStrIntITChar(String x) {
1378− return x.charAt(0);
1379− }
1380−
1381− public static String LFloatStr(double x) {
1382− return Double.toString(x);
1383− }
1384− public static double LStrFloat(String x) {
1385− return Double.parseDouble(x);
1386− }
1387−
1388− public static char LIntCh(byte x) {
1389− return (char)x;
1390− }
1391− public static char LIntCh(char x) {
1392− return x;
1393− }
1394− public static char LIntCh(short x) {
1395− return (char)x;
1396− }
1397− public static char LIntCh(int x) {
1398− return (char)x;
1399− }
1400− public static char LIntCh(long x) {
1401− return (char)x;
1402− }
1403− public static char LIntCh(BigInteger x) {
1404− return (char)(x.intValue());
1405− }
1406− public static byte LChIntIT8(char x) {
1407− return (byte)x;
1408− }
1409− public static short LChIntIT16(char x) {
1410− return (short)x;
1411− }
1412− public static int LChIntIT32(char x) {
1413− return (int)x;
1414− }
1415− public static long LChIntIT64(char x) {
1416− return (long)x;
1417− }
1418− public static BigInteger LChIntITBig(char x) {
1419− return BigInteger.valueOf((long)x);
1420− }
1421−
1422− public static void LPrintNum(Object x) {
1423− System.out.print(x);
1424− }
1425− public static void LPrintStr(String x) {
1426− System.out.print(x);
1427− }
1428− public static String LReadStr(Object x) {
1429− try {
1430− return ForeignPrimitives.idris_readStr(x);
1431− } catch (IOException ex) {
1432− throw new RuntimeException(ex);
1433− }
1434− }
1435−
1436− public static char LStrHead(String x) {
1437− return x.charAt(0);
1438− }
1439− public static String LStrTail(String x) {
1440− return x.substring(1);
1441− }
1442− public static String LStrCons(char x, String y) {
1443− return String.format("%c%s", x, y);
1444− }
1445− public static char LStrIndex(String x, int y) {
1446− return x.charAt(y);
1447− }
1448− public static String LStrRev(String x) {
1449− return new StringBuffer(x).reverse().toString();
1450− }
1451−
1452− public static InputStream LStdIn() {
1453− return System.in;
1454− }
1455− public static OutputStream LStdOut() {
1456− return System.out;
1457− }
1458− public static OutputStream LStdErr() {
1459− return System.err;
1460− }
1461− public static Thread LVMPtr() {
1462− return Thread.currentThread();
1463− }
1464−}