https://bugs.documentfoundation.org/show_bug.cgi?id=157794

Eike Rathke <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Keywords|                            |difficultyMedium, easyHack,
                   |                            |skillCpp

--- Comment #3 from Eike Rathke <[email protected]> ---
I think this may call for a rewrite of the sca::analysis::Complex::* functions
using the meanwhile available C++ std::complex type and its functions. In this
case, in Complex::Power()
https://opengrok.libreoffice.org/xref/core/scaddins/source/analysis/analysishelper.cxx?r=31486f92#1696
the Complex::Abs() (implemented by std::hypot(r,i)) with r=0.99999993365635909
and i=-5.6971371894503506e-09 returns p=0.99999993365635909 and phi=acos(r/p)
then correctly returns phi=0 that with i=sin(phi)*p obviously leads to no
imaginary part.

While the theory behind the implementation is correct, numeric cancellation of
smallest numbers seems to come into effect here. Let's hope the ::std
implementation does better, here
std::complex<double> std::pow( const std::complex<double>& x, const double& y )

To be investigated and verified. The results at least shouldn't be worse..

Then similar in Complex::Abs() use
double std::abs( const complex<double>& z )
and so on.

Flagging as EasyHack.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to