Use "float" instead of "double"
Change-Id: I93ed4d88ede4058f081dd8d634b00dfff4e96d07
diff --git a/native/jni/src/correction.cpp b/native/jni/src/correction.cpp
index a1f8129..5ae34cd 100644
--- a/native/jni/src/correction.cpp
+++ b/native/jni/src/correction.cpp
@@ -1113,7 +1113,7 @@
// So, we can normalize original score by dividing pow(2, min(b.l(),a.l())) * 255 * 2.
/* static */
-double Correction::RankingAlgorithm::calcNormalizedScore(const unsigned short* before,
+float Correction::RankingAlgorithm::calcNormalizedScore(const unsigned short* before,
const int beforeLength, const unsigned short* after, const int afterLength,
const int score) {
if (0 == beforeLength || 0 == afterLength) {
@@ -1131,14 +1131,14 @@
return 0;
}
- const double maxScore = score >= S_INT_MAX ? S_INT_MAX : MAX_INITIAL_SCORE
- * pow((double)TYPED_LETTER_MULTIPLIER,
- (double)min(beforeLength, afterLength - spaceCount)) * FULL_WORD_MULTIPLIER;
+ const float maxScore = score >= S_INT_MAX ? S_INT_MAX : MAX_INITIAL_SCORE
+ * pow((float)TYPED_LETTER_MULTIPLIER,
+ (float)min(beforeLength, afterLength - spaceCount)) * FULL_WORD_MULTIPLIER;
// add a weight based on edit distance.
// distance <= max(afterLength, beforeLength) == afterLength,
// so, 0 <= distance / afterLength <= 1
- const double weight = 1.0 - (double) distance / afterLength;
+ const float weight = 1.0 - (float) distance / afterLength;
return (score / maxScore) * weight;
}
diff --git a/native/jni/src/correction.h b/native/jni/src/correction.h
index 1b4e4bf..1ac4b87 100644
--- a/native/jni/src/correction.h
+++ b/native/jni/src/correction.h
@@ -162,7 +162,7 @@
static int calcFreqForSplitMultipleWords(const int *freqArray, const int *wordLengthArray,
const int wordCount, const Correction* correction, const bool isSpaceProximity,
const unsigned short *word);
- static double calcNormalizedScore(const unsigned short* before, const int beforeLength,
+ static float calcNormalizedScore(const unsigned short* before, const int beforeLength,
const unsigned short* after, const int afterLength, const int score);
static int editDistance(const unsigned short* before,
const int beforeLength, const unsigned short* after, const int afterLength);
diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h
index cb3dbb1..c6ad66a 100644
--- a/native/jni/src/defines.h
+++ b/native/jni/src/defines.h
@@ -46,8 +46,8 @@
#include <time.h>
#define PROF_BUF_SIZE 100
-static double profile_buf[PROF_BUF_SIZE];
-static double profile_old[PROF_BUF_SIZE];
+static float profile_buf[PROF_BUF_SIZE];
+static float profile_old[PROF_BUF_SIZE];
static unsigned int profile_counter[PROF_BUF_SIZE];
#define PROF_RESET prof_reset()
@@ -74,8 +74,8 @@
AKLOGI("Error: You must call PROF_OPEN before PROF_CLOSE.");
}
AKLOGI("Total time is %6.3f ms.",
- profile_buf[PROF_BUF_SIZE - 1] * 1000 / (double)CLOCKS_PER_SEC);
- double all = 0;
+ profile_buf[PROF_BUF_SIZE - 1] * 1000 / (float)CLOCKS_PER_SEC);
+ float all = 0;
for (int i = 0; i < PROF_BUF_SIZE - 1; ++i) {
all += profile_buf[i];
}
@@ -84,7 +84,7 @@
if (profile_buf[i] != 0) {
AKLOGI("(%d): Used %4.2f%%, %8.4f ms. Called %d times.",
i, (profile_buf[i] * 100 / all),
- profile_buf[i] * 1000 / (double)CLOCKS_PER_SEC, profile_counter[i]);
+ profile_buf[i] * 1000 / (float)CLOCKS_PER_SEC, profile_counter[i]);
}
}
}
diff --git a/native/jni/src/unigram_dictionary.cpp b/native/jni/src/unigram_dictionary.cpp
index 43fe892..ee8c497 100644
--- a/native/jni/src/unigram_dictionary.cpp
+++ b/native/jni/src/unigram_dictionary.cpp
@@ -202,7 +202,7 @@
PROF_START(20);
if (DEBUG_DICT) {
- double ns = queuePool->getMasterQueue()->getHighestNormalizedScore(
+ float ns = queuePool->getMasterQueue()->getHighestNormalizedScore(
proximityInfo->getPrimaryInputWord(), codesSize, 0, 0, 0);
ns += 0;
AKLOGI("Max normalized score = %f", ns);
@@ -212,7 +212,7 @@
proximityInfo->getPrimaryInputWord(), codesSize, frequencies, outWords);
if (DEBUG_DICT) {
- double ns = queuePool->getMasterQueue()->getHighestNormalizedScore(
+ float ns = queuePool->getMasterQueue()->getHighestNormalizedScore(
proximityInfo->getPrimaryInputWord(), codesSize, 0, 0, 0);
ns += 0;
AKLOGI("Returning %d words", suggestedWordsCount);
@@ -255,7 +255,7 @@
bool hasAutoCorrectionCandidate = false;
WordsPriorityQueue* masterQueue = queuePool->getMasterQueue();
if (masterQueue->size() > 0) {
- double nsForMaster = masterQueue->getHighestNormalizedScore(
+ float nsForMaster = masterQueue->getHighestNormalizedScore(
proximityInfo->getPrimaryInputWord(), inputLength, 0, 0, 0);
hasAutoCorrectionCandidate = (nsForMaster > START_TWO_WORDS_CORRECTION_THRESHOLD);
}
@@ -284,7 +284,7 @@
const int score = sw->mScore;
const unsigned short* word = sw->mWord;
const int wordLength = sw->mWordLength;
- double ns = Correction::RankingAlgorithm::calcNormalizedScore(
+ float ns = Correction::RankingAlgorithm::calcNormalizedScore(
proximityInfo->getPrimaryInputWord(), i, word, wordLength, score);
ns += 0;
AKLOGI("--- TOP SUB WORDS for %d --- %d %f [%d]", i, score, ns,
@@ -452,7 +452,7 @@
return false;
}
int score = 0;
- const double ns = queue->getHighestNormalizedScore(
+ const float ns = queue->getHighestNormalizedScore(
proximityInfo->getPrimaryInputWord(), inputWordLength,
&tempOutputWord, &score, &nextWordLength);
if (DEBUG_DICT) {
diff --git a/native/jni/src/words_priority_queue.h b/native/jni/src/words_priority_queue.h
index 1387267..7629251 100644
--- a/native/jni/src/words_priority_queue.h
+++ b/native/jni/src/words_priority_queue.h
@@ -112,13 +112,13 @@
if (size >= 2) {
SuggestedWord* nsMaxSw = 0;
unsigned int maxIndex = 0;
- double maxNs = 0;
+ float maxNs = 0;
for (unsigned int i = 0; i < size; ++i) {
SuggestedWord* tempSw = swBuffer[i];
if (!tempSw) {
continue;
}
- const double tempNs = getNormalizedScore(tempSw, before, beforeLength, 0, 0, 0);
+ const float tempNs = getNormalizedScore(tempSw, before, beforeLength, 0, 0, 0);
if (tempNs >= maxNs) {
maxNs = tempNs;
maxIndex = i;
@@ -172,7 +172,7 @@
DUMP_WORD(mHighestSuggestedWord->mWord, mHighestSuggestedWord->mWordLength);
}
- double getHighestNormalizedScore(const unsigned short* before, const int beforeLength,
+ float getHighestNormalizedScore(const unsigned short* before, const int beforeLength,
unsigned short** outWord, int *outScore, int *outLength) {
if (!mHighestSuggestedWord) {
return 0.0;
@@ -199,7 +199,7 @@
return 0;
}
- static double getNormalizedScore(SuggestedWord* sw, const unsigned short* before,
+ static float getNormalizedScore(SuggestedWord* sw, const unsigned short* before,
const int beforeLength, unsigned short** outWord, int *outScore, int *outLength) {
const int score = sw->mScore;
unsigned short* word = sw->mWord;