summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiu Hao <ianahao331@gmail.com>2022-08-15 18:07:07 +0800
committerEike Rathke <erack@redhat.com>2022-08-19 17:23:59 +0200
commit466f86abb7208e853ad48ae46e97a2455667fa42 (patch)
treee665c0711d1676f61331c16d323e5153a5fa4eee
parent6e97fcf162b8495f0584f0bb67d020b3f3754780 (diff)
tdf#148430 Use std math functions instead of rtl::math
Change-Id: I6bcb33d51c3974d0e8905e1ffeac556a99870aab Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138294 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
-rw-r--r--extensions/source/scanner/grid.cxx2
-rw-r--r--sal/qa/rtl/math/test-rtl-math.cxx58
-rw-r--r--sc/source/core/tool/interpr2.cxx14
-rw-r--r--sc/source/core/tool/interpr3.cxx20
-rw-r--r--sc/source/ui/dataprovider/datatransformation.cxx2
5 files changed, 48 insertions, 48 deletions
diff --git a/extensions/source/scanner/grid.cxx b/extensions/source/scanner/grid.cxx
index 110779c55080..c727c8c92a5a 100644
--- a/extensions/source/scanner/grid.cxx
+++ b/extensions/source/scanner/grid.cxx
@@ -648,7 +648,7 @@ void GridWindow::ChangeMode(ResetType nType)
{
for( int i = 0; i < m_nValues; i++ )
{
- m_pNewYValues[ i ] = m_fMinY + (m_fMaxY-m_fMinY)*(rtl::math::expm1((m_pXValues[i]-m_fMinX)/(m_fMaxX-m_fMinX)))/(M_E-1.0);
+ m_pNewYValues[ i ] = m_fMinY + (m_fMaxY-m_fMinY)*(std::expm1((m_pXValues[i]-m_fMinX)/(m_fMaxX-m_fMinX)))/(M_E-1.0);
}
}
break;
diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx
index ee4ae55a1a4b..69a54bd814ef 100644
--- a/sal/qa/rtl/math/test-rtl-math.cxx
+++ b/sal/qa/rtl/math/test-rtl-math.cxx
@@ -505,84 +505,84 @@ public:
void test_erf() {
double x, res;
x = 0.0;
- res = rtl::math::erf(x);
+ res = std::erf(x);
CPPUNIT_ASSERT_EQUAL(0.0,res);
rtl::math::setInf( &x, false);
- res = rtl::math::erf(x);
+ res = std::erf(x);
CPPUNIT_ASSERT_EQUAL(1.0,res);
rtl::math::setInf( &x, true);
- res = rtl::math::erf(x);
+ res = std::erf(x);
CPPUNIT_ASSERT_EQUAL(-1.0,res);
rtl::math::setNan( &x);
- res = rtl::math::erf(x);
+ res = std::erf(x);
CPPUNIT_ASSERT(std::isnan(res));
x = 3.0;
- res = rtl::math::erf(-x);
- CPPUNIT_ASSERT_DOUBLES_EQUAL( -rtl::math::erf(x), res, 1E-12);
+ res = std::erf(-x);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( -std::erf(x), res, 1E-12);
}
void test_erfc() {
double x, res;
x = 0.0;
- res = rtl::math::erfc(x);
+ res = std::erfc(x);
CPPUNIT_ASSERT_EQUAL(1.0,res);
rtl::math::setInf( &x, false);
- res = rtl::math::erfc(x);
+ res = std::erfc(x);
CPPUNIT_ASSERT_EQUAL(0.0,res);
rtl::math::setInf( &x, true);
- res = rtl::math::erfc(x);
+ res = std::erfc(x);
CPPUNIT_ASSERT_EQUAL(2.0,res);
rtl::math::setNan( &x);
- res = rtl::math::erfc(x);
+ res = std::erfc(x);
CPPUNIT_ASSERT(std::isnan(res));
x = 3.0;
- res = rtl::math::erfc(-x);
- CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.0 - rtl::math::erfc(x), res, 1E-12);
+ res = std::erfc(-x);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.0 - std::erfc(x), res, 1E-12);
}
void test_expm1() {
double x, res;
x = 0.0;
- res = rtl::math::expm1(x);
+ res = std::expm1(x);
CPPUNIT_ASSERT_EQUAL(0.0,res);
x = -0.0;
- res = rtl::math::expm1(x);
+ res = std::expm1(x);
CPPUNIT_ASSERT_EQUAL(-0.0,res);
CPPUNIT_ASSERT(std::signbit(res));
rtl::math::setInf( &x, false);
- res = rtl::math::expm1(x);
+ res = std::expm1(x);
CPPUNIT_ASSERT_EQUAL(true, std::isinf(res) && !std::signbit(res));
rtl::math::setInf( &x, true);
- res = rtl::math::expm1(x);
+ res = std::expm1(x);
CPPUNIT_ASSERT_EQUAL(-1.0,res);
rtl::math::setNan( &x);
- res = rtl::math::expm1(x);
+ res = std::expm1(x);
CPPUNIT_ASSERT(std::isnan(res));
}
void test_log1p() {
double x, res;
x = 0.0;
- res = rtl::math::log1p(x);
+ res = std::log1p(x);
CPPUNIT_ASSERT_EQUAL(0.0,res);
x = -0.0;
- res = rtl::math::log1p(x);
+ res = std::log1p(x);
CPPUNIT_ASSERT_EQUAL(-0.0,res);
CPPUNIT_ASSERT(std::signbit(res));
rtl::math::setInf( &x, false);
- res = rtl::math::log1p(x);
+ res = std::log1p(x);
CPPUNIT_ASSERT_EQUAL(true, std::isinf(res) && !std::signbit(res));
x = -1.0;
- res = rtl::math::log1p(x);
+ res = std::log1p(x);
CPPUNIT_ASSERT_EQUAL(true, std::isinf(res) && std::signbit(res));
x = -1.1;
- res = rtl::math::log1p(x);
+ res = std::log1p(x);
CPPUNIT_ASSERT(std::isnan(res));
rtl::math::setInf( &x, true);
- res = rtl::math::log1p(x);
+ res = std::log1p(x);
CPPUNIT_ASSERT(std::isnan(res));
rtl::math::setNan( &x);
- res = rtl::math::log1p(x);
+ res = std::log1p(x);
CPPUNIT_ASSERT(std::isnan(res));
}
@@ -636,20 +636,20 @@ public:
void test_atanh() {
double res;
- res = rtl::math::atanh(-2.0); // NaN
+ res = std::atanh(-2.0); // NaN
CPPUNIT_ASSERT(std::isnan(res));
- res = rtl::math::atanh(-1.0); // -Inf
+ res = std::atanh(-1.0); // -Inf
CPPUNIT_ASSERT(std::signbit(res));
CPPUNIT_ASSERT(std::isinf(res));
- CPPUNIT_ASSERT_EQUAL(0.0, rtl::math::atanh(0.0));
+ CPPUNIT_ASSERT_EQUAL(0.0, std::atanh(0.0));
- res = rtl::math::atanh(1.0); // +Inf
+ res = std::atanh(1.0); // +Inf
CPPUNIT_ASSERT(!std::signbit(res));
CPPUNIT_ASSERT(std::isinf(res));
- res = rtl::math::atanh(2.0); // NaN
+ res = std::atanh(2.0); // NaN
CPPUNIT_ASSERT(std::isnan(res));
}
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index 67fcd9f787f8..31b8812e8db7 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -1871,7 +1871,7 @@ void ScInterpreter::ScPDuration()
if ( fFuture <= 0.0 || fPresent <= 0.0 || fRate <= 0.0 )
PushIllegalArgument();
else
- PushDouble( std::log( fFuture / fPresent ) / rtl::math::log1p( fRate ) );
+ PushDouble( std::log( fFuture / fPresent ) / std::log1p( fRate ) );
}
}
@@ -1896,11 +1896,11 @@ double ScInterpreter::ScGetPMT(double fRate, double fNper, double fPv,
else
{
if (bPayInAdvance) // payment in advance
- fPayment = (fFv + fPv * exp( fNper * ::rtl::math::log1p(fRate) ) ) * fRate /
- (std::expm1( (fNper + 1) * ::rtl::math::log1p(fRate) ) - fRate);
+ fPayment = (fFv + fPv * exp( fNper * ::std::log1p(fRate) ) ) * fRate /
+ (std::expm1( (fNper + 1) * ::std::log1p(fRate) ) - fRate);
else // payment in arrear
- fPayment = (fFv + fPv * exp(fNper * ::rtl::math::log1p(fRate) ) ) * fRate /
- std::expm1( fNper * ::rtl::math::log1p(fRate) );
+ fPayment = (fFv + fPv * exp(fNper * ::std::log1p(fRate) ) ) * fRate /
+ std::expm1( fNper * ::std::log1p(fRate) );
}
return -fPayment;
}
@@ -1983,9 +1983,9 @@ void ScInterpreter::ScNper()
PushDouble(-(fPV + fFV)/fPmt);
else if (bPayInAdvance)
PushDouble(log(-(fRate*fFV-fPmt*(1.0+fRate))/(fRate*fPV+fPmt*(1.0+fRate)))
- / rtl::math::log1p(fRate));
+ / std::log1p(fRate));
else
- PushDouble(log(-(fRate*fFV-fPmt)/(fRate*fPV+fPmt)) / rtl::math::log1p(fRate));
+ PushDouble(log(-(fRate*fFV-fPmt)/(fRate*fPV+fPmt)) / std::log1p(fRate));
}
bool ScInterpreter::RateIteration( double fNper, double fPayment, double fPv,
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index e5ae61962014..73e576d011a2 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -601,7 +601,7 @@ double ScInterpreter::GetGamma(double fZ)
if (fZ >= -0.5) // shift to x>=1, might overflow
{
- double fLogTest = lcl_GetLogGammaHelper(fZ+2) - rtl::math::log1p(fZ) - log( std::abs(fZ));
+ double fLogTest = lcl_GetLogGammaHelper(fZ+2) - std::log1p(fZ) - log( std::abs(fZ));
if (fLogTest >= fLogDblMax)
{
SetError( FormulaError::IllegalFPOperation);
@@ -634,7 +634,7 @@ double ScInterpreter::GetLogGamma(double fZ)
return log(lcl_GetGammaHelper(fZ));
if (fZ >= 0.5)
return log( lcl_GetGammaHelper(fZ+1) / fZ);
- return lcl_GetLogGammaHelper(fZ+2) - rtl::math::log1p(fZ) - log(fZ);
+ return lcl_GetLogGammaHelper(fZ+2) - std::log1p(fZ) - log(fZ);
}
double ScInterpreter::GetFDist(double x, double fF1, double fF2)
@@ -823,8 +823,8 @@ double ScInterpreter::GetBeta(double fAlpha, double fBeta)
fLanczos *= sqrt((fABgm/(fA+fgm))/(fB+fgm));
double fTempA = fB/(fA+fgm); // (fA+fgm)/fABgm = 1 / ( 1 + fB/(fA+fgm))
double fTempB = fA/(fB+fgm);
- double fResult = exp(-fA * ::rtl::math::log1p(fTempA)
- -fB * ::rtl::math::log1p(fTempB)-fgm);
+ double fResult = exp(-fA * std::log1p(fTempA)
+ -fB * std::log1p(fTempB)-fgm);
fResult *= fLanczos;
return fResult;
}
@@ -852,8 +852,8 @@ double ScInterpreter::GetLogBeta(double fAlpha, double fBeta)
fLogLanczos += 0.5*(log(fABgm)-log(fA+fgm)-log(fB+fgm));
double fTempA = fB/(fA+fgm); // (fA+fgm)/fABgm = 1 / ( 1 + fB/(fA+fgm))
double fTempB = fA/(fB+fgm);
- double fResult = -fA * ::rtl::math::log1p(fTempA)
- -fB * ::rtl::math::log1p(fTempB)-fgm;
+ double fResult = -fA * std::log1p(fTempA)
+ -fB * std::log1p(fTempB)-fgm;
fResult += fLogLanczos;
return fResult;
}
@@ -874,7 +874,7 @@ double ScInterpreter::GetBetaDistPDF(double fX, double fA, double fB)
return HUGE_VAL;
}
if (fX <= 0.01)
- return fB + fB * std::expm1((fB-1.0) * ::rtl::math::log1p(-fX));
+ return fB + fB * std::expm1((fB-1.0) * std::log1p(-fX));
else
return fB * pow(0.5-fX+0.5,fB-1.0);
}
@@ -913,7 +913,7 @@ double ScInterpreter::GetBetaDistPDF(double fX, double fA, double fB)
// normal cases; result x^(a-1)*(1-x)^(b-1)/Beta(a,b)
const double fLogDblMax = log( ::std::numeric_limits<double>::max());
const double fLogDblMin = log( ::std::numeric_limits<double>::min());
- double fLogY = (fX < 0.1) ? ::rtl::math::log1p(-fX) : log(0.5-fX+0.5);
+ double fLogY = (fX < 0.1) ? std::log1p(-fX) : log(0.5-fX+0.5);
double fLogX = log(fX);
double fAm1LogX = (fA-1.0) * fLogX;
double fBm1LogY = (fB-1.0) * fLogY;
@@ -993,13 +993,13 @@ 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 -std::expm1(fBeta * ::rtl::math::log1p(-fXin));
+ return -std::expm1(fBeta * std::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
// faster nor more accurate.
double fY = (0.5-fXin)+0.5;
- double flnY = ::rtl::math::log1p(-fXin);
+ double flnY = std::log1p(-fXin);
double fX = fXin;
double flnX = log(fXin);
double fA = fAlpha;
diff --git a/sc/source/ui/dataprovider/datatransformation.cxx b/sc/source/ui/dataprovider/datatransformation.cxx
index b5ba65f5a5b8..9fa4c483a4b3 100644
--- a/sc/source/ui/dataprovider/datatransformation.cxx
+++ b/sc/source/ui/dataprovider/datatransformation.cxx
@@ -498,7 +498,7 @@ void NumberTransformation::Transform(ScDocument& rDoc) const
double nVal = rDoc.GetValue(rCol, nRow, 0);
if (nVal > 0)
{
- rDoc.SetValue(rCol, nRow, 0, rtl::math::log1p(nVal-1));
+ rDoc.SetValue(rCol, nRow, 0, std::log1p(nVal-1));
}
else
{