23 #ifndef otbEuclideanDistanceMetricWithMissingValuePow2_hxx
24 #define otbEuclideanDistanceMetricWithMissingValuePow2_hxx
27 #include "itkMeasurementVectorTraits.h"
35 template <
class TVector>
38 if (itk::NumericTraits<TVector>::GetLength(x1) != itk::NumericTraits<TVector>::GetLength(x2))
40 itkExceptionMacro(<<
"Vector lengths must be equal.");
43 double temp, distance = itk::NumericTraits<double>::Zero;
45 for (
unsigned int i = 0; i < x1.Size(); ++i)
47 if (!IsMissingValue(x1[i]) && !IsMissingValue(x2[i]))
50 distance += temp * temp;
57 template <
class TVector>
61 if (measurementVectorSize == 0)
63 itkExceptionMacro(<<
"Please set the MeasurementVectorSize first");
65 itk::Statistics::MeasurementVectorTraits::Assert(this->GetOrigin(), measurementVectorSize,
66 "EuclideanDistanceMetric::Evaluate Origin and input vector have different lengths");
68 double temp, distance = itk::NumericTraits<double>::Zero;
70 for (
unsigned int i = 0; i < measurementVectorSize; ++i)
72 if (!IsMissingValue(this->GetOrigin()[i]) && !IsMissingValue(x[i]))
74 temp = this->GetOrigin()[i] - x[i];
75 distance += temp * temp;
82 template <
class TVector>
86 if (IsMissingValue(a) || IsMissingValue(b))
93 template <
class TVector>
97 return static_cast<bool>(vnl_math_isnan(
static_cast<double>(v)));
100 template <
class TVector>
104 v = std::numeric_limits<ValueType>::signaling_NaN();