1 /*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #define LOG_TAG "Math"
18
19 #include "jni.h"
20 #include "JNIHelp.h"
21 #include "JniConstants.h"
22
23 #include <stdlib.h>
24 #include <math.h>
25
Math_tan(JNIEnv *,jclass,jdouble a)26 static jdouble Math_tan(JNIEnv*, jclass, jdouble a) {
27 return tan(a);
28 }
29
Math_asin(JNIEnv *,jclass,jdouble a)30 static jdouble Math_asin(JNIEnv*, jclass, jdouble a) {
31 return asin(a);
32 }
33
Math_acos(JNIEnv *,jclass,jdouble a)34 static jdouble Math_acos(JNIEnv*, jclass, jdouble a) {
35 return acos(a);
36 }
37
Math_atan(JNIEnv *,jclass,jdouble a)38 static jdouble Math_atan(JNIEnv*, jclass, jdouble a) {
39 return atan(a);
40 }
41
Math_exp(JNIEnv *,jclass,jdouble a)42 static jdouble Math_exp(JNIEnv*, jclass, jdouble a) {
43 return exp(a);
44 }
45
Math_log(JNIEnv *,jclass,jdouble a)46 static jdouble Math_log(JNIEnv*, jclass, jdouble a) {
47 return log(a);
48 }
49
Math_IEEEremainder(JNIEnv *,jclass,jdouble a,jdouble b)50 static jdouble Math_IEEEremainder(JNIEnv*, jclass, jdouble a, jdouble b) {
51 return remainder(a, b);
52 }
53
Math_floor(JNIEnv *,jclass,jdouble a)54 static jdouble Math_floor(JNIEnv*, jclass, jdouble a) {
55 return floor(a);
56 }
57
Math_ceil(JNIEnv *,jclass,jdouble a)58 static jdouble Math_ceil(JNIEnv*, jclass, jdouble a) {
59 return ceil(a);
60 }
61
Math_rint(JNIEnv *,jclass,jdouble a)62 static jdouble Math_rint(JNIEnv*, jclass, jdouble a) {
63 return rint(a);
64 }
65
Math_atan2(JNIEnv *,jclass,jdouble a,jdouble b)66 static jdouble Math_atan2(JNIEnv*, jclass, jdouble a, jdouble b) {
67 return atan2(a, b);
68 }
69
Math_pow(JNIEnv *,jclass,jdouble a,jdouble b)70 static jdouble Math_pow(JNIEnv*, jclass, jdouble a, jdouble b) {
71 return pow(a, b);
72 }
73
Math_sinh(JNIEnv *,jclass,jdouble a)74 static jdouble Math_sinh(JNIEnv*, jclass, jdouble a) {
75 return sinh(a);
76 }
77
Math_tanh(JNIEnv *,jclass,jdouble a)78 static jdouble Math_tanh(JNIEnv*, jclass, jdouble a) {
79 return tanh(a);
80 }
81
Math_cosh(JNIEnv *,jclass,jdouble a)82 static jdouble Math_cosh(JNIEnv*, jclass, jdouble a) {
83 return cosh(a);
84 }
85
Math_log10(JNIEnv *,jclass,jdouble a)86 static jdouble Math_log10(JNIEnv*, jclass, jdouble a) {
87 return log10(a);
88 }
89
Math_cbrt(JNIEnv *,jclass,jdouble a)90 static jdouble Math_cbrt(JNIEnv*, jclass, jdouble a) {
91 return cbrt(a);
92 }
93
Math_expm1(JNIEnv *,jclass,jdouble a)94 static jdouble Math_expm1(JNIEnv*, jclass, jdouble a) {
95 return expm1(a);
96 }
97
Math_hypot(JNIEnv *,jclass,jdouble a,jdouble b)98 static jdouble Math_hypot(JNIEnv*, jclass, jdouble a, jdouble b) {
99 return hypot(a, b);
100 }
101
Math_log1p(JNIEnv *,jclass,jdouble a)102 static jdouble Math_log1p(JNIEnv*, jclass, jdouble a) {
103 return log1p(a);
104 }
105
Math_nextafter(JNIEnv *,jclass,jdouble a,jdouble b)106 static jdouble Math_nextafter(JNIEnv*, jclass, jdouble a, jdouble b) {
107 return nextafter(a, b);
108 }
109
110 static JNINativeMethod gMethods[] = {
111 NATIVE_METHOD(Math, IEEEremainder, "!(DD)D"),
112 NATIVE_METHOD(Math, acos, "!(D)D"),
113 NATIVE_METHOD(Math, asin, "!(D)D"),
114 NATIVE_METHOD(Math, atan, "!(D)D"),
115 NATIVE_METHOD(Math, atan2, "!(DD)D"),
116 NATIVE_METHOD(Math, cbrt, "!(D)D"),
117 NATIVE_METHOD(Math, ceil, "!(D)D"),
118 NATIVE_METHOD(Math, cosh, "!(D)D"),
119 NATIVE_METHOD(Math, exp, "!(D)D"),
120 NATIVE_METHOD(Math, expm1, "!(D)D"),
121 NATIVE_METHOD(Math, floor, "!(D)D"),
122 NATIVE_METHOD(Math, hypot, "!(DD)D"),
123 NATIVE_METHOD(Math, log, "!(D)D"),
124 NATIVE_METHOD(Math, log10, "!(D)D"),
125 NATIVE_METHOD(Math, log1p, "!(D)D"),
126 NATIVE_METHOD(Math, nextafter, "!(DD)D"),
127 NATIVE_METHOD(Math, pow, "!(DD)D"),
128 NATIVE_METHOD(Math, rint, "!(D)D"),
129 NATIVE_METHOD(Math, sinh, "!(D)D"),
130 NATIVE_METHOD(Math, tan, "!(D)D"),
131 NATIVE_METHOD(Math, tanh, "!(D)D"),
132 };
133
register_java_lang_Math(JNIEnv * env)134 void register_java_lang_Math(JNIEnv* env) {
135 jniRegisterNativeMethods(env, "java/lang/Math", gMethods, NELEM(gMethods));
136 }
137