public class Math {
- //public static final double PI=3.14159265358979323846;
-
- public double fabs(double x) {
- if (x < 0) {
- return -x;
- } else {
- return x;
- }
- }
-
- public double sin(double rad) {
- double app;
- double diff;
- int inc = 1;
- double PI=3.14159265358979323846;
-
- while( rad > 2*PI ) rad -= 2*PI;
- while( rad < -2*PI ) rad += 2*PI;
- app = diff = rad;
- diff = (diff * (-(rad*rad))) / ((2.0 * inc) * (2.0 * inc + 1.0));
- app = app + diff;
- inc++;
- while( fabs(diff) >= 0.00001 ) {
- diff = (diff * (-(rad*rad))) / ((2.0 * inc) * (2.0 * inc + 1.0));
- app = app + diff;
- inc++;
- }
- return app;
+ //public static final double PI=3.14159265358979323846;
+
+ public static double fabs(double x) {
+ if (x < 0) {
+ return -x;
+ } else {
+ return x;
}
+ }
+
+ public static float abs(float a) {
+ if (a<0)
+ return -a;
+ else return a;
+ }
- public double cos(double rad) {
- double app;
- double diff;
- int inc = 1;
- double PI=3.14159265358979323846;
-
- rad += PI/2.0;
- while( rad > 2*PI ) rad -= 2*PI;
- while( rad < -2*PI ) rad += 2*PI;
- app = diff = rad;
- diff = (diff * (-(rad*rad))) / ((2.0 * inc) * (2.0 * inc + 1.0));
- app = app + diff;
- inc++;
- while( fabs(diff) >= 0.00001 ) {
- diff = (diff * (-(rad*rad))) / ((2.0 * inc) * (2.0 * inc + 1.0));
- app = app + diff;
- inc++;
- }
- return app;
- }
+ public static native double sin(double a);
+ public static native double cos(double a);
+ public static native double asin(double a);
+ public static native double acos(double a);
+ public static native double tan(double a);
+ public static native double atan(double a);
+ public static native double exp(double a);
+ public static native double sqrt(double a);
+ public static native double log(double a);
+ public static native double pow(double a, double b);
}
readSourceFile(state, ClassLibraryPrefix+"OutputStream.java");
readSourceFile(state, ClassLibraryPrefix+"FileOutputStream.java");
readSourceFile(state, ClassLibraryPrefix+"File.java");
+ readSourceFile(state, ClassLibraryPrefix+"Math.java");
readSourceFile(state, ClassLibraryPrefix+"InetAddress.java");
readSourceFile(state, ClassLibraryPrefix+"SocketInputStream.java");
readSourceFile(state, ClassLibraryPrefix+"SocketOutputStream.java");
--- /dev/null
+#include "runtime.h"
+#include "math.h"
+#include "structdefs.h"
+
+double CALL11(___Math______cos____D, double ___a___, double ___a___) {
+ return cos(___a___);
+}
+
+double CALL11(___Math______sin____D, double ___a___, double ___a___) {
+ return sin(___a___);
+}
+
+double CALL11(___Math______tan____D, double ___a___, double ___a___) {
+ return tan(___a___);
+}
+
+double CALL11(___Math______acos____D, double ___a___, double ___a___) {
+ return acos(___a___);
+}
+
+double CALL11(___Math______asin____D, double ___a___, double ___a___) {
+ return asin(___a___);
+}
+
+double CALL11(___Math______atan____D, double ___a___, double ___a___) {
+ return atan(___a___);
+}
+
+double CALL11(___Math______log____D, double ___a___, double ___a___) {
+ return log(___a___);
+}
+
+double CALL11(___Math______exp____D, double ___a___, double ___a___) {
+ return exp(___a___);
+}
+
+double CALL11(___Math______sqrt____D, double ___a___, double ___a___) {
+ return sqrt(___a___);
+}
+
+double CALL22(___Math______pow____D_D, double ___a___, double ___b___, double ___a___, double ___b___) {
+ return pow(___a___,___b___);
+}
#define CALL02(name, alt1, alt2) name(struct name ## _params * ___params___)
#define CALL11(name,rest, alt) name(struct name ## _params * ___params___, rest)
#define CALL12(name,rest, alt1, alt2) name(struct name ## _params * ___params___, rest)
+#define CALL22(name, rest, rest2, alt1, alt2) name(struct name ## _params * ___params___, rest, rest2)
#define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2)
#define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
#define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
#define CALL02(name, alt1, alt2) name(alt1, alt2)
#define CALL11(name,rest, alt) name(alt)
#define CALL12(name,rest, alt1, alt2) name(alt1, alt2)
+#define CALL22(name, rest, rest2, alt1, alt2) name(alt1, alt2)
#define CALL23(name, rest, rest2, alt1, alt2, alt3) name(alt1, alt2, alt3)
#define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
#define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
$ROBUSTROOT/Runtime/SimpleHash.c $ROBUSTROOT/Runtime/option.c \
$ROBUSTROOT/Runtime/ObjectHash.c \
$ROBUSTROOT/Runtime/garbage.c $ROBUSTROOT/Runtime/socket.c \
+$ROBUSTROOT/Runtime/math.c \
$ROBUSTROOT/Runtime/GenericHashtable.c $ROBUSTROOT/Runtime/object.c"
if $DSMFLAG