mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-24 16:20:49 +01:00
[apps/reg] Prevent fitting when data not suitable
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "logarithmic_model.h"
|
||||
#include "../store.h"
|
||||
#include <math.h>
|
||||
#include <poincare/layout_engine.h>
|
||||
#include <assert.h>
|
||||
@@ -35,6 +36,7 @@ double LogarithmicModel::levelSet(double * modelCoefficients, double y) const {
|
||||
double LogarithmicModel::partialDerivate(double * modelCoefficients, int derivateCoefficientIndex, double x) const {
|
||||
if (derivateCoefficientIndex == 0) {
|
||||
// Derivate: ln(x)
|
||||
assert(x >0);
|
||||
return log(x);
|
||||
}
|
||||
if (derivateCoefficientIndex == 1) {
|
||||
@@ -45,4 +47,17 @@ double LogarithmicModel::partialDerivate(double * modelCoefficients, int derivat
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
bool LogarithmicModel::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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user