[apps/reg] Prevent fitting when data not suitable

This commit is contained in:
Léa Saviot
2018-06-08 16:48:59 +02:00
committed by Émilie Feral
parent 4b8462ed8a
commit a8b2183afa
8 changed files with 51 additions and 18 deletions

View File

@@ -1,4 +1,5 @@
#include "power_model.h"
#include "../store.h"
#include <math.h>
#include <assert.h>
#include "../../poincare/include/poincare_layouts.h"
@@ -66,4 +67,18 @@ double PowerModel::partialDerivate(double * modelCoefficients, int derivateCoeff
return 0.0;
}
bool PowerModel::dataSuitableForFit(Store * store, int series) const {
if (!Model::dataSuitableForFit(store, series)) {
return false;
}
int numberOfPairs = store->numberOfPairsOfSeries(series);
for (int j = 0; j < numberOfPairs; j++) {
if (store->get(series, 0, j) < 0) {
return false;
}
}
return true;
}
}