18#ifndef itkArithmeticOpsFunctors_h
19#define itkArithmeticOpsFunctors_h
32template <
typename TInput1,
typename TInput2 = TInput1,
typename TOutput = TInput1>
33class ITK_TEMPLATE_EXPORT
Add2
47 return static_cast<TOutput
>(A + B);
57template <
typename TInput1,
typename TInput2,
typename TInput3,
typename TOutput>
58class ITK_TEMPLATE_EXPORT
Add3
70 operator()(
const TInput1 & A,
const TInput2 & B,
const TInput3 & C)
const
72 return static_cast<TOutput
>(A + B + C);
82template <
typename TInput1,
typename TInput2 = TInput1,
typename TOutput = TInput1>
83class ITK_TEMPLATE_EXPORT
Sub2
97 return static_cast<TOutput
>(A - B);
107template <
typename TInput1,
typename TInput2 = TInput1,
typename TOutput = TInput1>
122 return static_cast<TOutput
>(A * B);
132template <
typename TInput1,
typename TInput2,
typename TOutput>
133class ITK_TEMPLATE_EXPORT
Div
149 return (TOutput)(A / B);
164template <
typename TNumerator,
typename TDenominator = TNumerator,
typename TOutput = TNumerator>
171 m_Constant = TOutput{};
188 operator()(
const TNumerator & n,
const TDenominator & d)
const
194 return static_cast<TOutput
>(n) /
static_cast<TOutput
>(d);
206template <
typename TInput1,
typename TInput2,
typename TOutput>
223 return static_cast<TOutput
>(A % B);
232#if !defined(ITK_FUTURE_LEGACY_REMOVE)
242template <
typename TInput,
typename TOutput>
243class ITK_TEMPLATE_EXPORT ModulusTransform
246 ModulusTransform() { m_Dividend = 5; }
247 ~ModulusTransform() =
default;
249 SetDividend(TOutput dividend)
251 m_Dividend = dividend;
256 operator==(
const ModulusTransform & other)
const
258 return m_Dividend == other.m_Dividend;
261 ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(ModulusTransform);
264 operator()(
const TInput & x)
const
266 auto result =
static_cast<TOutput
>(x % m_Dividend);
286template <
class TInput1,
class TInput2,
class TOutput>
301 const double temp = std::floor(
static_cast<double>(A) /
static_cast<double>(B));
302 if (std::is_integral_v<TOutput> && Math::isinf(temp))
313 return static_cast<TOutput
>(temp);
328template <
class TInput1,
class TInput2,
class TOutput>
355template <
class TInput1,
class TOutput = TInput1>
370 return (TOutput)(-A);
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Add2)
bool operator==(const Add2 &) const
TOutput operator()(const TInput1 &A, const TInput2 &B) const
bool operator==(const Add3 &) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Add3)
TOutput operator()(const TInput1 &A, const TInput2 &B, const TInput3 &C) const
Cast arguments to double, performs division then takes the floor.
bool operator==(const DivFloor &) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(DivFloor)
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Promotes arguments to real type and performs division.
TOutput operator()(const TInput1 &A, const TInput2 &B) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(DivReal)
bool operator==(const DivReal &) const
bool operator==(const Div &) const
TOutput operator()(const TInput1 &A, const TInput2 &B) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Div)
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(DivideOrZeroOut)
~DivideOrZeroOut()=default
TOutput operator()(const TNumerator &n, const TDenominator &d) const
bool operator==(const DivideOrZeroOut &) const
bool operator==(const Modulus &) const
TOutput operator()(const TInput1 &A, const TInput2 &B) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Modulus)
TOutput operator()(const TInput1 &A, const TInput2 &B) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Mult)
bool operator==(const Mult &) const
bool operator==(const Sub2 &) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(Sub2)
TOutput operator()(const TInput1 &A, const TInput2 &B) const
Apply the unary minus operator.
bool operator==(const UnaryMinus &) const
TOutput operator()(const TInput1 &A) const
ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(UnaryMinus)
Define additional traits for native types such as int or float.
static constexpr T NonpositiveMin()
static constexpr T max(const T &)
bool NotAlmostEquals(T1 x1, T2 x2)
static constexpr double e
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
bool operator==(const Index< VDimension > &one, const Index< VDimension > &two)