Page 1 of 1

Error in CurvFitt.pas

Posted: Mon Oct 27, 2008 10:08 am
by 10545590
Hi !

Some of our user reported an error in CurvFitt.pas.

Function TCustomTrendFunction.Coefficient
.....
tmpDenominator:=Sqrt( (SumX2 - SumX*SumX/ICount) * (SumY2 - SumY*SumY/ICount) );

I checked this code and figured out that in a usercase the result of
(SumX2 - SumX*SumX/ICount) * (SumY2 - SumY*SumY/ICount)
is -6,4670491184e-12

And if you use sqrt then you will get something like this:
Ungültige Fließkommaausführung bei 004037AA
(EInvalidOp)

How can we correct this problem?

btw. We use still version 8.02

Greetz Dominik

Posted: Mon Oct 27, 2008 12:46 pm
by narcis
Hi Dominik,

I'm not able to reproduce the problem here using v8.04. Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.

Posted: Tue Nov 25, 2008 12:10 pm
by 10545590
Hi Narcis,

Sorry it takes a little time but now I´ve created a demo for you.
Received Problem - CurveFitt.zip Content Type application/x-zip-compressed Length 49041
I hope you can give us a fix!

Posted: Tue Nov 25, 2008 12:44 pm
by narcis
Hi Dominik,

Thanks for the example project. I could reproduce the issue here (TV52013602) and found that modifying Coefficient method as shown below solves the issue. If there's no problem with this fix it will be included in next maintenance release.

Code: Select all

Function TCustomTrendFunction.Coefficient(Source:TChartSeries; FirstIndex,LastIndex:Integer):Double;
var tmpNumerator   : Double;
    tmpDenominator : Double;
begin
  if CalculateValues(Source,FirstIndex,LastIndex) then
  begin
    tmpNumerator:=SumXY - SumX*SumY/ICount;
    tmpDenominator:=Sqrt(Abs( (SumX2 - SumX*SumX/ICount) * (SumY2 - SumY*SumY/ICount) ));
    if tmpDenominator=0 then
       result:=1
    else
       result:=tmpNumerator/tmpDenominator;
  end
  else result:=1;
end;

Posted: Tue Nov 25, 2008 12:52 pm
by 10545590
Thx Narcis,

it works here, too.

Now I can integrate it in the update of our software :)

Re: Error in CurvFitt.pas

Posted: Tue Sep 22, 2009 12:59 pm
by 10545590
Hi Narcis,
If there's no problem with this fix it will be included in next maintenance release
So far there is no problem.

When will this fix be integrated into a release?
8.06 has still the same problem !

Greetz Dominik

Re: Error in CurvFitt.pas

Posted: Tue Sep 22, 2009 1:50 pm
by narcis
Hi Dominik,

This is pending of further investigation but we think your suggestion is not the best solution here as may produce wrong results for the function.

Re: Error in CurvFitt.pas

Posted: Fri Sep 25, 2009 3:32 am
by 10545590
Hi Narcis,
but we think your suggestion is not the best solution
Sorry I´m a little bit confused ... :?: That was your solution - not mine !!

When will there be a fix in an official release ?

Re: Error in CurvFitt.pas

Posted: Fri Sep 25, 2009 7:27 am
by narcis
Hi moelski,

Yes, it was a solution for not throwing the error but not sure about giving correct results. We'll need to investigate it further to come to a definitive solution.