12 const std::vector<double *> &highDistMatrix,
13 const std::vector<double *> &lowDistMatrix,
14 double &distortionValue,
15 double *distortionVerticesValues)
const {
17 auto n = highDistMatrix.size();
19 if(lowDistMatrix.size() != n) {
20 this->
printErr(
" Sizes mismatch: the high distance matrix has "
22 +
" rows and the low distance matrix has "
23 + std::to_string(lowDistMatrix.size()) +
" rows.");
36 if(distortionVerticesValues ==
nullptr) {
38 " The output pointer to the distortionValues must be non NULL. "
39 "It must point to an allocated array of the right size.");
43#ifdef TTK_ENABLE_OPENMP
44#pragma omp parallel for num_threads(this->threadNumber_) reduction(max \
48 for(
size_t i = 0; i < n; i++) {
49 for(
size_t j = i + 1; j < n; j++) {
50 const double diff = lowDistMatrix[i][j] - highDistMatrix[i][j];
51 maxi = std::max(maxi, diff * diff);
58 "The two distance matrices provided for SIM computation are equal.");
64#ifdef TTK_ENABLE_OPENMP
65#pragma omp parallel for num_threads(this->threadNumber_), \
66 reduction(+ : totalSum)
68 for(
size_t i = 0; i < n; i++) {
70 for(
size_t j = 0; j < n; j++) {
71 const double diff = lowDistMatrix[i][j] - highDistMatrix[i][j];
72 const double diff2 = diff * diff;
75 const double sumNormalized = (this->
DoNotNormalize ? sum : sum / maxi);
76 distortionVerticesValues[i] = 1 - sumNormalized / n;
77 totalSum += 1 - sumNormalized / n;
80 distortionValue = totalSum / n;
82 this->
printMsg(
"Size of output in ttk/base = " + std::to_string(n));
84 this->
printMsg(
"Computed distortion value: "
85 + std::to_string(distortionValue));
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/| (_) |"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)