diff options
author | Winfried Donkers <winfrieddonkers@libreoffice.org> | 2016-09-15 13:39:35 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2016-10-15 00:57:34 +0000 |
commit | aaa38fd34faab3108245f8fa8c13642919ff0c95 (patch) | |
tree | 0bfc78127c7cd5a1ada53a716c1fc72ce699cd59 | |
parent | f617d9466632f656811474cd49311e13ab950753 (diff) |
tdf#94635 follow up; handle linear data properly when samples in period
are to be calculated by function.
Applies to all FORECAST.ETS functions with argument period_length having
value 1.
Reviewed-on: https://gerrit.libreoffice.org/28923
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
(cherry picked from commit fb790880eb11552b2e7d1dcf6c09d2663712290f)
Minus the modification to the function test case that does not exist in 5-2.
Change-Id: Icb5a0288670321caf0dd5b70bee4b8811b9ba4a9
Reviewed-on: https://gerrit.libreoffice.org/29891
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r-- | sc/source/core/tool/interpr8.cxx | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx index 7a02955df4ea..a31b061970ce 100644 --- a/sc/source/core/tool/interpr8.cxx +++ b/sc/source/core/tool/interpr8.cxx @@ -195,11 +195,6 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co } } - if ( rSmplInPrd != 1 ) - mnSmplInPrd = rSmplInPrd; - else - mnSmplInPrd = CalcPeriodLen(); - // Month intervals don't have exact stepsize, so first // detect if month interval is used. // Method: assume there is an month interval and verify. @@ -378,6 +373,16 @@ bool ScETSForecastCalculation::PreprocessDataRange( const ScMatrixRef& rMatX, co } } } + + if ( rSmplInPrd != 1 ) + mnSmplInPrd = rSmplInPrd; + else + { + mnSmplInPrd = CalcPeriodLen(); + if ( mnSmplInPrd == 1 ) + bEDS = true; // period length 1 means no periodic data: EDS suffices + } + if ( !initData() ) return false; // note: mnErrorValue is set in called function(s) @@ -536,7 +541,7 @@ SCSIZE ScETSForecastCalculation::CalcPeriodLen() SCSIZE nBestVal = mnCount; double fBestME = ::std::numeric_limits<double>::max(); - for ( SCSIZE nPeriodLen = mnCount / 2; nPeriodLen > 1; nPeriodLen-- ) + for ( SCSIZE nPeriodLen = mnCount / 2; nPeriodLen >= 1; nPeriodLen-- ) { double fMeanError = 0.0; SCSIZE nPeriods = mnCount / nPeriodLen; @@ -548,7 +553,7 @@ SCSIZE ScETSForecastCalculation::CalcPeriodLen() } fMeanError /= static_cast< double >( ( nPeriods - 1 ) * nPeriodLen - 1 ); - if ( fMeanError < fBestME || fMeanError == 0.0 ) + if ( fMeanError <= fBestME || fMeanError == 0.0 ) { nBestVal = nPeriodLen; fBestME = fMeanError; |