Error in CurvFitt.pas

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
moelski
Newbie
Newbie
Posts: 92
Joined: Tue Jun 19, 2007 12:00 am
Contact:

Error in CurvFitt.pas

Post by moelski » Mon Oct 27, 2008 10:08 am

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Oct 27, 2008 12:46 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

moelski
Newbie
Newbie
Posts: 92
Joined: Tue Jun 19, 2007 12:00 am
Contact:

Post by moelski » Tue Nov 25, 2008 12:10 pm

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!

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Nov 25, 2008 12:44 pm

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;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

moelski
Newbie
Newbie
Posts: 92
Joined: Tue Jun 19, 2007 12:00 am
Contact:

Post by moelski » Tue Nov 25, 2008 12:52 pm

Thx Narcis,

it works here, too.

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

moelski
Newbie
Newbie
Posts: 92
Joined: Tue Jun 19, 2007 12:00 am
Contact:

Re: Error in CurvFitt.pas

Post by moelski » Tue Sep 22, 2009 12:59 pm

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

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Error in CurvFitt.pas

Post by Narcís » Tue Sep 22, 2009 1:50 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

moelski
Newbie
Newbie
Posts: 92
Joined: Tue Jun 19, 2007 12:00 am
Contact:

Re: Error in CurvFitt.pas

Post by moelski » Fri Sep 25, 2009 3:32 am

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 ?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Error in CurvFitt.pas

Post by Narcís » Fri Sep 25, 2009 7:27 am

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply