Program Listing for File norms.hpp
↰ Return to documentation for file (/tmp/ws/src/ecl_core/ecl_math/include/ecl/math/norms.hpp
)
/*****************************************************************************
** Ifdefs
*****************************************************************************/
#ifndef ECL_MATH_NORMS_HPP_
#define ECL_MATH_NORMS_HPP_
/*****************************************************************************
** Includes
*****************************************************************************/
#include <cmath>
/*****************************************************************************
** Namespaces
*****************************************************************************/
namespace ecl {
/*****************************************************************************
** Functors
*****************************************************************************/
class EuclideanNorm {
public:
template <typename T>
T operator()(const T& x1, const T& x2) {
return std::sqrt(x1*x1 + x2*x2);
}
template <typename T>
T operator()(const T& x1, const T& x2, const T& x3) {
return std::sqrt(x1*x1 + x2*x2 + x3*x3);
}
// n dimensional cases using vectors, valarrays and eigen vectors here.
// maybe also a norm(vectorx, vectory) which is sqrt((x0-y0)^2+(x1-y1)^2.....)
};
/*****************************************************************************
** Functions
*****************************************************************************/
template <typename T>
T euclidean_norm(const T& x1, const T& x2) {
return std::sqrt(x1*x1 + x2*x2);
}
template <typename T>
T euclidean_norm(const T& x1, const T& x2, const T& x3) {
return std::sqrt(x1*x1 + x2*x2 + x3*x3);
}
} // namespace ecl
#endif /* ECL_MATH_NORMS_HPP_ */