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
26static jdouble Math_tan(JNIEnv*, jclass, jdouble a) {
27    return tan(a);
28}
29
30static jdouble Math_asin(JNIEnv*, jclass, jdouble a) {
31    return asin(a);
32}
33
34static jdouble Math_acos(JNIEnv*, jclass, jdouble a) {
35    return acos(a);
36}
37
38static jdouble Math_atan(JNIEnv*, jclass, jdouble a) {
39    return atan(a);
40}
41
42static jdouble Math_exp(JNIEnv*, jclass, jdouble a) {
43    return exp(a);
44}
45
46static jdouble Math_log(JNIEnv*, jclass, jdouble a) {
47    return log(a);
48}
49
50static jdouble Math_IEEEremainder(JNIEnv*, jclass, jdouble a, jdouble b) {
51    return remainder(a, b);
52}
53
54static jdouble Math_floor(JNIEnv*, jclass, jdouble a) {
55    return floor(a);
56}
57
58static jdouble Math_ceil(JNIEnv*, jclass, jdouble a) {
59    return ceil(a);
60}
61
62static jdouble Math_rint(JNIEnv*, jclass, jdouble a) {
63    return rint(a);
64}
65
66static jdouble Math_atan2(JNIEnv*, jclass, jdouble a, jdouble b) {
67    return atan2(a, b);
68}
69
70static jdouble Math_pow(JNIEnv*, jclass, jdouble a, jdouble b) {
71    return pow(a, b);
72}
73
74static jdouble Math_sinh(JNIEnv*, jclass, jdouble a) {
75    return sinh(a);
76}
77
78static jdouble Math_tanh(JNIEnv*, jclass, jdouble a) {
79    return tanh(a);
80}
81
82static jdouble Math_cosh(JNIEnv*, jclass, jdouble a) {
83    return cosh(a);
84}
85
86static jdouble Math_log10(JNIEnv*, jclass, jdouble a) {
87    return log10(a);
88}
89
90static jdouble Math_cbrt(JNIEnv*, jclass, jdouble a) {
91    return cbrt(a);
92}
93
94static jdouble Math_expm1(JNIEnv*, jclass, jdouble a) {
95    return expm1(a);
96}
97
98static jdouble Math_hypot(JNIEnv*, jclass, jdouble a, jdouble b) {
99    return hypot(a, b);
100}
101
102static jdouble Math_log1p(JNIEnv*, jclass, jdouble a) {
103    return log1p(a);
104}
105
106static jdouble Math_nextafter(JNIEnv*, jclass, jdouble a, jdouble b) {
107    return nextafter(a, b);
108}
109
110static 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
134void register_java_lang_Math(JNIEnv* env) {
135    jniRegisterNativeMethods(env, "java/lang/Math", gMethods, NELEM(gMethods));
136}
137