mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[apps/regression] Virtualize only the specialized part of initCoefs
This commit is contained in:
@@ -40,14 +40,6 @@ void Model::fit(Store * store, int series, double * modelCoefficients, Poincare:
|
||||
}
|
||||
}
|
||||
|
||||
void Model::initCoefficientsForFit(double * modelCoefficients, double defaultValue, bool forceDefaultValue, Store * store, int series) const {
|
||||
assert(defaultValue || (store != nullptr && series >= 0 && series < Store::k_numberOfSeries && !store->seriesIsEmpty(series)));
|
||||
int nbCoef = numberOfCoefficients();
|
||||
for (int i = 0; i < nbCoef; i++) {
|
||||
modelCoefficients[i] = defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
bool Model::dataSuitableForFit(Store * store, int series) const {
|
||||
if (!store->seriesNumberOfAbscissaeGreaterOrEqualTo(series, numberOfCoefficients())) {
|
||||
return false;
|
||||
@@ -209,5 +201,20 @@ int Model::solveLinearSystem(double * solutions, double * coefficients, double *
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Model::initCoefficientsForFit(double * modelCoefficients, double defaultValue, bool forceDefaultValue, Store * store, int series) const {
|
||||
assert(forceDefaultValue || (store != nullptr && series >= 0 && series < Store::k_numberOfSeries && !store->seriesIsEmpty(series)));
|
||||
if (forceDefaultValue) {
|
||||
Model::specializedInitCoefficientsForFit(modelCoefficients, defaultValue);
|
||||
} else {
|
||||
specializedInitCoefficientsForFit(modelCoefficients, defaultValue, store, series);
|
||||
}
|
||||
}
|
||||
|
||||
void Model::specializedInitCoefficientsForFit(double * modelCoefficients, double defaultValue, Store * store, int series) const {
|
||||
const int nbCoef = numberOfCoefficients();
|
||||
for (int i = 0; i < nbCoef; i++) {
|
||||
modelCoefficients[i] = defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ public:
|
||||
virtual int bannerLinesCount() const { return 2; }
|
||||
protected:
|
||||
// Fit
|
||||
virtual void initCoefficientsForFit(double * modelCoefficients, double defaultValue, bool forceDefaultValue, Store * store = nullptr, int series = -1) const;
|
||||
virtual bool dataSuitableForFit(Store * store, int series) const;
|
||||
constexpr static const KDFont * k_layoutFont = KDFont::SmallFont;
|
||||
Poincare::Layout m_layout;
|
||||
@@ -62,6 +61,8 @@ private:
|
||||
double alphaCoefficient(Store * store, int series, double * modelCoefficients, int k, int l) const;
|
||||
double betaCoefficient(Store * store, int series, double * modelCoefficients, int k) const;
|
||||
int solveLinearSystem(double * solutions, double * coefficients, double * constants, int solutionDimension, Poincare::Context * context);
|
||||
void initCoefficientsForFit(double * modelCoefficients, double defaultValue, bool forceDefaultValue, Store * store = nullptr, int series = -1) const;
|
||||
virtual void specializedInitCoefficientsForFit(double * modelCoefficients, double defaultValue, Store * store = nullptr, int series = -1) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -70,11 +70,7 @@ double TrigonometricModel::partialDerivate(double * modelCoefficients, int deriv
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void TrigonometricModel::initCoefficientsForFit(double * modelCoefficients, double defaultValue, bool forceDefaultValue, Store * store, int series) const {
|
||||
if (forceDefaultValue) {
|
||||
Model::initCoefficientsForFit(modelCoefficients, defaultValue, forceDefaultValue);
|
||||
return;
|
||||
}
|
||||
void TrigonometricModel::specializedInitCoefficientsForFit(double * modelCoefficients, double defaultValue, Store * store, int series) const {
|
||||
assert(store != nullptr && series >= 0 && series < Store::k_numberOfSeries && !store->seriesIsEmpty(series));
|
||||
for (int i = 1; i < k_numberOfCoefficients - 1; i++) {
|
||||
modelCoefficients[i] = defaultValue;
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
int bannerLinesCount() const override { return 4; }
|
||||
private:
|
||||
static constexpr int k_numberOfCoefficients = 4;
|
||||
void initCoefficientsForFit(double * modelCoefficients, double defaultValue, bool forceDefaultValue, Store * store = nullptr, int series = -1) const override;
|
||||
void specializedInitCoefficientsForFit(double * modelCoefficients, double defaultValue, Store * store, int series) const override;
|
||||
Poincare::Expression expression(double * modelCoefficients) override;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user