Commit 9a0b23f2 authored by Gregoire Mercier's avatar Gregoire Mercier

TEST: FlexibleDistanceWithMissingValue

parent 7812439f
......@@ -98,13 +98,14 @@ FlexibleDistanceWithMissingValue< TVector >
if (IsEuclidean())
return Superclass::Evaluate(a,b);
// FIXME throw NaN exception or not ??
// FIXME throw NaN exception instaed of returning 0. ??
if ( IsMissingValue( a ) || IsMissingValue( b ) )
return 0.0;
double temp = vcl_pow(vcl_abs(vcl_pow(a,this->Alpha) - vcl_pow(b,this->Alpha)), this->Beta) ;
return temp ;
}
template< class TVector >
void
FlexibleDistanceWithMissingValue< TVector >
......
......@@ -34,19 +34,20 @@ int otbFlexibleDistanceWithMissingValue( int argc, char * argv[] )
float a = 2.0;
float b = 0.5;
unsigned int dim = 3;
DistanceType::SetAlphaBeta(a,b);
VectorType x(3);
VectorType x( dim );
x.Fill( 1. );
VectorType y(3);
VectorType y( dim );
y.Fill( 2. );
DistanceType::Pointer dist = DistanceType::New();
double distanceValue = dist->Evaluate( x, y );
std::cout << "Distance: " << distanceValue << std::endl;
if ( (distanceValue - 3.*vcl_pow(3,b)) < epsilon )
if ( (distanceValue - dim*vcl_pow(3,b)) < epsilon )
return EXIT_SUCCESS;
else
return EXIT_FAILURE;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment