changes: now Inference engine works fine with the EyeTracking benchmark.
[IRC.git] / Robust / src / ClassLibrary / SSJavaInfer / Math.java
1
2 public class Math {
3
4   static final double PI = 3.14159265358979323846;
5
6   // an alias for setPI()
7   public static double PI() {
8     double PI = 3.14159265358979323846;
9     return PI;
10   }
11
12   public static int abs(int x) {
13     return (x < 0) ? -x : x;
14   }
15
16   public static long abs(long x) {
17     return (x < 0) ? -x : x;
18   }
19
20   public static double abs(double x) {
21     return (x < 0) ? -x : x;
22   }
23
24   public static float abs(float x) {
25     return (x < 0) ? -x : x;
26   }
27
28   public static double max(double a, double b) {
29     return (a > b) ? a : b;
30   }
31
32   public static float max(float a, float b) {
33     return (a > b) ? a : b;
34   }
35
36   public static int max(int a, int b) {
37     return (a > b) ? a : b;
38   }
39
40   public static long max(long a, long b) {
41     return (a > b) ? a : b;
42   }
43
44   public static double min(double a, double b) {
45     return (a < b) ? a : b;
46   }
47
48   public static float min(float a, float b) {
49     return (a < b) ? a : b;
50   }
51
52   public static int min(int a, int b) {
53     return (a < b) ? a : b;
54   }
55
56   public static long min(long a, long b) {
57     return (a < b) ? a : b;
58   }
59
60   /** sqrt(a^2 + b^2) without under/overflow. **/
61   public static double hypot(double a, double b) {
62     double r;
63     if (abs(a) > abs(b)) {
64       r = b / a;
65       r = abs(a) * sqrt(1 + r * r);
66     } else if (b != 0) {
67       r = a / b;
68       r = abs(b) * sqrt(1 + r * r);
69     } else {
70       r = 0.0;
71     }
72     return r;
73   }
74
75   public static int round(float a) {
76     // this check for NaN, from JLS 15.21.1, saves a method call
77     return (int) floor(a + 0.5f);
78   }
79
80   public static double rint(double x) {
81     double y = ceil(x);
82     double d = y - x;
83     if (d == 0.5) {
84       if (((int) y) % 2 == 0) {
85         return y;
86       } else {
87         return y - 1.0;
88       }
89     } else if (d < 0.5) {
90       return y;
91     }
92     return y - 1.0;
93   }
94
95   public static native double sin(double a);
96
97   public static native double cos(double a);
98
99   public static native double asin(double a);
100
101   public static native double acos(double a);
102
103   public static native double tan(double a);
104
105   public static native double atan(double a);
106
107   public static native double atan2(double a, double b);
108
109   public static native double exp(double a);
110
111   public static native double sqrt(double a);
112
113   public static native double log(double a);
114
115   public static native double pow(double a, double b);
116
117   public static native double ceil(double a);
118
119   public static native double floor(double a);
120
121   public static native float sinf(float a);
122
123   public static native float cosf(float a);
124
125   public static native float expf(float a);
126
127   public static native float sqrtf(float a);
128
129   public static native float logf(float a);
130
131   public static native float powf(float a, float b);
132
133   public static native float ceilf(float a);
134
135   public static native float IEEEremainder(float f1, float f2);
136 }