Mercurial > lasercutter
diff src/clojure/lang/Numbers.java @ 10:ef7dbbd6452c
added clojure source goodness
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sat, 21 Aug 2010 06:25:44 -0400 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/clojure/lang/Numbers.java Sat Aug 21 06:25:44 2010 -0400 1.3 @@ -0,0 +1,4527 @@ 1.4 +/** 1.5 + * Copyright (c) Rich Hickey. All rights reserved. 1.6 + * The use and distribution terms for this software are covered by the 1.7 + * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) 1.8 + * which can be found in the file epl-v10.html at the root of this distribution. 1.9 + * By using this software in any fashion, you are agreeing to be bound by 1.10 + * the terms of this license. 1.11 + * You must not remove this notice, or any other, from this software. 1.12 + **/ 1.13 + 1.14 +/* rich Mar 31, 2008 */ 1.15 + 1.16 +package clojure.lang; 1.17 + 1.18 +import java.math.BigInteger; 1.19 +import java.math.BigDecimal; 1.20 +import java.math.MathContext; 1.21 + 1.22 +public class Numbers{ 1.23 + 1.24 +static interface Ops{ 1.25 + Ops combine(Ops y); 1.26 + 1.27 + Ops opsWith(IntegerOps x); 1.28 + 1.29 + Ops opsWith(LongOps x); 1.30 + 1.31 + Ops opsWith(FloatOps x); 1.32 + 1.33 + Ops opsWith(DoubleOps x); 1.34 + 1.35 + Ops opsWith(RatioOps x); 1.36 + 1.37 + Ops opsWith(BigIntegerOps x); 1.38 + 1.39 + Ops opsWith(BigDecimalOps x); 1.40 + 1.41 + public boolean isZero(Number x); 1.42 + 1.43 + public boolean isPos(Number x); 1.44 + 1.45 + public boolean isNeg(Number x); 1.46 + 1.47 + public Number add(Number x, Number y); 1.48 + 1.49 + public Number multiply(Number x, Number y); 1.50 + 1.51 + public Number divide(Number x, Number y); 1.52 + 1.53 + public Number quotient(Number x, Number y); 1.54 + 1.55 + public Number remainder(Number x, Number y); 1.56 + 1.57 + public boolean equiv(Number x, Number y); 1.58 + 1.59 + public boolean lt(Number x, Number y); 1.60 + 1.61 + public Number negate(Number x); 1.62 + 1.63 + public Number inc(Number x); 1.64 + 1.65 + public Number dec(Number x); 1.66 +} 1.67 + 1.68 +static interface BitOps{ 1.69 + BitOps combine(BitOps y); 1.70 + 1.71 + BitOps bitOpsWith(IntegerBitOps x); 1.72 + 1.73 + BitOps bitOpsWith(LongBitOps x); 1.74 + 1.75 + BitOps bitOpsWith(BigIntegerBitOps x); 1.76 + 1.77 + public Number not(Number x); 1.78 + 1.79 + public Number and(Number x, Number y); 1.80 + 1.81 + public Number or(Number x, Number y); 1.82 + 1.83 + public Number xor(Number x, Number y); 1.84 + 1.85 + public Number andNot(Number x, Number y); 1.86 + 1.87 + public Number clearBit(Number x, int n); 1.88 + 1.89 + public Number setBit(Number x, int n); 1.90 + 1.91 + public Number flipBit(Number x, int n); 1.92 + 1.93 + public boolean testBit(Number x, int n); 1.94 + 1.95 + public Number shiftLeft(Number x, int n); 1.96 + 1.97 + public Number shiftRight(Number x, int n); 1.98 +} 1.99 + 1.100 + 1.101 +static public boolean isZero(Object x){ 1.102 + return ops(x).isZero((Number)x); 1.103 +} 1.104 + 1.105 +static public boolean isPos(Object x){ 1.106 + return ops(x).isPos((Number)x); 1.107 +} 1.108 + 1.109 +static public boolean isNeg(Object x){ 1.110 + return ops(x).isNeg((Number)x); 1.111 +} 1.112 + 1.113 +static public Number minus(Object x){ 1.114 + return ops(x).negate((Number)x); 1.115 +} 1.116 + 1.117 +static public Number inc(Object x){ 1.118 + return ops(x).inc((Number)x); 1.119 +} 1.120 + 1.121 +static public Number dec(Object x){ 1.122 + return ops(x).dec((Number)x); 1.123 +} 1.124 + 1.125 +static public Number add(Object x, Object y){ 1.126 + return ops(x).combine(ops(y)).add((Number)x, (Number)y); 1.127 +} 1.128 + 1.129 +static public Number minus(Object x, Object y){ 1.130 + Ops yops = ops(y); 1.131 + return ops(x).combine(yops).add((Number)x, yops.negate((Number)y)); 1.132 +} 1.133 + 1.134 +static public Number multiply(Object x, Object y){ 1.135 + return ops(x).combine(ops(y)).multiply((Number)x, (Number)y); 1.136 +} 1.137 + 1.138 +static public Number divide(Object x, Object y){ 1.139 + Ops yops = ops(y); 1.140 + if(yops.isZero((Number)y)) 1.141 + throw new ArithmeticException("Divide by zero"); 1.142 + return ops(x).combine(yops).divide((Number)x, (Number)y); 1.143 +} 1.144 + 1.145 +static public Number quotient(Number x, Number y){ 1.146 + Ops yops = ops(y); 1.147 + if(yops.isZero(y)) 1.148 + throw new ArithmeticException("Divide by zero"); 1.149 + return reduce(ops(x).combine(yops).quotient(x, y)); 1.150 +} 1.151 + 1.152 +static public Number remainder(Number x, Number y){ 1.153 + Ops yops = ops(y); 1.154 + if(yops.isZero(y)) 1.155 + throw new ArithmeticException("Divide by zero"); 1.156 + return reduce(ops(x).combine(yops).remainder(x, y)); 1.157 +} 1.158 + 1.159 +static Number quotient(double n, double d){ 1.160 + double q = n / d; 1.161 + if(q <= Integer.MAX_VALUE && q >= Integer.MIN_VALUE) 1.162 + { 1.163 + return (int) q; 1.164 + } 1.165 + else 1.166 + { //bigint quotient 1.167 + return reduce(new BigDecimal(q).toBigInteger()); 1.168 + } 1.169 +} 1.170 + 1.171 +static Number remainder(double n, double d){ 1.172 + double q = n / d; 1.173 + if(q <= Integer.MAX_VALUE && q >= Integer.MIN_VALUE) 1.174 + { 1.175 + return (n - ((int) q) * d); 1.176 + } 1.177 + else 1.178 + { //bigint quotient 1.179 + Number bq = reduce(new BigDecimal(q).toBigInteger()); 1.180 + return (n - bq.doubleValue() * d); 1.181 + } 1.182 +} 1.183 + 1.184 +static public boolean equiv(Object x, Object y){ 1.185 + return equiv((Number) x, (Number) y); 1.186 +} 1.187 + 1.188 +static public boolean equiv(Number x, Number y){ 1.189 + return ops(x).combine(ops(y)).equiv(x, y); 1.190 +} 1.191 + 1.192 +static public boolean lt(Object x, Object y){ 1.193 + return ops(x).combine(ops(y)).lt((Number)x, (Number)y); 1.194 +} 1.195 + 1.196 +static public boolean lte(Object x, Object y){ 1.197 + return !ops(x).combine(ops(y)).lt((Number)y, (Number)x); 1.198 +} 1.199 + 1.200 +static public boolean gt(Object x, Object y){ 1.201 + return ops(x).combine(ops(y)).lt((Number)y, (Number)x); 1.202 +} 1.203 + 1.204 +static public boolean gte(Object x, Object y){ 1.205 + return !ops(x).combine(ops(y)).lt((Number)x, (Number)y); 1.206 +} 1.207 + 1.208 +static public int compare(Number x, Number y){ 1.209 + Ops ops = ops(x).combine(ops(y)); 1.210 + if(ops.lt(x, y)) 1.211 + return -1; 1.212 + else if(ops.lt(y, x)) 1.213 + return 1; 1.214 + return 0; 1.215 +} 1.216 + 1.217 +static BigInteger toBigInteger(Object x){ 1.218 + if(x instanceof BigInteger) 1.219 + return (BigInteger) x; 1.220 + else 1.221 + return BigInteger.valueOf(((Number) x).longValue()); 1.222 +} 1.223 + 1.224 +static BigDecimal toBigDecimal(Object x){ 1.225 + if(x instanceof BigDecimal) 1.226 + return (BigDecimal) x; 1.227 + else if(x instanceof BigInteger) 1.228 + return new BigDecimal((BigInteger) x); 1.229 + else 1.230 + return BigDecimal.valueOf(((Number) x).longValue()); 1.231 +} 1.232 + 1.233 +static Ratio toRatio(Object x){ 1.234 + if(x instanceof Ratio) 1.235 + return (Ratio) x; 1.236 + else if(x instanceof BigDecimal) 1.237 + { 1.238 + BigDecimal bx = (BigDecimal) x; 1.239 + BigInteger bv = bx.unscaledValue(); 1.240 + int scale = bx.scale(); 1.241 + if(scale < 0) 1.242 + return new Ratio(bv.multiply(BigInteger.TEN.pow(-scale)), BigInteger.ONE); 1.243 + else 1.244 + return new Ratio(bv, BigInteger.TEN.pow(scale)); 1.245 + } 1.246 + return new Ratio(toBigInteger(x), BigInteger.ONE); 1.247 +} 1.248 + 1.249 +static public Number rationalize(Number x){ 1.250 + if(x instanceof Float || x instanceof Double) 1.251 + return rationalize(BigDecimal.valueOf(x.doubleValue())); 1.252 + else if(x instanceof BigDecimal) 1.253 + { 1.254 + BigDecimal bx = (BigDecimal) x; 1.255 + BigInteger bv = bx.unscaledValue(); 1.256 + int scale = bx.scale(); 1.257 + if(scale < 0) 1.258 + return bv.multiply(BigInteger.TEN.pow(-scale)); 1.259 + else 1.260 + return divide(bv, BigInteger.TEN.pow(scale)); 1.261 + } 1.262 + return x; 1.263 +} 1.264 + 1.265 +static public Number reduce(Number val){ 1.266 + if(val instanceof Long) 1.267 + return reduce(val.longValue()); 1.268 + else if (val instanceof BigInteger) 1.269 + return reduce((BigInteger) val); 1.270 + return val; 1.271 +} 1.272 + 1.273 +static public Number reduce(BigInteger val){ 1.274 + int bitLength = val.bitLength(); 1.275 + if(bitLength < 32) 1.276 + return val.intValue(); 1.277 + else if(bitLength < 64) 1.278 + return val.longValue(); 1.279 + else 1.280 + return val; 1.281 +} 1.282 + 1.283 +static public Number reduce(long val){ 1.284 + if(val >= Integer.MIN_VALUE && val <= Integer.MAX_VALUE) 1.285 + return (int) val; 1.286 + else 1.287 + return val; 1.288 +} 1.289 + 1.290 +static public Number divide(BigInteger n, BigInteger d){ 1.291 + if(d.equals(BigInteger.ZERO)) 1.292 + throw new ArithmeticException("Divide by zero"); 1.293 + BigInteger gcd = n.gcd(d); 1.294 + if(gcd.equals(BigInteger.ZERO)) 1.295 + return 0; 1.296 + n = n.divide(gcd); 1.297 + d = d.divide(gcd); 1.298 + if(d.equals(BigInteger.ONE)) 1.299 + return reduce(n); 1.300 + else if(d.equals(BigInteger.ONE.negate())) 1.301 + return reduce(n.negate()); 1.302 + return new Ratio((d.signum() < 0 ? n.negate() : n), 1.303 + (d.signum() < 0 ? d.negate() : d)); 1.304 +} 1.305 + 1.306 +static public Number not(Object x){ 1.307 + return bitOps(x).not((Number)x); 1.308 +} 1.309 + 1.310 + 1.311 +static public Number and(Object x, Object y){ 1.312 + return bitOps(x).combine(bitOps(y)).and((Number)x, (Number)y); 1.313 +} 1.314 + 1.315 +static public Number or(Object x, Object y){ 1.316 + return bitOps(x).combine(bitOps(y)).or((Number)x, (Number)y); 1.317 +} 1.318 + 1.319 +static public Number xor(Object x, Object y){ 1.320 + return bitOps(x).combine(bitOps(y)).xor((Number)x, (Number)y); 1.321 +} 1.322 + 1.323 +static public Number andNot(Number x, Number y){ 1.324 + return bitOps(x).combine(bitOps(y)).andNot(x, y); 1.325 +} 1.326 + 1.327 +static public Number clearBit(Number x, int n){ 1.328 + if(n < 0) 1.329 + throw new ArithmeticException("Negative bit index"); 1.330 + return bitOps(x).clearBit(x, n); 1.331 +} 1.332 + 1.333 +static public Number setBit(Number x, int n){ 1.334 + if(n < 0) 1.335 + throw new ArithmeticException("Negative bit index"); 1.336 + return bitOps(x).setBit(x, n); 1.337 +} 1.338 + 1.339 +static public Number flipBit(Number x, int n){ 1.340 + if(n < 0) 1.341 + throw new ArithmeticException("Negative bit index"); 1.342 + return bitOps(x).flipBit(x, n); 1.343 +} 1.344 + 1.345 +static public boolean testBit(Number x, int n){ 1.346 + if(n < 0) 1.347 + throw new ArithmeticException("Negative bit index"); 1.348 + return bitOps(x).testBit(x, n); 1.349 +} 1.350 + 1.351 +static public Number shiftLeft(Object x, Object n){ 1.352 + return bitOps(x).shiftLeft((Number)x, ((Number)n).intValue()); 1.353 +} 1.354 + 1.355 +static public int shiftLeft(int x, int n){ 1.356 + return x << n; 1.357 +} 1.358 + 1.359 +static public Number shiftRight(Object x, Object n){ 1.360 + return bitOps(x).shiftRight((Number)x, ((Number)n).intValue()); 1.361 +} 1.362 + 1.363 +static public int shiftRight(int x, int n){ 1.364 + return x >> n; 1.365 +} 1.366 + 1.367 +final static class IntegerOps implements Ops{ 1.368 + public Ops combine(Ops y){ 1.369 + return y.opsWith(this); 1.370 + } 1.371 + 1.372 + final public Ops opsWith(IntegerOps x){ 1.373 + return this; 1.374 + } 1.375 + 1.376 + final public Ops opsWith(LongOps x){ 1.377 + return LONG_OPS; 1.378 + } 1.379 + 1.380 + final public Ops opsWith(FloatOps x){ 1.381 + return FLOAT_OPS; 1.382 + } 1.383 + 1.384 + final public Ops opsWith(DoubleOps x){ 1.385 + return DOUBLE_OPS; 1.386 + } 1.387 + 1.388 + final public Ops opsWith(RatioOps x){ 1.389 + return RATIO_OPS; 1.390 + } 1.391 + 1.392 + final public Ops opsWith(BigIntegerOps x){ 1.393 + return BIGINTEGER_OPS; 1.394 + } 1.395 + 1.396 + final public Ops opsWith(BigDecimalOps x){ 1.397 + return BIGDECIMAL_OPS; 1.398 + } 1.399 + 1.400 + public boolean isZero(Number x){ 1.401 + return x.intValue() == 0; 1.402 + } 1.403 + 1.404 + public boolean isPos(Number x){ 1.405 + return x.intValue() > 0; 1.406 + } 1.407 + 1.408 + public boolean isNeg(Number x){ 1.409 + return x.intValue() < 0; 1.410 + } 1.411 + 1.412 + final public Number add(Number x, Number y){ 1.413 + long ret = x.longValue() + y.longValue(); 1.414 + if(ret <= Integer.MAX_VALUE && ret >= Integer.MIN_VALUE) 1.415 + return (int) ret; 1.416 + return ret; 1.417 + } 1.418 + 1.419 + final public Number multiply(Number x, Number y){ 1.420 + long ret = x.longValue() * y.longValue(); 1.421 + if(ret <= Integer.MAX_VALUE && ret >= Integer.MIN_VALUE) 1.422 + return (int) ret; 1.423 + return ret; 1.424 + } 1.425 + 1.426 + static int gcd(int u, int v){ 1.427 + while(v != 0) 1.428 + { 1.429 + int r = u % v; 1.430 + u = v; 1.431 + v = r; 1.432 + } 1.433 + return u; 1.434 + } 1.435 + 1.436 + public Number divide(Number x, Number y){ 1.437 + int n = x.intValue(); 1.438 + int val = y.intValue(); 1.439 + int gcd = gcd(n, val); 1.440 + if(gcd == 0) 1.441 + return 0; 1.442 + 1.443 + n = n / gcd; 1.444 + int d = val / gcd; 1.445 + if(d == 1) 1.446 + return n; 1.447 + if(d < 0) 1.448 + { 1.449 + n = -n; 1.450 + d = -d; 1.451 + } 1.452 + return new Ratio(BigInteger.valueOf(n), BigInteger.valueOf(d)); 1.453 + } 1.454 + 1.455 + public Number quotient(Number x, Number y){ 1.456 + return x.intValue() / y.intValue(); 1.457 + } 1.458 + 1.459 + public Number remainder(Number x, Number y){ 1.460 + return x.intValue() % y.intValue(); 1.461 + } 1.462 + 1.463 + public boolean equiv(Number x, Number y){ 1.464 + return x.intValue() == y.intValue(); 1.465 + } 1.466 + 1.467 + public boolean lt(Number x, Number y){ 1.468 + return x.intValue() < y.intValue(); 1.469 + } 1.470 + 1.471 + //public Number subtract(Number x, Number y); 1.472 + final public Number negate(Number x){ 1.473 + int val = x.intValue(); 1.474 + if(val > Integer.MIN_VALUE) 1.475 + return -val; 1.476 + return -((long) val); 1.477 + } 1.478 + 1.479 + public Number inc(Number x){ 1.480 + int val = x.intValue(); 1.481 + if(val < Integer.MAX_VALUE) 1.482 + return val + 1; 1.483 + return (long) val + 1; 1.484 + } 1.485 + 1.486 + public Number dec(Number x){ 1.487 + int val = x.intValue(); 1.488 + if(val > Integer.MIN_VALUE) 1.489 + return val - 1; 1.490 + return (long) val - 1; 1.491 + } 1.492 +} 1.493 + 1.494 +final static class LongOps implements Ops{ 1.495 + public Ops combine(Ops y){ 1.496 + return y.opsWith(this); 1.497 + } 1.498 + 1.499 + final public Ops opsWith(IntegerOps x){ 1.500 + return this; 1.501 + } 1.502 + 1.503 + final public Ops opsWith(LongOps x){ 1.504 + return this; 1.505 + } 1.506 + 1.507 + final public Ops opsWith(FloatOps x){ 1.508 + return FLOAT_OPS; 1.509 + } 1.510 + 1.511 + final public Ops opsWith(DoubleOps x){ 1.512 + return DOUBLE_OPS; 1.513 + } 1.514 + 1.515 + final public Ops opsWith(RatioOps x){ 1.516 + return RATIO_OPS; 1.517 + } 1.518 + 1.519 + final public Ops opsWith(BigIntegerOps x){ 1.520 + return BIGINTEGER_OPS; 1.521 + } 1.522 + 1.523 + final public Ops opsWith(BigDecimalOps x){ 1.524 + return BIGDECIMAL_OPS; 1.525 + } 1.526 + 1.527 + public boolean isZero(Number x){ 1.528 + return x.longValue() == 0; 1.529 + } 1.530 + 1.531 + public boolean isPos(Number x){ 1.532 + return x.longValue() > 0; 1.533 + } 1.534 + 1.535 + public boolean isNeg(Number x){ 1.536 + return x.longValue() < 0; 1.537 + } 1.538 + 1.539 + final public Number add(Number x, Number y){ 1.540 + long lx = x.longValue(), ly = y.longValue(); 1.541 + long ret = lx + ly; 1.542 + if ((ret ^ lx) < 0 && (ret ^ ly) < 0) 1.543 + return BIGINTEGER_OPS.add(x, y); 1.544 + return ret; 1.545 + } 1.546 + 1.547 + final public Number multiply(Number x, Number y){ 1.548 + long lx = x.longValue(), ly = y.longValue(); 1.549 + long ret = lx * ly; 1.550 + if (ly != 0 && ret/ly != lx) 1.551 + return BIGINTEGER_OPS.multiply(x, y); 1.552 + return ret; 1.553 + } 1.554 + 1.555 + static long gcd(long u, long v){ 1.556 + while(v != 0) 1.557 + { 1.558 + long r = u % v; 1.559 + u = v; 1.560 + v = r; 1.561 + } 1.562 + return u; 1.563 + } 1.564 + 1.565 + public Number divide(Number x, Number y){ 1.566 + long n = x.longValue(); 1.567 + long val = y.longValue(); 1.568 + long gcd = gcd(n, val); 1.569 + if(gcd == 0) 1.570 + return 0; 1.571 + 1.572 + n = n / gcd; 1.573 + long d = val / gcd; 1.574 + if(d == 1) 1.575 + return n; 1.576 + if(d < 0) 1.577 + { 1.578 + n = -n; 1.579 + d = -d; 1.580 + } 1.581 + return new Ratio(BigInteger.valueOf(n), BigInteger.valueOf(d)); 1.582 + } 1.583 + 1.584 + public Number quotient(Number x, Number y){ 1.585 + return x.longValue() / y.longValue(); 1.586 + } 1.587 + 1.588 + public Number remainder(Number x, Number y){ 1.589 + return x.longValue() % y.longValue(); 1.590 + } 1.591 + 1.592 + public boolean equiv(Number x, Number y){ 1.593 + return x.longValue() == y.longValue(); 1.594 + } 1.595 + 1.596 + public boolean lt(Number x, Number y){ 1.597 + return x.longValue() < y.longValue(); 1.598 + } 1.599 + 1.600 + //public Number subtract(Number x, Number y); 1.601 + final public Number negate(Number x){ 1.602 + long val = x.longValue(); 1.603 + if(val > Long.MIN_VALUE) 1.604 + return -val; 1.605 + return BigInteger.valueOf(val).negate(); 1.606 + } 1.607 + 1.608 + public Number inc(Number x){ 1.609 + long val = x.longValue(); 1.610 + if(val < Long.MAX_VALUE) 1.611 + return val + 1; 1.612 + return BIGINTEGER_OPS.inc(x); 1.613 + } 1.614 + 1.615 + public Number dec(Number x){ 1.616 + long val = x.longValue(); 1.617 + if(val > Long.MIN_VALUE) 1.618 + return val - 1; 1.619 + return BIGINTEGER_OPS.dec(x); 1.620 + } 1.621 +} 1.622 + 1.623 +final static class FloatOps implements Ops{ 1.624 + public Ops combine(Ops y){ 1.625 + return y.opsWith(this); 1.626 + } 1.627 + 1.628 + final public Ops opsWith(IntegerOps x){ 1.629 + return this; 1.630 + } 1.631 + 1.632 + final public Ops opsWith(LongOps x){ 1.633 + return this; 1.634 + } 1.635 + 1.636 + final public Ops opsWith(FloatOps x){ 1.637 + return this; 1.638 + } 1.639 + 1.640 + final public Ops opsWith(DoubleOps x){ 1.641 + return DOUBLE_OPS; 1.642 + } 1.643 + 1.644 + final public Ops opsWith(RatioOps x){ 1.645 + return this; 1.646 + } 1.647 + 1.648 + final public Ops opsWith(BigIntegerOps x){ 1.649 + return this; 1.650 + } 1.651 + 1.652 + final public Ops opsWith(BigDecimalOps x){ 1.653 + return this; 1.654 + } 1.655 + 1.656 + public boolean isZero(Number x){ 1.657 + return x.floatValue() == 0; 1.658 + } 1.659 + 1.660 + public boolean isPos(Number x){ 1.661 + return x.floatValue() > 0; 1.662 + } 1.663 + 1.664 + public boolean isNeg(Number x){ 1.665 + return x.floatValue() < 0; 1.666 + } 1.667 + 1.668 + final public Number add(Number x, Number y){ 1.669 + return x.floatValue() + y.floatValue(); 1.670 + } 1.671 + 1.672 + final public Number multiply(Number x, Number y){ 1.673 + return x.floatValue() * y.floatValue(); 1.674 + } 1.675 + 1.676 + public Number divide(Number x, Number y){ 1.677 + return x.floatValue() / y.floatValue(); 1.678 + } 1.679 + 1.680 + public Number quotient(Number x, Number y){ 1.681 + return Numbers.quotient(x.doubleValue(), y.doubleValue()); 1.682 + } 1.683 + 1.684 + public Number remainder(Number x, Number y){ 1.685 + return Numbers.remainder(x.doubleValue(), y.doubleValue()); 1.686 + } 1.687 + 1.688 + public boolean equiv(Number x, Number y){ 1.689 + return x.floatValue() == y.floatValue(); 1.690 + } 1.691 + 1.692 + public boolean lt(Number x, Number y){ 1.693 + return x.floatValue() < y.floatValue(); 1.694 + } 1.695 + 1.696 + //public Number subtract(Number x, Number y); 1.697 + final public Number negate(Number x){ 1.698 + return -x.floatValue(); 1.699 + } 1.700 + 1.701 + public Number inc(Number x){ 1.702 + return x.floatValue() + 1; 1.703 + } 1.704 + 1.705 + public Number dec(Number x){ 1.706 + return x.floatValue() - 1; 1.707 + } 1.708 +} 1.709 + 1.710 +final static class DoubleOps implements Ops{ 1.711 + public Ops combine(Ops y){ 1.712 + return y.opsWith(this); 1.713 + } 1.714 + 1.715 + final public Ops opsWith(IntegerOps x){ 1.716 + return this; 1.717 + } 1.718 + 1.719 + final public Ops opsWith(LongOps x){ 1.720 + return this; 1.721 + } 1.722 + 1.723 + final public Ops opsWith(FloatOps x){ 1.724 + return this; 1.725 + } 1.726 + 1.727 + final public Ops opsWith(DoubleOps x){ 1.728 + return this; 1.729 + } 1.730 + 1.731 + final public Ops opsWith(RatioOps x){ 1.732 + return this; 1.733 + } 1.734 + 1.735 + final public Ops opsWith(BigIntegerOps x){ 1.736 + return this; 1.737 + } 1.738 + 1.739 + final public Ops opsWith(BigDecimalOps x){ 1.740 + return this; 1.741 + } 1.742 + 1.743 + public boolean isZero(Number x){ 1.744 + return x.doubleValue() == 0; 1.745 + } 1.746 + 1.747 + public boolean isPos(Number x){ 1.748 + return x.doubleValue() > 0; 1.749 + } 1.750 + 1.751 + public boolean isNeg(Number x){ 1.752 + return x.doubleValue() < 0; 1.753 + } 1.754 + 1.755 + final public Number add(Number x, Number y){ 1.756 + return x.doubleValue() + y.doubleValue(); 1.757 + } 1.758 + 1.759 + final public Number multiply(Number x, Number y){ 1.760 + return x.doubleValue() * y.doubleValue(); 1.761 + } 1.762 + 1.763 + public Number divide(Number x, Number y){ 1.764 + return x.doubleValue() / y.doubleValue(); 1.765 + } 1.766 + 1.767 + public Number quotient(Number x, Number y){ 1.768 + return Numbers.quotient(x.doubleValue(), y.doubleValue()); 1.769 + } 1.770 + 1.771 + public Number remainder(Number x, Number y){ 1.772 + return Numbers.remainder(x.doubleValue(), y.doubleValue()); 1.773 + } 1.774 + 1.775 + public boolean equiv(Number x, Number y){ 1.776 + return x.doubleValue() == y.doubleValue(); 1.777 + } 1.778 + 1.779 + public boolean lt(Number x, Number y){ 1.780 + return x.doubleValue() < y.doubleValue(); 1.781 + } 1.782 + 1.783 + //public Number subtract(Number x, Number y); 1.784 + final public Number negate(Number x){ 1.785 + return -x.doubleValue(); 1.786 + } 1.787 + 1.788 + public Number inc(Number x){ 1.789 + return x.doubleValue() + 1; 1.790 + } 1.791 + 1.792 + public Number dec(Number x){ 1.793 + return x.doubleValue() - 1; 1.794 + } 1.795 +} 1.796 + 1.797 +final static class RatioOps implements Ops{ 1.798 + public Ops combine(Ops y){ 1.799 + return y.opsWith(this); 1.800 + } 1.801 + 1.802 + final public Ops opsWith(IntegerOps x){ 1.803 + return this; 1.804 + } 1.805 + 1.806 + final public Ops opsWith(LongOps x){ 1.807 + return this; 1.808 + } 1.809 + 1.810 + final public Ops opsWith(FloatOps x){ 1.811 + return FLOAT_OPS; 1.812 + } 1.813 + 1.814 + final public Ops opsWith(DoubleOps x){ 1.815 + return DOUBLE_OPS; 1.816 + } 1.817 + 1.818 + final public Ops opsWith(RatioOps x){ 1.819 + return this; 1.820 + } 1.821 + 1.822 + final public Ops opsWith(BigIntegerOps x){ 1.823 + return this; 1.824 + } 1.825 + 1.826 + final public Ops opsWith(BigDecimalOps x){ 1.827 + return this; 1.828 + } 1.829 + 1.830 + public boolean isZero(Number x){ 1.831 + Ratio r = (Ratio) x; 1.832 + return r.numerator.signum() == 0; 1.833 + } 1.834 + 1.835 + public boolean isPos(Number x){ 1.836 + Ratio r = (Ratio) x; 1.837 + return r.numerator.signum() > 0; 1.838 + } 1.839 + 1.840 + public boolean isNeg(Number x){ 1.841 + Ratio r = (Ratio) x; 1.842 + return r.numerator.signum() < 0; 1.843 + } 1.844 + 1.845 + final public Number add(Number x, Number y){ 1.846 + Ratio rx = toRatio(x); 1.847 + Ratio ry = toRatio(y); 1.848 + return divide(ry.numerator.multiply(rx.denominator) 1.849 + .add(rx.numerator.multiply(ry.denominator)) 1.850 + , ry.denominator.multiply(rx.denominator)); 1.851 + } 1.852 + 1.853 + final public Number multiply(Number x, Number y){ 1.854 + Ratio rx = toRatio(x); 1.855 + Ratio ry = toRatio(y); 1.856 + return Numbers.divide(ry.numerator.multiply(rx.numerator) 1.857 + , ry.denominator.multiply(rx.denominator)); 1.858 + } 1.859 + 1.860 + public Number divide(Number x, Number y){ 1.861 + Ratio rx = toRatio(x); 1.862 + Ratio ry = toRatio(y); 1.863 + return Numbers.divide(ry.denominator.multiply(rx.numerator) 1.864 + , ry.numerator.multiply(rx.denominator)); 1.865 + } 1.866 + 1.867 + public Number quotient(Number x, Number y){ 1.868 + Ratio rx = toRatio(x); 1.869 + Ratio ry = toRatio(y); 1.870 + BigInteger q = rx.numerator.multiply(ry.denominator).divide( 1.871 + rx.denominator.multiply(ry.numerator)); 1.872 + return reduce(q); 1.873 + } 1.874 + 1.875 + public Number remainder(Number x, Number y){ 1.876 + Ratio rx = toRatio(x); 1.877 + Ratio ry = toRatio(y); 1.878 + BigInteger q = rx.numerator.multiply(ry.denominator).divide( 1.879 + rx.denominator.multiply(ry.numerator)); 1.880 + return Numbers.minus(x, Numbers.multiply(q, y)); 1.881 + } 1.882 + 1.883 + public boolean equiv(Number x, Number y){ 1.884 + Ratio rx = toRatio(x); 1.885 + Ratio ry = toRatio(y); 1.886 + return rx.numerator.equals(ry.numerator) 1.887 + && rx.denominator.equals(ry.denominator); 1.888 + } 1.889 + 1.890 + public boolean lt(Number x, Number y){ 1.891 + Ratio rx = toRatio(x); 1.892 + Ratio ry = toRatio(y); 1.893 + return Numbers.lt(rx.numerator.multiply(ry.denominator), ry.numerator.multiply(rx.denominator)); 1.894 + } 1.895 + 1.896 + //public Number subtract(Number x, Number y); 1.897 + final public Number negate(Number x){ 1.898 + Ratio r = (Ratio) x; 1.899 + return new Ratio(r.numerator.negate(), r.denominator); 1.900 + } 1.901 + 1.902 + public Number inc(Number x){ 1.903 + return Numbers.add(x, 1); 1.904 + } 1.905 + 1.906 + public Number dec(Number x){ 1.907 + return Numbers.add(x, -1); 1.908 + } 1.909 + 1.910 +} 1.911 + 1.912 +final static class BigIntegerOps implements Ops{ 1.913 + public Ops combine(Ops y){ 1.914 + return y.opsWith(this); 1.915 + } 1.916 + 1.917 + final public Ops opsWith(IntegerOps x){ 1.918 + return this; 1.919 + } 1.920 + 1.921 + final public Ops opsWith(LongOps x){ 1.922 + return this; 1.923 + } 1.924 + 1.925 + final public Ops opsWith(FloatOps x){ 1.926 + return FLOAT_OPS; 1.927 + } 1.928 + 1.929 + final public Ops opsWith(DoubleOps x){ 1.930 + return DOUBLE_OPS; 1.931 + } 1.932 + 1.933 + final public Ops opsWith(RatioOps x){ 1.934 + return RATIO_OPS; 1.935 + } 1.936 + 1.937 + final public Ops opsWith(BigIntegerOps x){ 1.938 + return this; 1.939 + } 1.940 + 1.941 + final public Ops opsWith(BigDecimalOps x){ 1.942 + return BIGDECIMAL_OPS; 1.943 + } 1.944 + 1.945 + public boolean isZero(Number x){ 1.946 + BigInteger bx = toBigInteger(x); 1.947 + return bx.signum() == 0; 1.948 + } 1.949 + 1.950 + public boolean isPos(Number x){ 1.951 + BigInteger bx = toBigInteger(x); 1.952 + return bx.signum() > 0; 1.953 + } 1.954 + 1.955 + public boolean isNeg(Number x){ 1.956 + BigInteger bx = toBigInteger(x); 1.957 + return bx.signum() < 0; 1.958 + } 1.959 + 1.960 + final public Number add(Number x, Number y){ 1.961 + return reduce(toBigInteger(x).add(toBigInteger(y))); 1.962 + } 1.963 + 1.964 + final public Number multiply(Number x, Number y){ 1.965 + return reduce(toBigInteger(x).multiply(toBigInteger(y))); 1.966 + } 1.967 + 1.968 + public Number divide(Number x, Number y){ 1.969 + return Numbers.divide(toBigInteger(x), toBigInteger(y)); 1.970 + } 1.971 + 1.972 + public Number quotient(Number x, Number y){ 1.973 + return toBigInteger(x).divide(toBigInteger(y)); 1.974 + } 1.975 + 1.976 + public Number remainder(Number x, Number y){ 1.977 + return toBigInteger(x).remainder(toBigInteger(y)); 1.978 + } 1.979 + 1.980 + public boolean equiv(Number x, Number y){ 1.981 + return toBigInteger(x).equals(toBigInteger(y)); 1.982 + } 1.983 + 1.984 + public boolean lt(Number x, Number y){ 1.985 + return toBigInteger(x).compareTo(toBigInteger(y)) < 0; 1.986 + } 1.987 + 1.988 + //public Number subtract(Number x, Number y); 1.989 + final public Number negate(Number x){ 1.990 + return toBigInteger(x).negate(); 1.991 + } 1.992 + 1.993 + public Number inc(Number x){ 1.994 + BigInteger bx = toBigInteger(x); 1.995 + return reduce(bx.add(BigInteger.ONE)); 1.996 + } 1.997 + 1.998 + public Number dec(Number x){ 1.999 + BigInteger bx = toBigInteger(x); 1.1000 + return reduce(bx.subtract(BigInteger.ONE)); 1.1001 + } 1.1002 +} 1.1003 + 1.1004 +final static class BigDecimalOps implements Ops{ 1.1005 + final static Var MATH_CONTEXT = RT.MATH_CONTEXT; 1.1006 + 1.1007 + public Ops combine(Ops y){ 1.1008 + return y.opsWith(this); 1.1009 + } 1.1010 + 1.1011 + final public Ops opsWith(IntegerOps x){ 1.1012 + return this; 1.1013 + } 1.1014 + 1.1015 + final public Ops opsWith(LongOps x){ 1.1016 + return this; 1.1017 + } 1.1018 + 1.1019 + final public Ops opsWith(FloatOps x){ 1.1020 + return FLOAT_OPS; 1.1021 + } 1.1022 + 1.1023 + final public Ops opsWith(DoubleOps x){ 1.1024 + return DOUBLE_OPS; 1.1025 + } 1.1026 + 1.1027 + final public Ops opsWith(RatioOps x){ 1.1028 + return RATIO_OPS; 1.1029 + } 1.1030 + 1.1031 + final public Ops opsWith(BigIntegerOps x){ 1.1032 + return this; 1.1033 + } 1.1034 + 1.1035 + final public Ops opsWith(BigDecimalOps x){ 1.1036 + return this; 1.1037 + } 1.1038 + 1.1039 + public boolean isZero(Number x){ 1.1040 + BigDecimal bx = (BigDecimal) x; 1.1041 + return bx.signum() == 0; 1.1042 + } 1.1043 + 1.1044 + public boolean isPos(Number x){ 1.1045 + BigDecimal bx = (BigDecimal) x; 1.1046 + return bx.signum() > 0; 1.1047 + } 1.1048 + 1.1049 + public boolean isNeg(Number x){ 1.1050 + BigDecimal bx = (BigDecimal) x; 1.1051 + return bx.signum() < 0; 1.1052 + } 1.1053 + 1.1054 + final public Number add(Number x, Number y){ 1.1055 + MathContext mc = (MathContext) MATH_CONTEXT.deref(); 1.1056 + return mc == null 1.1057 + ? toBigDecimal(x).add(toBigDecimal(y)) 1.1058 + : toBigDecimal(x).add(toBigDecimal(y), mc); 1.1059 + } 1.1060 + 1.1061 + final public Number multiply(Number x, Number y){ 1.1062 + MathContext mc = (MathContext) MATH_CONTEXT.deref(); 1.1063 + return mc == null 1.1064 + ? toBigDecimal(x).multiply(toBigDecimal(y)) 1.1065 + : toBigDecimal(x).multiply(toBigDecimal(y), mc); 1.1066 + } 1.1067 + 1.1068 + public Number divide(Number x, Number y){ 1.1069 + MathContext mc = (MathContext) MATH_CONTEXT.deref(); 1.1070 + return mc == null 1.1071 + ? toBigDecimal(x).divide(toBigDecimal(y)) 1.1072 + : toBigDecimal(x).divide(toBigDecimal(y), mc); 1.1073 + } 1.1074 + 1.1075 + public Number quotient(Number x, Number y){ 1.1076 + MathContext mc = (MathContext) MATH_CONTEXT.deref(); 1.1077 + return mc == null 1.1078 + ? toBigDecimal(x).divideToIntegralValue(toBigDecimal(y)) 1.1079 + : toBigDecimal(x).divideToIntegralValue(toBigDecimal(y), mc); 1.1080 + } 1.1081 + 1.1082 + public Number remainder(Number x, Number y){ 1.1083 + MathContext mc = (MathContext) MATH_CONTEXT.deref(); 1.1084 + return mc == null 1.1085 + ? toBigDecimal(x).remainder(toBigDecimal(y)) 1.1086 + : toBigDecimal(x).remainder(toBigDecimal(y), mc); 1.1087 + } 1.1088 + 1.1089 + public boolean equiv(Number x, Number y){ 1.1090 + return toBigDecimal(x).equals(toBigDecimal(y)); 1.1091 + } 1.1092 + 1.1093 + public boolean lt(Number x, Number y){ 1.1094 + return toBigDecimal(x).compareTo(toBigDecimal(y)) < 0; 1.1095 + } 1.1096 + 1.1097 + //public Number subtract(Number x, Number y); 1.1098 + final public Number negate(Number x){ 1.1099 + MathContext mc = (MathContext) MATH_CONTEXT.deref(); 1.1100 + return mc == null 1.1101 + ? ((BigDecimal) x).negate() 1.1102 + : ((BigDecimal) x).negate(mc); 1.1103 + } 1.1104 + 1.1105 + public Number inc(Number x){ 1.1106 + MathContext mc = (MathContext) MATH_CONTEXT.deref(); 1.1107 + BigDecimal bx = (BigDecimal) x; 1.1108 + return mc == null 1.1109 + ? bx.add(BigDecimal.ONE) 1.1110 + : bx.add(BigDecimal.ONE, mc); 1.1111 + } 1.1112 + 1.1113 + public Number dec(Number x){ 1.1114 + MathContext mc = (MathContext) MATH_CONTEXT.deref(); 1.1115 + BigDecimal bx = (BigDecimal) x; 1.1116 + return mc == null 1.1117 + ? bx.subtract(BigDecimal.ONE) 1.1118 + : bx.subtract(BigDecimal.ONE, mc); 1.1119 + } 1.1120 +} 1.1121 + 1.1122 +final static class IntegerBitOps implements BitOps{ 1.1123 + public BitOps combine(BitOps y){ 1.1124 + return y.bitOpsWith(this); 1.1125 + } 1.1126 + 1.1127 + final public BitOps bitOpsWith(IntegerBitOps x){ 1.1128 + return this; 1.1129 + } 1.1130 + 1.1131 + final public BitOps bitOpsWith(LongBitOps x){ 1.1132 + return LONG_BITOPS; 1.1133 + } 1.1134 + 1.1135 + final public BitOps bitOpsWith(BigIntegerBitOps x){ 1.1136 + return BIGINTEGER_BITOPS; 1.1137 + } 1.1138 + 1.1139 + 1.1140 + public Number not(Number x){ 1.1141 + return ~x.intValue(); 1.1142 + } 1.1143 + 1.1144 + public Number and(Number x, Number y){ 1.1145 + return x.intValue() & y.intValue(); 1.1146 + } 1.1147 + 1.1148 + public Number or(Number x, Number y){ 1.1149 + return x.intValue() | y.intValue(); 1.1150 + } 1.1151 + 1.1152 + public Number xor(Number x, Number y){ 1.1153 + return x.intValue() ^ y.intValue(); 1.1154 + } 1.1155 + 1.1156 + public Number andNot(Number x, Number y){ 1.1157 + return x.intValue() & ~y.intValue(); 1.1158 + } 1.1159 + 1.1160 + public Number clearBit(Number x, int n){ 1.1161 + if(n < 31) 1.1162 + return x.intValue() & ~(1 << n); 1.1163 + else if(n < 63) 1.1164 + return x.longValue() & ~(1L << n); 1.1165 + else 1.1166 + return toBigInteger(x).clearBit(n); 1.1167 + } 1.1168 + 1.1169 + public Number setBit(Number x, int n){ 1.1170 + if(n < 31) 1.1171 + return x.intValue() | (1 << n); 1.1172 + else if(n < 63) 1.1173 + return x.longValue() | (1L << n); 1.1174 + else 1.1175 + return toBigInteger(x).setBit(n); 1.1176 + } 1.1177 + 1.1178 + public Number flipBit(Number x, int n){ 1.1179 + if(n < 31) 1.1180 + return x.intValue() ^ (1 << n); 1.1181 + else if(n < 63) 1.1182 + return x.longValue() ^ (1L << n); 1.1183 + else 1.1184 + return toBigInteger(x).flipBit(n); 1.1185 + } 1.1186 + 1.1187 + public boolean testBit(Number x, int n){ 1.1188 + if(n < 32) 1.1189 + return (x.intValue() & (1 << n)) != 0; 1.1190 + else if(n < 64) 1.1191 + return (x.longValue() & (1L << n)) != 0; 1.1192 + else 1.1193 + return toBigInteger(x).testBit(n); 1.1194 + } 1.1195 + 1.1196 + public Number shiftLeft(Number x, int n){ 1.1197 + if(n < 32) 1.1198 + { 1.1199 + if(n < 0) 1.1200 + return shiftRight(x, -n); 1.1201 + return reduce(x.longValue() << n); 1.1202 + } 1.1203 + else 1.1204 + return reduce(toBigInteger(x).shiftLeft(n)); 1.1205 + } 1.1206 + 1.1207 + public Number shiftRight(Number x, int n){ 1.1208 + if(n < 0) 1.1209 + return shiftLeft(x, -n); 1.1210 + return x.intValue() >> n; 1.1211 + } 1.1212 +} 1.1213 + 1.1214 +final static class LongBitOps implements BitOps{ 1.1215 + public BitOps combine(BitOps y){ 1.1216 + return y.bitOpsWith(this); 1.1217 + } 1.1218 + 1.1219 + final public BitOps bitOpsWith(IntegerBitOps x){ 1.1220 + return this; 1.1221 + } 1.1222 + 1.1223 + final public BitOps bitOpsWith(LongBitOps x){ 1.1224 + return this; 1.1225 + } 1.1226 + 1.1227 + final public BitOps bitOpsWith(BigIntegerBitOps x){ 1.1228 + return BIGINTEGER_BITOPS; 1.1229 + } 1.1230 + 1.1231 + public Number not(Number x){ 1.1232 + return ~x.longValue(); 1.1233 + } 1.1234 + 1.1235 + public Number and(Number x, Number y){ 1.1236 + return x.longValue() & y.longValue(); 1.1237 + } 1.1238 + 1.1239 + public Number or(Number x, Number y){ 1.1240 + return x.longValue() | y.longValue(); 1.1241 + } 1.1242 + 1.1243 + public Number xor(Number x, Number y){ 1.1244 + return x.longValue() ^ y.longValue(); 1.1245 + } 1.1246 + 1.1247 + public Number andNot(Number x, Number y){ 1.1248 + return x.longValue() & ~y.longValue(); 1.1249 + } 1.1250 + 1.1251 + public Number clearBit(Number x, int n){ 1.1252 + if(n < 63) 1.1253 + return x.longValue() & ~(1L << n); 1.1254 + else 1.1255 + return toBigInteger(x).clearBit(n); 1.1256 + } 1.1257 + 1.1258 + public Number setBit(Number x, int n){ 1.1259 + if(n < 63) 1.1260 + return x.longValue() | (1L << n); 1.1261 + else 1.1262 + return toBigInteger(x).setBit(n); 1.1263 + } 1.1264 + 1.1265 + public Number flipBit(Number x, int n){ 1.1266 + if(n < 63) 1.1267 + return x.longValue() ^ (1L << n); 1.1268 + else 1.1269 + return toBigInteger(x).flipBit(n); 1.1270 + } 1.1271 + 1.1272 + public boolean testBit(Number x, int n){ 1.1273 + if(n < 64) 1.1274 + return (x.longValue() & (1L << n)) != 0; 1.1275 + else 1.1276 + return toBigInteger(x).testBit(n); 1.1277 + } 1.1278 + 1.1279 + public Number shiftLeft(Number x, int n){ 1.1280 + if(n < 0) 1.1281 + return shiftRight(x, -n); 1.1282 + return reduce(toBigInteger(x).shiftLeft(n)); 1.1283 + } 1.1284 + 1.1285 + public Number shiftRight(Number x, int n){ 1.1286 + if(n < 0) 1.1287 + return shiftLeft(x, -n); 1.1288 + return x.longValue() >> n; 1.1289 + } 1.1290 +} 1.1291 + 1.1292 +final static class BigIntegerBitOps implements BitOps{ 1.1293 + public BitOps combine(BitOps y){ 1.1294 + return y.bitOpsWith(this); 1.1295 + } 1.1296 + 1.1297 + final public BitOps bitOpsWith(IntegerBitOps x){ 1.1298 + return this; 1.1299 + } 1.1300 + 1.1301 + final public BitOps bitOpsWith(LongBitOps x){ 1.1302 + return this; 1.1303 + } 1.1304 + 1.1305 + final public BitOps bitOpsWith(BigIntegerBitOps x){ 1.1306 + return this; 1.1307 + } 1.1308 + 1.1309 + public Number not(Number x){ 1.1310 + return toBigInteger(x).not(); 1.1311 + } 1.1312 + 1.1313 + public Number and(Number x, Number y){ 1.1314 + return toBigInteger(x).and(toBigInteger(y)); 1.1315 + } 1.1316 + 1.1317 + public Number or(Number x, Number y){ 1.1318 + return toBigInteger(x).or(toBigInteger(y)); 1.1319 + } 1.1320 + 1.1321 + public Number xor(Number x, Number y){ 1.1322 + return toBigInteger(x).xor(toBigInteger(y)); 1.1323 + } 1.1324 + 1.1325 + public Number andNot(Number x, Number y){ 1.1326 + return toBigInteger(x).andNot(toBigInteger(y)); 1.1327 + } 1.1328 + 1.1329 + public Number clearBit(Number x, int n){ 1.1330 + return toBigInteger(x).clearBit(n); 1.1331 + } 1.1332 + 1.1333 + public Number setBit(Number x, int n){ 1.1334 + return toBigInteger(x).setBit(n); 1.1335 + } 1.1336 + 1.1337 + public Number flipBit(Number x, int n){ 1.1338 + return toBigInteger(x).flipBit(n); 1.1339 + } 1.1340 + 1.1341 + public boolean testBit(Number x, int n){ 1.1342 + return toBigInteger(x).testBit(n); 1.1343 + } 1.1344 + 1.1345 + public Number shiftLeft(Number x, int n){ 1.1346 + return toBigInteger(x).shiftLeft(n); 1.1347 + } 1.1348 + 1.1349 + public Number shiftRight(Number x, int n){ 1.1350 + return toBigInteger(x).shiftRight(n); 1.1351 + } 1.1352 +} 1.1353 + 1.1354 +static final IntegerOps INTEGER_OPS = new IntegerOps(); 1.1355 +static final LongOps LONG_OPS = new LongOps(); 1.1356 +static final FloatOps FLOAT_OPS = new FloatOps(); 1.1357 +static final DoubleOps DOUBLE_OPS = new DoubleOps(); 1.1358 +static final RatioOps RATIO_OPS = new RatioOps(); 1.1359 +static final BigIntegerOps BIGINTEGER_OPS = new BigIntegerOps(); 1.1360 +static final BigDecimalOps BIGDECIMAL_OPS = new BigDecimalOps(); 1.1361 + 1.1362 +static final IntegerBitOps INTEGER_BITOPS = new IntegerBitOps(); 1.1363 +static final LongBitOps LONG_BITOPS = new LongBitOps(); 1.1364 +static final BigIntegerBitOps BIGINTEGER_BITOPS = new BigIntegerBitOps(); 1.1365 + 1.1366 +static Ops ops(Object x){ 1.1367 + Class xc = x.getClass(); 1.1368 + 1.1369 + if(xc == Integer.class) 1.1370 + return INTEGER_OPS; 1.1371 + else if(xc == Double.class) 1.1372 + return DOUBLE_OPS; 1.1373 + else if(xc == Float.class) 1.1374 + return FLOAT_OPS; 1.1375 + else if(xc == BigInteger.class) 1.1376 + return BIGINTEGER_OPS; 1.1377 + else if(xc == Long.class) 1.1378 + return LONG_OPS; 1.1379 + else if(xc == Ratio.class) 1.1380 + return RATIO_OPS; 1.1381 + else if(xc == BigDecimal.class) 1.1382 + return BIGDECIMAL_OPS; 1.1383 + else 1.1384 + return INTEGER_OPS; 1.1385 +} 1.1386 + 1.1387 +static BitOps bitOps(Object x){ 1.1388 + Class xc = x.getClass(); 1.1389 + 1.1390 + if(xc == Integer.class) 1.1391 + return INTEGER_BITOPS; 1.1392 + else if(xc == Long.class) 1.1393 + return LONG_BITOPS; 1.1394 + else if(xc == BigInteger.class) 1.1395 + return BIGINTEGER_BITOPS; 1.1396 + else if(xc == Double.class || xc == Float.class || xc == BigDecimalOps.class || xc == Ratio.class) 1.1397 + throw new ArithmeticException("bit operation on non integer type: " + xc); 1.1398 + else 1.1399 + return INTEGER_BITOPS; 1.1400 +} 1.1401 + 1.1402 +//final static ExecutorService executor = Executors.newCachedThreadPool(); 1.1403 +//static public int minChunk = 100; 1.1404 +//static int chunkSize(int alength){ 1.1405 +// return Math.max(alength / Runtime.getRuntime().availableProcessors(), minChunk); 1.1406 +//} 1.1407 + 1.1408 +// } 1.1409 +// else 1.1410 +// { 1.1411 +// LinkedList<Callable<Float>> ops = new LinkedList<Callable<Float>>(); 1.1412 +// for(int offset = 0;offset < xs.length;offset+=chunk) 1.1413 +// { 1.1414 +// final int start = offset; 1.1415 +// final int end = Math.min(xs.length, start + chunk); 1.1416 +// ops.add(new Callable<Float>(){ 1.1417 +// public Float call() throws Exception{ 1.1418 +// for(int i=start;i<end;i++) 1.1419 +// xs[i] += ys[i]; 1.1420 +// return null; 1.1421 +// }}); 1.1422 +// } 1.1423 +// executor.invokeAll(ops); 1.1424 +// } 1.1425 + 1.1426 + 1.1427 + static public float[] float_array(int size, Object init){ 1.1428 + float[] ret = new float[size]; 1.1429 + if(init instanceof Number) 1.1430 + { 1.1431 + float f = ((Number) init).floatValue(); 1.1432 + for(int i = 0; i < ret.length; i++) 1.1433 + ret[i] = f; 1.1434 + } 1.1435 + else 1.1436 + { 1.1437 + ISeq s = RT.seq(init); 1.1438 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1439 + ret[i] = ((Number) s.first()).floatValue(); 1.1440 + } 1.1441 + return ret; 1.1442 + } 1.1443 + 1.1444 + static public float[] float_array(Object sizeOrSeq){ 1.1445 + if(sizeOrSeq instanceof Number) 1.1446 + return new float[((Number) sizeOrSeq).intValue()]; 1.1447 + else 1.1448 + { 1.1449 + ISeq s = RT.seq(sizeOrSeq); 1.1450 + int size = RT.count(s); 1.1451 + float[] ret = new float[size]; 1.1452 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1453 + ret[i] = ((Number) s.first()).floatValue(); 1.1454 + return ret; 1.1455 + } 1.1456 + } 1.1457 + 1.1458 +static public double[] double_array(int size, Object init){ 1.1459 + double[] ret = new double[size]; 1.1460 + if(init instanceof Number) 1.1461 + { 1.1462 + double f = ((Number) init).doubleValue(); 1.1463 + for(int i = 0; i < ret.length; i++) 1.1464 + ret[i] = f; 1.1465 + } 1.1466 + else 1.1467 + { 1.1468 + ISeq s = RT.seq(init); 1.1469 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1470 + ret[i] = ((Number) s.first()).doubleValue(); 1.1471 + } 1.1472 + return ret; 1.1473 +} 1.1474 + 1.1475 +static public double[] double_array(Object sizeOrSeq){ 1.1476 + if(sizeOrSeq instanceof Number) 1.1477 + return new double[((Number) sizeOrSeq).intValue()]; 1.1478 + else 1.1479 + { 1.1480 + ISeq s = RT.seq(sizeOrSeq); 1.1481 + int size = RT.count(s); 1.1482 + double[] ret = new double[size]; 1.1483 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1484 + ret[i] = ((Number) s.first()).doubleValue(); 1.1485 + return ret; 1.1486 + } 1.1487 +} 1.1488 + 1.1489 +static public int[] int_array(int size, Object init){ 1.1490 + int[] ret = new int[size]; 1.1491 + if(init instanceof Number) 1.1492 + { 1.1493 + int f = ((Number) init).intValue(); 1.1494 + for(int i = 0; i < ret.length; i++) 1.1495 + ret[i] = f; 1.1496 + } 1.1497 + else 1.1498 + { 1.1499 + ISeq s = RT.seq(init); 1.1500 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1501 + ret[i] = ((Number) s.first()).intValue(); 1.1502 + } 1.1503 + return ret; 1.1504 +} 1.1505 + 1.1506 +static public int[] int_array(Object sizeOrSeq){ 1.1507 + if(sizeOrSeq instanceof Number) 1.1508 + return new int[((Number) sizeOrSeq).intValue()]; 1.1509 + else 1.1510 + { 1.1511 + ISeq s = RT.seq(sizeOrSeq); 1.1512 + int size = RT.count(s); 1.1513 + int[] ret = new int[size]; 1.1514 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1515 + ret[i] = ((Number) s.first()).intValue(); 1.1516 + return ret; 1.1517 + } 1.1518 +} 1.1519 + 1.1520 +static public long[] long_array(int size, Object init){ 1.1521 + long[] ret = new long[size]; 1.1522 + if(init instanceof Number) 1.1523 + { 1.1524 + long f = ((Number) init).longValue(); 1.1525 + for(int i = 0; i < ret.length; i++) 1.1526 + ret[i] = f; 1.1527 + } 1.1528 + else 1.1529 + { 1.1530 + ISeq s = RT.seq(init); 1.1531 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1532 + ret[i] = ((Number) s.first()).longValue(); 1.1533 + } 1.1534 + return ret; 1.1535 +} 1.1536 + 1.1537 +static public long[] long_array(Object sizeOrSeq){ 1.1538 + if(sizeOrSeq instanceof Number) 1.1539 + return new long[((Number) sizeOrSeq).intValue()]; 1.1540 + else 1.1541 + { 1.1542 + ISeq s = RT.seq(sizeOrSeq); 1.1543 + int size = RT.count(s); 1.1544 + long[] ret = new long[size]; 1.1545 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1546 + ret[i] = ((Number) s.first()).longValue(); 1.1547 + return ret; 1.1548 + } 1.1549 +} 1.1550 + 1.1551 +static public short[] short_array(int size, Object init){ 1.1552 + short[] ret = new short[size]; 1.1553 + if(init instanceof Short) 1.1554 + { 1.1555 + short s = (Short) init; 1.1556 + for(int i = 0; i < ret.length; i++) 1.1557 + ret[i] = s; 1.1558 + } 1.1559 + else 1.1560 + { 1.1561 + ISeq s = RT.seq(init); 1.1562 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1563 + ret[i] = (Short) s.first(); 1.1564 + } 1.1565 + return ret; 1.1566 +} 1.1567 + 1.1568 +static public short[] short_array(Object sizeOrSeq){ 1.1569 + if(sizeOrSeq instanceof Number) 1.1570 + return new short[((Number) sizeOrSeq).intValue()]; 1.1571 + else 1.1572 + { 1.1573 + ISeq s = RT.seq(sizeOrSeq); 1.1574 + int size = RT.count(s); 1.1575 + short[] ret = new short[size]; 1.1576 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1577 + ret[i] = (Short) s.first(); 1.1578 + return ret; 1.1579 + } 1.1580 +} 1.1581 + 1.1582 +static public char[] char_array(int size, Object init){ 1.1583 + char[] ret = new char[size]; 1.1584 + if(init instanceof Character) 1.1585 + { 1.1586 + char c = (Character) init; 1.1587 + for(int i = 0; i < ret.length; i++) 1.1588 + ret[i] = c; 1.1589 + } 1.1590 + else 1.1591 + { 1.1592 + ISeq s = RT.seq(init); 1.1593 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1594 + ret[i] = (Character) s.first(); 1.1595 + } 1.1596 + return ret; 1.1597 +} 1.1598 + 1.1599 +static public char[] char_array(Object sizeOrSeq){ 1.1600 + if(sizeOrSeq instanceof Number) 1.1601 + return new char[((Number) sizeOrSeq).intValue()]; 1.1602 + else 1.1603 + { 1.1604 + ISeq s = RT.seq(sizeOrSeq); 1.1605 + int size = RT.count(s); 1.1606 + char[] ret = new char[size]; 1.1607 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1608 + ret[i] = (Character) s.first(); 1.1609 + return ret; 1.1610 + } 1.1611 +} 1.1612 + 1.1613 +static public byte[] byte_array(int size, Object init){ 1.1614 + byte[] ret = new byte[size]; 1.1615 + if(init instanceof Byte) 1.1616 + { 1.1617 + byte b = (Byte) init; 1.1618 + for(int i = 0; i < ret.length; i++) 1.1619 + ret[i] = b; 1.1620 + } 1.1621 + else 1.1622 + { 1.1623 + ISeq s = RT.seq(init); 1.1624 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1625 + ret[i] = (Byte) s.first(); 1.1626 + } 1.1627 + return ret; 1.1628 +} 1.1629 + 1.1630 +static public byte[] byte_array(Object sizeOrSeq){ 1.1631 + if(sizeOrSeq instanceof Number) 1.1632 + return new byte[((Number) sizeOrSeq).intValue()]; 1.1633 + else 1.1634 + { 1.1635 + ISeq s = RT.seq(sizeOrSeq); 1.1636 + int size = RT.count(s); 1.1637 + byte[] ret = new byte[size]; 1.1638 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1639 + ret[i] = (Byte)s.first(); 1.1640 + return ret; 1.1641 + } 1.1642 +} 1.1643 + 1.1644 +static public boolean[] boolean_array(int size, Object init){ 1.1645 + boolean[] ret = new boolean[size]; 1.1646 + if(init instanceof Boolean) 1.1647 + { 1.1648 + boolean b = (Boolean) init; 1.1649 + for(int i = 0; i < ret.length; i++) 1.1650 + ret[i] = b; 1.1651 + } 1.1652 + else 1.1653 + { 1.1654 + ISeq s = RT.seq(init); 1.1655 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1656 + ret[i] = (Boolean)s.first(); 1.1657 + } 1.1658 + return ret; 1.1659 +} 1.1660 + 1.1661 +static public boolean[] boolean_array(Object sizeOrSeq){ 1.1662 + if(sizeOrSeq instanceof Number) 1.1663 + return new boolean[((Number) sizeOrSeq).intValue()]; 1.1664 + else 1.1665 + { 1.1666 + ISeq s = RT.seq(sizeOrSeq); 1.1667 + int size = RT.count(s); 1.1668 + boolean[] ret = new boolean[size]; 1.1669 + for(int i = 0; i < size && s != null; i++, s = s.next()) 1.1670 + ret[i] = (Boolean)s.first(); 1.1671 + return ret; 1.1672 + } 1.1673 +} 1.1674 + 1.1675 +static public boolean[] booleans(Object array){ 1.1676 + return (boolean[]) array; 1.1677 +} 1.1678 + 1.1679 +static public byte[] bytes(Object array){ 1.1680 + return (byte[]) array; 1.1681 +} 1.1682 + 1.1683 +static public char[] chars(Object array){ 1.1684 + return (char[]) array; 1.1685 +} 1.1686 + 1.1687 +static public short[] shorts(Object array){ 1.1688 + return (short[]) array; 1.1689 +} 1.1690 + 1.1691 +static public float[] floats(Object array){ 1.1692 + return (float[]) array; 1.1693 +} 1.1694 + 1.1695 +static public double[] doubles(Object array){ 1.1696 + return (double[]) array; 1.1697 +} 1.1698 + 1.1699 +static public int[] ints(Object array){ 1.1700 + return (int[]) array; 1.1701 +} 1.1702 + 1.1703 +static public long[] longs(Object array){ 1.1704 + return (long[]) array; 1.1705 +} 1.1706 + 1.1707 +static public Number num(Object x){ 1.1708 + return (Number) x; 1.1709 +} 1.1710 + 1.1711 +static public Number num(float x){ 1.1712 + return x; 1.1713 +} 1.1714 + 1.1715 +static public float add(float x, float y){ 1.1716 + return x + y; 1.1717 +} 1.1718 + 1.1719 +static public float minus(float x, float y){ 1.1720 + return x - y; 1.1721 +} 1.1722 + 1.1723 +static public float minus(float x){ 1.1724 + return -x; 1.1725 +} 1.1726 + 1.1727 +static public float inc(float x){ 1.1728 + return x + 1; 1.1729 +} 1.1730 + 1.1731 +static public float dec(float x){ 1.1732 + return x - 1; 1.1733 +} 1.1734 + 1.1735 +static public float multiply(float x, float y){ 1.1736 + return x * y; 1.1737 +} 1.1738 + 1.1739 +static public float divide(float x, float y){ 1.1740 + return x / y; 1.1741 +} 1.1742 + 1.1743 +static public boolean equiv(float x, float y){ 1.1744 + return x == y; 1.1745 +} 1.1746 + 1.1747 +static public boolean lt(float x, float y){ 1.1748 + return x < y; 1.1749 +} 1.1750 + 1.1751 +static public boolean lte(float x, float y){ 1.1752 + return x <= y; 1.1753 +} 1.1754 + 1.1755 +static public boolean gt(float x, float y){ 1.1756 + return x > y; 1.1757 +} 1.1758 + 1.1759 +static public boolean gte(float x, float y){ 1.1760 + return x >= y; 1.1761 +} 1.1762 + 1.1763 +static public boolean isPos(float x){ 1.1764 + return x > 0; 1.1765 +} 1.1766 + 1.1767 +static public boolean isNeg(float x){ 1.1768 + return x < 0; 1.1769 +} 1.1770 + 1.1771 +static public boolean isZero(float x){ 1.1772 + return x == 0; 1.1773 +} 1.1774 + 1.1775 +static public Number num(double x){ 1.1776 + return x; 1.1777 +} 1.1778 + 1.1779 +static public double add(double x, double y){ 1.1780 + return x + y; 1.1781 +} 1.1782 + 1.1783 +static public double minus(double x, double y){ 1.1784 + return x - y; 1.1785 +} 1.1786 + 1.1787 +static public double minus(double x){ 1.1788 + return -x; 1.1789 +} 1.1790 + 1.1791 +static public double inc(double x){ 1.1792 + return x + 1; 1.1793 +} 1.1794 + 1.1795 +static public double dec(double x){ 1.1796 + return x - 1; 1.1797 +} 1.1798 + 1.1799 +static public double multiply(double x, double y){ 1.1800 + return x * y; 1.1801 +} 1.1802 + 1.1803 +static public double divide(double x, double y){ 1.1804 + return x / y; 1.1805 +} 1.1806 + 1.1807 +static public boolean equiv(double x, double y){ 1.1808 + return x == y; 1.1809 +} 1.1810 + 1.1811 +static public boolean lt(double x, double y){ 1.1812 + return x < y; 1.1813 +} 1.1814 + 1.1815 +static public boolean lte(double x, double y){ 1.1816 + return x <= y; 1.1817 +} 1.1818 + 1.1819 +static public boolean gt(double x, double y){ 1.1820 + return x > y; 1.1821 +} 1.1822 + 1.1823 +static public boolean gte(double x, double y){ 1.1824 + return x >= y; 1.1825 +} 1.1826 + 1.1827 +static public boolean isPos(double x){ 1.1828 + return x > 0; 1.1829 +} 1.1830 + 1.1831 +static public boolean isNeg(double x){ 1.1832 + return x < 0; 1.1833 +} 1.1834 + 1.1835 +static public boolean isZero(double x){ 1.1836 + return x == 0; 1.1837 +} 1.1838 + 1.1839 +static int throwIntOverflow(){ 1.1840 + throw new ArithmeticException("integer overflow"); 1.1841 +} 1.1842 + 1.1843 +static public Number num(int x){ 1.1844 + return x; 1.1845 +} 1.1846 + 1.1847 +static public int unchecked_add(int x, int y){ 1.1848 + return x + y; 1.1849 +} 1.1850 + 1.1851 +static public int unchecked_subtract(int x, int y){ 1.1852 + return x - y; 1.1853 +} 1.1854 + 1.1855 +static public int unchecked_negate(int x){ 1.1856 + return -x; 1.1857 +} 1.1858 + 1.1859 +static public int unchecked_inc(int x){ 1.1860 + return x + 1; 1.1861 +} 1.1862 + 1.1863 +static public int unchecked_dec(int x){ 1.1864 + return x - 1; 1.1865 +} 1.1866 + 1.1867 +static public int unchecked_multiply(int x, int y){ 1.1868 + return x * y; 1.1869 +} 1.1870 + 1.1871 +static public int add(int x, int y){ 1.1872 + int ret = x + y; 1.1873 + if ((ret ^ x) < 0 && (ret ^ y) < 0) 1.1874 + return throwIntOverflow(); 1.1875 + return ret; 1.1876 +} 1.1877 + 1.1878 +static public int not(int x){ 1.1879 + return ~x; 1.1880 +} 1.1881 + 1.1882 +static public int and(int x, int y){ 1.1883 + return x & y; 1.1884 +} 1.1885 + 1.1886 +static public int or(int x, int y){ 1.1887 + return x | y; 1.1888 +} 1.1889 + 1.1890 +static public int xor(int x, int y){ 1.1891 + return x ^ y; 1.1892 +} 1.1893 + 1.1894 +static public int minus(int x, int y){ 1.1895 + int ret = x - y; 1.1896 + if (((ret ^ x) < 0 && (ret ^ ~y) < 0)) 1.1897 + return throwIntOverflow(); 1.1898 + return ret; 1.1899 +} 1.1900 + 1.1901 +static public int minus(int x){ 1.1902 + if(x == Integer.MIN_VALUE) 1.1903 + return throwIntOverflow(); 1.1904 + return -x; 1.1905 +} 1.1906 + 1.1907 +static public int inc(int x){ 1.1908 + if(x == Integer.MAX_VALUE) 1.1909 + return throwIntOverflow(); 1.1910 + return x + 1; 1.1911 +} 1.1912 + 1.1913 +static public int dec(int x){ 1.1914 + if(x == Integer.MIN_VALUE) 1.1915 + return throwIntOverflow(); 1.1916 + return x - 1; 1.1917 +} 1.1918 + 1.1919 +static public int multiply(int x, int y){ 1.1920 + int ret = x * y; 1.1921 + if (y != 0 && ret/y != x) 1.1922 + return throwIntOverflow(); 1.1923 + return ret; 1.1924 +} 1.1925 + 1.1926 +static public int unchecked_divide(int x, int y){ 1.1927 + return x / y; 1.1928 +} 1.1929 + 1.1930 +static public int unchecked_remainder(int x, int y){ 1.1931 + return x % y; 1.1932 +} 1.1933 + 1.1934 +static public boolean equiv(int x, int y){ 1.1935 + return x == y; 1.1936 +} 1.1937 + 1.1938 +static public boolean lt(int x, int y){ 1.1939 + return x < y; 1.1940 +} 1.1941 + 1.1942 +static public boolean lte(int x, int y){ 1.1943 + return x <= y; 1.1944 +} 1.1945 + 1.1946 +static public boolean gt(int x, int y){ 1.1947 + return x > y; 1.1948 +} 1.1949 + 1.1950 +static public boolean gte(int x, int y){ 1.1951 + return x >= y; 1.1952 +} 1.1953 + 1.1954 +static public boolean isPos(int x){ 1.1955 + return x > 0; 1.1956 +} 1.1957 + 1.1958 +static public boolean isNeg(int x){ 1.1959 + return x < 0; 1.1960 +} 1.1961 + 1.1962 +static public boolean isZero(int x){ 1.1963 + return x == 0; 1.1964 +} 1.1965 + 1.1966 +static public Number num(long x){ 1.1967 + return x; 1.1968 +} 1.1969 + 1.1970 +static public long unchecked_add(long x, long y){ 1.1971 + return x + y; 1.1972 +} 1.1973 + 1.1974 +static public long unchecked_subtract(long x, long y){ 1.1975 + return x - y; 1.1976 +} 1.1977 + 1.1978 +static public long unchecked_negate(long x){ 1.1979 + return -x; 1.1980 +} 1.1981 + 1.1982 +static public long unchecked_inc(long x){ 1.1983 + return x + 1; 1.1984 +} 1.1985 + 1.1986 +static public long unchecked_dec(long x){ 1.1987 + return x - 1; 1.1988 +} 1.1989 + 1.1990 +static public long unchecked_multiply(long x, long y){ 1.1991 + return x * y; 1.1992 +} 1.1993 + 1.1994 +static public long add(long x, long y){ 1.1995 + long ret = x + y; 1.1996 + if ((ret ^ x) < 0 && (ret ^ y) < 0) 1.1997 + return throwIntOverflow(); 1.1998 + return ret; 1.1999 +} 1.2000 + 1.2001 +static public long minus(long x, long y){ 1.2002 + long ret = x - y; 1.2003 + if (((ret ^ x) < 0 && (ret ^ ~y) < 0)) 1.2004 + return throwIntOverflow(); 1.2005 + return ret; 1.2006 +} 1.2007 + 1.2008 +static public long minus(long x){ 1.2009 + if(x == Long.MIN_VALUE) 1.2010 + return throwIntOverflow(); 1.2011 + return -x; 1.2012 +} 1.2013 + 1.2014 +static public long inc(long x){ 1.2015 + if(x == Long.MAX_VALUE) 1.2016 + return throwIntOverflow(); 1.2017 + return x + 1; 1.2018 +} 1.2019 + 1.2020 +static public long dec(long x){ 1.2021 + if(x == Long.MIN_VALUE) 1.2022 + return throwIntOverflow(); 1.2023 + return x - 1; 1.2024 +} 1.2025 + 1.2026 +static public long multiply(long x, long y){ 1.2027 + long ret = x * y; 1.2028 + if (y != 0 && ret/y != x) 1.2029 + return throwIntOverflow(); 1.2030 + return ret; 1.2031 +} 1.2032 + 1.2033 +static public long unchecked_divide(long x, long y){ 1.2034 + return x / y; 1.2035 +} 1.2036 + 1.2037 +static public long unchecked_remainder(long x, long y){ 1.2038 + return x % y; 1.2039 +} 1.2040 + 1.2041 +static public boolean equiv(long x, long y){ 1.2042 + return x == y; 1.2043 +} 1.2044 + 1.2045 +static public boolean lt(long x, long y){ 1.2046 + return x < y; 1.2047 +} 1.2048 + 1.2049 +static public boolean lte(long x, long y){ 1.2050 + return x <= y; 1.2051 +} 1.2052 + 1.2053 +static public boolean gt(long x, long y){ 1.2054 + return x > y; 1.2055 +} 1.2056 + 1.2057 +static public boolean gte(long x, long y){ 1.2058 + return x >= y; 1.2059 +} 1.2060 + 1.2061 +static public boolean isPos(long x){ 1.2062 + return x > 0; 1.2063 +} 1.2064 + 1.2065 +static public boolean isNeg(long x){ 1.2066 + return x < 0; 1.2067 +} 1.2068 + 1.2069 +static public boolean isZero(long x){ 1.2070 + return x == 0; 1.2071 +} 1.2072 + 1.2073 +/* 1.2074 +static public class F{ 1.2075 + static public float add(float x, float y){ 1.2076 + return x + y; 1.2077 + } 1.2078 + 1.2079 + static public float subtract(float x, float y){ 1.2080 + return x - y; 1.2081 + } 1.2082 + 1.2083 + static public float negate(float x){ 1.2084 + return -x; 1.2085 + } 1.2086 + 1.2087 + static public float inc(float x){ 1.2088 + return x + 1; 1.2089 + } 1.2090 + 1.2091 + static public float dec(float x){ 1.2092 + return x - 1; 1.2093 + } 1.2094 + 1.2095 + static public float multiply(float x, float y){ 1.2096 + return x * y; 1.2097 + } 1.2098 + 1.2099 + static public float divide(float x, float y){ 1.2100 + return x / y; 1.2101 + } 1.2102 + 1.2103 + static public boolean equiv(float x, float y){ 1.2104 + return x == y; 1.2105 + } 1.2106 + 1.2107 + static public boolean lt(float x, float y){ 1.2108 + return x < y; 1.2109 + } 1.2110 + 1.2111 + static public boolean lte(float x, float y){ 1.2112 + return x <= y; 1.2113 + } 1.2114 + 1.2115 + static public boolean gt(float x, float y){ 1.2116 + return x > y; 1.2117 + } 1.2118 + 1.2119 + static public boolean gte(float x, float y){ 1.2120 + return x >= y; 1.2121 + } 1.2122 + 1.2123 + static public boolean pos(float x){ 1.2124 + return x > 0; 1.2125 + } 1.2126 + 1.2127 + static public boolean neg(float x){ 1.2128 + return x < 0; 1.2129 + } 1.2130 + 1.2131 + static public boolean zero(float x){ 1.2132 + return x == 0; 1.2133 + } 1.2134 + 1.2135 + static public float aget(float[] xs, int i){ 1.2136 + return xs[i]; 1.2137 + } 1.2138 + 1.2139 + static public float aset(float[] xs, int i, float v){ 1.2140 + xs[i] = v; 1.2141 + return v; 1.2142 + } 1.2143 + 1.2144 + static public int alength(float[] xs){ 1.2145 + return xs.length; 1.2146 + } 1.2147 + 1.2148 + static public float[] aclone(float[] xs){ 1.2149 + return xs.clone(); 1.2150 + } 1.2151 + 1.2152 + static public float[] vec(int size, Object init){ 1.2153 + float[] ret = new float[size]; 1.2154 + if(init instanceof Number) 1.2155 + { 1.2156 + float f = ((Number) init).floatValue(); 1.2157 + for(int i = 0; i < ret.length; i++) 1.2158 + ret[i] = f; 1.2159 + } 1.2160 + else 1.2161 + { 1.2162 + ISeq s = RT.seq(init); 1.2163 + for(int i = 0; i < size && s != null; i++, s = s.rest()) 1.2164 + ret[i] = ((Number) s.first()).floatValue(); 1.2165 + } 1.2166 + return ret; 1.2167 + } 1.2168 + 1.2169 + static public float[] vec(Object sizeOrSeq){ 1.2170 + if(sizeOrSeq instanceof Number) 1.2171 + return new float[((Number) sizeOrSeq).intValue()]; 1.2172 + else 1.2173 + { 1.2174 + ISeq s = RT.seq(sizeOrSeq); 1.2175 + int size = s.count(); 1.2176 + float[] ret = new float[size]; 1.2177 + for(int i = 0; i < size && s != null; i++, s = s.rest()) 1.2178 + ret[i] = ((Number) s.first()).intValue(); 1.2179 + return ret; 1.2180 + } 1.2181 + } 1.2182 + 1.2183 + 1.2184 + static public float[] vsadd(float[] x, float y){ 1.2185 + final float[] xs = x.clone(); 1.2186 + for(int i = 0; i < xs.length; i++) 1.2187 + xs[i] += y; 1.2188 + return xs; 1.2189 + } 1.2190 + 1.2191 + static public float[] vssub(float[] x, float y){ 1.2192 + final float[] xs = x.clone(); 1.2193 + for(int i = 0; i < xs.length; i++) 1.2194 + xs[i] -= y; 1.2195 + return xs; 1.2196 + } 1.2197 + 1.2198 + static public float[] vsdiv(float[] x, float y){ 1.2199 + final float[] xs = x.clone(); 1.2200 + for(int i = 0; i < xs.length; i++) 1.2201 + xs[i] /= y; 1.2202 + return xs; 1.2203 + } 1.2204 + 1.2205 + static public float[] vsmul(float[] x, float y){ 1.2206 + final float[] xs = x.clone(); 1.2207 + for(int i = 0; i < xs.length; i++) 1.2208 + xs[i] *= y; 1.2209 + return xs; 1.2210 + } 1.2211 + 1.2212 + static public float[] svdiv(float y, float[] x){ 1.2213 + final float[] xs = x.clone(); 1.2214 + for(int i = 0; i < xs.length; i++) 1.2215 + xs[i] = y / xs[i]; 1.2216 + return xs; 1.2217 + } 1.2218 + 1.2219 + static public float[] vsmuladd(float[] x, float y, float[] zs){ 1.2220 + final float[] xs = x.clone(); 1.2221 + for(int i = 0; i < xs.length; i++) 1.2222 + xs[i] = xs[i] * y + zs[i]; 1.2223 + return xs; 1.2224 + } 1.2225 + 1.2226 + static public float[] vsmulsub(float[] x, float y, float[] zs){ 1.2227 + final float[] xs = x.clone(); 1.2228 + for(int i = 0; i < xs.length; i++) 1.2229 + xs[i] = xs[i] * y - zs[i]; 1.2230 + return xs; 1.2231 + } 1.2232 + 1.2233 + static public float[] vsmulsadd(float[] x, float y, float z){ 1.2234 + final float[] xs = x.clone(); 1.2235 + for(int i = 0; i < xs.length; i++) 1.2236 + xs[i] = xs[i] * y + z; 1.2237 + return xs; 1.2238 + } 1.2239 + 1.2240 + static public float[] vsmulssub(float[] x, float y, float z){ 1.2241 + final float[] xs = x.clone(); 1.2242 + for(int i = 0; i < xs.length; i++) 1.2243 + xs[i] = xs[i] * y - z; 1.2244 + return xs; 1.2245 + } 1.2246 + 1.2247 + static public float[] vabs(float[] x){ 1.2248 + final float[] xs = x.clone(); 1.2249 + for(int i = 0; i < xs.length; i++) 1.2250 + xs[i] = Math.abs(xs[i]); 1.2251 + return xs; 1.2252 + } 1.2253 + 1.2254 + static public float[] vnegabs(float[] x){ 1.2255 + final float[] xs = x.clone(); 1.2256 + for(int i = 0; i < xs.length; i++) 1.2257 + xs[i] = -Math.abs(xs[i]); 1.2258 + return xs; 1.2259 + } 1.2260 + 1.2261 + static public float[] vneg(float[] x){ 1.2262 + final float[] xs = x.clone(); 1.2263 + for(int i = 0; i < xs.length; i++) 1.2264 + xs[i] = -xs[i]; 1.2265 + return xs; 1.2266 + } 1.2267 + 1.2268 + static public float[] vsqr(float[] x){ 1.2269 + final float[] xs = x.clone(); 1.2270 + for(int i = 0; i < xs.length; i++) 1.2271 + xs[i] *= xs[i]; 1.2272 + return xs; 1.2273 + } 1.2274 + 1.2275 + static public float[] vsignedsqr(float[] x){ 1.2276 + final float[] xs = x.clone(); 1.2277 + for(int i = 0; i < xs.length; i++) 1.2278 + xs[i] *= Math.abs(xs[i]); 1.2279 + return xs; 1.2280 + } 1.2281 + 1.2282 + static public float[] vclip(float[] x, float low, float high){ 1.2283 + final float[] xs = x.clone(); 1.2284 + for(int i = 0; i < xs.length; i++) 1.2285 + { 1.2286 + if(xs[i] < low) 1.2287 + xs[i] = low; 1.2288 + else if(xs[i] > high) 1.2289 + xs[i] = high; 1.2290 + } 1.2291 + return xs; 1.2292 + } 1.2293 + 1.2294 + static public IPersistentVector vclipcounts(float[] x, float low, float high){ 1.2295 + final float[] xs = x.clone(); 1.2296 + int lowc = 0; 1.2297 + int highc = 0; 1.2298 + 1.2299 + for(int i = 0; i < xs.length; i++) 1.2300 + { 1.2301 + if(xs[i] < low) 1.2302 + { 1.2303 + ++lowc; 1.2304 + xs[i] = low; 1.2305 + } 1.2306 + else if(xs[i] > high) 1.2307 + { 1.2308 + ++highc; 1.2309 + xs[i] = high; 1.2310 + } 1.2311 + } 1.2312 + return RT.vector(xs, lowc, highc); 1.2313 + } 1.2314 + 1.2315 + static public float[] vthresh(float[] x, float thresh, float otherwise){ 1.2316 + final float[] xs = x.clone(); 1.2317 + for(int i = 0; i < xs.length; i++) 1.2318 + { 1.2319 + if(xs[i] < thresh) 1.2320 + xs[i] = otherwise; 1.2321 + } 1.2322 + return xs; 1.2323 + } 1.2324 + 1.2325 + static public float[] vreverse(float[] x){ 1.2326 + final float[] xs = x.clone(); 1.2327 + for(int i = 0; i < xs.length; i++) 1.2328 + xs[i] = xs[xs.length - i - 1]; 1.2329 + return xs; 1.2330 + } 1.2331 + 1.2332 + static public float[] vrunningsum(float[] x){ 1.2333 + final float[] xs = x.clone(); 1.2334 + for(int i = 1; i < xs.length; i++) 1.2335 + xs[i] = xs[i - 1] + xs[i]; 1.2336 + return xs; 1.2337 + } 1.2338 + 1.2339 + static public float[] vsort(float[] x){ 1.2340 + final float[] xs = x.clone(); 1.2341 + Arrays.sort(xs); 1.2342 + return xs; 1.2343 + } 1.2344 + 1.2345 + static public float vdot(float[] xs, float[] ys){ 1.2346 + float ret = 0; 1.2347 + for(int i = 0; i < xs.length; i++) 1.2348 + ret += xs[i] * ys[i]; 1.2349 + return ret; 1.2350 + } 1.2351 + 1.2352 + static public float vmax(float[] xs){ 1.2353 + if(xs.length == 0) 1.2354 + return 0; 1.2355 + float ret = xs[0]; 1.2356 + for(int i = 0; i < xs.length; i++) 1.2357 + ret = Math.max(ret, xs[i]); 1.2358 + return ret; 1.2359 + } 1.2360 + 1.2361 + static public float vmin(float[] xs){ 1.2362 + if(xs.length == 0) 1.2363 + return 0; 1.2364 + float ret = xs[0]; 1.2365 + for(int i = 0; i < xs.length; i++) 1.2366 + ret = Math.min(ret, xs[i]); 1.2367 + return ret; 1.2368 + } 1.2369 + 1.2370 + static public float vmean(float[] xs){ 1.2371 + if(xs.length == 0) 1.2372 + return 0; 1.2373 + return vsum(xs) / xs.length; 1.2374 + } 1.2375 + 1.2376 + static public double vrms(float[] xs){ 1.2377 + if(xs.length == 0) 1.2378 + return 0; 1.2379 + float ret = 0; 1.2380 + for(int i = 0; i < xs.length; i++) 1.2381 + ret += xs[i] * xs[i]; 1.2382 + return Math.sqrt(ret / xs.length); 1.2383 + } 1.2384 + 1.2385 + static public float vsum(float[] xs){ 1.2386 + float ret = 0; 1.2387 + for(int i = 0; i < xs.length; i++) 1.2388 + ret += xs[i]; 1.2389 + return ret; 1.2390 + } 1.2391 + 1.2392 + static public boolean vequiv(float[] xs, float[] ys){ 1.2393 + return Arrays.equals(xs, ys); 1.2394 + } 1.2395 + 1.2396 + static public float[] vadd(float[] x, float[] ys){ 1.2397 + final float[] xs = x.clone(); 1.2398 + for(int i = 0; i < xs.length; i++) 1.2399 + xs[i] += ys[i]; 1.2400 + return xs; 1.2401 + } 1.2402 + 1.2403 + static public float[] vsub(float[] x, float[] ys){ 1.2404 + final float[] xs = x.clone(); 1.2405 + for(int i = 0; i < xs.length; i++) 1.2406 + xs[i] -= ys[i]; 1.2407 + return xs; 1.2408 + } 1.2409 + 1.2410 + static public float[] vaddmul(float[] x, float[] ys, float[] zs){ 1.2411 + final float[] xs = x.clone(); 1.2412 + for(int i = 0; i < xs.length; i++) 1.2413 + xs[i] = (xs[i] + ys[i]) * zs[i]; 1.2414 + return xs; 1.2415 + } 1.2416 + 1.2417 + static public float[] vsubmul(float[] x, float[] ys, float[] zs){ 1.2418 + final float[] xs = x.clone(); 1.2419 + for(int i = 0; i < xs.length; i++) 1.2420 + xs[i] = (xs[i] - ys[i]) * zs[i]; 1.2421 + return xs; 1.2422 + } 1.2423 + 1.2424 + static public float[] vaddsmul(float[] x, float[] ys, float z){ 1.2425 + final float[] xs = x.clone(); 1.2426 + for(int i = 0; i < xs.length; i++) 1.2427 + xs[i] = (xs[i] + ys[i]) * z; 1.2428 + return xs; 1.2429 + } 1.2430 + 1.2431 + static public float[] vsubsmul(float[] x, float[] ys, float z){ 1.2432 + final float[] xs = x.clone(); 1.2433 + for(int i = 0; i < xs.length; i++) 1.2434 + xs[i] = (xs[i] - ys[i]) * z; 1.2435 + return xs; 1.2436 + } 1.2437 + 1.2438 + static public float[] vmulsadd(float[] x, float[] ys, float z){ 1.2439 + final float[] xs = x.clone(); 1.2440 + for(int i = 0; i < xs.length; i++) 1.2441 + xs[i] = (xs[i] * ys[i]) + z; 1.2442 + return xs; 1.2443 + } 1.2444 + 1.2445 + static public float[] vdiv(float[] x, float[] ys){ 1.2446 + final float[] xs = x.clone(); 1.2447 + for(int i = 0; i < xs.length; i++) 1.2448 + xs[i] /= ys[i]; 1.2449 + return xs; 1.2450 + } 1.2451 + 1.2452 + static public float[] vmul(float[] x, float[] ys){ 1.2453 + final float[] xs = x.clone(); 1.2454 + for(int i = 0; i < xs.length; i++) 1.2455 + xs[i] *= ys[i]; 1.2456 + return xs; 1.2457 + } 1.2458 + 1.2459 + static public float[] vmuladd(float[] x, float[] ys, float[] zs){ 1.2460 + final float[] xs = x.clone(); 1.2461 + for(int i = 0; i < xs.length; i++) 1.2462 + xs[i] = (xs[i] * ys[i]) + zs[i]; 1.2463 + return xs; 1.2464 + } 1.2465 + 1.2466 + static public float[] vmulsub(float[] x, float[] ys, float[] zs){ 1.2467 + final float[] xs = x.clone(); 1.2468 + for(int i = 0; i < xs.length; i++) 1.2469 + xs[i] = (xs[i] * ys[i]) - zs[i]; 1.2470 + return xs; 1.2471 + } 1.2472 + 1.2473 + static public float[] vmax(float[] x, float[] ys){ 1.2474 + final float[] xs = x.clone(); 1.2475 + for(int i = 0; i < xs.length; i++) 1.2476 + xs[i] = Math.max(xs[i], ys[i]); 1.2477 + return xs; 1.2478 + } 1.2479 + 1.2480 + static public float[] vmin(float[] x, float[] ys){ 1.2481 + final float[] xs = x.clone(); 1.2482 + for(int i = 0; i < xs.length; i++) 1.2483 + xs[i] = Math.min(xs[i], ys[i]); 1.2484 + return xs; 1.2485 + } 1.2486 + 1.2487 + static public float[] vmap(IFn fn, float[] x) throws Exception{ 1.2488 + float[] xs = x.clone(); 1.2489 + for(int i = 0; i < xs.length; i++) 1.2490 + xs[i] = ((Number) fn.invoke(xs[i])).floatValue(); 1.2491 + return xs; 1.2492 + } 1.2493 + 1.2494 + static public float[] vmap(IFn fn, float[] x, float[] ys) throws Exception{ 1.2495 + float[] xs = x.clone(); 1.2496 + for(int i = 0; i < xs.length; i++) 1.2497 + xs[i] = ((Number) fn.invoke(xs[i], ys[i])).floatValue(); 1.2498 + return xs; 1.2499 + } 1.2500 + 1.2501 +} 1.2502 + 1.2503 +static public class D{ 1.2504 + static public double add(double x, double y){ 1.2505 + return x + y; 1.2506 + } 1.2507 + 1.2508 + static public double subtract(double x, double y){ 1.2509 + return x - y; 1.2510 + } 1.2511 + 1.2512 + static public double negate(double x){ 1.2513 + return -x; 1.2514 + } 1.2515 + 1.2516 + static public double inc(double x){ 1.2517 + return x + 1; 1.2518 + } 1.2519 + 1.2520 + static public double dec(double x){ 1.2521 + return x - 1; 1.2522 + } 1.2523 + 1.2524 + static public double multiply(double x, double y){ 1.2525 + return x * y; 1.2526 + } 1.2527 + 1.2528 + static public double divide(double x, double y){ 1.2529 + return x / y; 1.2530 + } 1.2531 + 1.2532 + static public boolean equiv(double x, double y){ 1.2533 + return x == y; 1.2534 + } 1.2535 + 1.2536 + static public boolean lt(double x, double y){ 1.2537 + return x < y; 1.2538 + } 1.2539 + 1.2540 + static public boolean lte(double x, double y){ 1.2541 + return x <= y; 1.2542 + } 1.2543 + 1.2544 + static public boolean gt(double x, double y){ 1.2545 + return x > y; 1.2546 + } 1.2547 + 1.2548 + static public boolean gte(double x, double y){ 1.2549 + return x >= y; 1.2550 + } 1.2551 + 1.2552 + static public boolean pos(double x){ 1.2553 + return x > 0; 1.2554 + } 1.2555 + 1.2556 + static public boolean neg(double x){ 1.2557 + return x < 0; 1.2558 + } 1.2559 + 1.2560 + static public boolean zero(double x){ 1.2561 + return x == 0; 1.2562 + } 1.2563 + 1.2564 + static public double aget(double[] xs, int i){ 1.2565 + return xs[i]; 1.2566 + } 1.2567 + 1.2568 + static public double aset(double[] xs, int i, double v){ 1.2569 + xs[i] = v; 1.2570 + return v; 1.2571 + } 1.2572 + 1.2573 + static public int alength(double[] xs){ 1.2574 + return xs.length; 1.2575 + } 1.2576 + 1.2577 + static public double[] aclone(double[] xs){ 1.2578 + return xs.clone(); 1.2579 + } 1.2580 + 1.2581 + static public double[] vec(int size, Object init){ 1.2582 + double[] ret = new double[size]; 1.2583 + if(init instanceof Number) 1.2584 + { 1.2585 + double f = ((Number) init).doubleValue(); 1.2586 + for(int i = 0; i < ret.length; i++) 1.2587 + ret[i] = f; 1.2588 + } 1.2589 + else 1.2590 + { 1.2591 + ISeq s = RT.seq(init); 1.2592 + for(int i = 0; i < size && s != null; i++, s = s.rest()) 1.2593 + ret[i] = ((Number) s.first()).doubleValue(); 1.2594 + } 1.2595 + return ret; 1.2596 + } 1.2597 + 1.2598 + static public double[] vec(Object sizeOrSeq){ 1.2599 + if(sizeOrSeq instanceof Number) 1.2600 + return new double[((Number) sizeOrSeq).intValue()]; 1.2601 + else 1.2602 + { 1.2603 + ISeq s = RT.seq(sizeOrSeq); 1.2604 + int size = s.count(); 1.2605 + double[] ret = new double[size]; 1.2606 + for(int i = 0; i < size && s != null; i++, s = s.rest()) 1.2607 + ret[i] = ((Number) s.first()).intValue(); 1.2608 + return ret; 1.2609 + } 1.2610 + } 1.2611 + 1.2612 + static public double[] vsadd(double[] x, double y){ 1.2613 + final double[] xs = x.clone(); 1.2614 + for(int i = 0; i < xs.length; i++) 1.2615 + xs[i] += y; 1.2616 + return xs; 1.2617 + } 1.2618 + 1.2619 + static public double[] vssub(double[] x, double y){ 1.2620 + final double[] xs = x.clone(); 1.2621 + for(int i = 0; i < xs.length; i++) 1.2622 + xs[i] -= y; 1.2623 + return xs; 1.2624 + } 1.2625 + 1.2626 + static public double[] vsdiv(double[] x, double y){ 1.2627 + final double[] xs = x.clone(); 1.2628 + for(int i = 0; i < xs.length; i++) 1.2629 + xs[i] /= y; 1.2630 + return xs; 1.2631 + } 1.2632 + 1.2633 + static public double[] vsmul(double[] x, double y){ 1.2634 + final double[] xs = x.clone(); 1.2635 + for(int i = 0; i < xs.length; i++) 1.2636 + xs[i] *= y; 1.2637 + return xs; 1.2638 + } 1.2639 + 1.2640 + static public double[] svdiv(double y, double[] x){ 1.2641 + final double[] xs = x.clone(); 1.2642 + for(int i = 0; i < xs.length; i++) 1.2643 + xs[i] = y / xs[i]; 1.2644 + return xs; 1.2645 + } 1.2646 + 1.2647 + static public double[] vsmuladd(double[] x, double y, double[] zs){ 1.2648 + final double[] xs = x.clone(); 1.2649 + for(int i = 0; i < xs.length; i++) 1.2650 + xs[i] = xs[i] * y + zs[i]; 1.2651 + return xs; 1.2652 + } 1.2653 + 1.2654 + static public double[] vsmulsub(double[] x, double y, double[] zs){ 1.2655 + final double[] xs = x.clone(); 1.2656 + for(int i = 0; i < xs.length; i++) 1.2657 + xs[i] = xs[i] * y - zs[i]; 1.2658 + return xs; 1.2659 + } 1.2660 + 1.2661 + static public double[] vsmulsadd(double[] x, double y, double z){ 1.2662 + final double[] xs = x.clone(); 1.2663 + for(int i = 0; i < xs.length; i++) 1.2664 + xs[i] = xs[i] * y + z; 1.2665 + return xs; 1.2666 + } 1.2667 + 1.2668 + static public double[] vsmulssub(double[] x, double y, double z){ 1.2669 + final double[] xs = x.clone(); 1.2670 + for(int i = 0; i < xs.length; i++) 1.2671 + xs[i] = xs[i] * y - z; 1.2672 + return xs; 1.2673 + } 1.2674 + 1.2675 + static public double[] vabs(double[] x){ 1.2676 + final double[] xs = x.clone(); 1.2677 + for(int i = 0; i < xs.length; i++) 1.2678 + xs[i] = Math.abs(xs[i]); 1.2679 + return xs; 1.2680 + } 1.2681 + 1.2682 + static public double[] vnegabs(double[] x){ 1.2683 + final double[] xs = x.clone(); 1.2684 + for(int i = 0; i < xs.length; i++) 1.2685 + xs[i] = -Math.abs(xs[i]); 1.2686 + return xs; 1.2687 + } 1.2688 + 1.2689 + static public double[] vneg(double[] x){ 1.2690 + final double[] xs = x.clone(); 1.2691 + for(int i = 0; i < xs.length; i++) 1.2692 + xs[i] = -xs[i]; 1.2693 + return xs; 1.2694 + } 1.2695 + 1.2696 + static public double[] vsqr(double[] x){ 1.2697 + final double[] xs = x.clone(); 1.2698 + for(int i = 0; i < xs.length; i++) 1.2699 + xs[i] *= xs[i]; 1.2700 + return xs; 1.2701 + } 1.2702 + 1.2703 + static public double[] vsignedsqr(double[] x){ 1.2704 + final double[] xs = x.clone(); 1.2705 + for(int i = 0; i < xs.length; i++) 1.2706 + xs[i] *= Math.abs(xs[i]); 1.2707 + return xs; 1.2708 + } 1.2709 + 1.2710 + static public double[] vclip(double[] x, double low, double high){ 1.2711 + final double[] xs = x.clone(); 1.2712 + for(int i = 0; i < xs.length; i++) 1.2713 + { 1.2714 + if(xs[i] < low) 1.2715 + xs[i] = low; 1.2716 + else if(xs[i] > high) 1.2717 + xs[i] = high; 1.2718 + } 1.2719 + return xs; 1.2720 + } 1.2721 + 1.2722 + static public IPersistentVector vclipcounts(double[] x, double low, double high){ 1.2723 + final double[] xs = x.clone(); 1.2724 + int lowc = 0; 1.2725 + int highc = 0; 1.2726 + 1.2727 + for(int i = 0; i < xs.length; i++) 1.2728 + { 1.2729 + if(xs[i] < low) 1.2730 + { 1.2731 + ++lowc; 1.2732 + xs[i] = low; 1.2733 + } 1.2734 + else if(xs[i] > high) 1.2735 + { 1.2736 + ++highc; 1.2737 + xs[i] = high; 1.2738 + } 1.2739 + } 1.2740 + return RT.vector(xs, lowc, highc); 1.2741 + } 1.2742 + 1.2743 + static public double[] vthresh(double[] x, double thresh, double otherwise){ 1.2744 + final double[] xs = x.clone(); 1.2745 + for(int i = 0; i < xs.length; i++) 1.2746 + { 1.2747 + if(xs[i] < thresh) 1.2748 + xs[i] = otherwise; 1.2749 + } 1.2750 + return xs; 1.2751 + } 1.2752 + 1.2753 + static public double[] vreverse(double[] x){ 1.2754 + final double[] xs = x.clone(); 1.2755 + for(int i = 0; i < xs.length; i++) 1.2756 + xs[i] = xs[xs.length - i - 1]; 1.2757 + return xs; 1.2758 + } 1.2759 + 1.2760 + static public double[] vrunningsum(double[] x){ 1.2761 + final double[] xs = x.clone(); 1.2762 + for(int i = 1; i < xs.length; i++) 1.2763 + xs[i] = xs[i - 1] + xs[i]; 1.2764 + return xs; 1.2765 + } 1.2766 + 1.2767 + static public double[] vsort(double[] x){ 1.2768 + final double[] xs = x.clone(); 1.2769 + Arrays.sort(xs); 1.2770 + return xs; 1.2771 + } 1.2772 + 1.2773 + static public double vdot(double[] xs, double[] ys){ 1.2774 + double ret = 0; 1.2775 + for(int i = 0; i < xs.length; i++) 1.2776 + ret += xs[i] * ys[i]; 1.2777 + return ret; 1.2778 + } 1.2779 + 1.2780 + static public double vmax(double[] xs){ 1.2781 + if(xs.length == 0) 1.2782 + return 0; 1.2783 + double ret = xs[0]; 1.2784 + for(int i = 0; i < xs.length; i++) 1.2785 + ret = Math.max(ret, xs[i]); 1.2786 + return ret; 1.2787 + } 1.2788 + 1.2789 + static public double vmin(double[] xs){ 1.2790 + if(xs.length == 0) 1.2791 + return 0; 1.2792 + double ret = xs[0]; 1.2793 + for(int i = 0; i < xs.length; i++) 1.2794 + ret = Math.min(ret, xs[i]); 1.2795 + return ret; 1.2796 + } 1.2797 + 1.2798 + static public double vmean(double[] xs){ 1.2799 + if(xs.length == 0) 1.2800 + return 0; 1.2801 + return vsum(xs) / xs.length; 1.2802 + } 1.2803 + 1.2804 + static public double vrms(double[] xs){ 1.2805 + if(xs.length == 0) 1.2806 + return 0; 1.2807 + double ret = 0; 1.2808 + for(int i = 0; i < xs.length; i++) 1.2809 + ret += xs[i] * xs[i]; 1.2810 + return Math.sqrt(ret / xs.length); 1.2811 + } 1.2812 + 1.2813 + static public double vsum(double[] xs){ 1.2814 + double ret = 0; 1.2815 + for(int i = 0; i < xs.length; i++) 1.2816 + ret += xs[i]; 1.2817 + return ret; 1.2818 + } 1.2819 + 1.2820 + static public boolean vequiv(double[] xs, double[] ys){ 1.2821 + return Arrays.equals(xs, ys); 1.2822 + } 1.2823 + 1.2824 + static public double[] vadd(double[] x, double[] ys){ 1.2825 + final double[] xs = x.clone(); 1.2826 + for(int i = 0; i < xs.length; i++) 1.2827 + xs[i] += ys[i]; 1.2828 + return xs; 1.2829 + } 1.2830 + 1.2831 + static public double[] vsub(double[] x, double[] ys){ 1.2832 + final double[] xs = x.clone(); 1.2833 + for(int i = 0; i < xs.length; i++) 1.2834 + xs[i] -= ys[i]; 1.2835 + return xs; 1.2836 + } 1.2837 + 1.2838 + static public double[] vaddmul(double[] x, double[] ys, double[] zs){ 1.2839 + final double[] xs = x.clone(); 1.2840 + for(int i = 0; i < xs.length; i++) 1.2841 + xs[i] = (xs[i] + ys[i]) * zs[i]; 1.2842 + return xs; 1.2843 + } 1.2844 + 1.2845 + static public double[] vsubmul(double[] x, double[] ys, double[] zs){ 1.2846 + final double[] xs = x.clone(); 1.2847 + for(int i = 0; i < xs.length; i++) 1.2848 + xs[i] = (xs[i] - ys[i]) * zs[i]; 1.2849 + return xs; 1.2850 + } 1.2851 + 1.2852 + static public double[] vaddsmul(double[] x, double[] ys, double z){ 1.2853 + final double[] xs = x.clone(); 1.2854 + for(int i = 0; i < xs.length; i++) 1.2855 + xs[i] = (xs[i] + ys[i]) * z; 1.2856 + return xs; 1.2857 + } 1.2858 + 1.2859 + static public double[] vsubsmul(double[] x, double[] ys, double z){ 1.2860 + final double[] xs = x.clone(); 1.2861 + for(int i = 0; i < xs.length; i++) 1.2862 + xs[i] = (xs[i] - ys[i]) * z; 1.2863 + return xs; 1.2864 + } 1.2865 + 1.2866 + static public double[] vmulsadd(double[] x, double[] ys, double z){ 1.2867 + final double[] xs = x.clone(); 1.2868 + for(int i = 0; i < xs.length; i++) 1.2869 + xs[i] = (xs[i] * ys[i]) + z; 1.2870 + return xs; 1.2871 + } 1.2872 + 1.2873 + static public double[] vdiv(double[] x, double[] ys){ 1.2874 + final double[] xs = x.clone(); 1.2875 + for(int i = 0; i < xs.length; i++) 1.2876 + xs[i] /= ys[i]; 1.2877 + return xs; 1.2878 + } 1.2879 + 1.2880 + static public double[] vmul(double[] x, double[] ys){ 1.2881 + final double[] xs = x.clone(); 1.2882 + for(int i = 0; i < xs.length; i++) 1.2883 + xs[i] *= ys[i]; 1.2884 + return xs; 1.2885 + } 1.2886 + 1.2887 + static public double[] vmuladd(double[] x, double[] ys, double[] zs){ 1.2888 + final double[] xs = x.clone(); 1.2889 + for(int i = 0; i < xs.length; i++) 1.2890 + xs[i] = (xs[i] * ys[i]) + zs[i]; 1.2891 + return xs; 1.2892 + } 1.2893 + 1.2894 + static public double[] vmulsub(double[] x, double[] ys, double[] zs){ 1.2895 + final double[] xs = x.clone(); 1.2896 + for(int i = 0; i < xs.length; i++) 1.2897 + xs[i] = (xs[i] * ys[i]) - zs[i]; 1.2898 + return xs; 1.2899 + } 1.2900 + 1.2901 + static public double[] vmax(double[] x, double[] ys){ 1.2902 + final double[] xs = x.clone(); 1.2903 + for(int i = 0; i < xs.length; i++) 1.2904 + xs[i] = Math.max(xs[i], ys[i]); 1.2905 + return xs; 1.2906 + } 1.2907 + 1.2908 + static public double[] vmin(double[] x, double[] ys){ 1.2909 + final double[] xs = x.clone(); 1.2910 + for(int i = 0; i < xs.length; i++) 1.2911 + xs[i] = Math.min(xs[i], ys[i]); 1.2912 + return xs; 1.2913 + } 1.2914 + 1.2915 + static public double[] vmap(IFn fn, double[] x) throws Exception{ 1.2916 + double[] xs = x.clone(); 1.2917 + for(int i = 0; i < xs.length; i++) 1.2918 + xs[i] = ((Number) fn.invoke(xs[i])).doubleValue(); 1.2919 + return xs; 1.2920 + } 1.2921 + 1.2922 + static public double[] vmap(IFn fn, double[] x, double[] ys) throws Exception{ 1.2923 + double[] xs = x.clone(); 1.2924 + for(int i = 0; i < xs.length; i++) 1.2925 + xs[i] = ((Number) fn.invoke(xs[i], ys[i])).doubleValue(); 1.2926 + return xs; 1.2927 + } 1.2928 +} 1.2929 + 1.2930 +static public class I{ 1.2931 + static public int add(int x, int y){ 1.2932 + return x + y; 1.2933 + } 1.2934 + 1.2935 + static public int subtract(int x, int y){ 1.2936 + return x - y; 1.2937 + } 1.2938 + 1.2939 + static public int negate(int x){ 1.2940 + return -x; 1.2941 + } 1.2942 + 1.2943 + static public int inc(int x){ 1.2944 + return x + 1; 1.2945 + } 1.2946 + 1.2947 + static public int dec(int x){ 1.2948 + return x - 1; 1.2949 + } 1.2950 + 1.2951 + static public int multiply(int x, int y){ 1.2952 + return x * y; 1.2953 + } 1.2954 + 1.2955 + static public int divide(int x, int y){ 1.2956 + return x / y; 1.2957 + } 1.2958 + 1.2959 + static public boolean equiv(int x, int y){ 1.2960 + return x == y; 1.2961 + } 1.2962 + 1.2963 + static public boolean lt(int x, int y){ 1.2964 + return x < y; 1.2965 + } 1.2966 + 1.2967 + static public boolean lte(int x, int y){ 1.2968 + return x <= y; 1.2969 + } 1.2970 + 1.2971 + static public boolean gt(int x, int y){ 1.2972 + return x > y; 1.2973 + } 1.2974 + 1.2975 + static public boolean gte(int x, int y){ 1.2976 + return x >= y; 1.2977 + } 1.2978 + 1.2979 + static public boolean pos(int x){ 1.2980 + return x > 0; 1.2981 + } 1.2982 + 1.2983 + static public boolean neg(int x){ 1.2984 + return x < 0; 1.2985 + } 1.2986 + 1.2987 + static public boolean zero(int x){ 1.2988 + return x == 0; 1.2989 + } 1.2990 + 1.2991 + static public int aget(int[] xs, int i){ 1.2992 + return xs[i]; 1.2993 + } 1.2994 + 1.2995 + static public int aset(int[] xs, int i, int v){ 1.2996 + xs[i] = v; 1.2997 + return v; 1.2998 + } 1.2999 + 1.3000 + static public int alength(int[] xs){ 1.3001 + return xs.length; 1.3002 + } 1.3003 + 1.3004 + static public int[] aclone(int[] xs){ 1.3005 + return xs.clone(); 1.3006 + } 1.3007 + 1.3008 + static public int[] vec(int size, Object init){ 1.3009 + int[] ret = new int[size]; 1.3010 + if(init instanceof Number) 1.3011 + { 1.3012 + int f = ((Number) init).intValue(); 1.3013 + for(int i = 0; i < ret.length; i++) 1.3014 + ret[i] = f; 1.3015 + } 1.3016 + else 1.3017 + { 1.3018 + ISeq s = RT.seq(init); 1.3019 + for(int i = 0; i < size && s != null; i++, s = s.rest()) 1.3020 + ret[i] = ((Number) s.first()).intValue(); 1.3021 + } 1.3022 + return ret; 1.3023 + } 1.3024 + 1.3025 + static public int[] vec(Object sizeOrSeq){ 1.3026 + if(sizeOrSeq instanceof Number) 1.3027 + return new int[((Number) sizeOrSeq).intValue()]; 1.3028 + else 1.3029 + { 1.3030 + ISeq s = RT.seq(sizeOrSeq); 1.3031 + int size = s.count(); 1.3032 + int[] ret = new int[size]; 1.3033 + for(int i = 0; i < size && s != null; i++, s = s.rest()) 1.3034 + ret[i] = ((Number) s.first()).intValue(); 1.3035 + return ret; 1.3036 + } 1.3037 + } 1.3038 + 1.3039 + static public int[] vsadd(int[] x, int y){ 1.3040 + final int[] xs = x.clone(); 1.3041 + for(int i = 0; i < xs.length; i++) 1.3042 + xs[i] += y; 1.3043 + return xs; 1.3044 + } 1.3045 + 1.3046 + static public int[] vssub(int[] x, int y){ 1.3047 + final int[] xs = x.clone(); 1.3048 + for(int i = 0; i < xs.length; i++) 1.3049 + xs[i] -= y; 1.3050 + return xs; 1.3051 + } 1.3052 + 1.3053 + static public int[] vsdiv(int[] x, int y){ 1.3054 + final int[] xs = x.clone(); 1.3055 + for(int i = 0; i < xs.length; i++) 1.3056 + xs[i] /= y; 1.3057 + return xs; 1.3058 + } 1.3059 + 1.3060 + static public int[] vsmul(int[] x, int y){ 1.3061 + final int[] xs = x.clone(); 1.3062 + for(int i = 0; i < xs.length; i++) 1.3063 + xs[i] *= y; 1.3064 + return xs; 1.3065 + } 1.3066 + 1.3067 + static public int[] svdiv(int y, int[] x){ 1.3068 + final int[] xs = x.clone(); 1.3069 + for(int i = 0; i < xs.length; i++) 1.3070 + xs[i] = y / xs[i]; 1.3071 + return xs; 1.3072 + } 1.3073 + 1.3074 + static public int[] vsmuladd(int[] x, int y, int[] zs){ 1.3075 + final int[] xs = x.clone(); 1.3076 + for(int i = 0; i < xs.length; i++) 1.3077 + xs[i] = xs[i] * y + zs[i]; 1.3078 + return xs; 1.3079 + } 1.3080 + 1.3081 + static public int[] vsmulsub(int[] x, int y, int[] zs){ 1.3082 + final int[] xs = x.clone(); 1.3083 + for(int i = 0; i < xs.length; i++) 1.3084 + xs[i] = xs[i] * y - zs[i]; 1.3085 + return xs; 1.3086 + } 1.3087 + 1.3088 + static public int[] vsmulsadd(int[] x, int y, int z){ 1.3089 + final int[] xs = x.clone(); 1.3090 + for(int i = 0; i < xs.length; i++) 1.3091 + xs[i] = xs[i] * y + z; 1.3092 + return xs; 1.3093 + } 1.3094 + 1.3095 + static public int[] vsmulssub(int[] x, int y, int z){ 1.3096 + final int[] xs = x.clone(); 1.3097 + for(int i = 0; i < xs.length; i++) 1.3098 + xs[i] = xs[i] * y - z; 1.3099 + return xs; 1.3100 + } 1.3101 + 1.3102 + static public int[] vabs(int[] x){ 1.3103 + final int[] xs = x.clone(); 1.3104 + for(int i = 0; i < xs.length; i++) 1.3105 + xs[i] = Math.abs(xs[i]); 1.3106 + return xs; 1.3107 + } 1.3108 + 1.3109 + static public int[] vnegabs(int[] x){ 1.3110 + final int[] xs = x.clone(); 1.3111 + for(int i = 0; i < xs.length; i++) 1.3112 + xs[i] = -Math.abs(xs[i]); 1.3113 + return xs; 1.3114 + } 1.3115 + 1.3116 + static public int[] vneg(int[] x){ 1.3117 + final int[] xs = x.clone(); 1.3118 + for(int i = 0; i < xs.length; i++) 1.3119 + xs[i] = -xs[i]; 1.3120 + return xs; 1.3121 + } 1.3122 + 1.3123 + static public int[] vsqr(int[] x){ 1.3124 + final int[] xs = x.clone(); 1.3125 + for(int i = 0; i < xs.length; i++) 1.3126 + xs[i] *= xs[i]; 1.3127 + return xs; 1.3128 + } 1.3129 + 1.3130 + static public int[] vsignedsqr(int[] x){ 1.3131 + final int[] xs = x.clone(); 1.3132 + for(int i = 0; i < xs.length; i++) 1.3133 + xs[i] *= Math.abs(xs[i]); 1.3134 + return xs; 1.3135 + } 1.3136 + 1.3137 + static public int[] vclip(int[] x, int low, int high){ 1.3138 + final int[] xs = x.clone(); 1.3139 + for(int i = 0; i < xs.length; i++) 1.3140 + { 1.3141 + if(xs[i] < low) 1.3142 + xs[i] = low; 1.3143 + else if(xs[i] > high) 1.3144 + xs[i] = high; 1.3145 + } 1.3146 + return xs; 1.3147 + } 1.3148 + 1.3149 + static public IPersistentVector vclipcounts(int[] x, int low, int high){ 1.3150 + final int[] xs = x.clone(); 1.3151 + int lowc = 0; 1.3152 + int highc = 0; 1.3153 + 1.3154 + for(int i = 0; i < xs.length; i++) 1.3155 + { 1.3156 + if(xs[i] < low) 1.3157 + { 1.3158 + ++lowc; 1.3159 + xs[i] = low; 1.3160 + } 1.3161 + else if(xs[i] > high) 1.3162 + { 1.3163 + ++highc; 1.3164 + xs[i] = high; 1.3165 + } 1.3166 + } 1.3167 + return RT.vector(xs, lowc, highc); 1.3168 + } 1.3169 + 1.3170 + static public int[] vthresh(int[] x, int thresh, int otherwise){ 1.3171 + final int[] xs = x.clone(); 1.3172 + for(int i = 0; i < xs.length; i++) 1.3173 + { 1.3174 + if(xs[i] < thresh) 1.3175 + xs[i] = otherwise; 1.3176 + } 1.3177 + return xs; 1.3178 + } 1.3179 + 1.3180 + static public int[] vreverse(int[] x){ 1.3181 + final int[] xs = x.clone(); 1.3182 + for(int i = 0; i < xs.length; i++) 1.3183 + xs[i] = xs[xs.length - i - 1]; 1.3184 + return xs; 1.3185 + } 1.3186 + 1.3187 + static public int[] vrunningsum(int[] x){ 1.3188 + final int[] xs = x.clone(); 1.3189 + for(int i = 1; i < xs.length; i++) 1.3190 + xs[i] = xs[i - 1] + xs[i]; 1.3191 + return xs; 1.3192 + } 1.3193 + 1.3194 + static public int[] vsort(int[] x){ 1.3195 + final int[] xs = x.clone(); 1.3196 + Arrays.sort(xs); 1.3197 + return xs; 1.3198 + } 1.3199 + 1.3200 + static public int vdot(int[] xs, int[] ys){ 1.3201 + int ret = 0; 1.3202 + for(int i = 0; i < xs.length; i++) 1.3203 + ret += xs[i] * ys[i]; 1.3204 + return ret; 1.3205 + } 1.3206 + 1.3207 + static public int vmax(int[] xs){ 1.3208 + if(xs.length == 0) 1.3209 + return 0; 1.3210 + int ret = xs[0]; 1.3211 + for(int i = 0; i < xs.length; i++) 1.3212 + ret = Math.max(ret, xs[i]); 1.3213 + return ret; 1.3214 + } 1.3215 + 1.3216 + static public int vmin(int[] xs){ 1.3217 + if(xs.length == 0) 1.3218 + return 0; 1.3219 + int ret = xs[0]; 1.3220 + for(int i = 0; i < xs.length; i++) 1.3221 + ret = Math.min(ret, xs[i]); 1.3222 + return ret; 1.3223 + } 1.3224 + 1.3225 + static public double vmean(int[] xs){ 1.3226 + if(xs.length == 0) 1.3227 + return 0; 1.3228 + return vsum(xs) / (double) xs.length; 1.3229 + } 1.3230 + 1.3231 + static public double vrms(int[] xs){ 1.3232 + if(xs.length == 0) 1.3233 + return 0; 1.3234 + int ret = 0; 1.3235 + for(int i = 0; i < xs.length; i++) 1.3236 + ret += xs[i] * xs[i]; 1.3237 + return Math.sqrt(ret / (double) xs.length); 1.3238 + } 1.3239 + 1.3240 + static public int vsum(int[] xs){ 1.3241 + int ret = 0; 1.3242 + for(int i = 0; i < xs.length; i++) 1.3243 + ret += xs[i]; 1.3244 + return ret; 1.3245 + } 1.3246 + 1.3247 + static public boolean vequiv(int[] xs, int[] ys){ 1.3248 + return Arrays.equals(xs, ys); 1.3249 + } 1.3250 + 1.3251 + static public int[] vadd(int[] x, int[] ys){ 1.3252 + final int[] xs = x.clone(); 1.3253 + for(int i = 0; i < xs.length; i++) 1.3254 + xs[i] += ys[i]; 1.3255 + return xs; 1.3256 + } 1.3257 + 1.3258 + static public int[] vsub(int[] x, int[] ys){ 1.3259 + final int[] xs = x.clone(); 1.3260 + for(int i = 0; i < xs.length; i++) 1.3261 + xs[i] -= ys[i]; 1.3262 + return xs; 1.3263 + } 1.3264 + 1.3265 + static public int[] vaddmul(int[] x, int[] ys, int[] zs){ 1.3266 + final int[] xs = x.clone(); 1.3267 + for(int i = 0; i < xs.length; i++) 1.3268 + xs[i] = (xs[i] + ys[i]) * zs[i]; 1.3269 + return xs; 1.3270 + } 1.3271 + 1.3272 + static public int[] vsubmul(int[] x, int[] ys, int[] zs){ 1.3273 + final int[] xs = x.clone(); 1.3274 + for(int i = 0; i < xs.length; i++) 1.3275 + xs[i] = (xs[i] - ys[i]) * zs[i]; 1.3276 + return xs; 1.3277 + } 1.3278 + 1.3279 + static public int[] vaddsmul(int[] x, int[] ys, int z){ 1.3280 + final int[] xs = x.clone(); 1.3281 + for(int i = 0; i < xs.length; i++) 1.3282 + xs[i] = (xs[i] + ys[i]) * z; 1.3283 + return xs; 1.3284 + } 1.3285 + 1.3286 + static public int[] vsubsmul(int[] x, int[] ys, int z){ 1.3287 + final int[] xs = x.clone(); 1.3288 + for(int i = 0; i < xs.length; i++) 1.3289 + xs[i] = (xs[i] - ys[i]) * z; 1.3290 + return xs; 1.3291 + } 1.3292 + 1.3293 + static public int[] vmulsadd(int[] x, int[] ys, int z){ 1.3294 + final int[] xs = x.clone(); 1.3295 + for(int i = 0; i < xs.length; i++) 1.3296 + xs[i] = (xs[i] * ys[i]) + z; 1.3297 + return xs; 1.3298 + } 1.3299 + 1.3300 + static public int[] vdiv(int[] x, int[] ys){ 1.3301 + final int[] xs = x.clone(); 1.3302 + for(int i = 0; i < xs.length; i++) 1.3303 + xs[i] /= ys[i]; 1.3304 + return xs; 1.3305 + } 1.3306 + 1.3307 + static public int[] vmul(int[] x, int[] ys){ 1.3308 + final int[] xs = x.clone(); 1.3309 + for(int i = 0; i < xs.length; i++) 1.3310 + xs[i] *= ys[i]; 1.3311 + return xs; 1.3312 + } 1.3313 + 1.3314 + static public int[] vmuladd(int[] x, int[] ys, int[] zs){ 1.3315 + final int[] xs = x.clone(); 1.3316 + for(int i = 0; i < xs.length; i++) 1.3317 + xs[i] = (xs[i] * ys[i]) + zs[i]; 1.3318 + return xs; 1.3319 + } 1.3320 + 1.3321 + static public int[] vmulsub(int[] x, int[] ys, int[] zs){ 1.3322 + final int[] xs = x.clone(); 1.3323 + for(int i = 0; i < xs.length; i++) 1.3324 + xs[i] = (xs[i] * ys[i]) - zs[i]; 1.3325 + return xs; 1.3326 + } 1.3327 + 1.3328 + static public int[] vmax(int[] x, int[] ys){ 1.3329 + final int[] xs = x.clone(); 1.3330 + for(int i = 0; i < xs.length; i++) 1.3331 + xs[i] = Math.max(xs[i], ys[i]); 1.3332 + return xs; 1.3333 + } 1.3334 + 1.3335 + static public int[] vmin(int[] x, int[] ys){ 1.3336 + final int[] xs = x.clone(); 1.3337 + for(int i = 0; i < xs.length; i++) 1.3338 + xs[i] = Math.min(xs[i], ys[i]); 1.3339 + return xs; 1.3340 + } 1.3341 + 1.3342 + static public int[] vmap(IFn fn, int[] x) throws Exception{ 1.3343 + int[] xs = x.clone(); 1.3344 + for(int i = 0; i < xs.length; i++) 1.3345 + xs[i] = ((Number) fn.invoke(xs[i])).intValue(); 1.3346 + return xs; 1.3347 + } 1.3348 + 1.3349 + static public int[] vmap(IFn fn, int[] x, int[] ys) throws Exception{ 1.3350 + int[] xs = x.clone(); 1.3351 + for(int i = 0; i < xs.length; i++) 1.3352 + xs[i] = ((Number) fn.invoke(xs[i], ys[i])).intValue(); 1.3353 + return xs; 1.3354 + } 1.3355 + 1.3356 +} 1.3357 + 1.3358 +static public class L{ 1.3359 + static public long add(long x, long y){ 1.3360 + return x + y; 1.3361 + } 1.3362 + 1.3363 + static public long subtract(long x, long y){ 1.3364 + return x - y; 1.3365 + } 1.3366 + 1.3367 + static public long negate(long x){ 1.3368 + return -x; 1.3369 + } 1.3370 + 1.3371 + static public long inc(long x){ 1.3372 + return x + 1; 1.3373 + } 1.3374 + 1.3375 + static public long dec(long x){ 1.3376 + return x - 1; 1.3377 + } 1.3378 + 1.3379 + static public long multiply(long x, long y){ 1.3380 + return x * y; 1.3381 + } 1.3382 + 1.3383 + static public long divide(long x, long y){ 1.3384 + return x / y; 1.3385 + } 1.3386 + 1.3387 + static public boolean equiv(long x, long y){ 1.3388 + return x == y; 1.3389 + } 1.3390 + 1.3391 + static public boolean lt(long x, long y){ 1.3392 + return x < y; 1.3393 + } 1.3394 + 1.3395 + static public boolean lte(long x, long y){ 1.3396 + return x <= y; 1.3397 + } 1.3398 + 1.3399 + static public boolean gt(long x, long y){ 1.3400 + return x > y; 1.3401 + } 1.3402 + 1.3403 + static public boolean gte(long x, long y){ 1.3404 + return x >= y; 1.3405 + } 1.3406 + 1.3407 + static public boolean pos(long x){ 1.3408 + return x > 0; 1.3409 + } 1.3410 + 1.3411 + static public boolean neg(long x){ 1.3412 + return x < 0; 1.3413 + } 1.3414 + 1.3415 + static public boolean zero(long x){ 1.3416 + return x == 0; 1.3417 + } 1.3418 + 1.3419 + static public long aget(long[] xs, int i){ 1.3420 + return xs[i]; 1.3421 + } 1.3422 + 1.3423 + static public long aset(long[] xs, int i, long v){ 1.3424 + xs[i] = v; 1.3425 + return v; 1.3426 + } 1.3427 + 1.3428 + static public int alength(long[] xs){ 1.3429 + return xs.length; 1.3430 + } 1.3431 + 1.3432 + static public long[] aclone(long[] xs){ 1.3433 + return xs.clone(); 1.3434 + } 1.3435 + 1.3436 + static public long[] vec(int size, Object init){ 1.3437 + long[] ret = new long[size]; 1.3438 + if(init instanceof Number) 1.3439 + { 1.3440 + long f = ((Number) init).longValue(); 1.3441 + for(int i = 0; i < ret.length; i++) 1.3442 + ret[i] = f; 1.3443 + } 1.3444 + else 1.3445 + { 1.3446 + ISeq s = RT.seq(init); 1.3447 + for(int i = 0; i < size && s != null; i++, s = s.rest()) 1.3448 + ret[i] = ((Number) s.first()).longValue(); 1.3449 + } 1.3450 + return ret; 1.3451 + } 1.3452 + 1.3453 + static public long[] vec(Object sizeOrSeq){ 1.3454 + if(sizeOrSeq instanceof Number) 1.3455 + return new long[((Number) sizeOrSeq).intValue()]; 1.3456 + else 1.3457 + { 1.3458 + ISeq s = RT.seq(sizeOrSeq); 1.3459 + int size = s.count(); 1.3460 + long[] ret = new long[size]; 1.3461 + for(int i = 0; i < size && s != null; i++, s = s.rest()) 1.3462 + ret[i] = ((Number) s.first()).intValue(); 1.3463 + return ret; 1.3464 + } 1.3465 + } 1.3466 + 1.3467 + 1.3468 + static public long[] vsadd(long[] x, long y){ 1.3469 + final long[] xs = x.clone(); 1.3470 + for(int i = 0; i < xs.length; i++) 1.3471 + xs[i] += y; 1.3472 + return xs; 1.3473 + } 1.3474 + 1.3475 + static public long[] vssub(long[] x, long y){ 1.3476 + final long[] xs = x.clone(); 1.3477 + for(int i = 0; i < xs.length; i++) 1.3478 + xs[i] -= y; 1.3479 + return xs; 1.3480 + } 1.3481 + 1.3482 + static public long[] vsdiv(long[] x, long y){ 1.3483 + final long[] xs = x.clone(); 1.3484 + for(int i = 0; i < xs.length; i++) 1.3485 + xs[i] /= y; 1.3486 + return xs; 1.3487 + } 1.3488 + 1.3489 + static public long[] vsmul(long[] x, long y){ 1.3490 + final long[] xs = x.clone(); 1.3491 + for(int i = 0; i < xs.length; i++) 1.3492 + xs[i] *= y; 1.3493 + return xs; 1.3494 + } 1.3495 + 1.3496 + static public long[] svdiv(long y, long[] x){ 1.3497 + final long[] xs = x.clone(); 1.3498 + for(int i = 0; i < xs.length; i++) 1.3499 + xs[i] = y / xs[i]; 1.3500 + return xs; 1.3501 + } 1.3502 + 1.3503 + static public long[] vsmuladd(long[] x, long y, long[] zs){ 1.3504 + final long[] xs = x.clone(); 1.3505 + for(int i = 0; i < xs.length; i++) 1.3506 + xs[i] = xs[i] * y + zs[i]; 1.3507 + return xs; 1.3508 + } 1.3509 + 1.3510 + static public long[] vsmulsub(long[] x, long y, long[] zs){ 1.3511 + final long[] xs = x.clone(); 1.3512 + for(int i = 0; i < xs.length; i++) 1.3513 + xs[i] = xs[i] * y - zs[i]; 1.3514 + return xs; 1.3515 + } 1.3516 + 1.3517 + static public long[] vsmulsadd(long[] x, long y, long z){ 1.3518 + final long[] xs = x.clone(); 1.3519 + for(int i = 0; i < xs.length; i++) 1.3520 + xs[i] = xs[i] * y + z; 1.3521 + return xs; 1.3522 + } 1.3523 + 1.3524 + static public long[] vsmulssub(long[] x, long y, long z){ 1.3525 + final long[] xs = x.clone(); 1.3526 + for(int i = 0; i < xs.length; i++) 1.3527 + xs[i] = xs[i] * y - z; 1.3528 + return xs; 1.3529 + } 1.3530 + 1.3531 + static public long[] vabs(long[] x){ 1.3532 + final long[] xs = x.clone(); 1.3533 + for(int i = 0; i < xs.length; i++) 1.3534 + xs[i] = Math.abs(xs[i]); 1.3535 + return xs; 1.3536 + } 1.3537 + 1.3538 + static public long[] vnegabs(long[] x){ 1.3539 + final long[] xs = x.clone(); 1.3540 + for(int i = 0; i < xs.length; i++) 1.3541 + xs[i] = -Math.abs(xs[i]); 1.3542 + return xs; 1.3543 + } 1.3544 + 1.3545 + static public long[] vneg(long[] x){ 1.3546 + final long[] xs = x.clone(); 1.3547 + for(int i = 0; i < xs.length; i++) 1.3548 + xs[i] = -xs[i]; 1.3549 + return xs; 1.3550 + } 1.3551 + 1.3552 + static public long[] vsqr(long[] x){ 1.3553 + final long[] xs = x.clone(); 1.3554 + for(int i = 0; i < xs.length; i++) 1.3555 + xs[i] *= xs[i]; 1.3556 + return xs; 1.3557 + } 1.3558 + 1.3559 + static public long[] vsignedsqr(long[] x){ 1.3560 + final long[] xs = x.clone(); 1.3561 + for(int i = 0; i < xs.length; i++) 1.3562 + xs[i] *= Math.abs(xs[i]); 1.3563 + return xs; 1.3564 + } 1.3565 + 1.3566 + static public long[] vclip(long[] x, long low, long high){ 1.3567 + final long[] xs = x.clone(); 1.3568 + for(int i = 0; i < xs.length; i++) 1.3569 + { 1.3570 + if(xs[i] < low) 1.3571 + xs[i] = low; 1.3572 + else if(xs[i] > high) 1.3573 + xs[i] = high; 1.3574 + } 1.3575 + return xs; 1.3576 + } 1.3577 + 1.3578 + static public IPersistentVector vclipcounts(long[] x, long low, long high){ 1.3579 + final long[] xs = x.clone(); 1.3580 + int lowc = 0; 1.3581 + int highc = 0; 1.3582 + 1.3583 + for(int i = 0; i < xs.length; i++) 1.3584 + { 1.3585 + if(xs[i] < low) 1.3586 + { 1.3587 + ++lowc; 1.3588 + xs[i] = low; 1.3589 + } 1.3590 + else if(xs[i] > high) 1.3591 + { 1.3592 + ++highc; 1.3593 + xs[i] = high; 1.3594 + } 1.3595 + } 1.3596 + return RT.vector(xs, lowc, highc); 1.3597 + } 1.3598 + 1.3599 + static public long[] vthresh(long[] x, long thresh, long otherwise){ 1.3600 + final long[] xs = x.clone(); 1.3601 + for(int i = 0; i < xs.length; i++) 1.3602 + { 1.3603 + if(xs[i] < thresh) 1.3604 + xs[i] = otherwise; 1.3605 + } 1.3606 + return xs; 1.3607 + } 1.3608 + 1.3609 + static public long[] vreverse(long[] x){ 1.3610 + final long[] xs = x.clone(); 1.3611 + for(int i = 0; i < xs.length; i++) 1.3612 + xs[i] = xs[xs.length - i - 1]; 1.3613 + return xs; 1.3614 + } 1.3615 + 1.3616 + static public long[] vrunningsum(long[] x){ 1.3617 + final long[] xs = x.clone(); 1.3618 + for(int i = 1; i < xs.length; i++) 1.3619 + xs[i] = xs[i - 1] + xs[i]; 1.3620 + return xs; 1.3621 + } 1.3622 + 1.3623 + static public long[] vsort(long[] x){ 1.3624 + final long[] xs = x.clone(); 1.3625 + Arrays.sort(xs); 1.3626 + return xs; 1.3627 + } 1.3628 + 1.3629 + static public long vdot(long[] xs, long[] ys){ 1.3630 + long ret = 0; 1.3631 + for(int i = 0; i < xs.length; i++) 1.3632 + ret += xs[i] * ys[i]; 1.3633 + return ret; 1.3634 + } 1.3635 + 1.3636 + static public long vmax(long[] xs){ 1.3637 + if(xs.length == 0) 1.3638 + return 0; 1.3639 + long ret = xs[0]; 1.3640 + for(int i = 0; i < xs.length; i++) 1.3641 + ret = Math.max(ret, xs[i]); 1.3642 + return ret; 1.3643 + } 1.3644 + 1.3645 + static public long vmin(long[] xs){ 1.3646 + if(xs.length == 0) 1.3647 + return 0; 1.3648 + long ret = xs[0]; 1.3649 + for(int i = 0; i < xs.length; i++) 1.3650 + ret = Math.min(ret, xs[i]); 1.3651 + return ret; 1.3652 + } 1.3653 + 1.3654 + static public double vmean(long[] xs){ 1.3655 + if(xs.length == 0) 1.3656 + return 0; 1.3657 + return vsum(xs) / (double) xs.length; 1.3658 + } 1.3659 + 1.3660 + static public double vrms(long[] xs){ 1.3661 + if(xs.length == 0) 1.3662 + return 0; 1.3663 + long ret = 0; 1.3664 + for(int i = 0; i < xs.length; i++) 1.3665 + ret += xs[i] * xs[i]; 1.3666 + return Math.sqrt(ret / (double) xs.length); 1.3667 + } 1.3668 + 1.3669 + static public long vsum(long[] xs){ 1.3670 + long ret = 0; 1.3671 + for(int i = 0; i < xs.length; i++) 1.3672 + ret += xs[i]; 1.3673 + return ret; 1.3674 + } 1.3675 + 1.3676 + static public boolean vequiv(long[] xs, long[] ys){ 1.3677 + return Arrays.equals(xs, ys); 1.3678 + } 1.3679 + 1.3680 + static public long[] vadd(long[] x, long[] ys){ 1.3681 + final long[] xs = x.clone(); 1.3682 + for(int i = 0; i < xs.length; i++) 1.3683 + xs[i] += ys[i]; 1.3684 + return xs; 1.3685 + } 1.3686 + 1.3687 + static public long[] vsub(long[] x, long[] ys){ 1.3688 + final long[] xs = x.clone(); 1.3689 + for(int i = 0; i < xs.length; i++) 1.3690 + xs[i] -= ys[i]; 1.3691 + return xs; 1.3692 + } 1.3693 + 1.3694 + static public long[] vaddmul(long[] x, long[] ys, long[] zs){ 1.3695 + final long[] xs = x.clone(); 1.3696 + for(int i = 0; i < xs.length; i++) 1.3697 + xs[i] = (xs[i] + ys[i]) * zs[i]; 1.3698 + return xs; 1.3699 + } 1.3700 + 1.3701 + static public long[] vsubmul(long[] x, long[] ys, long[] zs){ 1.3702 + final long[] xs = x.clone(); 1.3703 + for(int i = 0; i < xs.length; i++) 1.3704 + xs[i] = (xs[i] - ys[i]) * zs[i]; 1.3705 + return xs; 1.3706 + } 1.3707 + 1.3708 + static public long[] vaddsmul(long[] x, long[] ys, long z){ 1.3709 + final long[] xs = x.clone(); 1.3710 + for(int i = 0; i < xs.length; i++) 1.3711 + xs[i] = (xs[i] + ys[i]) * z; 1.3712 + return xs; 1.3713 + } 1.3714 + 1.3715 + static public long[] vsubsmul(long[] x, long[] ys, long z){ 1.3716 + final long[] xs = x.clone(); 1.3717 + for(int i = 0; i < xs.length; i++) 1.3718 + xs[i] = (xs[i] - ys[i]) * z; 1.3719 + return xs; 1.3720 + } 1.3721 + 1.3722 + static public long[] vmulsadd(long[] x, long[] ys, long z){ 1.3723 + final long[] xs = x.clone(); 1.3724 + for(int i = 0; i < xs.length; i++) 1.3725 + xs[i] = (xs[i] * ys[i]) + z; 1.3726 + return xs; 1.3727 + } 1.3728 + 1.3729 + static public long[] vdiv(long[] x, long[] ys){ 1.3730 + final long[] xs = x.clone(); 1.3731 + for(int i = 0; i < xs.length; i++) 1.3732 + xs[i] /= ys[i]; 1.3733 + return xs; 1.3734 + } 1.3735 + 1.3736 + static public long[] vmul(long[] x, long[] ys){ 1.3737 + final long[] xs = x.clone(); 1.3738 + for(int i = 0; i < xs.length; i++) 1.3739 + xs[i] *= ys[i]; 1.3740 + return xs; 1.3741 + } 1.3742 + 1.3743 + static public long[] vmuladd(long[] x, long[] ys, long[] zs){ 1.3744 + final long[] xs = x.clone(); 1.3745 + for(int i = 0; i < xs.length; i++) 1.3746 + xs[i] = (xs[i] * ys[i]) + zs[i]; 1.3747 + return xs; 1.3748 + } 1.3749 + 1.3750 + static public long[] vmulsub(long[] x, long[] ys, long[] zs){ 1.3751 + final long[] xs = x.clone(); 1.3752 + for(int i = 0; i < xs.length; i++) 1.3753 + xs[i] = (xs[i] * ys[i]) - zs[i]; 1.3754 + return xs; 1.3755 + } 1.3756 + 1.3757 + static public long[] vmax(long[] x, long[] ys){ 1.3758 + final long[] xs = x.clone(); 1.3759 + for(int i = 0; i < xs.length; i++) 1.3760 + xs[i] = Math.max(xs[i], ys[i]); 1.3761 + return xs; 1.3762 + } 1.3763 + 1.3764 + static public long[] vmin(long[] x, long[] ys){ 1.3765 + final long[] xs = x.clone(); 1.3766 + for(int i = 0; i < xs.length; i++) 1.3767 + xs[i] = Math.min(xs[i], ys[i]); 1.3768 + return xs; 1.3769 + } 1.3770 + 1.3771 + static public long[] vmap(IFn fn, long[] x) throws Exception{ 1.3772 + long[] xs = x.clone(); 1.3773 + for(int i = 0; i < xs.length; i++) 1.3774 + xs[i] = ((Number) fn.invoke(xs[i])).longValue(); 1.3775 + return xs; 1.3776 + } 1.3777 + 1.3778 + static public long[] vmap(IFn fn, long[] x, long[] ys) throws Exception{ 1.3779 + long[] xs = x.clone(); 1.3780 + for(int i = 0; i < xs.length; i++) 1.3781 + xs[i] = ((Number) fn.invoke(xs[i], ys[i])).longValue(); 1.3782 + return xs; 1.3783 + } 1.3784 + 1.3785 +} 1.3786 +*/ 1.3787 + 1.3788 + 1.3789 +//overload resolution 1.3790 + 1.3791 +static public Number add(int x, Object y){ 1.3792 + return add((Object)x,y); 1.3793 +} 1.3794 + 1.3795 +static public Number add(Object x, int y){ 1.3796 + return add(x,(Object)y); 1.3797 +} 1.3798 + 1.3799 +static public Number and(int x, Object y){ 1.3800 + return and((Object)x,y); 1.3801 +} 1.3802 + 1.3803 +static public Number and(Object x, int y){ 1.3804 + return and(x,(Object)y); 1.3805 +} 1.3806 + 1.3807 +static public Number or(int x, Object y){ 1.3808 + return or((Object)x,y); 1.3809 +} 1.3810 + 1.3811 +static public Number or(Object x, int y){ 1.3812 + return or(x,(Object)y); 1.3813 +} 1.3814 + 1.3815 +static public Number xor(int x, Object y){ 1.3816 + return xor((Object)x,y); 1.3817 +} 1.3818 + 1.3819 +static public Number xor(Object x, int y){ 1.3820 + return xor(x,(Object)y); 1.3821 +} 1.3822 + 1.3823 +static public Number add(float x, Object y){ 1.3824 + return add((Object)x,y); 1.3825 +} 1.3826 + 1.3827 +static public Number add(Object x, float y){ 1.3828 + return add(x,(Object)y); 1.3829 +} 1.3830 + 1.3831 +static public Number add(long x, Object y){ 1.3832 + return add((Object)x,y); 1.3833 +} 1.3834 + 1.3835 +static public Number add(Object x, long y){ 1.3836 + return add(x,(Object)y); 1.3837 +} 1.3838 + 1.3839 +static public Number add(double x, Object y){ 1.3840 + return add((Object)x,y); 1.3841 +} 1.3842 + 1.3843 +static public Number add(Object x, double y){ 1.3844 + return add(x,(Object)y); 1.3845 +} 1.3846 + 1.3847 +static public Number minus(int x, Object y){ 1.3848 + return minus((Object)x,y); 1.3849 +} 1.3850 + 1.3851 +static public Number minus(Object x, int y){ 1.3852 + return minus(x,(Object)y); 1.3853 +} 1.3854 + 1.3855 +static public Number minus(float x, Object y){ 1.3856 + return minus((Object)x,y); 1.3857 +} 1.3858 + 1.3859 +static public Number minus(Object x, float y){ 1.3860 + return minus(x,(Object)y); 1.3861 +} 1.3862 + 1.3863 +static public Number minus(long x, Object y){ 1.3864 + return minus((Object)x,y); 1.3865 +} 1.3866 + 1.3867 +static public Number minus(Object x, long y){ 1.3868 + return minus(x,(Object)y); 1.3869 +} 1.3870 + 1.3871 +static public Number minus(double x, Object y){ 1.3872 + return minus((Object)x,y); 1.3873 +} 1.3874 + 1.3875 +static public Number minus(Object x, double y){ 1.3876 + return minus(x,(Object)y); 1.3877 +} 1.3878 + 1.3879 +static public Number multiply(int x, Object y){ 1.3880 + return multiply((Object)x,y); 1.3881 +} 1.3882 + 1.3883 +static public Number multiply(Object x, int y){ 1.3884 + return multiply(x,(Object)y); 1.3885 +} 1.3886 + 1.3887 +static public Number multiply(float x, Object y){ 1.3888 + return multiply((Object)x,y); 1.3889 +} 1.3890 + 1.3891 +static public Number multiply(Object x, float y){ 1.3892 + return multiply(x,(Object)y); 1.3893 +} 1.3894 + 1.3895 +static public Number multiply(long x, Object y){ 1.3896 + return multiply((Object)x,y); 1.3897 +} 1.3898 + 1.3899 +static public Number multiply(Object x, long y){ 1.3900 + return multiply(x,(Object)y); 1.3901 +} 1.3902 + 1.3903 +static public Number multiply(double x, Object y){ 1.3904 + return multiply((Object)x,y); 1.3905 +} 1.3906 + 1.3907 +static public Number multiply(Object x, double y){ 1.3908 + return multiply(x,(Object)y); 1.3909 +} 1.3910 + 1.3911 +static public Number divide(int x, Object y){ 1.3912 + return divide((Object)x,y); 1.3913 +} 1.3914 + 1.3915 +static public Number divide(Object x, int y){ 1.3916 + return divide(x,(Object)y); 1.3917 +} 1.3918 + 1.3919 +static public Number divide(float x, Object y){ 1.3920 + return divide((Object)x,y); 1.3921 +} 1.3922 + 1.3923 +static public Number divide(Object x, float y){ 1.3924 + return divide(x,(Object)y); 1.3925 +} 1.3926 + 1.3927 +static public Number divide(long x, Object y){ 1.3928 + return divide((Object)x,y); 1.3929 +} 1.3930 + 1.3931 +static public Number divide(Object x, long y){ 1.3932 + return divide(x,(Object)y); 1.3933 +} 1.3934 + 1.3935 +static public Number divide(double x, Object y){ 1.3936 + return divide((Object)x,y); 1.3937 +} 1.3938 + 1.3939 +static public Number divide(Object x, double y){ 1.3940 + return divide(x,(Object)y); 1.3941 +} 1.3942 + 1.3943 +static public boolean lt(int x, Object y){ 1.3944 + return lt((Object)x,y); 1.3945 +} 1.3946 + 1.3947 +static public boolean lt(Object x, int y){ 1.3948 + return lt(x,(Object)y); 1.3949 +} 1.3950 + 1.3951 +static public boolean lt(float x, Object y){ 1.3952 + return lt((Object)x,y); 1.3953 +} 1.3954 + 1.3955 +static public boolean lt(Object x, float y){ 1.3956 + return lt(x,(Object)y); 1.3957 +} 1.3958 + 1.3959 +static public boolean lt(long x, Object y){ 1.3960 + return lt((Object)x,y); 1.3961 +} 1.3962 + 1.3963 +static public boolean lt(Object x, long y){ 1.3964 + return lt(x,(Object)y); 1.3965 +} 1.3966 + 1.3967 +static public boolean lt(double x, Object y){ 1.3968 + return lt((Object)x,y); 1.3969 +} 1.3970 + 1.3971 +static public boolean lt(Object x, double y){ 1.3972 + return lt(x,(Object)y); 1.3973 +} 1.3974 + 1.3975 +static public boolean lte(int x, Object y){ 1.3976 + return lte((Object)x,y); 1.3977 +} 1.3978 + 1.3979 +static public boolean lte(Object x, int y){ 1.3980 + return lte(x,(Object)y); 1.3981 +} 1.3982 + 1.3983 +static public boolean lte(float x, Object y){ 1.3984 + return lte((Object)x,y); 1.3985 +} 1.3986 + 1.3987 +static public boolean lte(Object x, float y){ 1.3988 + return lte(x,(Object)y); 1.3989 +} 1.3990 + 1.3991 +static public boolean lte(long x, Object y){ 1.3992 + return lte((Object)x,y); 1.3993 +} 1.3994 + 1.3995 +static public boolean lte(Object x, long y){ 1.3996 + return lte(x,(Object)y); 1.3997 +} 1.3998 + 1.3999 +static public boolean lte(double x, Object y){ 1.4000 + return lte((Object)x,y); 1.4001 +} 1.4002 + 1.4003 +static public boolean lte(Object x, double y){ 1.4004 + return lte(x,(Object)y); 1.4005 +} 1.4006 + 1.4007 +static public boolean gt(int x, Object y){ 1.4008 + return gt((Object)x,y); 1.4009 +} 1.4010 + 1.4011 +static public boolean gt(Object x, int y){ 1.4012 + return gt(x,(Object)y); 1.4013 +} 1.4014 + 1.4015 +static public boolean gt(float x, Object y){ 1.4016 + return gt((Object)x,y); 1.4017 +} 1.4018 + 1.4019 +static public boolean gt(Object x, float y){ 1.4020 + return gt(x,(Object)y); 1.4021 +} 1.4022 + 1.4023 +static public boolean gt(long x, Object y){ 1.4024 + return gt((Object)x,y); 1.4025 +} 1.4026 + 1.4027 +static public boolean gt(Object x, long y){ 1.4028 + return gt(x,(Object)y); 1.4029 +} 1.4030 + 1.4031 +static public boolean gt(double x, Object y){ 1.4032 + return gt((Object)x,y); 1.4033 +} 1.4034 + 1.4035 +static public boolean gt(Object x, double y){ 1.4036 + return gt(x,(Object)y); 1.4037 +} 1.4038 + 1.4039 +static public boolean gte(int x, Object y){ 1.4040 + return gte((Object)x,y); 1.4041 +} 1.4042 + 1.4043 +static public boolean gte(Object x, int y){ 1.4044 + return gte(x,(Object)y); 1.4045 +} 1.4046 + 1.4047 +static public boolean gte(float x, Object y){ 1.4048 + return gte((Object)x,y); 1.4049 +} 1.4050 + 1.4051 +static public boolean gte(Object x, float y){ 1.4052 + return gte(x,(Object)y); 1.4053 +} 1.4054 + 1.4055 +static public boolean gte(long x, Object y){ 1.4056 + return gte((Object)x,y); 1.4057 +} 1.4058 + 1.4059 +static public boolean gte(Object x, long y){ 1.4060 + return gte(x,(Object)y); 1.4061 +} 1.4062 + 1.4063 +static public boolean gte(double x, Object y){ 1.4064 + return gte((Object)x,y); 1.4065 +} 1.4066 + 1.4067 +static public boolean gte(Object x, double y){ 1.4068 + return gte(x,(Object)y); 1.4069 +} 1.4070 + 1.4071 + 1.4072 +static public boolean equiv(int x, Object y){ 1.4073 + return equiv((Object)x,y); 1.4074 +} 1.4075 + 1.4076 +static public boolean equiv(Object x, int y){ 1.4077 + return equiv(x,(Object)y); 1.4078 +} 1.4079 + 1.4080 +static public boolean equiv(float x, Object y){ 1.4081 + return equiv((Object)x,y); 1.4082 +} 1.4083 + 1.4084 +static public boolean equiv(Object x, float y){ 1.4085 + return equiv(x,(Object)y); 1.4086 +} 1.4087 + 1.4088 +static public boolean equiv(long x, Object y){ 1.4089 + return equiv((Object)x,y); 1.4090 +} 1.4091 + 1.4092 +static public boolean equiv(Object x, long y){ 1.4093 + return equiv(x,(Object)y); 1.4094 +} 1.4095 + 1.4096 +static public boolean equiv(double x, Object y){ 1.4097 + return equiv((Object)x,y); 1.4098 +} 1.4099 + 1.4100 +static public boolean equiv(Object x, double y){ 1.4101 + return equiv(x,(Object)y); 1.4102 +} 1.4103 + 1.4104 + 1.4105 +static public float add(int x, float y){ 1.4106 + return add((float)x,y); 1.4107 +} 1.4108 + 1.4109 +static public float add(float x, int y){ 1.4110 + return add(x,(float)y); 1.4111 +} 1.4112 + 1.4113 +static public double add(int x, double y){ 1.4114 + return add((double)x,y); 1.4115 +} 1.4116 + 1.4117 +static public double add(double x, int y){ 1.4118 + return add(x,(double)y); 1.4119 +} 1.4120 + 1.4121 +static public long add(int x, long y){ 1.4122 + return add((long)x,y); 1.4123 +} 1.4124 + 1.4125 +static public long add(long x, int y){ 1.4126 + return add(x,(long)y); 1.4127 +} 1.4128 + 1.4129 +static public float add(long x, float y){ 1.4130 + return add((float)x,y); 1.4131 +} 1.4132 + 1.4133 +static public float add(float x, long y){ 1.4134 + return add(x,(float)y); 1.4135 +} 1.4136 + 1.4137 +static public double add(long x, double y){ 1.4138 + return add((double)x,y); 1.4139 +} 1.4140 + 1.4141 +static public double add(double x, long y){ 1.4142 + return add(x,(double)y); 1.4143 +} 1.4144 + 1.4145 +static public double add(float x, double y){ 1.4146 + return add((double)x,y); 1.4147 +} 1.4148 + 1.4149 +static public double add(double x, float y){ 1.4150 + return add(x,(double)y); 1.4151 +} 1.4152 + 1.4153 +static public float minus(int x, float y){ 1.4154 + return minus((float)x,y); 1.4155 +} 1.4156 + 1.4157 +static public float minus(float x, int y){ 1.4158 + return minus(x,(float)y); 1.4159 +} 1.4160 + 1.4161 +static public double minus(int x, double y){ 1.4162 + return minus((double)x,y); 1.4163 +} 1.4164 + 1.4165 +static public double minus(double x, int y){ 1.4166 + return minus(x,(double)y); 1.4167 +} 1.4168 + 1.4169 +static public long minus(int x, long y){ 1.4170 + return minus((long)x,y); 1.4171 +} 1.4172 + 1.4173 +static public long minus(long x, int y){ 1.4174 + return minus(x,(long)y); 1.4175 +} 1.4176 + 1.4177 +static public float minus(long x, float y){ 1.4178 + return minus((float)x,y); 1.4179 +} 1.4180 + 1.4181 +static public float minus(float x, long y){ 1.4182 + return minus(x,(float)y); 1.4183 +} 1.4184 + 1.4185 +static public double minus(long x, double y){ 1.4186 + return minus((double)x,y); 1.4187 +} 1.4188 + 1.4189 +static public double minus(double x, long y){ 1.4190 + return minus(x,(double)y); 1.4191 +} 1.4192 + 1.4193 +static public double minus(float x, double y){ 1.4194 + return minus((double)x,y); 1.4195 +} 1.4196 + 1.4197 +static public double minus(double x, float y){ 1.4198 + return minus(x,(double)y); 1.4199 +} 1.4200 + 1.4201 +static public float multiply(int x, float y){ 1.4202 + return multiply((float)x,y); 1.4203 +} 1.4204 + 1.4205 +static public float multiply(float x, int y){ 1.4206 + return multiply(x,(float)y); 1.4207 +} 1.4208 + 1.4209 +static public double multiply(int x, double y){ 1.4210 + return multiply((double)x,y); 1.4211 +} 1.4212 + 1.4213 +static public double multiply(double x, int y){ 1.4214 + return multiply(x,(double)y); 1.4215 +} 1.4216 + 1.4217 +static public long multiply(int x, long y){ 1.4218 + return multiply((long)x,y); 1.4219 +} 1.4220 + 1.4221 +static public long multiply(long x, int y){ 1.4222 + return multiply(x,(long)y); 1.4223 +} 1.4224 + 1.4225 +static public float multiply(long x, float y){ 1.4226 + return multiply((float)x,y); 1.4227 +} 1.4228 + 1.4229 +static public float multiply(float x, long y){ 1.4230 + return multiply(x,(float)y); 1.4231 +} 1.4232 + 1.4233 +static public double multiply(long x, double y){ 1.4234 + return multiply((double)x,y); 1.4235 +} 1.4236 + 1.4237 +static public double multiply(double x, long y){ 1.4238 + return multiply(x,(double)y); 1.4239 +} 1.4240 + 1.4241 +static public double multiply(float x, double y){ 1.4242 + return multiply((double)x,y); 1.4243 +} 1.4244 + 1.4245 +static public double multiply(double x, float y){ 1.4246 + return multiply(x,(double)y); 1.4247 +} 1.4248 + 1.4249 +static public float divide(int x, float y){ 1.4250 + return divide((float)x,y); 1.4251 +} 1.4252 + 1.4253 +static public float divide(float x, int y){ 1.4254 + return divide(x,(float)y); 1.4255 +} 1.4256 + 1.4257 +static public double divide(int x, double y){ 1.4258 + return divide((double)x,y); 1.4259 +} 1.4260 + 1.4261 +static public double divide(double x, int y){ 1.4262 + return divide(x,(double)y); 1.4263 +} 1.4264 + 1.4265 +static public float divide(long x, float y){ 1.4266 + return divide((float)x,y); 1.4267 +} 1.4268 + 1.4269 +static public float divide(float x, long y){ 1.4270 + return divide(x,(float)y); 1.4271 +} 1.4272 + 1.4273 +static public double divide(long x, double y){ 1.4274 + return divide((double)x,y); 1.4275 +} 1.4276 + 1.4277 +static public double divide(double x, long y){ 1.4278 + return divide(x,(double)y); 1.4279 +} 1.4280 + 1.4281 +static public double divide(float x, double y){ 1.4282 + return divide((double)x,y); 1.4283 +} 1.4284 + 1.4285 +static public double divide(double x, float y){ 1.4286 + return divide(x,(double)y); 1.4287 +} 1.4288 + 1.4289 +static public boolean lt(int x, float y){ 1.4290 + return lt((float)x,y); 1.4291 +} 1.4292 + 1.4293 +static public boolean lt(float x, int y){ 1.4294 + return lt(x,(float)y); 1.4295 +} 1.4296 + 1.4297 +static public boolean lt(int x, double y){ 1.4298 + return lt((double)x,y); 1.4299 +} 1.4300 + 1.4301 +static public boolean lt(double x, int y){ 1.4302 + return lt(x,(double)y); 1.4303 +} 1.4304 + 1.4305 +static public boolean lt(int x, long y){ 1.4306 + return lt((long)x,y); 1.4307 +} 1.4308 + 1.4309 +static public boolean lt(long x, int y){ 1.4310 + return lt(x,(long)y); 1.4311 +} 1.4312 + 1.4313 +static public boolean lt(long x, float y){ 1.4314 + return lt((float)x,y); 1.4315 +} 1.4316 + 1.4317 +static public boolean lt(float x, long y){ 1.4318 + return lt(x,(float)y); 1.4319 +} 1.4320 + 1.4321 +static public boolean lt(long x, double y){ 1.4322 + return lt((double)x,y); 1.4323 +} 1.4324 + 1.4325 +static public boolean lt(double x, long y){ 1.4326 + return lt(x,(double)y); 1.4327 +} 1.4328 + 1.4329 +static public boolean lt(float x, double y){ 1.4330 + return lt((double)x,y); 1.4331 +} 1.4332 + 1.4333 +static public boolean lt(double x, float y){ 1.4334 + return lt(x,(double)y); 1.4335 +} 1.4336 + 1.4337 + 1.4338 +static public boolean lte(int x, float y){ 1.4339 + return lte((float)x,y); 1.4340 +} 1.4341 + 1.4342 +static public boolean lte(float x, int y){ 1.4343 + return lte(x,(float)y); 1.4344 +} 1.4345 + 1.4346 +static public boolean lte(int x, double y){ 1.4347 + return lte((double)x,y); 1.4348 +} 1.4349 + 1.4350 +static public boolean lte(double x, int y){ 1.4351 + return lte(x,(double)y); 1.4352 +} 1.4353 + 1.4354 +static public boolean lte(int x, long y){ 1.4355 + return lte((long)x,y); 1.4356 +} 1.4357 + 1.4358 +static public boolean lte(long x, int y){ 1.4359 + return lte(x,(long)y); 1.4360 +} 1.4361 + 1.4362 +static public boolean lte(long x, float y){ 1.4363 + return lte((float)x,y); 1.4364 +} 1.4365 + 1.4366 +static public boolean lte(float x, long y){ 1.4367 + return lte(x,(float)y); 1.4368 +} 1.4369 + 1.4370 +static public boolean lte(long x, double y){ 1.4371 + return lte((double)x,y); 1.4372 +} 1.4373 + 1.4374 +static public boolean lte(double x, long y){ 1.4375 + return lte(x,(double)y); 1.4376 +} 1.4377 + 1.4378 +static public boolean lte(float x, double y){ 1.4379 + return lte((double)x,y); 1.4380 +} 1.4381 + 1.4382 +static public boolean lte(double x, float y){ 1.4383 + return lte(x,(double)y); 1.4384 +} 1.4385 + 1.4386 +static public boolean gt(int x, float y){ 1.4387 + return gt((float)x,y); 1.4388 +} 1.4389 + 1.4390 +static public boolean gt(float x, int y){ 1.4391 + return gt(x,(float)y); 1.4392 +} 1.4393 + 1.4394 +static public boolean gt(int x, double y){ 1.4395 + return gt((double)x,y); 1.4396 +} 1.4397 + 1.4398 +static public boolean gt(double x, int y){ 1.4399 + return gt(x,(double)y); 1.4400 +} 1.4401 + 1.4402 +static public boolean gt(int x, long y){ 1.4403 + return gt((long)x,y); 1.4404 +} 1.4405 + 1.4406 +static public boolean gt(long x, int y){ 1.4407 + return gt(x,(long)y); 1.4408 +} 1.4409 + 1.4410 +static public boolean gt(long x, float y){ 1.4411 + return gt((float)x,y); 1.4412 +} 1.4413 + 1.4414 +static public boolean gt(float x, long y){ 1.4415 + return gt(x,(float)y); 1.4416 +} 1.4417 + 1.4418 +static public boolean gt(long x, double y){ 1.4419 + return gt((double)x,y); 1.4420 +} 1.4421 + 1.4422 +static public boolean gt(double x, long y){ 1.4423 + return gt(x,(double)y); 1.4424 +} 1.4425 + 1.4426 +static public boolean gt(float x, double y){ 1.4427 + return gt((double)x,y); 1.4428 +} 1.4429 + 1.4430 +static public boolean gt(double x, float y){ 1.4431 + return gt(x,(double)y); 1.4432 +} 1.4433 + 1.4434 +static public boolean gte(int x, float y){ 1.4435 + return gte((float)x,y); 1.4436 +} 1.4437 + 1.4438 +static public boolean gte(float x, int y){ 1.4439 + return gte(x,(float)y); 1.4440 +} 1.4441 + 1.4442 +static public boolean gte(int x, double y){ 1.4443 + return gte((double)x,y); 1.4444 +} 1.4445 + 1.4446 +static public boolean gte(double x, int y){ 1.4447 + return gte(x,(double)y); 1.4448 +} 1.4449 + 1.4450 +static public boolean gte(int x, long y){ 1.4451 + return gte((long)x,y); 1.4452 +} 1.4453 + 1.4454 +static public boolean gte(long x, int y){ 1.4455 + return gte(x,(long)y); 1.4456 +} 1.4457 + 1.4458 +static public boolean gte(long x, float y){ 1.4459 + return gte((float)x,y); 1.4460 +} 1.4461 + 1.4462 +static public boolean gte(float x, long y){ 1.4463 + return gte(x,(float)y); 1.4464 +} 1.4465 + 1.4466 +static public boolean gte(long x, double y){ 1.4467 + return gte((double)x,y); 1.4468 +} 1.4469 + 1.4470 +static public boolean gte(double x, long y){ 1.4471 + return gte(x,(double)y); 1.4472 +} 1.4473 + 1.4474 +static public boolean gte(float x, double y){ 1.4475 + return gte((double)x,y); 1.4476 +} 1.4477 + 1.4478 +static public boolean gte(double x, float y){ 1.4479 + return gte(x,(double)y); 1.4480 +} 1.4481 + 1.4482 +static public boolean equiv(int x, float y){ 1.4483 + return equiv((float)x,y); 1.4484 +} 1.4485 + 1.4486 +static public boolean equiv(float x, int y){ 1.4487 + return equiv(x,(float)y); 1.4488 +} 1.4489 + 1.4490 +static public boolean equiv(int x, double y){ 1.4491 + return equiv((double)x,y); 1.4492 +} 1.4493 + 1.4494 +static public boolean equiv(double x, int y){ 1.4495 + return equiv(x,(double)y); 1.4496 +} 1.4497 + 1.4498 +static public boolean equiv(int x, long y){ 1.4499 + return equiv((long)x,y); 1.4500 +} 1.4501 + 1.4502 +static public boolean equiv(long x, int y){ 1.4503 + return equiv(x,(long)y); 1.4504 +} 1.4505 + 1.4506 +static public boolean equiv(long x, float y){ 1.4507 + return equiv((float)x,y); 1.4508 +} 1.4509 + 1.4510 +static public boolean equiv(float x, long y){ 1.4511 + return equiv(x,(float)y); 1.4512 +} 1.4513 + 1.4514 +static public boolean equiv(long x, double y){ 1.4515 + return equiv((double)x,y); 1.4516 +} 1.4517 + 1.4518 +static public boolean equiv(double x, long y){ 1.4519 + return equiv(x,(double)y); 1.4520 +} 1.4521 + 1.4522 +static public boolean equiv(float x, double y){ 1.4523 + return equiv((double)x,y); 1.4524 +} 1.4525 + 1.4526 +static public boolean equiv(double x, float y){ 1.4527 + return equiv(x,(double)y); 1.4528 +} 1.4529 + 1.4530 +}