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 26 static jdouble Math_sin(JNIEnv*, jclass, jdouble a) { 27 return sin(a); 28 } 29 30 static jdouble Math_cos(JNIEnv*, jclass, jdouble a) { 31 return cos(a); 32 } 33 34 static jdouble Math_tan(JNIEnv*, jclass, jdouble a) { 35 return tan(a); 36 } 37 38 static jdouble Math_asin(JNIEnv*, jclass, jdouble a) { 39 return asin(a); 40 } 41 42 static jdouble Math_acos(JNIEnv*, jclass, jdouble a) { 43 return acos(a); 44 } 45 46 static jdouble Math_atan(JNIEnv*, jclass, jdouble a) { 47 return atan(a); 48 } 49 50 static jdouble Math_exp(JNIEnv*, jclass, jdouble a) { 51 return exp(a); 52 } 53 54 static jdouble Math_log(JNIEnv*, jclass, jdouble a) { 55 return log(a); 56 } 57 58 static jdouble Math_sqrt(JNIEnv*, jclass, jdouble a) { 59 return sqrt(a); 60 } 61 62 static jdouble Math_IEEEremainder(JNIEnv*, jclass, jdouble a, jdouble b) { 63 return remainder(a, b); 64 } 65 66 static jdouble Math_floor(JNIEnv*, jclass, jdouble a) { 67 return floor(a); 68 } 69 70 static jdouble Math_ceil(JNIEnv*, jclass, jdouble a) { 71 return ceil(a); 72 } 73 74 static jdouble Math_rint(JNIEnv*, jclass, jdouble a) { 75 return rint(a); 76 } 77 78 static jdouble Math_atan2(JNIEnv*, jclass, jdouble a, jdouble b) { 79 return atan2(a, b); 80 } 81 82 static jdouble Math_pow(JNIEnv*, jclass, jdouble a, jdouble b) { 83 return pow(a, b); 84 } 85 86 static jdouble Math_sinh(JNIEnv*, jclass, jdouble a) { 87 return sinh(a); 88 } 89 90 static jdouble Math_tanh(JNIEnv*, jclass, jdouble a) { 91 return tanh(a); 92 } 93 94 static jdouble Math_cosh(JNIEnv*, jclass, jdouble a) { 95 return cosh(a); 96 } 97 98 static jdouble Math_log10(JNIEnv*, jclass, jdouble a) { 99 return log10(a); 100 } 101 102 static jdouble Math_cbrt(JNIEnv*, jclass, jdouble a) { 103 return cbrt(a); 104 } 105 106 static jdouble Math_expm1(JNIEnv*, jclass, jdouble a) { 107 return expm1(a); 108 } 109 110 static jdouble Math_hypot(JNIEnv*, jclass, jdouble a, jdouble b) { 111 return hypot(a, b); 112 } 113 114 static jdouble Math_log1p(JNIEnv*, jclass, jdouble a) { 115 return log1p(a); 116 } 117 118 static jdouble Math_nextafter(JNIEnv*, jclass, jdouble a, jdouble b) { 119 return nextafter(a, b); 120 } 121 122 static jfloat Math_nextafterf(JNIEnv*, jclass, jfloat a, jfloat b) { 123 return nextafterf(a, b); 124 } 125 126 static JNINativeMethod gMethods[] = { 127 NATIVE_METHOD(Math, IEEEremainder, "(DD)D"), 128 NATIVE_METHOD(Math, acos, "(D)D"), 129 NATIVE_METHOD(Math, asin, "(D)D"), 130 NATIVE_METHOD(Math, atan, "(D)D"), 131 NATIVE_METHOD(Math, atan2, "(DD)D"), 132 NATIVE_METHOD(Math, cbrt, "(D)D"), 133 NATIVE_METHOD(Math, ceil, "(D)D"), 134 NATIVE_METHOD(Math, cos, "(D)D"), 135 NATIVE_METHOD(Math, cosh, "(D)D"), 136 NATIVE_METHOD(Math, exp, "(D)D"), 137 NATIVE_METHOD(Math, expm1, "(D)D"), 138 NATIVE_METHOD(Math, floor, "(D)D"), 139 NATIVE_METHOD(Math, hypot, "(DD)D"), 140 NATIVE_METHOD(Math, log, "(D)D"), 141 NATIVE_METHOD(Math, log10, "(D)D"), 142 NATIVE_METHOD(Math, log1p, "(D)D"), 143 NATIVE_METHOD(Math, nextafter, "(DD)D"), 144 NATIVE_METHOD(Math, nextafterf, "(FF)F"), 145 NATIVE_METHOD(Math, pow, "(DD)D"), 146 NATIVE_METHOD(Math, rint, "(D)D"), 147 NATIVE_METHOD(Math, sin, "(D)D"), 148 NATIVE_METHOD(Math, sinh, "(D)D"), 149 NATIVE_METHOD(Math, sqrt, "(D)D"), 150 NATIVE_METHOD(Math, tan, "(D)D"), 151 NATIVE_METHOD(Math, tanh, "(D)D"), 152 }; 153 154 int register_java_lang_Math(JNIEnv* env) { 155 return jniRegisterNativeMethods(env, "java/lang/Math", gMethods, NELEM(gMethods)); 156 } 157