summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBaiXiaochun <bai.xiaochun.mofan@protonmail.com>2021-06-29 21:06:12 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2021-07-02 07:53:02 +0200
commit557d7a8bdad148501c491a060da74a6214284ca4 (patch)
tree5413a35b51169c6f3b62ef82c3b4b15465aacd6d
parentFix code style for primitive2dxmldump.cxx (diff)
downloadcore-557d7a8bdad148501c491a060da74a6214284ca4.tar.gz
core-557d7a8bdad148501c491a060da74a6214284ca4.zip
Purge rtl::math:: ( erf / erfc / expm1 )
Change-Id: Id0e0dce5f9a3bf0bb9ddc73e3aeaa8faf683ad2a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118134 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r--sc/source/core/tool/interpr2.cxx4
-rw-r--r--sc/source/core/tool/interpr3.cxx6
-rw-r--r--sc/source/core/tool/interpr7.cxx10
-rw-r--r--scaddins/source/analysis/analysishelper.cxx6
-rw-r--r--scaddins/source/pricing/black_scholes.cxx3
5 files changed, 10 insertions, 19 deletions
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 632b04643a28..f4d906a7d8c1 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -1896,10 +1896,10 @@ double ScInterpreter::ScGetPMT(double fRate, double fNper, double fPv,
{
if (bPayInAdvance) // payment in advance
fPayment = (fFv + fPv * exp( fNper * ::rtl::math::log1p(fRate) ) ) * fRate /
- (::rtl::math::expm1( (fNper + 1) * ::rtl::math::log1p(fRate) ) - fRate);
+ (std::expm1( (fNper + 1) * ::rtl::math::log1p(fRate) ) - fRate);
else // payment in arrear
fPayment = (fFv + fPv * exp(fNper * ::rtl::math::log1p(fRate) ) ) * fRate /
- ::rtl::math::expm1( fNper * ::rtl::math::log1p(fRate) );
+ std::expm1( fNper * ::rtl::math::log1p(fRate) );
}
return -fPayment;
}
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 9f5812a787a1..c2c91f621bfd 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -200,7 +200,7 @@ double ScInterpreter::phi(double x)
double ScInterpreter::integralPhi(double x)
{ // Using gauss(x)+0.5 has severe cancellation errors for x<-4
- return 0.5 * ::rtl::math::erfc(-x * 0.7071067811865475); // * 1/sqrt(2)
+ return 0.5 * std::erfc(-x * 0.7071067811865475); // * 1/sqrt(2)
}
double ScInterpreter::taylor(const double* pPolynom, sal_uInt16 nMax, double x)
@@ -875,7 +875,7 @@ double ScInterpreter::GetBetaDistPDF(double fX, double fA, double fB)
return HUGE_VAL;
}
if (fX <= 0.01)
- return fB + fB * ::rtl::math::expm1((fB-1.0) * ::rtl::math::log1p(-fX));
+ return fB + fB * std::expm1((fB-1.0) * ::rtl::math::log1p(-fX));
else
return fB * pow(0.5-fX+0.5,fB-1.0);
}
@@ -994,7 +994,7 @@ double ScInterpreter::GetBetaDist(double fXin, double fAlpha, double fBeta)
return pow(fXin, fAlpha);
if (fAlpha == 1.0)
// 1.0 - pow(1.0-fX,fBeta) is not accurate enough
- return -::rtl::math::expm1(fBeta * ::rtl::math::log1p(-fXin));
+ return -std::expm1(fBeta * ::rtl::math::log1p(-fXin));
//FIXME: need special algorithm for fX near fP for large fA,fB
double fResult;
// I use always continued fraction, power series are neither
diff --git a/sc/source/core/tool/interpr7.cxx b/sc/source/core/tool/interpr7.cxx
index d50a084acb75..7b2a7a7a563a 100644
--- a/sc/source/core/tool/interpr7.cxx
+++ b/sc/source/core/tool/interpr7.cxx
@@ -497,20 +497,14 @@ void ScInterpreter::ScErf()
{
sal_uInt8 nParamCount = GetByte();
if (MustHaveParamCount( nParamCount, 1 ) )
- {
- double x = GetDouble();
- PushDouble( ::rtl::math::erf( x ) );
- }
+ PushDouble( std::erf( GetDouble() ) );
}
void ScInterpreter::ScErfc()
{
sal_uInt8 nParamCount = GetByte();
if (MustHaveParamCount( nParamCount, 1 ) )
- {
- double x = GetDouble();
- PushDouble( ::rtl::math::erfc( x ) );
- }
+ PushDouble( std::erfc( GetDouble() ) );
}
void ScInterpreter::ScColor()
diff --git a/scaddins/source/analysis/analysishelper.cxx b/scaddins/source/analysis/analysishelper.cxx
index fd4de83c3ce2..405fdae9e5e6 100644
--- a/scaddins/source/analysis/analysishelper.cxx
+++ b/scaddins/source/analysis/analysishelper.cxx
@@ -732,16 +732,14 @@ OUString ConvertFromDec( double fNum, double fMin, double fMax, sal_uInt16 nBase
return aRet;
}
-// implementation moved to module sal, see #i97091#
double Erf( double x )
{
- return ::rtl::math::erf(x);
+ return std::erf(x);
}
-// implementation moved to module sal, see #i97091#
double Erfc( double x )
{
- return ::rtl::math::erfc(x);
+ return std::erfc(x);
}
static bool IsNum( sal_Unicode c )
diff --git a/scaddins/source/pricing/black_scholes.cxx b/scaddins/source/pricing/black_scholes.cxx
index 57344d85cbec..88bdfc999b35 100644
--- a/scaddins/source/pricing/black_scholes.cxx
+++ b/scaddins/source/pricing/black_scholes.cxx
@@ -93,8 +93,7 @@ static double dnorm(double x) {
}
// cumulative normal distribution (see also ScInterpreter::integralPhi)
static double pnorm(double x) {
- //return 0.5*(erf(sqrt(0.5)*x)+1.0); // windows may not have erf
- return 0.5 * ::rtl::math::erfc(-x * 0.7071067811865475);
+ return 0.5 * std::erfc(-x * 0.7071067811865475);
}
// binary option cash (domestic)