30 template <
class dataType>
31 int execute(
const dataType *
const inputData1,
32 const dataType *
const inputData2,
33 dataType *
const outputData,
34 const std::string &distanceType,
37 template <
class dataType,
typename PowerFunc>
38 int computeLn(
const dataType *
const input1,
39 const dataType *
const input2,
40 dataType *
const output,
43 const PowerFunc &powerFunc);
45 template <
class dataType>
47 const dataType *
const input2,
48 dataType *
const output,
59 template <
typename type>
60 static type
abs_diff(
const type var1,
const type var2) {
61 return (var1 > var2) ? var1 - var2 : var2 - var1;
71template <
class dataType>
73 const dataType *
const inputData2,
74 dataType *
const outputData,
75 const std::string &distanceType,
82#ifndef TTK_ENABLE_KAMIKAZE
83 if(inputData1 ==
nullptr || inputData2 ==
nullptr) {
88 if(distanceType ==
"inf") {
89 status =
computeLinf(inputData1, inputData2, outputData, vertexNumber);
91 int const n = stoi(distanceType);
96 outputData, n, vertexNumber);
101 "Data-set processed", 1.0, t.
getElapsedTime(), this->threadNumber_);
107template <
class dataType,
typename PowerFunc>
109 const dataType *
const input2,
110 dataType *
const output,
113 const PowerFunc &powerFunc) {
117#ifdef TTK_ENABLE_OPENMP
118#pragma omp parallel for num_threads(threadNumber_) reduction(+ : sum)
121 const dataType diff = abs_diff<dataType>(input1[i], input2[i]);
122 const dataType power = powerFunc(diff);
136 result = (double)sum;
138 this->
printMsg(
"L" + std::to_string(n)
139 +
"-distance: " + std::to_string(result));
145template <
class dataType>
147 const dataType *
const input2,
148 dataType *
const output,
153 dataType maxValue = abs_diff<dataType>(input1[0], input2[0]);
156#ifdef TTK_ENABLE_OPENMP
157#pragma omp parallel for num_threads(threadNumber_) reduction(max : maxValue)
160 const dataType iter = abs_diff<dataType>(input1[i], input2[i]);
170 result = (double)maxValue;
172 this->
printMsg(
"Linf-distance: " + std::to_string(result));
#define TTK_POW_LAMBDA(CALLEXPR, TYPE, EXPN,...)
Optimized Power function with lambdas.
Minimalist debugging class.
TTK lDistance processing package.
int computeLinf(const dataType *const input1, const dataType *const input2, dataType *const output, const SimplexId vertexNumber)
int computeLn(const dataType *const input1, const dataType *const input2, dataType *const output, const int n, const SimplexId vertexNumber, const PowerFunc &powerFunc)
int execute(const dataType *const inputData1, const dataType *const inputData2, dataType *const outputData, const std::string &distanceType, const SimplexId vertexNumber)
static type abs_diff(const type var1, const type var2)
void setPrintRes(const bool data)
T1 pow(const T1 val, const T2 n)
int SimplexId
Identifier type for simplices of any dimension.
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)