Skip to content

Commit d754a92

Browse files
committed
STYLE: Use itk::Math::safe_abs name directly
The itk::Math::safe_abs 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 654b48f commit d754a92

File tree

501 files changed

+1680
-1651
lines changed

Some content is hidden

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

501 files changed

+1680
-1651
lines changed

Documentation/docs/releases/4.13.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Bradley Lowekamp (93) @blowekamp :
215215
BUG: Modify google test to define _VARIADIC_MAX=10
216216
COMP: Fix using system GoogleTest with a compiled system library
217217
ENH: Add SliceImageFilter
218-
COMP: Use itk::Math::abs over vnl_math_abs
218+
COMP: Use itk::Math::safe_abs over vnl_math_abs
219219
ENH: Add GetProbe method to collectors base.
220220
BUG: Add missing exports for GTest::* targets
221221
BUG: Fix computation of central moments for shape label map

Documentation/docs/releases/5.3.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ Remote Module Changes Since v5.3rc04
13311331

13321332
#### Style Changes
13331333

1334-
- use itk::Math::abs instead of fabs ([9f910c8a](https://github.com/RTKConsortium/RTK/commit/9f910c8a))
1334+
- use itk::Math::safe_abs instead of fabs ([9f910c8a](https://github.com/RTKConsortium/RTK/commit/9f910c8a))
13351335

13361336

13371337
### Shengpeng YU (1):

Documentation/docs/releases/5.3rc03.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ ITK Changes Since v5.3rc02
294294
- Address clang-tidy warnings in itkNumericTraitsTest.cxxv ([89f1bca360](https://github.com/InsightSoftwareConsortium/ITK/commit/89f1bca360))
295295
- Remove IsInteger and replace with std::is_integer ([b3f80bb295](https://github.com/InsightSoftwareConsortium/ITK/commit/b3f80bb295))
296296
- Remove IsSigned and replace with std::is_signed ([da13473cb0](https://github.com/InsightSoftwareConsortium/ITK/commit/da13473cb0))
297-
- Prefer itk::Math::abs over abs or fabs ([d715b098ba](https://github.com/InsightSoftwareConsortium/ITK/commit/d715b098ba))
297+
- Prefer itk::Math::safe_abs over abs or fabs ([d715b098ba](https://github.com/InsightSoftwareConsortium/ITK/commit/d715b098ba))
298298
- Allow use of clang-tidy as part of cmake compilation ([55db25c240](https://github.com/InsightSoftwareConsortium/ITK/commit/55db25c240))
299299
- Do not use double underscore defines ([191e122087](https://github.com/InsightSoftwareConsortium/ITK/commit/191e122087))
300300
- Remove recursive inclusion of .h files ([f84720ee08](https://github.com/InsightSoftwareConsortium/ITK/commit/f84720ee08))
@@ -820,7 +820,7 @@ ITK Sphinx Examples Changes Since v5.3rc02
820820

821821
#### Style Changes
822822

823-
- Prefer itk::Math::abs for consistency. ([28820f48](https://github.com/InsightSoftwareConsortium/ITKSphinxExamples/commit/28820f48))
823+
- Prefer itk::Math::safe_abs for consistency. ([28820f48](https://github.com/InsightSoftwareConsortium/ITKSphinxExamples/commit/28820f48))
824824
- address unused variable warnings. ([89a73005](https://github.com/InsightSoftwareConsortium/ITKSphinxExamples/commit/89a73005))
825825
- Remove outdated pre ITKv4 code ([5b3015a7](https://github.com/InsightSoftwareConsortium/ITKSphinxExamples/commit/5b3015a7))
826826
- Remove python style warnings ([e4742994](https://github.com/InsightSoftwareConsortium/ITKSphinxExamples/commit/e4742994))

Documentation/docs/releases/5.3rc04.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ Remote Module Changes Since v5.3rc03
13291329

13301330
#### Style Changes
13311331

1332-
- Prefer itk::Math::abs for consistency. ([c8db62a](https://github.com/InsightSoftwareConsortium/ITKGrowCut/commit/c8db62a))
1332+
- Prefer itk::Math::safe_abs for consistency. ([c8db62a](https://github.com/InsightSoftwareConsortium/ITKGrowCut/commit/c8db62a))
13331333

13341334

13351335
### Kian Weimer (3):
@@ -1427,7 +1427,7 @@ Remote Module Changes Since v5.3rc03
14271427

14281428
#### Style Changes
14291429

1430-
- Prefer itk::Math::abs for consistency. ([3ac09fa](https://github.com/KitwareMedical/ITKIOScanco/commit/3ac09fa))
1430+
- Prefer itk::Math::safe_abs for consistency. ([3ac09fa](https://github.com/KitwareMedical/ITKIOScanco/commit/3ac09fa))
14311431

14321432

14331433

@@ -1469,7 +1469,7 @@ Remote Module Changes Since v5.3rc03
14691469

14701470
#### Style Changes
14711471

1472-
- Prefer itk::Math::abs for consistency. ([c1a8417](https://github.com/InsightSoftwareConsortium/LesionSizingToolkit/commit/c1a8417))
1472+
- Prefer itk::Math::safe_abs for consistency. ([c1a8417](https://github.com/InsightSoftwareConsortium/LesionSizingToolkit/commit/c1a8417))
14731473

14741474

14751475

@@ -1489,7 +1489,7 @@ Remote Module Changes Since v5.3rc03
14891489

14901490
#### Style Changes
14911491

1492-
- Prefer itk::Math::abs for consistency. ([8decfcf](https://github.com/InsightSoftwareConsortium/itkMGHImageIO/commit/8decfcf))
1492+
- Prefer itk::Math::safe_abs for consistency. ([8decfcf](https://github.com/InsightSoftwareConsortium/itkMGHImageIO/commit/8decfcf))
14931493

14941494

14951495
### Jean-Christophe Fillion-Robin (2):
@@ -1596,8 +1596,8 @@ Remote Module Changes Since v5.3rc03
15961596

15971597
#### Style Changes
15981598

1599-
- Prefer itk::Math::abs for consistency. ([7ad5492](https://github.com/InsightSoftwareConsortium/ITKMontage/commit/7ad5492))
1600-
- Prefer itk::Math::abs for consistency. ([d595149](https://github.com/InsightSoftwareConsortium/ITKMontage/commit/d595149))
1599+
- Prefer itk::Math::safe_abs for consistency. ([7ad5492](https://github.com/InsightSoftwareConsortium/ITKMontage/commit/7ad5492))
1600+
- Prefer itk::Math::safe_abs for consistency. ([d595149](https://github.com/InsightSoftwareConsortium/ITKMontage/commit/d595149))
16011601
- Match clang-format style ([c11ec2a](https://github.com/InsightSoftwareConsortium/ITKMontage/commit/c11ec2a))
16021602

16031603

@@ -1630,7 +1630,7 @@ Remote Module Changes Since v5.3rc03
16301630

16311631
#### Style Changes
16321632

1633-
- Prefer itk::Math::abs for consistency. ([aa4cf17](https://github.com/KitwareMedical/ITKMorphologicalContourInterpolation/commit/aa4cf17))
1633+
- Prefer itk::Math::safe_abs for consistency. ([aa4cf17](https://github.com/KitwareMedical/ITKMorphologicalContourInterpolation/commit/aa4cf17))
16341634

16351635

16361636

@@ -1697,7 +1697,7 @@ Remote Module Changes Since v5.3rc03
16971697

16981698
#### Style Changes
16991699

1700-
- Prefer itk::Math::abs for consistency. ([aa5f6a0](https://github.com/InsightSoftwareConsortium/ITKPolarTransform/commit/aa5f6a0))
1700+
- Prefer itk::Math::safe_abs for consistency. ([aa5f6a0](https://github.com/InsightSoftwareConsortium/ITKPolarTransform/commit/aa5f6a0))
17011701

17021702

17031703

@@ -1773,7 +1773,7 @@ Remote Module Changes Since v5.3rc03
17731773

17741774
#### Style Changes
17751775

1776-
- Prefer itk::Math::abs for consistency. ([05f3ad2c](https://github.com/SimonRit/RTK/commit/05f3ad2c))
1776+
- Prefer itk::Math::safe_abs for consistency. ([05f3ad2c](https://github.com/SimonRit/RTK/commit/05f3ad2c))
17771777

17781778

17791779
### Lucas Gandel (2):
@@ -1824,7 +1824,7 @@ Remote Module Changes Since v5.3rc03
18241824

18251825
#### Style Changes
18261826

1827-
- Prefer itk::Math::abs for consistency. ([c759c9a9](https://github.com/SimonRit/RTK/commit/c759c9a9))
1827+
- Prefer itk::Math::safe_abs for consistency. ([c759c9a9](https://github.com/SimonRit/RTK/commit/c759c9a9))
18281828
- fix clang-format style in a few RTK files ([a9bd58e7](https://github.com/SimonRit/RTK/commit/a9bd58e7))
18291829
- remove useless member for the union of 3 objects ([5522ddd3](https://github.com/SimonRit/RTK/commit/5522ddd3))
18301830
- Prefer error checked std::stod over atof ([e6c48ebc](https://github.com/SimonRit/RTK/commit/e6c48ebc))
@@ -2017,7 +2017,7 @@ Remote Module Changes Since v5.3rc03
20172017

20182018
#### Style Changes
20192019

2020-
- Prefer itk::Math::abs for consistency. ([8e77598](https://github.com/InsightSoftwareConsortium/ITKTwoProjectionRegistration/commit/8e77598))
2020+
- Prefer itk::Math::safe_abs for consistency. ([8e77598](https://github.com/InsightSoftwareConsortium/ITKTwoProjectionRegistration/commit/8e77598))
20212021

20222022

20232023

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::safe_abs(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::safe_abs(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::safe_abs(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::safe_abs(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::safe_abs(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::safe_abs(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::safe_abs(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::safe_abs(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::safe_abs(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::safe_abs(distanceFromCenter) <= (halfAxisLength) &&
106106
m_Radius >= std::sqrt(Math::sqr(pointVector.GetNorm()) - Math::sqr(distanceFromCenter)))
107107
{
108108
return 1;

0 commit comments

Comments
 (0)