18 #include "SamplingSchemeDistanceCLP.h" 21 #include <vnl/vnl_matrix.h> 27 main (
int argc,
char const* argv[])
32 typedef utl_shared_ptr<MatrixType> MatrixPointer;
33 MatrixPointer grad1, grad2;
37 utlGlobalException(grad1->Rows()!=grad2->Rows(),
"two file should have the same number of rows");
41 int N = grad1->Rows();
42 double maxDist=-1, distTmp=-1;
44 MatrixType dist(N,N,0.0);
46 for (
int i = 0; i < N; i += 1 )
48 v1 = grad1->GetRow(i);
52 for ( ; j < N; j += 1 )
54 v2 = grad2->GetRow(j);
55 double tmp =
utl::min( utl::ToVector<double>(v1-v2)->GetTwoNorm(), utl::ToVector<double>(v1+v2)->GetTwoNorm() );
65 if (distTmp > maxDist)
75 std::cout <<
"maximal Euclidean distance = " << maxDist <<
", angular distance = " << std::acos(1-maxDist*maxDist*0.5)/
M_PI*180 <<
" degree, between the " << iMax+1 <<
"-th sample ["<<
utl::UtlVectorToStdVector(grad1->GetRow(iMax)) <<
"] in file " << _InputFile1 <<
76 " and the " << jMax+1 <<
"-th sample [" <<
utl::UtlVectorToStdVector(grad2->GetRow(jMax)) <<
"] in file " << _InputFile2 << std::endl << std::flush;
helper functions specifically used in dmritool
#define utlPrintVar3(cond, var1, var2, var3)
const T & max(const T &a, const T &b)
Return the maximum between a and b.
const T & min(const T &a, const T &b)
Return the minimum between a and b.
#define utlGlobalException(cond, expout)
#define utlPrintVar2(cond, var1, var2)
std::vector< T > UtlVectorToStdVector(const NDArray< T, 1 > &vec)
int main(int argc, char const *argv[])
calculate the distances between to sampling schemes