diff --git a/components/tachart/languages/tachartstrconsts.de.po b/components/tachart/languages/tachartstrconsts.de.po index 2e417cc14c..483e0d9b92 100644 --- a/components/tachart/languages/tachartstrconsts.de.po +++ b/components/tachart/languages/tachartstrconsts.de.po @@ -215,6 +215,10 @@ msgstr "Die Anzahl der Fitparameter kann nicht kleiner als 1 sein." msgid "Expression result type must be integer or float. Got \"%s\"." msgstr "Der Typ des Ausdrucksergebnisses muss integer oder float sein, ist aber \"%s\"." +#: tachartstrconsts.rserrnumericaloverflow +msgid "Numerical overflow." +msgstr "" + #: tachartstrconsts.rsexpressioncolormapseries msgid "Math expression color map series" msgstr "Math. Funktion (farb-kodiert)" diff --git a/components/tachart/languages/tachartstrconsts.fi.po b/components/tachart/languages/tachartstrconsts.fi.po index 971cc2bb5a..6a5e0bcdfa 100644 --- a/components/tachart/languages/tachartstrconsts.fi.po +++ b/components/tachart/languages/tachartstrconsts.fi.po @@ -203,6 +203,10 @@ msgstr "" msgid "Expression result type must be integer or float. Got \"%s\"." msgstr "" +#: tachartstrconsts.rserrnumericaloverflow +msgid "Numerical overflow." +msgstr "" + #: tachartstrconsts.rsexpressioncolormapseries msgid "Math expression color map series" msgstr "" diff --git a/components/tachart/languages/tachartstrconsts.fr.po b/components/tachart/languages/tachartstrconsts.fr.po index b056405a51..b39d566582 100644 --- a/components/tachart/languages/tachartstrconsts.fr.po +++ b/components/tachart/languages/tachartstrconsts.fr.po @@ -213,6 +213,10 @@ msgstr "Le nombre de paramètres appropriés ne peut pas être inférieur à 1." msgid "Expression result type must be integer or float. Got \"%s\"." msgstr "Le type de résultat d'expression doit être entier ou flottant. On a obtenu \"%s\"." +#: tachartstrconsts.rserrnumericaloverflow +msgid "Numerical overflow." +msgstr "" + #: tachartstrconsts.rsexpressioncolormapseries msgid "Math expression color map series" msgstr "Séries de cartes de couleurs d'expressions mathématiques" diff --git a/components/tachart/languages/tachartstrconsts.hu.po b/components/tachart/languages/tachartstrconsts.hu.po index f266ccc13a..acfd1b5bd8 100644 --- a/components/tachart/languages/tachartstrconsts.hu.po +++ b/components/tachart/languages/tachartstrconsts.hu.po @@ -213,6 +213,10 @@ msgstr "" msgid "Expression result type must be integer or float. Got \"%s\"." msgstr "A kifejezés típusának egész vagy lebegőpontos számnak kell lennie. Most \"%s\"." +#: tachartstrconsts.rserrnumericaloverflow +msgid "Numerical overflow." +msgstr "" + #: tachartstrconsts.rsexpressioncolormapseries msgid "Math expression color map series" msgstr "Színtérkép matematikai kifejezés alapján" diff --git a/components/tachart/languages/tachartstrconsts.lt.po b/components/tachart/languages/tachartstrconsts.lt.po index 3d7b11433e..5ba2e56507 100644 --- a/components/tachart/languages/tachartstrconsts.lt.po +++ b/components/tachart/languages/tachartstrconsts.lt.po @@ -214,6 +214,10 @@ msgstr "" msgid "Expression result type must be integer or float. Got \"%s\"." msgstr "" +#: tachartstrconsts.rserrnumericaloverflow +msgid "Numerical overflow." +msgstr "" + #: tachartstrconsts.rsexpressioncolormapseries msgid "Math expression color map series" msgstr "" diff --git a/components/tachart/languages/tachartstrconsts.pl.po b/components/tachart/languages/tachartstrconsts.pl.po index ec92c22868..aae2fe30f2 100644 --- a/components/tachart/languages/tachartstrconsts.pl.po +++ b/components/tachart/languages/tachartstrconsts.pl.po @@ -213,6 +213,10 @@ msgstr "" msgid "Expression result type must be integer or float. Got \"%s\"." msgstr "" +#: tachartstrconsts.rserrnumericaloverflow +msgid "Numerical overflow." +msgstr "" + #: tachartstrconsts.rsexpressioncolormapseries msgid "Math expression color map series" msgstr "" diff --git a/components/tachart/languages/tachartstrconsts.pot b/components/tachart/languages/tachartstrconsts.pot index 3f02045edf..9b98134a6a 100644 --- a/components/tachart/languages/tachartstrconsts.pot +++ b/components/tachart/languages/tachartstrconsts.pot @@ -203,6 +203,10 @@ msgstr "" msgid "Expression result type must be integer or float. Got \"%s\"." msgstr "" +#: tachartstrconsts.rserrnumericaloverflow +msgid "Numerical overflow." +msgstr "" + #: tachartstrconsts.rsexpressioncolormapseries msgid "Math expression color map series" msgstr "" diff --git a/components/tachart/languages/tachartstrconsts.pt_BR.po b/components/tachart/languages/tachartstrconsts.pt_BR.po index e7d857227d..ab81cd704f 100644 --- a/components/tachart/languages/tachartstrconsts.pt_BR.po +++ b/components/tachart/languages/tachartstrconsts.pt_BR.po @@ -213,6 +213,10 @@ msgstr "O número de parâmetros à preencher não pode ser menor que 1." msgid "Expression result type must be integer or float. Got \"%s\"." msgstr "Tipo de resultado da expressão deve ser inteiro ou flutuante. Obtido \"%s\"." +#: tachartstrconsts.rserrnumericaloverflow +msgid "Numerical overflow." +msgstr "" + #: tachartstrconsts.rsexpressioncolormapseries msgid "Math expression color map series" msgstr "Série Mapa de cor de expressão matemática" diff --git a/components/tachart/languages/tachartstrconsts.ru.po b/components/tachart/languages/tachartstrconsts.ru.po index 9f8f774b42..23bed15697 100644 --- a/components/tachart/languages/tachartstrconsts.ru.po +++ b/components/tachart/languages/tachartstrconsts.ru.po @@ -213,6 +213,10 @@ msgstr "Независимых переменных не может быть м msgid "Expression result type must be integer or float. Got \"%s\"." msgstr "Тип результата выражения должен быть целым либо вещественным, но сейчас является \"%s\"." +#: tachartstrconsts.rserrnumericaloverflow +msgid "Numerical overflow." +msgstr "" + #: tachartstrconsts.rsexpressioncolormapseries msgid "Math expression color map series" msgstr "Диаграмма с картой цветов по математическому выражению" diff --git a/components/tachart/languages/tachartstrconsts.se.po b/components/tachart/languages/tachartstrconsts.se.po index fe2478c19c..1292975487 100644 --- a/components/tachart/languages/tachartstrconsts.se.po +++ b/components/tachart/languages/tachartstrconsts.se.po @@ -216,6 +216,10 @@ msgstr "" msgid "Expression result type must be integer or float. Got \"%s\"." msgstr "" +#: tachartstrconsts.rserrnumericaloverflow +msgid "Numerical overflow." +msgstr "" + #: tachartstrconsts.rsexpressioncolormapseries msgid "Math expression color map series" msgstr "" diff --git a/components/tachart/languages/tachartstrconsts.uk.po b/components/tachart/languages/tachartstrconsts.uk.po index a92ab908a5..24f04a6b96 100644 --- a/components/tachart/languages/tachartstrconsts.uk.po +++ b/components/tachart/languages/tachartstrconsts.uk.po @@ -216,6 +216,10 @@ msgstr "Число параметрів апроксимації не може msgid "Expression result type must be integer or float. Got \"%s\"." msgstr "Тип значення виразу повинен бути цілим або дійсним. Отримано \"%s\"." +#: tachartstrconsts.rserrnumericaloverflow +msgid "Numerical overflow." +msgstr "" + #: tachartstrconsts.rsexpressioncolormapseries msgid "Math expression color map series" msgstr "Колірна карта" diff --git a/components/tachart/languages/tachartstrconsts.zh_CN.po b/components/tachart/languages/tachartstrconsts.zh_CN.po index 77e9e6374d..210a7adfcc 100644 --- a/components/tachart/languages/tachartstrconsts.zh_CN.po +++ b/components/tachart/languages/tachartstrconsts.zh_CN.po @@ -214,6 +214,10 @@ msgstr "" msgid "Expression result type must be integer or float. Got \"%s\"." msgstr "表达式结果类型必须是整型(integer)或浮点型(float).得到\"%s\"." +#: tachartstrconsts.rserrnumericaloverflow +msgid "Numerical overflow." +msgstr "" + #: tachartstrconsts.rsexpressioncolormapseries msgid "Math expression color map series" msgstr "数学表达式彩色图系列" diff --git a/components/tachart/tachartstrconsts.pas b/components/tachart/tachartstrconsts.pas index 423405070f..8be98c2a17 100644 --- a/components/tachart/tachartstrconsts.pas +++ b/components/tachart/tachartstrconsts.pas @@ -148,6 +148,7 @@ resourcestring rsErrFitNoFitParams = 'No fit parameters specified.'; rsErrFitSingular = 'Fitting matrix is (nearly) singular.'; rsErrFitNoBaseFunctions = 'Not enough user-provided base functions.'; + rsErrNumericalOverflow = 'Numerical overflow.'; rsFitNumObservations = 'Number of observations'; rsFitNumFitParams = 'Number of fit parameters'; rsFitDegreesOfFreedom = 'Degrees of freedom'; diff --git a/components/tachart/tafitlib.pas b/components/tachart/tafitlib.pas index 918227d314..f89c4b79ba 100644 --- a/components/tachart/tafitlib.pas +++ b/components/tachart/tafitlib.pas @@ -35,7 +35,8 @@ type fitMoreParamsThanValues, // There are more fitting parameters than data values fitNoFitParams, // No fit parameters specified fitSingular, // Matrix is (nearly) singular - fitNoBaseFunctions // No user-provided base functions + fitNoBaseFunctions, // No user-provided base functions + fitOverflow // Numerical overflow ); TFitResults = record @@ -201,9 +202,6 @@ end; - Numerical Recipes, Ch 14, Modelling of data, General linear least squares } function LinearFit(const x, y, dy: TArbFloatArray; FitParams: TFitParamArray): TFitResults; -const - TOO_LARGE = 1E100; - TOO_SMALL = 1.0 / TOO_LARGE; var alpha: TArbFloatArray = nil; beta: TArbFloatArray = nil; @@ -297,11 +295,6 @@ begin kj := k * mfit + j; jk := j * mfit + k; alpha[kj] := alpha[jk]; - if not InRange(abs(alpha[kj]), TOO_SMALL, TOO_LARGE) then - begin - Result.ErrCode := fitSingular; - exit; - end; end; // Solve equation system diff --git a/components/tachart/tafuncseries.pas b/components/tachart/tafuncseries.pas index 68954b5551..aa9418a91a 100644 --- a/components/tachart/tafuncseries.pas +++ b/components/tachart/tafuncseries.pas @@ -1821,6 +1821,7 @@ begin fitNoFitParams : Result := rsErrFitNoFitParams; fitSingular : Result := rsErrFitSingular; fitNoBaseFunctions : Result := rsErrFitNoBaseFunctions; + fitOverflow : Result := rsErrNumericalOverflow; else raise EChartError.CreateFmt('[%s.ErrorMsg] No message text assigned to error code #%d.', [NameOrClassName(self), ord(ErrCode)]); @@ -1885,25 +1886,30 @@ var end; // Execute the polynomial fit; the degree of the polynomial is np - 1. - fitRes := LinearFit(xv, yv, dy, FFitParams); - FErrCode := fitRes.ErrCode; - if fitRes.ErrCode <> fitOK then - exit; + try + fitRes := LinearFit(xv, yv, dy, FFitParams); - // Store values of fit parameters. - // Note: In case of exponential and power fit equations, the first fitted - // parameter is the logarithm of the "real" parameter. It needs to be - // transformed back to real units by exp function. This is done by the - // getter of the property - for i:= 0 to High(FFitParams) do - FFitParams[i].Value := fitRes.ParamValues[i]; + FErrCode := fitRes.ErrCode; + if fitRes.ErrCode <> fitOK then + exit; - // Analysis of variance, variance-covariance matrix - FFitStatistics.Free; - FFitStatistics := TFitStatistics.Create(fitRes, 1 - FConfidenceLevel); + // Store values of fit parameters. + // Note: In case of exponential and power fit equations, the first fitted + // parameter is the logarithm of the "real" parameter. It needs to be + // transformed back to real units by exp function. This is done by the + // getter of the property + for i:= 0 to High(FFitParams) do + FFitParams[i].Value := fitRes.ParamValues[i]; - // State of the fit - FState := fpsValid; + // Analysis of variance, variance-covariance matrix + FFitStatistics.Free; + FFitStatistics := TFitStatistics.Create(fitRes, 1 - FConfidenceLevel); + + // State of the fit + FState := fpsValid; + except + FErrCode := fitOverflow; + end; end; begin