summaryrefslogtreecommitdiff
path: root/scaddins
diff options
context:
space:
mode:
authorBaiXiaochun <bai.xiaochun.mofan@protonmail.com>2021-06-30 18:12:08 +0200
committerEike Rathke <erack@redhat.com>2021-07-03 21:57:29 +0200
commit3128fd02c069765a4428022e84a324e991c69521 (patch)
tree77ae23473888cc8f547e9de1831ee5f41c2f7573 /scaddins
parente732bbacbf33a3d0c08fb96a18072e5b1ca46691 (diff)
Purge out when safe rtl::math ( isValidArcArg / sin / cos )
/** If a value is a valid argument for sin(), cos(), tan(). IEEE 754 specifies that absolute values up to 2^64 (=1.844e19) for the radian must be supported by trigonometric functions. Unfortunately, at least on x86 architectures, the FPU doesn't generate an error pattern for values >2^64 but produces erroneous results instead and sets only the "invalid operation" (IM) flag in the status word :-( Thus the application has to handle it itself. */ chart2/source/tools/RelativePositionHelper.cxx Function name: RelativePositionHelper::getCenterOfAnchoredObject From here: suppose it's related to the orientation of the chart << 2^64 chart2/source/view/main/LabelPositionHelper.cxx LabelPositionHelper::LabelPositionHelper Suppose: setup label position. There won't be angles grater than 360º. chart2/source/view/main/PlottingPositionHelper.cxx PolarPlottingPositionHelper::transformUnitCircleToScene Suppose: maybe disc chart orientation? Internal angle should be safe. chart2/source/view/main/ShapeFactory.cxx ShapeFactory::getSizeAfterRotation Suppose: rotate shape Internal angle should be safe. drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx Constant 100% safe sc/source/core/data/documen4.cxx bool ScDocument::Solver Suppose: the tangent is being used as numerical derivative (Regula falsi algorithm) So no impossible angles scaddins/source/analysis/bessel.cxx Filtered it out as bad imput Change-Id: Ib348cca6ce13263d087b6731f93f58d8a15cc725 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118193 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'scaddins')
-rw-r--r--scaddins/source/analysis/bessel.cxx10
1 files changed, 6 insertions, 4 deletions
diff --git a/scaddins/source/analysis/bessel.cxx b/scaddins/source/analysis/bessel.cxx
index bb6023a4f2f9..b356dc219e44 100644
--- a/scaddins/source/analysis/bessel.cxx
+++ b/scaddins/source/analysis/bessel.cxx
@@ -325,12 +325,13 @@ double BesselK( double fNum, sal_Int32 nOrder )
/// @throws NoConvergenceException
static double Bessely0( double fX )
{
- if (fX <= 0)
+ // If fX > 2^64 then sin and cos fail
+ if (fX <= 0 || !rtl::math::isValidArcArg(fX))
throw IllegalArgumentException();
const double fMaxIteration = 9000000.0; // should not be reached
if (fX > 5.0e+6) // iteration is not considerable better then approximation
return sqrt(1/f_PI/fX)
- *(rtl::math::sin(fX)-rtl::math::cos(fX));
+ *(std::sin(fX)-std::cos(fX));
const double epsilon = 1.0e-15;
const double EulerGamma = 0.57721566490153286060;
double alpha = log(fX/2.0)+EulerGamma;
@@ -378,12 +379,13 @@ static double Bessely0( double fX )
/// @throws NoConvergenceException
static double Bessely1( double fX )
{
- if (fX <= 0)
+ // If fX > 2^64 then sin and cos fail
+ if (fX <= 0 || !rtl::math::isValidArcArg(fX))
throw IllegalArgumentException();
const double fMaxIteration = 9000000.0; // should not be reached
if (fX > 5.0e+6) // iteration is not considerable better then approximation
return - sqrt(1/f_PI/fX)
- *(rtl::math::sin(fX)+rtl::math::cos(fX));
+ *(std::sin(fX)+std::cos(fX));
const double epsilon = 1.0e-15;
const double EulerGamma = 0.57721566490153286060;
double alpha = 1.0/fX;