Added few more Math functionality for 2DFFT benchmark
authoradash <adash>
Fri, 31 Oct 2008 23:29:10 +0000 (23:29 +0000)
committeradash <adash>
Fri, 31 Oct 2008 23:29:10 +0000 (23:29 +0000)
Robust/src/ClassLibrary/Math.java

index 15e3ce246503a24d5667eb2986798a60268d78f7..6f3e56bd3f47b4ed4c5f67ac1d837936dd4bec41 100644 (file)
@@ -1,5 +1,9 @@
 public class Math {
-  //public static final double PI=3.14159265358979323846;
+
+  public static double setPI() {
+    double PI = 3.14159265358979323846;
+    return PI;
+  }
 
   public static double fabs(double x) {
     if (x < 0) {
@@ -15,6 +19,51 @@ public class Math {
     else return a;
   }
 
+  public static double max(double a, double b) {
+    if(a == b)
+      return a;
+    if(a > b) {
+      return a;
+    } else {
+      return b;
+    }
+  }
+
+  public static int imax(int a, int b) {
+    if(a == b)
+      return a;
+    if(a > b) {
+      return a;
+    } else {
+      return b;
+    }
+  }
+
+  public static int imin(int a, int b) {
+    if(a == b)
+      return a;
+    if(a > b) {
+      return b;
+    } else {
+      return a;
+    }
+  }
+
+  /** sqrt(a^2 + b^2) without under/overflow. **/
+  public static double hypot(double a, double b) {
+    double r;
+    if (fabs(a) > fabs(b)) {
+      r = b/a;
+      r = fabs(a)*sqrt(1+r*r);
+    } else if (b != 0) {
+      r = a/b;
+      r = fabs(b)*sqrt(1+r*r);
+    } else {
+      r = 0.0;
+    }
+    return r;
+  }
+
   public static native double sin(double a);
   public static native double cos(double a);
   public static native double asin(double a);