Commit 486097bf authored by James Frink's avatar James Frink
Browse files

Working with android NDK

parent 349e7c3e
......@@ -18,6 +18,25 @@
#include "../dependencies/json/json.h"
#endif
#ifdef __ANDROID__
#include <ostream>
namespace std
{ // Workaround for android
template <typename T>
std::string to_string(T Value)
{
std::ostringstream TempStream;
TempStream << Value;
return TempStream.str();
}
inline long double strtold(const char * str, char ** str_end)
{
return strtod(str, str_end);
}
}
#endif
/** Base class for wekinator models. Implemented by NN and KNN classes */
template<typename T>
class baseModel {
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -10,6 +10,7 @@
#include <vector>
#include <cmath>
#include <cassert>
#include <limits>
#include "dtw.h"
template<typename T>
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -6,7 +6,7 @@
// Copyright © 2016 Goldsmiths. All rights reserved.
//
#include <cmath>
#include <math.h>
#include <utility>
#include <map>
#include <vector>
......@@ -128,7 +128,7 @@ T knnClassification<T>::run(const std::vector<T> &inputVector) {
std::map<int, int> classVoteMap;
typedef std::pair<int, int> classVotePair;
for (int i = 0; i < currentK; ++i){
int classNum = (int) std::round(neighbours[nearestNeighbours[i].first].output[0]);
int classNum = (int) round(neighbours[nearestNeighbours[i].first].output[0]);
if ( classVoteMap.find(classNum) == classVoteMap.end() ) {
classVoteMap.insert(classVotePair(classNum, 1));
} else {
......
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
......@@ -6,6 +6,7 @@
* @copyright Copyright © 2017 Goldsmiths. All rights reserved.
*/
#include <limits>
#include "searchWindow.h"
template<typename T>
......
File mode changed from 100644 to 100755
......@@ -9,6 +9,8 @@
#include <vector>
#include <cassert>
#include <limits>
#include <algorithm>
#include "seriesClassification.h"
#ifdef EMSCRIPTEN
#include "emscripten/seriesClassificationEmbindings.h"
......@@ -83,7 +85,7 @@ std::string seriesClassificationTemplate<T>::run(const std::vector<std::vector<T
allCosts.clear();
T lowestCost = fastDTW<T>::getCost(inputSeries, allTrainingSeries[0].input, SEARCH_RADIUS);
allCosts.push_back(lowestCost);
for (int i = 1; i < allTrainingSeries.size(); ++i) {
T currentCost = fastDTW<T>::getCost(inputSeries, allTrainingSeries[i].input, SEARCH_RADIUS);
allCosts.push_back(currentCost);
......@@ -163,7 +165,8 @@ int seriesClassificationTemplate<T>::getMaxLength(std::string label) const {
}
template<typename T>
seriesClassificationTemplate<T>::minMax<T> seriesClassificationTemplate<T>::calculateCosts(std::string label) const {
typename
seriesClassificationTemplate<T>::template minMax<T> seriesClassificationTemplate<T>::calculateCosts(std::string label) const {
minMax<T> calculatedMinMax;
bool foundSeries = false;
std::vector<T> labelCosts;
......@@ -188,7 +191,7 @@ seriesClassificationTemplate<T>::minMax<T> seriesClassificationTemplate<T>::calc
}
template<typename T>
seriesClassificationTemplate<T>::minMax<T> seriesClassificationTemplate<T>::calculateCosts(std::string label1, std::string label2) const {
typename seriesClassificationTemplate<T>::template minMax<T> seriesClassificationTemplate<T>::calculateCosts(std::string label1, std::string label2) const {
minMax<T> calculatedMinMax;
bool foundSeries = false;
std::vector<T> labelCosts;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment