1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
/*!
@authors Andrei Novikov (pyclustering@yandex.ru)
@date 2014-2020
@copyright BSD-3-Clause
*/
#pragma once
namespace pyclustering {
namespace utils {
namespace math {
/*!
@brief Mathematical constant pi.
*/
const double pi = 3.14159265358979323846;
/**
*
* @brief Calculates Heaviside function.
* @details If value >= 0.0 then 1.0 is returned, otherwise 0.0 is returned.
*
* @param[in] value: Input argument of the Heaviside function.
*
* @return Returns result of Heaviside function.
*
*/
double heaviside(const double value);
/**
*
* @brief Calculates absolute difference between two objects.
*
* @param[in] p_value1: The first value of the operation.
* @param[in] p_value2: The second value of the operation.
*
* @return Returns absolute difference.
*
*/
template <class TypeValue>
TypeValue absolute_difference(const TypeValue & p_value1, const TypeValue & p_value2) {
return (p_value1 >= p_value2) ? p_value1 - p_value2 : p_value2 - p_value1;
}
}
}
}
|