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_), reduction(+:totalSum)
67 for(
size_t i = 0; i < n; i++) {
69 for(
size_t j = 0; j < n; j++) {
70 const double diff = lowDistMatrix[i][j] - highDistMatrix[i][j];
71 const double diff2 = diff * diff;
74 const double sumNormalized = (this->DoNotNormalize ? sum : sum / maxi);
75 distortionVerticesValues[i] = 1 - sumNormalized / n;
76 totalSum += 1 - sumNormalized / n;
79 distortionValue = totalSum / n;
81 this->
printMsg(
"Size of output in ttk/base = " + std::to_string(n));
83 this->
printMsg(
"Computed distortion value: "
84 + std::to_string(distortionValue));
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)