Skip to content

Commit d36ba88

Browse files
committed
STYLE: Use itk::Math::Absolute name directly
The itk::Math::Absolute is subtly different from the std::abs and other typical absolute value functions, so use the more explicit name to clearly indicate that the behaviors are not the same as the core c++ similarly named functions. Use ITK_FUTURE_LEGACY_REMOVE of the itk::Math::abs supported name.
1 parent 4a70082 commit d36ba88

File tree

497 files changed

+1665
-1636
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

497 files changed

+1665
-1636
lines changed

Examples/RegistrationITKv4/ImageRegistration11.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class CommandIterationUpdate : public itk::Command
8585
}
8686
const double currentValue = optimizer->GetValue();
8787
// Only print out when the Metric value changes
88-
if (itk::Math::abs(m_LastMetricValue - currentValue) > 1e-7)
88+
if (itk::Math::Absolute(m_LastMetricValue - currentValue) > 1e-7)
8989
{
9090
std::cout << optimizer->GetCurrentIteration() << " ";
9191
std::cout << currentValue << " ";

Examples/RegistrationITKv4/ImageRegistration14.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class CommandIterationUpdate : public itk::Command
7676
}
7777
const double currentValue = optimizer->GetValue();
7878
// Only print out when the Metric value changes
79-
if (itk::Math::abs(m_LastMetricValue - currentValue) > 1e-7)
79+
if (itk::Math::Absolute(m_LastMetricValue - currentValue) > 1e-7)
8080
{
8181
std::cout << optimizer->GetCurrentIteration() << " ";
8282
std::cout << currentValue << " ";

Examples/RegistrationITKv4/ImageRegistration15.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class CommandIterationUpdate : public itk::Command
7575
}
7676
const double currentValue = optimizer->GetValue();
7777
// Only print out when the Metric value changes
78-
if (itk::Math::abs(m_LastMetricValue - currentValue) > 1e-7)
78+
if (itk::Math::Absolute(m_LastMetricValue - currentValue) > 1e-7)
7979
{
8080
std::cout << optimizer->GetCurrentIteration() << " ";
8181
std::cout << currentValue << " ";

Modules/Core/Common/include/itkBSplineKernelFunction.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class ITK_TEMPLATE_EXPORT BSplineKernelFunction : public KernelFunctionBase<TRea
9898
static inline TRealValueType
9999
Evaluate(const Dispatch<0> &, const TRealValueType & u)
100100
{
101-
const TRealValueType absValue = itk::Math::abs(u);
101+
const TRealValueType absValue = itk::Math::Absolute(u);
102102
if (absValue < TRealValueType{ 0.5 })
103103
{
104104
return TRealValueType{ 1.0 };
@@ -117,7 +117,7 @@ class ITK_TEMPLATE_EXPORT BSplineKernelFunction : public KernelFunctionBase<TRea
117117
static inline TRealValueType
118118
Evaluate(const Dispatch<1> &, const TRealValueType & u)
119119
{
120-
const TRealValueType absValue = itk::Math::abs(u);
120+
const TRealValueType absValue = itk::Math::Absolute(u);
121121
if (absValue < TRealValueType{ 1.0 })
122122
{
123123
return TRealValueType{ 1.0 } - absValue;
@@ -130,7 +130,7 @@ class ITK_TEMPLATE_EXPORT BSplineKernelFunction : public KernelFunctionBase<TRea
130130
static inline TRealValueType
131131
Evaluate(const Dispatch<2> &, const TRealValueType & u)
132132
{
133-
const TRealValueType absValue = itk::Math::abs(u);
133+
const TRealValueType absValue = itk::Math::Absolute(u);
134134
if (absValue < TRealValueType{ 0.5 })
135135
{
136136
const TRealValueType sqrValue = itk::Math::sqr(absValue);
@@ -153,7 +153,7 @@ class ITK_TEMPLATE_EXPORT BSplineKernelFunction : public KernelFunctionBase<TRea
153153
static inline TRealValueType
154154
Evaluate(const Dispatch<3> &, const TRealValueType & u)
155155
{
156-
const TRealValueType absValue = itk::Math::abs(u);
156+
const TRealValueType absValue = itk::Math::Absolute(u);
157157
if (absValue < TRealValueType{ 1.0 })
158158
{
159159
const TRealValueType sqrValue = itk::Math::sqr(absValue);

Modules/Core/Common/include/itkBresenhamLine.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ BresenhamLine<VDimension>::BuildLine(LType Direction, IdentifierType length) ->
4949
IndexType overflowIncrement;
5050
for (unsigned int i = 0; i < VDimension; ++i)
5151
{
52-
auto distance = static_cast<long>(itk::Math::abs(LastIndex[i]));
52+
auto distance = static_cast<long>(itk::Math::Absolute(LastIndex[i]));
5353
if (distance > maxDistance)
5454
{
5555
maxDistance = distance;
@@ -113,7 +113,7 @@ BresenhamLine<VDimension>::BuildLine(IndexType p0, IndexType p1) -> IndexArray
113113
{
114114
point0[i] = p0[i];
115115
point1[i] = p1[i];
116-
const IdentifierType distance = itk::Math::abs(p0[i] - p1[i]) + 1;
116+
const IdentifierType distance = itk::Math::Absolute(p0[i] - p1[i]) + 1;
117117
if (distance > maxDistance)
118118
{
119119
maxDistance = distance;

Modules/Core/Common/include/itkFiniteCylinderSpatialFunction.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ FiniteCylinderSpatialFunction<VDimension, TInput>::Evaluate(const InputType & po
102102
FloatingPointExceptions::SetEnabled(saveFPEState);
103103
}
104104

105-
if (itk::Math::abs(distanceFromCenter) <= (halfAxisLength) &&
105+
if (itk::Math::Absolute(distanceFromCenter) <= (halfAxisLength) &&
106106
m_Radius >= std::sqrt(Math::sqr(pointVector.GetNorm()) - Math::sqr(distanceFromCenter)))
107107
{
108108
return 1;

Modules/Core/Common/include/itkFrustumSpatialFunction.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ FrustumSpatialFunction<VDimension, TInput>::Evaluate(const InputType & position)
6262

6363
// Check planes along Y
6464
const double angleY = std::atan2(dy, distanceXZ);
65-
if (itk::Math::abs(angleY) > m_ApertureAngleY * deg2rad)
65+
if (itk::Math::Absolute(angleY) > m_ApertureAngleY * deg2rad)
6666
{
6767
return 0;
6868
}
@@ -89,7 +89,7 @@ FrustumSpatialFunction<VDimension, TInput>::Evaluate(const InputType & position)
8989

9090
// Check planes along X
9191
const double angleX = std::atan2(dx, distanceYZ);
92-
if (itk::Math::abs(angleX) > m_ApertureAngleX * deg2rad)
92+
if (itk::Math::Absolute(angleX) > m_ApertureAngleX * deg2rad)
9393
{
9494
return 0;
9595
}

Modules/Core/Common/include/itkGaussianDerivativeOperator.hxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ GaussianDerivativeOperator<TPixel, VDimension, TAllocator>::ModifiedBesselI0(dou
163163
{
164164
double accumulator = NAN;
165165

166-
const double d = itk::Math::abs(y);
166+
const double d = itk::Math::Absolute(y);
167167
if (d < 3.75)
168168
{
169169
double m = y / 3.75;
@@ -191,7 +191,7 @@ double
191191
GaussianDerivativeOperator<TPixel, VDimension, TAllocator>::ModifiedBesselI1(double y)
192192
{
193193
double accumulator = NAN;
194-
const double d = itk::Math::abs(y);
194+
const double d = itk::Math::Absolute(y);
195195
if (d < 3.75)
196196
{
197197
double m = y / 3.75;
@@ -236,15 +236,15 @@ GaussianDerivativeOperator<TPixel, VDimension, TAllocator>::ModifiedBesselI(int
236236
return 0.0;
237237
}
238238

239-
const double toy = 2.0 / itk::Math::abs(y);
239+
const double toy = 2.0 / itk::Math::Absolute(y);
240240
double qip = accumulator = 0.0;
241241
double qi = 1.0;
242242
for (int j = 2 * (n + static_cast<int>(DIGITS * std::sqrt(static_cast<double>(n)))); j > 0; j--)
243243
{
244244
const double qim = qip + j * toy * qi;
245245
qip = qi;
246246
qi = qim;
247-
if (itk::Math::abs(qi) > 1.0e10)
247+
if (itk::Math::Absolute(qi) > 1.0e10)
248248
{
249249
accumulator *= 1.0e-10;
250250
qi *= 1.0e-10;

Modules/Core/Common/include/itkGaussianOperator.hxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ template <typename TPixel, unsigned int VDimension, typename TAllocator>
7575
double
7676
GaussianOperator<TPixel, VDimension, TAllocator>::ModifiedBesselI0(double y)
7777
{
78-
const double d = itk::Math::abs(y);
78+
const double d = itk::Math::Absolute(y);
7979
double accumulator = NAN;
8080

8181
if (d < 3.75)
@@ -104,7 +104,7 @@ template <typename TPixel, unsigned int VDimension, typename TAllocator>
104104
double
105105
GaussianOperator<TPixel, VDimension, TAllocator>::ModifiedBesselI1(double y)
106106
{
107-
const double d = itk::Math::abs(y);
107+
const double d = itk::Math::Absolute(y);
108108
double accumulator = NAN;
109109

110110
if (d < 3.75)
@@ -151,7 +151,7 @@ GaussianOperator<TPixel, VDimension, TAllocator>::ModifiedBesselI(int n, double
151151
return 0.0;
152152
}
153153

154-
const double toy = 2.0 / itk::Math::abs(y);
154+
const double toy = 2.0 / itk::Math::Absolute(y);
155155
double qip = 0.0;
156156
double accumulator = 0.0;
157157
double qi = 1.0;
@@ -161,7 +161,7 @@ GaussianOperator<TPixel, VDimension, TAllocator>::ModifiedBesselI(int n, double
161161
const double qim = qip + j * toy * qi;
162162
qip = qi;
163163
qi = qim;
164-
if (itk::Math::abs(qi) > 1.0e10)
164+
if (itk::Math::Absolute(qi) > 1.0e10)
165165
{
166166
accumulator *= 1.0e-10;
167167
qi *= 1.0e-10;

Modules/Core/Common/include/itkHexahedronCell.hxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ HexahedronCell<TCellInterface>::EvaluatePosition(CoordinateType * x,
402402
// spell-check-disable
403403
// d=vtkMath::Determinant3x3(rcol,scol,tcol);
404404
// spell-check-enable
405-
if (itk::Math::abs(d) < 1.e-20)
405+
if (itk::Math::Absolute(d) < 1.e-20)
406406
{
407407
return false;
408408
}
@@ -443,16 +443,16 @@ HexahedronCell<TCellInterface>::EvaluatePosition(CoordinateType * x,
443443
}
444444

445445
// check for convergence
446-
if (((itk::Math::abs(pcoords[0] - params[0])) < ITK_HEX_CONVERGED) &&
447-
((itk::Math::abs(pcoords[1] - params[1])) < ITK_HEX_CONVERGED) &&
448-
((itk::Math::abs(pcoords[2] - params[2])) < ITK_HEX_CONVERGED))
446+
if (((itk::Math::Absolute(pcoords[0] - params[0])) < ITK_HEX_CONVERGED) &&
447+
((itk::Math::Absolute(pcoords[1] - params[1])) < ITK_HEX_CONVERGED) &&
448+
((itk::Math::Absolute(pcoords[2] - params[2])) < ITK_HEX_CONVERGED))
449449
{
450450
converged = 1;
451451
}
452452

453453
// Test for bad divergence (S.Hirschberg 11.12.2001)
454-
else if ((itk::Math::abs(pcoords[0]) > ITK_DIVERGED) || (itk::Math::abs(pcoords[1]) > ITK_DIVERGED) ||
455-
(itk::Math::abs(pcoords[2]) > ITK_DIVERGED))
454+
else if ((itk::Math::Absolute(pcoords[0]) > ITK_DIVERGED) || (itk::Math::Absolute(pcoords[1]) > ITK_DIVERGED) ||
455+
(itk::Math::Absolute(pcoords[2]) > ITK_DIVERGED))
456456
{
457457
return false;
458458
}

0 commit comments

Comments
 (0)