diff options
Diffstat (limited to 'java/src/com/android')
-rw-r--r-- | java/src/com/android/inputmethod/latin/NativeUtils.java | 32 | ||||
-rw-r--r-- | java/src/com/android/inputmethod/latin/UserHistoryForgettingCurveUtils.java | 4 |
2 files changed, 34 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/NativeUtils.java b/java/src/com/android/inputmethod/latin/NativeUtils.java new file mode 100644 index 000000000..9cc2bc02e --- /dev/null +++ b/java/src/com/android/inputmethod/latin/NativeUtils.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.latin; + +public class NativeUtils { + static { + JniUtils.loadNativeLibrary(); + } + + private NativeUtils() { + // This utility class is not publicly instantiable. + } + + /** + * This method just calls up libm's powf() directly. + */ + public static native float powf(float x, float y); +} diff --git a/java/src/com/android/inputmethod/latin/UserHistoryForgettingCurveUtils.java b/java/src/com/android/inputmethod/latin/UserHistoryForgettingCurveUtils.java index 6e71885cc..1de95d7b8 100644 --- a/java/src/com/android/inputmethod/latin/UserHistoryForgettingCurveUtils.java +++ b/java/src/com/android/inputmethod/latin/UserHistoryForgettingCurveUtils.java @@ -211,8 +211,8 @@ public class UserHistoryForgettingCurveUtils { } for (int j = 0; j < ELAPSED_TIME_MAX; ++j) { final float elapsedHours = j * ELAPSED_TIME_INTERVAL_HOURS; - final double freq = - initialFreq * Math.pow(initialFreq, elapsedHours / HALF_LIFE_HOURS); + final float freq = initialFreq + * NativeUtils.powf(initialFreq, elapsedHours / HALF_LIFE_HOURS); final int intFreq = Math.min(FC_FREQ_MAX, Math.max(0, (int)freq)); SCORE_TABLE[i][j] = intFreq; } |