Javolution 6.0.0 java
MathLib.java
Go to the documentation of this file.
1 /*
2  * Javolution - Java(TM) Solution for Real-Time and Embedded Systems
3  * Copyright (C) 2012 - Javolution (http://javolution.org/)
4  * All rights reserved.
5  *
6  * Permission to use, copy, modify, and distribute this software is
7  * freely granted, provided that this notice is preserved.
8  */
9 package javolution.lang;
10 
11 
19 @Realtime
20 public final class MathLib {
21 
25  private MathLib() {}
26 
38  public static int bitLength(int i) {
39  if (i < 0)
40  i = -++i;
41  return (i < 1 << 16) ? (i < 1 << 8) ? BIT_LENGTH[i]
42  : BIT_LENGTH[i >>> 8] + 8
43  : (i < 1 << 24) ? BIT_LENGTH[i >>> 16] + 16
44  : BIT_LENGTH[i >>> 24] + 24;
45  }
46 
47  private static final byte[] BIT_LENGTH = { 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4,
48  4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6,
49  6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
50  6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
51  7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
52  7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
53  7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
54  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
55  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
56  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
57  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
58  8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
59  8, 8, 8 };
60 
72  public static int bitLength(long l) {
73  int i = (int) (l >> 32);
74  if (i > 0)
75  return (i < 1 << 16) ? (i < 1 << 8) ? BIT_LENGTH[i] + 32
76  : BIT_LENGTH[i >>> 8] + 40
77  : (i < 1 << 24) ? BIT_LENGTH[i >>> 16] + 48
78  : BIT_LENGTH[i >>> 24] + 56;
79  if (i < 0)
80  return bitLength(-++l);
81  i = (int) l;
82  return (i < 0) ? 32 : (i < 1 << 16) ? (i < 1 << 8) ? BIT_LENGTH[i]
83  : BIT_LENGTH[i >>> 8] + 8
84  : (i < 1 << 24) ? BIT_LENGTH[i >>> 16] + 16
85  : BIT_LENGTH[i >>> 24] + 24;
86  }
87 
97  public static int bitCount(long longValue) {
98  longValue = longValue - ((longValue >>> 1) & 0x5555555555555555L);
99  longValue = (longValue & 0x3333333333333333L)
100  + ((longValue >>> 2) & 0x3333333333333333L);
101  longValue = (longValue + (longValue >>> 4)) & 0x0f0f0f0f0f0f0f0fL;
102  longValue = longValue + (longValue >>> 8);
103  longValue = longValue + (longValue >>> 16);
104  longValue = longValue + (longValue >>> 32);
105  return (int) longValue & 0x7f;
106  }
107 
117  public static int numberOfLeadingZeros(long longValue) {
118  // From Hacker's Delight
119  if (longValue == 0)
120  return 64;
121  int n = 1;
122  int x = (int)(longValue >>> 32);
123  if (x == 0) { n += 32; x = (int)longValue; }
124  if (x >>> 16 == 0) { n += 16; x <<= 16; }
125  if (x >>> 24 == 0) { n += 8; x <<= 8; }
126  if (x >>> 28 == 0) { n += 4; x <<= 4; }
127  if (x >>> 30 == 0) { n += 2; x <<= 2; }
128  n -= x >>> 31;
129  return n;
130  }
131 
140  public static int numberOfTrailingZeros(long longValue) {
141  // From Hacker's Delight
142  int x, y;
143  if (longValue == 0) return 64;
144  int n = 63;
145  y = (int)longValue; if (y != 0) { n = n -32; x = y; } else x = (int)(longValue>>>32);
146  y = x <<16; if (y != 0) { n = n -16; x = y; }
147  y = x << 8; if (y != 0) { n = n - 8; x = y; }
148  y = x << 4; if (y != 0) { n = n - 4; x = y; }
149  y = x << 2; if (y != 0) { n = n - 2; x = y; }
150  return n - ((x << 1) >>> 31);
151  }
152 
161  public static int digitLength(int i) {
162  if (i >= 0)
163  return (i >= 100000) ? (i >= 10000000) ? (i >= 1000000000) ? 10
164  : (i >= 100000000) ? 9 : 8 : (i >= 1000000) ? 7 : 6
165  : (i >= 100) ? (i >= 10000) ? 5 : (i >= 1000) ? 4 : 3
166  : (i >= 10) ? 2 : 1;
167  if (i == Integer.MIN_VALUE)
168  return 10; // "2147483648".length()
169  return digitLength(-i); // No overflow possible.
170  }
171 
180  public static int digitLength(long l) {
181  if (l >= 0)
182  return (l <= Integer.MAX_VALUE) ? digitLength((int) l)
183  : // At least 10 digits or more.
184  (l >= 100000000000000L) ? (l >= 10000000000000000L) ? (l >= 1000000000000000000L) ? 19
185  : (l >= 100000000000000000L) ? 18 : 17
186  : (l >= 1000000000000000L) ? 16 : 15
187  : (l >= 100000000000L) ? (l >= 10000000000000L) ? 14
188  : (l >= 1000000000000L) ? 13 : 12
189  : (l >= 10000000000L) ? 11 : 10;
190  if (l == Long.MIN_VALUE)
191  return 19; // "9223372036854775808".length()
192  return digitLength(-l);
193  }
194 
203  public static double toDoublePow2(long m, int n) {
204  if (m == 0)
205  return 0.0;
206  if (m == Long.MIN_VALUE)
207  return toDoublePow2(Long.MIN_VALUE >> 1, n + 1);
208  if (m < 0)
209  return -toDoublePow2(-m, n);
210  int bitLength = MathLib.bitLength(m);
211  int shift = bitLength - 53;
212  long exp = 1023L + 52 + n + shift; // Use long to avoid overflow.
213  if (exp >= 0x7FF)
214  return Double.POSITIVE_INFINITY;
215  if (exp <= 0) { // Degenerated number (subnormal, assume 0 for bit 52)
216  if (exp <= -54)
217  return 0.0;
218  return toDoublePow2(m, n + 54) / 18014398509481984L; // 2^54 Exact.
219  }
220  // Normal number.
221  long bits = (shift > 0) ? (m >> shift) + ((m >> (shift - 1)) & 1) : // Rounding.
222  m << -shift;
223  if (((bits >> 52) != 1) && (++exp >= 0x7FF))
224  return Double.POSITIVE_INFINITY;
225  bits &= 0x000fffffffffffffL; // Clears MSB (bit 52)
226  bits |= exp << 52;
227  return Double.longBitsToDouble(bits);
228  }
229 
230 
231 
240  public static double toDoublePow10(long m, int n) {
241  if (m == 0)
242  return 0.0;
243  if (m == Long.MIN_VALUE)
244  return toDoublePow10(Long.MIN_VALUE / 10, n + 1);
245  if (m < 0)
246  return -toDoublePow10(-m, n);
247  if (n >= 0) { // Positive power.
248  if (n > 308)
249  return Double.POSITIVE_INFINITY;
250  // Works with 4 x 32 bits registers (x3:x2:x1:x0)
251  long x0 = 0; // 32 bits.
252  long x1 = 0; // 32 bits.
253  long x2 = m & MASK_32; // 32 bits.
254  long x3 = m >>> 32; // 32 bits.
255  int pow2 = 0;
256  while (n != 0) {
257  int i = (n >= POW5_INT.length) ? POW5_INT.length - 1 : n;
258  int coef = POW5_INT[i]; // 31 bits max.
259 
260  if (((int) x0) != 0)
261  x0 *= coef; // 63 bits max.
262  if (((int) x1) != 0)
263  x1 *= coef; // 63 bits max.
264  x2 *= coef; // 63 bits max.
265  x3 *= coef; // 63 bits max.
266 
267  x1 += x0 >>> 32;
268  x0 &= MASK_32;
269 
270  x2 += x1 >>> 32;
271  x1 &= MASK_32;
272 
273  x3 += x2 >>> 32;
274  x2 &= MASK_32;
275 
276  // Adjusts powers.
277  pow2 += i;
278  n -= i;
279 
280  // Normalizes (x3 should be 32 bits max).
281  long carry = x3 >>> 32;
282  if (carry != 0) { // Shift.
283  x0 = x1;
284  x1 = x2;
285  x2 = x3 & MASK_32;
286  x3 = carry;
287  pow2 += 32;
288  }
289  }
290 
291  // Merges registers to a 63 bits mantissa.
292  int shift = 31 - MathLib.bitLength(x3); // -1..30
293  pow2 -= shift;
294  long mantissa = (shift < 0) ? (x3 << 31) | (x2 >>> 1) : // x3 is 32 bits.
295  (((x3 << 32) | x2) << shift) | (x1 >>> (32 - shift));
296  return toDoublePow2(mantissa, pow2);
297 
298  } else { // n < 0
299  if (n < -324 - 20)
300  return 0.0;
301 
302  // Works with x1:x0 126 bits register.
303  long x1 = m; // 63 bits.
304  long x0 = 0; // 63 bits.
305  int pow2 = 0;
306  while (true) {
307 
308  // Normalizes x1:x0
309  int shift = 63 - MathLib.bitLength(x1);
310  x1 <<= shift;
311  x1 |= x0 >>> (63 - shift);
312  x0 = (x0 << shift) & MASK_63;
313  pow2 -= shift;
314 
315  // Checks if division has to be performed.
316  if (n == 0)
317  break; // Done.
318 
319  // Retrieves power of 5 divisor.
320  int i = (-n >= POW5_INT.length) ? POW5_INT.length - 1 : -n;
321  int divisor = POW5_INT[i];
322 
323  // Performs the division (126 bits by 31 bits).
324  long wh = (x1 >>> 32);
325  long qh = wh / divisor;
326  long r = wh - qh * divisor;
327  long wl = (r << 32) | (x1 & MASK_32);
328  long ql = wl / divisor;
329  r = wl - ql * divisor;
330  x1 = (qh << 32) | ql;
331 
332  wh = (r << 31) | (x0 >>> 32);
333  qh = wh / divisor;
334  r = wh - qh * divisor;
335  wl = (r << 32) | (x0 & MASK_32);
336  ql = wl / divisor;
337  x0 = (qh << 32) | ql;
338 
339  // Adjusts powers.
340  n += i;
341  pow2 -= i;
342  }
343  return toDoublePow2(x1, pow2);
344  }
345  }
346 
347  private static final long MASK_63 = 0x7FFFFFFFFFFFFFFFL;
348 
349  private static final long MASK_32 = 0xFFFFFFFFL;
350 
351  private static final int[] POW5_INT = { 1, 5, 25, 125, 625, 3125, 15625,
352  78125, 390625, 1953125, 9765625, 48828125, 244140625, 1220703125 };
353 
354 
355 
366  public static long toLongPow2(double d, int n) {
367  long bits = Double.doubleToLongBits(d);
368  boolean isNegative = (bits >> 63) != 0;
369  int exp = ((int) (bits >> 52)) & 0x7FF;
370  long m = bits & 0x000fffffffffffffL;
371  if (exp == 0x7FF)
372  throw new ArithmeticException(
373  "Cannot convert to long (Infinity or NaN)");
374  if (exp == 0) {
375  if (m == 0)
376  return 0L;
377  return toLongPow2(d * 18014398509481984L, n - 54); // 2^54 Exact.
378  }
379  m |= 0x0010000000000000L; // Sets MSB (bit 52)
380  long shift = exp - 1023L - 52 + n; // Use long to avoid overflow.
381  if (shift <= -64)
382  return 0L;
383  if (shift >= 11)
384  throw new ArithmeticException("Cannot convert to long (overflow)");
385  m = (shift >= 0) ? m << shift : (m >> -shift)
386  + ((m >> -(shift + 1)) & 1); // Rounding.
387  return isNegative ? -m : m;
388  }
389 
390 
391 
400  public static long toLongPow10(double d, int n) {
401  long bits = Double.doubleToLongBits(d);
402  boolean isNegative = (bits >> 63) != 0;
403  int exp = ((int) (bits >> 52)) & 0x7FF;
404  long m = bits & 0x000fffffffffffffL;
405  if (exp == 0x7FF)
406  throw new ArithmeticException(
407  "Cannot convert to long (Infinity or NaN)");
408  if (exp == 0) {
409  if (m == 0)
410  return 0L;
411  return toLongPow10(d * 1E16, n - 16);
412  }
413  m |= 0x0010000000000000L; // Sets MSB (bit 52)
414  int pow2 = exp - 1023 - 52;
415  // Retrieves 63 bits m with n == 0.
416  if (n >= 0) {
417  // Works with 4 x 32 bits registers (x3:x2:x1:x0)
418  long x0 = 0; // 32 bits.
419  long x1 = 0; // 32 bits.
420  long x2 = m & MASK_32; // 32 bits.
421  long x3 = m >>> 32; // 32 bits.
422  while (n != 0) {
423  int i = (n >= POW5_INT.length) ? POW5_INT.length - 1 : n;
424  int coef = POW5_INT[i]; // 31 bits max.
425 
426  if (((int) x0) != 0)
427  x0 *= coef; // 63 bits max.
428  if (((int) x1) != 0)
429  x1 *= coef; // 63 bits max.
430  x2 *= coef; // 63 bits max.
431  x3 *= coef; // 63 bits max.
432 
433  x1 += x0 >>> 32;
434  x0 &= MASK_32;
435 
436  x2 += x1 >>> 32;
437  x1 &= MASK_32;
438 
439  x3 += x2 >>> 32;
440  x2 &= MASK_32;
441 
442  // Adjusts powers.
443  pow2 += i;
444  n -= i;
445 
446  // Normalizes (x3 should be 32 bits max).
447  long carry = x3 >>> 32;
448  if (carry != 0) { // Shift.
449  x0 = x1;
450  x1 = x2;
451  x2 = x3 & MASK_32;
452  x3 = carry;
453  pow2 += 32;
454  }
455  }
456 
457  // Merges registers to a 63 bits mantissa.
458  int shift = 31 - MathLib.bitLength(x3); // -1..30
459  pow2 -= shift;
460  m = (shift < 0) ? (x3 << 31) | (x2 >>> 1) : // x3 is 32 bits.
461  (((x3 << 32) | x2) << shift) | (x1 >>> (32 - shift));
462 
463  } else { // n < 0
464 
465  // Works with x1:x0 126 bits register.
466  long x1 = m; // 63 bits.
467  long x0 = 0; // 63 bits.
468  while (true) {
469 
470  // Normalizes x1:x0
471  int shift = 63 - MathLib.bitLength(x1);
472  x1 <<= shift;
473  x1 |= x0 >>> (63 - shift);
474  x0 = (x0 << shift) & MASK_63;
475  pow2 -= shift;
476 
477  // Checks if division has to be performed.
478  if (n == 0)
479  break; // Done.
480 
481  // Retrieves power of 5 divisor.
482  int i = (-n >= POW5_INT.length) ? POW5_INT.length - 1 : -n;
483  int divisor = POW5_INT[i];
484 
485  // Performs the division (126 bits by 31 bits).
486  long wh = (x1 >>> 32);
487  long qh = wh / divisor;
488  long r = wh - qh * divisor;
489  long wl = (r << 32) | (x1 & MASK_32);
490  long ql = wl / divisor;
491  r = wl - ql * divisor;
492  x1 = (qh << 32) | ql;
493 
494  wh = (r << 31) | (x0 >>> 32);
495  qh = wh / divisor;
496  r = wh - qh * divisor;
497  wl = (r << 32) | (x0 & MASK_32);
498  ql = wl / divisor;
499  x0 = (qh << 32) | ql;
500 
501  // Adjusts powers.
502  n += i;
503  pow2 -= i;
504  }
505  m = x1;
506  }
507  if (pow2 > 0)
508  throw new ArithmeticException("Overflow");
509  if (pow2 < -63)
510  return 0;
511  m = (m >> -pow2) + ((m >> -(pow2 + 1)) & 1); // Rounding.
512  return isNegative ? -m : m;
513  }
514 
515 
516 
526  public static int floorLog2(double d) {
527  if (d <= 0)
528  throw new ArithmeticException("Negative number or zero");
529  long bits = Double.doubleToLongBits(d);
530  int exp = ((int) (bits >> 52)) & 0x7FF;
531  if (exp == 0x7FF)
532  throw new ArithmeticException("Infinity or NaN");
533  if (exp == 0)
534  return floorLog2(d * 18014398509481984L) - 54; // 2^54 Exact.
535  return exp - 1023;
536  }
537 
538 
539 
549  public static int floorLog10(double d) {
550  int guess = (int) (LOG2_DIV_LOG10 * MathLib.floorLog2(d));
551  double pow10 = MathLib.toDoublePow10(1, guess);
552  if ((pow10 <= d) && (pow10 * 10 > d))
553  return guess;
554  if (pow10 > d)
555  return guess - 1;
556  return guess + 1;
557  }
558 
559  private static final double LOG2_DIV_LOG10 = 0.3010299956639811952137388947;
560 
564  public static final double E = 2.71828182845904523536028747135266;
565 
569  public static final double PI = 3.1415926535897932384626433832795;
570 
574  public static final double HALF_PI = 1.5707963267948966192313216916398;
575 
579  public static final double TWO_PI = 6.283185307179586476925286766559;
580 
584  public static final double FOUR_PI = 12.566370614359172953850573533118;
585 
589  public static final double PI_SQUARE = 9.8696044010893586188344909998762;
590 
594  public static final double LOG2 = 0.69314718055994530941723212145818;
595 
599  public static final double LOG10 = 2.3025850929940456840179914546844;
600 
604  public static final double SQRT2 = 1.4142135623730950488016887242097;
605 
609  public static final double NaN = 0.0 / 0.0;
610 
614  public static final double Infinity = 1.0 / 0.0;
615 
616 
623  public static double toRadians(double degrees) {
624  return degrees * (PI / 180.0);
625  }
626 
627 
628 
635  public static double toDegrees(double radians) {
636  return radians * (180.0 / PI);
637  }
638 
639 
640 
647  public static double sqrt(double x) {
648  return Math.sqrt(x); // CLDC 1.1
649  }
650 
651 
652 
660  public static double rem(double x, double y) {
661  double tmp = x / y;
662  if (MathLib.abs(tmp) <= Long.MAX_VALUE)
663  return x - MathLib.round(tmp) * y;
664  else
665  return NaN;
666  }
667 
668 
669 
678  public static double ceil(double x) {
679  return Math.ceil(x); // CLDC 1.1
680  }
681 
682 
683 
692  public static double floor(double x) {
693  return Math.floor(x); // CLDC 1.1
694  }
695 
696 
697 
704  public static double sin(double radians) {
705  return Math.sin(radians); // CLDC 1.1
706  }
707 
708 
709 
716  public static double cos(double radians) {
717  return Math.cos(radians); // CLDC 1.1
718  }
719 
720 
721 
728  public static double tan(double radians) {
729  return Math.tan(radians); // CLDC 1.1
730  }
731 
732 
733 
741  public static double asin(double x) {
742  if (x < -1.0 || x > 1.0)
743  return MathLib.NaN;
744  if (x == -1.0)
745  return -HALF_PI;
746  if (x == 1.0)
747  return HALF_PI;
748  return MathLib.atan(x / MathLib.sqrt(1.0 - x * x));
749  }
750 
751 
752 
760  public static double acos(double x) {
761  return HALF_PI - MathLib.asin(x);
762  }
763 
764 
765 
775  public static double atan(double x) {
776  return MathLib._atan(x);
777  }
778 
779 
780 
790  public static double atan2(double y, double x) {
791  // From Wikipedia.
792  if (x > 0) return MathLib.atan(y / x);
793  if ((y >= 0) && (x < 0)) return MathLib.atan(y / x) + PI;
794  if ((y < 0) && (x < 0)) return MathLib.atan(y / x) - PI;
795  if ((y > 0) && (x == 0)) return PI / 2;
796  if ((y < 0) && (x == 0)) return -PI / 2;
797  return Double.NaN; // ((y == 0) && (x == 0))
798  }
799 
800 
801 
808  public static double sinh(double x) {
809  return (MathLib.exp(x) - MathLib.exp(-x)) * 0.5;
810  }
811 
812 
813 
820  public static double cosh(double x) {
821  return (MathLib.exp(x) + MathLib.exp(-x)) * 0.5;
822  }
823 
824 
825 
832  public static double tanh(double x) {
833  return (MathLib.exp(2 * x) - 1) / (MathLib.exp(2 * x) + 1);
834  }
835 
836 
837 
846  public static double exp(double x) {
847  return MathLib._ieee754_exp(x);
848  }
849 
850 
851 
859  public static double log(double x) {
860  return MathLib._ieee754_log(x);
861  }
862 
863 
864 
871  public static double log10(double x) {
872  return log(x) * INV_LOG10;
873  }
874 
875  private static double INV_LOG10 = 0.43429448190325182765112891891661;
876 
885  public static double pow(double x, double y) {
886  // Use close approximation (+/- LSB)
887  if ((x < 0) && (y == (int) y))
888  return (((int) y) & 1) == 0 ? pow(-x, y) : -pow(-x, y);
889  return MathLib.exp(y * MathLib.log(x));
890  }
891 
898  public static int round(float f) {
899  return (int) floor(f + 0.5f);
900  }
901 
902 
903 
911  public static long round(double d) {
912  return (long) floor(d + 0.5d);
913  }
914 
921  public static int abs(int i) {
922  return (i < 0) ? -i : i;
923  }
924 
931  public static long abs(long l) {
932  return (l < 0) ? -l : l;
933  }
934 
941  public static float abs(float f) {
942  return (f < 0) ? -f : f;
943  }
944 
951  public static double abs(double d) {
952  return (d < 0) ? -d : d;
953  }
954 
955 
956 
964  public static int max(int x, int y) {
965  return (x >= y) ? x : y;
966  }
967 
975  public static long max(long x, long y) {
976  return (x >= y) ? x : y;
977  }
978 
986  public static float max(float x, float y) {
987  return (x >= y) ? x : y;
988  }
989 
997  public static double max(double x, double y) {
998  return (x >= y) ? x : y;
999  }
1000 
1001 
1002 
1010  public static int min(int x, int y) {
1011  return (x < y) ? x : y;
1012  }
1013 
1021  public static long min(long x, long y) {
1022  return (x < y) ? x : y;
1023  }
1024 
1032  public static float min(float x, float y) {
1033  return (x < y) ? x : y;
1034  }
1035 
1036 
1037 
1045  public static double min(double x, double y) {
1046  return (x < y) ? x : y;
1047  }
1048 
1050  /* @(#)s_atan.c 1.3 95/01/18 */
1051  /*
1052  * ====================================================
1053  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
1054  *
1055  * Developed at SunSoft, a Sun Microsystems, Inc. business.
1056  * Permission to use, copy, modify, and distribute this
1057  * software is freely granted, provided that this notice
1058  * is preserved.
1059  * ====================================================
1060  *
1061  */
1062 
1063  /* atan(x)
1064  * Method
1065  * 1. Reduce x to positive by atan(x) = -atan(-x).
1066  * 2. According to the integer k=4t+0.25 chopped, t=x, the argument
1067  * is further reduced to one of the following intervals and the
1068  * arctangent of t is evaluated by the corresponding formula:
1069  *
1070  * [0,7/16] atan(x) = t-t^3*(a1+t^2*(a2+...(a10+t^2*a11)...)
1071  * [7/16,11/16] atan(x) = atan(1/2) + atan( (t-0.5)/(1+t/2) )
1072  * [11/16.19/16] atan(x) = atan( 1 ) + atan( (t-1)/(1+t) )
1073  * [19/16,39/16] atan(x) = atan(3/2) + atan( (t-1.5)/(1+1.5t) )
1074  * [39/16,INF] atan(x) = atan(INF) + atan( -1/t )
1075  *
1076  * Constants:
1077  * The hexadecimal values are the intended ones for the following
1078  * constants. The decimal values may be used, provided that the
1079  * compiler will convert from decimal to binary accurately enough
1080  * to produce the hexadecimal values shown.
1081  */
1082  static final double atanhi[] = { 4.63647609000806093515e-01, // atan(0.5)hi 0x3FDDAC67, 0x0561BB4F
1083  7.85398163397448278999e-01, // atan(1.0)hi 0x3FE921FB, 0x54442D18
1084  9.82793723247329054082e-01, // atan(1.5)hi 0x3FEF730B, 0xD281F69B
1085  1.57079632679489655800e+00, // atan(inf)hi 0x3FF921FB, 0x54442D18
1086  };
1087 
1088  static final double atanlo[] = { 2.26987774529616870924e-17, // atan(0.5)lo 0x3C7A2B7F, 0x222F65E2
1089  3.06161699786838301793e-17, // atan(1.0)lo 0x3C81A626, 0x33145C07
1090  1.39033110312309984516e-17, // atan(1.5)lo 0x3C700788, 0x7AF0CBBD
1091  6.12323399573676603587e-17, // atan(inf)lo 0x3C91A626, 0x33145C07
1092  };
1093 
1094  static final double aT[] = { 3.33333333333329318027e-01, // 0x3FD55555, 0x5555550D
1095  -1.99999999998764832476e-01, // 0xBFC99999, 0x9998EBC4
1096  1.42857142725034663711e-01, // 0x3FC24924, 0x920083FF
1097  -1.11111104054623557880e-01, // 0xBFBC71C6, 0xFE231671
1098  9.09088713343650656196e-02, // 0x3FB745CD, 0xC54C206E
1099  -7.69187620504482999495e-02, // 0xBFB3B0F2, 0xAF749A6D
1100  6.66107313738753120669e-02, // 0x3FB10D66, 0xA0D03D51
1101  -5.83357013379057348645e-02, // 0xBFADDE2D, 0x52DEFD9A
1102  4.97687799461593236017e-02, // 0x3FA97B4B, 0x24760DEB
1103  -3.65315727442169155270e-02, // 0xBFA2B444, 0x2C6A6C2F
1104  1.62858201153657823623e-02, // 0x3F90AD3A, 0xE322DA11
1105  };
1106 
1107  static final double one = 1.0, huge = 1.0e300;
1108 
1109  static double _atan(double x) {
1110  double w, s1, s2, z;
1111  int ix, hx, id;
1112  long xBits = Double.doubleToLongBits(x);
1113  int __HIx = (int) (xBits >> 32);
1114  int __LOx = (int) xBits;
1115 
1116  hx = __HIx;
1117  ix = hx & 0x7fffffff;
1118  if (ix >= 0x44100000) { // if |x| >= 2^66
1119  if (ix > 0x7ff00000 || (ix == 0x7ff00000 && (__LOx != 0)))
1120  return x + x; // NaN
1121  if (hx > 0)
1122  return atanhi[3] + atanlo[3];
1123  else
1124  return -atanhi[3] - atanlo[3];
1125  }
1126  if (ix < 0x3fdc0000) { // |x| < 0.4375
1127  if (ix < 0x3e200000) // |x| < 2^-29
1128  if (huge + x > one)
1129  return x;
1130  id = -1;
1131  } else {
1132  x = MathLib.abs(x);
1133  if (ix < 0x3ff30000) // |x| < 1.1875
1134  if (ix < 0x3fe60000) { // 7/16 <=|x|<11/16
1135  id = 0;
1136  x = (2.0 * x - one) / (2.0 + x);
1137  } else { // 11/16<=|x|< 19/16
1138  id = 1;
1139  x = (x - one) / (x + one);
1140  }
1141  else if (ix < 0x40038000) { // |x| < 2.4375
1142  id = 2;
1143  x = (x - 1.5) / (one + 1.5 * x);
1144  } else { // 2.4375 <= |x| < 2^66
1145  id = 3;
1146  x = -1.0 / x;
1147  }
1148  }
1149  // end of argument reduction
1150  z = x * x;
1151  w = z * z;
1152  // break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly
1153  s1 = z
1154  * (aT[0] + w
1155  * (aT[2] + w
1156  * (aT[4] + w
1157  * (aT[6] + w * (aT[8] + w * aT[10])))));
1158  s2 = w * (aT[1] + w * (aT[3] + w * (aT[5] + w * (aT[7] + w * aT[9]))));
1159  if (id < 0)
1160  return x - x * (s1 + s2);
1161  else {
1162  z = atanhi[id] - ((x * (s1 + s2) - atanlo[id]) - x);
1163  return (hx < 0) ? -z : z;
1164  }
1165  }
1166 
1167 
1169  /* @(#)e_log.c 1.3 95/01/18 */
1170  /*
1171  * ====================================================
1172  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
1173  *
1174  * Developed at SunSoft, a Sun Microsystems, Inc. business.
1175  * Permission to use, copy, modify, and distribute this
1176  * software is freely granted, provided that this notice
1177  * is preserved.
1178  * ====================================================
1179  */
1180 
1181  /* __ieee754_log(x)
1182  * Return the logrithm of x
1183  *
1184  * Method :
1185  * 1. Argument Reduction: find k and f such that
1186  * x = 2^k * (1+f),
1187  * where sqrt(2)/2 < 1+f < sqrt(2) .
1188  *
1189  * 2. Approximation of log(1+f).
1190  * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
1191  * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
1192  * = 2s + s*R
1193  * We use a special Reme algorithm on [0,0.1716] to generate
1194  * a polynomial of degree 14 to approximate R The maximum error
1195  * of this polynomial approximation is bounded by 2**-58.45. In
1196  * other words,
1197  * 2 4 6 8 10 12 14
1198  * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s
1199  * (the values of Lg1 to Lg7 are listed in the program)
1200  * and
1201  * | 2 14 | -58.45
1202  * | Lg1*s +...+Lg7*s - R(z) | <= 2
1203  * | |
1204  * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
1205  * In order to guarantee error in log below 1ulp, we compute log
1206  * by
1207  * log(1+f) = f - s*(f - R) (if f is not too large)
1208  * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy)
1209  *
1210  * 3. Finally, log(x) = k*ln2 + log(1+f).
1211  * = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
1212  * Here ln2 is split into two floating point number:
1213  * ln2_hi + ln2_lo,
1214  * where n*ln2_hi is always exact for |n| < 2000.
1215  *
1216  * Special cases:
1217  * log(x) is NaN with signal if x < 0 (including -INF) ;
1218  * log(+INF) is +INF; log(0) is -INF with signal;
1219  * log(NaN) is that NaN with no signal.
1220  *
1221  * Accuracy:
1222  * according to an error analysis, the error is always less than
1223  * 1 ulp (unit in the last place).
1224  *
1225  * Constants:
1226  * The hexadecimal values are the intended ones for the following
1227  * constants. The decimal values may be used, provided that the
1228  * compiler will convert from decimal to binary accurately enough
1229  * to produce the hexadecimal values shown.
1230  */
1231  static final double ln2_hi = 6.93147180369123816490e-01, // 3fe62e42 fee00000
1232  ln2_lo = 1.90821492927058770002e-10, // 3dea39ef 35793c76
1233  two54 = 1.80143985094819840000e+16, // 43500000 00000000
1234  Lg1 = 6.666666666666735130e-01, // 3FE55555 55555593
1235  Lg2 = 3.999999999940941908e-01, // 3FD99999 9997FA04
1236  Lg3 = 2.857142874366239149e-01, // 3FD24924 94229359
1237  Lg4 = 2.222219843214978396e-01, // 3FCC71C5 1D8E78AF
1238  Lg5 = 1.818357216161805012e-01, // 3FC74664 96CB03DE
1239  Lg6 = 1.531383769920937332e-01, // 3FC39A09 D078C69F
1240  Lg7 = 1.479819860511658591e-01; // 3FC2F112 DF3E5244
1241 
1242  static final double zero = 0.0;
1243 
1244  static double _ieee754_log(double x) {
1245  double hfsq, f, s, z, R, w, t1, t2, dk;
1246  int k, hx, i, j;
1247  int lx; // unsigned
1248 
1249  long xBits = Double.doubleToLongBits(x);
1250  hx = (int) (xBits >> 32);
1251  lx = (int) xBits;
1252 
1253  k = 0;
1254  if (hx < 0x00100000) { // x < 2**-1022
1255  if (((hx & 0x7fffffff) | lx) == 0)
1256  return -two54 / zero; // log(+-0)=-inf
1257  if (hx < 0)
1258  return (x - x) / zero; // log(-#) = NaN
1259  k -= 54;
1260  x *= two54; // subnormal number, scale up x
1261  xBits = Double.doubleToLongBits(x);
1262  hx = (int) (xBits >> 32); // high word of x
1263  }
1264  if (hx >= 0x7ff00000)
1265  return x + x;
1266  k += (hx >> 20) - 1023;
1267  hx &= 0x000fffff;
1268  i = (hx + 0x95f64) & 0x100000;
1269  xBits = Double.doubleToLongBits(x);
1270  int HIx = hx | (i ^ 0x3ff00000); // normalize x or x/2
1271  xBits = ((HIx & 0xFFFFFFFFL) << 32) | (xBits & 0xFFFFFFFFL);
1272  x = Double.longBitsToDouble(xBits);
1273  k += (i >> 20);
1274  f = x - 1.0;
1275  if ((0x000fffff & (2 + hx)) < 3) { // |f| < 2**-20
1276  if (f == zero)
1277  if (k == 0)
1278  return zero;
1279  else {
1280  dk = (double) k;
1281  return dk * ln2_hi + dk * ln2_lo;
1282  }
1283  R = f * f * (0.5 - 0.33333333333333333 * f);
1284  if (k == 0)
1285  return f - R;
1286  else {
1287  dk = (double) k;
1288  return dk * ln2_hi - ((R - dk * ln2_lo) - f);
1289  }
1290  }
1291  s = f / (2.0 + f);
1292  dk = (double) k;
1293  z = s * s;
1294  i = hx - 0x6147a;
1295  w = z * z;
1296  j = 0x6b851 - hx;
1297  t1 = w * (Lg2 + w * (Lg4 + w * Lg6));
1298  t2 = z * (Lg1 + w * (Lg3 + w * (Lg5 + w * Lg7)));
1299  i |= j;
1300  R = t2 + t1;
1301  if (i > 0) {
1302  hfsq = 0.5 * f * f;
1303  if (k == 0)
1304  return f - (hfsq - s * (hfsq + R));
1305  else
1306  return dk * ln2_hi
1307  - ((hfsq - (s * (hfsq + R) + dk * ln2_lo)) - f);
1308  } else if (k == 0)
1309  return f - s * (f - R);
1310  else
1311  return dk * ln2_hi - ((s * (f - R) - dk * ln2_lo) - f);
1312  }
1313 
1314 
1316  /* @(#)e_exp.c 1.6 04/04/22 */
1317  /*
1318  * ====================================================
1319  * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
1320  *
1321  * Permission to use, copy, modify, and distribute this
1322  * software is freely granted, provided that this notice
1323  * is preserved.
1324  * ====================================================
1325  */
1326 
1327  /* __ieee754_exp(x)
1328  * Returns the exponential of x.
1329  *
1330  * Method
1331  * 1. Argument reduction:
1332  * Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658.
1333  * Given x, find r and integer k such that
1334  *
1335  * x = k*ln2 + r, |r| <= 0.5*ln2.
1336  *
1337  * Here r will be represented as r = hi-lo for better
1338  * accuracy.
1339  *
1340  * 2. Approximation of exp(r) by a special rational function on
1341  * the interval [0,0.34658]:
1342  * Write
1343  * R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ...
1344  * We use a special Remes algorithm on [0,0.34658] to generate
1345  * a polynomial of degree 5 to approximate R. The maximum error
1346  * of this polynomial approximation is bounded by 2**-59. In
1347  * other words,
1348  * R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5
1349  * (where z=r*r, and the values of P1 to P5 are listed below)
1350  * and
1351  * | 5 | -59
1352  * | 2.0+P1*z+...+P5*z - R(z) | <= 2
1353  * | |
1354  * The computation of exp(r) thus becomes
1355  * 2*r
1356  * exp(r) = 1 + -------
1357  * R - r
1358  * r*R1(r)
1359  * = 1 + r + ----------- (for better accuracy)
1360  * 2 - R1(r)
1361  * where
1362  * 2 4 10
1363  * R1(r) = r - (P1*r + P2*r + ... + P5*r ).
1364  *
1365  * 3. Scale back to obtain exp(x):
1366  * From step 1, we have
1367  * exp(x) = 2^k * exp(r)
1368  *
1369  * Special cases:
1370  * exp(INF) is INF, exp(NaN) is NaN;
1371  * exp(-INF) is 0, and
1372  * for finite argument, only exp(0)=1 is exact.
1373  *
1374  * Accuracy:
1375  * according to an error analysis, the error is always less than
1376  * 1 ulp (unit in the last place).
1377  *
1378  * Misc. info.
1379  * For IEEE double
1380  * if x > 7.09782712893383973096e+02 then exp(x) overflow
1381  * if x < -7.45133219101941108420e+02 then exp(x) underflow
1382  *
1383  * Constants:
1384  * The hexadecimal values are the intended ones for the following
1385  * constants. The decimal values may be used, provided that the
1386  * compiler will convert from decimal to binary accurately enough
1387  * to produce the hexadecimal values shown.
1388  */
1389  static final double halF[] = { 0.5, -0.5, },
1390  twom1000 = 9.33263618503218878990e-302, // 2**-1000=0x01700000,0
1391  o_threshold = 7.09782712893383973096e+02, // 0x40862E42, 0xFEFA39EF
1392  u_threshold = -7.45133219101941108420e+02, // 0xc0874910, 0xD52D3051
1393  ln2HI[] = { 6.93147180369123816490e-01, // 0x3fe62e42, 0xfee00000
1394  -6.93147180369123816490e-01, },// 0xbfe62e42, 0xfee00000
1395  ln2LO[] = { 1.90821492927058770002e-10, // 0x3dea39ef, 0x35793c76
1396  -1.90821492927058770002e-10, },// 0xbdea39ef, 0x35793c76
1397  invln2 = 1.44269504088896338700e+00, // 0x3ff71547, 0x652b82fe
1398  P1 = 1.66666666666666019037e-01, // 0x3FC55555, 0x5555553E
1399  P2 = -2.77777777770155933842e-03, // 0xBF66C16C, 0x16BEBD93
1400  P3 = 6.61375632143793436117e-05, // 0x3F11566A, 0xAF25DE2C
1401  P4 = -1.65339022054652515390e-06, // 0xBEBBBD41, 0xC5D26BF1
1402  P5 = 4.13813679705723846039e-08; // 0x3E663769, 0x72BEA4D0
1403 
1404  static double _ieee754_exp(double x) // default IEEE double exp
1405  {
1406  double y, hi = 0, lo = 0, c, t;
1407  int k = 0, xsb;
1408  int hx; // Unsigned.
1409  long xBits = Double.doubleToLongBits(x);
1410  int __HIx = (int) (xBits >> 32);
1411  int __LOx = (int) xBits;
1412 
1413  hx = __HIx; // high word of x
1414  xsb = (hx >> 31) & 1; // sign bit of x
1415  hx &= 0x7fffffff; // high word of |x|
1416 
1417  // filter out non-finite argument
1418  if (hx >= 0x40862E42) { // if |x|>=709.78...
1419  if (hx >= 0x7ff00000)
1420  if (((hx & 0xfffff) | __LOx) != 0)
1421  return x + x; // NaN
1422  else
1423  return (xsb == 0) ? x : 0.0;
1424  if (x > o_threshold)
1425  return huge * huge; // overflow
1426  if (x < u_threshold)
1427  return twom1000 * twom1000; // underflow
1428  }
1429 
1430  // argument reduction
1431  if (hx > 0x3fd62e42) { // if |x| > 0.5 ln2
1432  if (hx < 0x3FF0A2B2) { // and |x| < 1.5 ln2
1433  hi = x - ln2HI[xsb];
1434  lo = ln2LO[xsb];
1435  k = 1 - xsb - xsb;
1436  } else {
1437  k = (int) (invln2 * x + halF[xsb]);
1438  t = k;
1439  hi = x - t * ln2HI[0]; // t*ln2HI is exact here
1440  lo = t * ln2LO[0];
1441  }
1442  x = hi - lo;
1443  } else if (hx < 0x3e300000) { // when |x|<2**-28
1444  if (huge + x > one)
1445  return one + x;// trigger inexact
1446  } else
1447  k = 0;
1448 
1449  // x is now in primary range
1450  t = x * x;
1451  c = x - t * (P1 + t * (P2 + t * (P3 + t * (P4 + t * P5))));
1452  if (k == 0)
1453  return one - ((x * c) / (c - 2.0) - x);
1454  else
1455  y = one - ((lo - (x * c) / (2.0 - c)) - hi);
1456  long yBits = Double.doubleToLongBits(y);
1457  int __HIy = (int) (yBits >> 32);
1458  if (k >= -1021) {
1459  __HIy += (k << 20); // add k to y's exponent
1460  yBits = ((__HIy & 0xFFFFFFFFL) << 32) | (yBits & 0xFFFFFFFFL);
1461  y = Double.longBitsToDouble(yBits);
1462  return y;
1463  } else {
1464  __HIy += ((k + 1000) << 20);// add k to y's exponent
1465  yBits = ((__HIy & 0xFFFFFFFFL) << 32) | (yBits & 0xFFFFFFFFL);
1466  y = Double.longBitsToDouble(yBits);
1467  return y * twom1000;
1468  }
1469  }
1470 
1471 }
javolution.lang.MathLib.max
static int max(int x, int y)
Definition: MathLib.java:964
javolution.lang.MathLib.Lg1
static final double Lg1
Definition: MathLib.java:1234
javolution.lang.MathLib.Lg3
static final double Lg3
Definition: MathLib.java:1236
javolution.lang.MathLib.POW5_INT
static final int[] POW5_INT
Definition: MathLib.java:351
javolution.lang.MathLib.Lg6
static final double Lg6
Definition: MathLib.java:1239
javolution.lang.MathLib.digitLength
static int digitLength(long l)
Definition: MathLib.java:180
javolution.lang.MathLib.log
static double log(double x)
Definition: MathLib.java:859
javolution.lang.MathLib.toLongPow2
static long toLongPow2(double d, int n)
Definition: MathLib.java:366
javolution.lang.MathLib.numberOfTrailingZeros
static int numberOfTrailingZeros(long longValue)
Definition: MathLib.java:140
javolution.lang.MathLib.toDoublePow2
static double toDoublePow2(long m, int n)
Definition: MathLib.java:203
javolution.lang.MathLib.ln2_lo
static final double ln2_lo
Definition: MathLib.java:1232
javolution.lang.MathLib
Definition: MathLib.java:20
javolution.lang.MathLib.SQRT2
static final double SQRT2
Definition: MathLib.java:604
javolution.lang.MathLib.max
static long max(long x, long y)
Definition: MathLib.java:975
javolution.lang.MathLib.sin
static double sin(double radians)
Definition: MathLib.java:704
javolution.lang.MathLib.ln2_hi
static final double ln2_hi
Definition: MathLib.java:1231
javolution.lang.MathLib.bitLength
static int bitLength(int i)
Definition: MathLib.java:38
javolution.lang.MathLib.P4
static final double P4
Definition: MathLib.java:1401
javolution.lang.MathLib.LOG2
static final double LOG2
Definition: MathLib.java:594
javolution.lang.MathLib.NaN
static final double NaN
Definition: MathLib.java:609
javolution.lang.MathLib._ieee754_exp
static double _ieee754_exp(double x)
Definition: MathLib.java:1404
javolution.lang.MathLib.P5
static final double P5
Definition: MathLib.java:1402
javolution.lang.MathLib.Lg2
static final double Lg2
Definition: MathLib.java:1235
javolution.lang.MathLib.asin
static double asin(double x)
Definition: MathLib.java:741
javolution.lang.MathLib._atan
static double _atan(double x)
Definition: MathLib.java:1109
javolution.lang.MathLib.atan2
static double atan2(double y, double x)
Definition: MathLib.java:790
javolution.lang.MathLib.aT
static final double aT[]
Definition: MathLib.java:1094
javolution.lang.MathLib.cos
static double cos(double radians)
Definition: MathLib.java:716
javolution.lang.MathLib.one
static final double one
Definition: MathLib.java:1107
javolution.lang.MathLib.invln2
static final double invln2
Definition: MathLib.java:1397
javolution.lang.MathLib.rem
static double rem(double x, double y)
Definition: MathLib.java:660
javolution.lang.MathLib.E
static final double E
Definition: MathLib.java:564
javolution.lang.MathLib.floor
static double floor(double x)
Definition: MathLib.java:692
javolution.lang.MathLib.sinh
static double sinh(double x)
Definition: MathLib.java:808
javolution.lang.MathLib.ln2HI
static final double ln2HI[]
Definition: MathLib.java:1393
javolution.lang.MathLib.sqrt
static double sqrt(double x)
Definition: MathLib.java:647
javolution.lang.MathLib.Lg4
static final double Lg4
Definition: MathLib.java:1237
javolution.lang.MathLib.u_threshold
static final double u_threshold
Definition: MathLib.java:1392
javolution.lang.MathLib.round
static int round(float f)
Definition: MathLib.java:898
javolution.lang.MathLib.floorLog10
static int floorLog10(double d)
Definition: MathLib.java:549
javolution.lang.MathLib.BIT_LENGTH
static final byte[] BIT_LENGTH
Definition: MathLib.java:47
javolution.lang.MathLib.ln2LO
static final double ln2LO[]
Definition: MathLib.java:1395
javolution.lang.MathLib.PI_SQUARE
static final double PI_SQUARE
Definition: MathLib.java:589
javolution.lang.MathLib.bitLength
static int bitLength(long l)
Definition: MathLib.java:72
javolution.lang.MathLib.atanlo
static final double atanlo[]
Definition: MathLib.java:1088
javolution.lang.MathLib.two54
static final double two54
Definition: MathLib.java:1233
javolution.lang.MathLib.digitLength
static int digitLength(int i)
Definition: MathLib.java:161
javolution.lang.MathLib.log10
static double log10(double x)
Definition: MathLib.java:871
javolution.lang.MathLib.toLongPow10
static long toLongPow10(double d, int n)
Definition: MathLib.java:400
javolution.lang.MathLib.toDegrees
static double toDegrees(double radians)
Definition: MathLib.java:635
javolution.lang.MathLib.bitCount
static int bitCount(long longValue)
Definition: MathLib.java:97
javolution.lang.MathLib.LOG10
static final double LOG10
Definition: MathLib.java:599
javolution.lang.MathLib.Lg7
static final double Lg7
Definition: MathLib.java:1240
javolution.lang.MathLib.floorLog2
static int floorLog2(double d)
Definition: MathLib.java:526
javolution.lang.MathLib.MASK_32
static final long MASK_32
Definition: MathLib.java:349
javolution.lang.MathLib.P3
static final double P3
Definition: MathLib.java:1400
javolution.lang.MathLib.Lg5
static final double Lg5
Definition: MathLib.java:1238
javolution.lang.MathLib.round
static long round(double d)
Definition: MathLib.java:911
javolution.lang.MathLib.min
static float min(float x, float y)
Definition: MathLib.java:1032
javolution.lang.MathLib.toRadians
static double toRadians(double degrees)
Definition: MathLib.java:623
javolution.lang.MathLib.P1
static final double P1
Definition: MathLib.java:1398
javolution.lang.MathLib.toDoublePow10
static double toDoublePow10(long m, int n)
Definition: MathLib.java:240
javolution.lang.MathLib.exp
static double exp(double x)
Definition: MathLib.java:846
javolution.lang.MathLib.atanhi
static final double atanhi[]
Definition: MathLib.java:1082
javolution.lang.MathLib.FOUR_PI
static final double FOUR_PI
Definition: MathLib.java:584
javolution.lang.MathLib.MathLib
MathLib()
Definition: MathLib.java:25
javolution.lang.MathLib.tan
static double tan(double radians)
Definition: MathLib.java:728
javolution.lang.MathLib.max
static double max(double x, double y)
Definition: MathLib.java:997
javolution.lang.MathLib.abs
static int abs(int i)
Definition: MathLib.java:921
javolution.lang.MathLib.abs
static double abs(double d)
Definition: MathLib.java:951
javolution.lang.MathLib.abs
static long abs(long l)
Definition: MathLib.java:931
javolution.lang.MathLib.ceil
static double ceil(double x)
Definition: MathLib.java:678
javolution.lang.MathLib.Infinity
static final double Infinity
Definition: MathLib.java:614
javolution.lang.MathLib.LOG2_DIV_LOG10
static final double LOG2_DIV_LOG10
Definition: MathLib.java:559
javolution.lang.MathLib.P2
static final double P2
Definition: MathLib.java:1399
javolution.lang.MathLib.twom1000
static final double twom1000
Definition: MathLib.java:1390
javolution.lang.MathLib.zero
static final double zero
Definition: MathLib.java:1242
javolution.lang.MathLib.pow
static double pow(double x, double y)
Definition: MathLib.java:885
javolution.lang.MathLib.numberOfLeadingZeros
static int numberOfLeadingZeros(long longValue)
Definition: MathLib.java:117
javolution.lang.MathLib.atan
static double atan(double x)
Definition: MathLib.java:775
javolution.lang.MathLib.halF
static final double halF[]
Definition: MathLib.java:1389
javolution.lang.MathLib.MASK_63
static final long MASK_63
Definition: MathLib.java:347
javolution.lang.MathLib.acos
static double acos(double x)
Definition: MathLib.java:760
javolution.lang.MathLib.max
static float max(float x, float y)
Definition: MathLib.java:986
javolution.lang.MathLib.PI
static final double PI
Definition: MathLib.java:569
javolution.lang.MathLib.HALF_PI
static final double HALF_PI
Definition: MathLib.java:574
javolution.lang.MathLib.cosh
static double cosh(double x)
Definition: MathLib.java:820
javolution.lang.MathLib.o_threshold
static final double o_threshold
Definition: MathLib.java:1391
javolution.lang.MathLib._ieee754_log
static double _ieee754_log(double x)
Definition: MathLib.java:1244
javolution.lang.MathLib.min
static long min(long x, long y)
Definition: MathLib.java:1021
javolution.lang.MathLib.TWO_PI
static final double TWO_PI
Definition: MathLib.java:579
javolution.lang.MathLib.INV_LOG10
static double INV_LOG10
Definition: MathLib.java:875
javolution.lang.MathLib.tanh
static double tanh(double x)
Definition: MathLib.java:832
javolution.lang.MathLib.min
static double min(double x, double y)
Definition: MathLib.java:1045
javolution.lang.MathLib.min
static int min(int x, int y)
Definition: MathLib.java:1010
javolution.lang.MathLib.abs
static float abs(float f)
Definition: MathLib.java:941
javolution.lang.MathLib.huge
static final double huge
Definition: MathLib.java:1107