norms.hpp
Go to the documentation of this file.
1 
12 /*****************************************************************************
13 ** Ifdefs
14 *****************************************************************************/
15 
16 #ifndef ECL_MATH_NORMS_HPP_
17 #define ECL_MATH_NORMS_HPP_
18 
19 /*****************************************************************************
20 ** Includes
21 *****************************************************************************/
22 
23 #include <cmath>
24 
25 /*****************************************************************************
26 ** Namespaces
27 *****************************************************************************/
28 
29 namespace ecl {
30 
31 /*****************************************************************************
32 ** Functors
33 *****************************************************************************/
39 class EuclideanNorm {
40 public:
48  template <typename T>
49  T operator()(const T& x1, const T& x2) {
50  return std::sqrt(x1*x1 + x2*x2);
51  }
52 
61  template <typename T>
62  T operator()(const T& x1, const T& x2, const T& x3) {
63  return std::sqrt(x1*x1 + x2*x2 + x3*x3);
64  }
65 
66  // n dimensional cases using vectors, valarrays and eigen vectors here.
67 
68  // maybe also a norm(vectorx, vectory) which is sqrt((x0-y0)^2+(x1-y1)^2.....)
69 };
70 
71 /*****************************************************************************
72 ** Functions
73 *****************************************************************************/
81 template <typename T>
82 T euclidean_norm(const T& x1, const T& x2) {
83  return std::sqrt(x1*x1 + x2*x2);
84 }
85 
94 template <typename T>
95 T euclidean_norm(const T& x1, const T& x2, const T& x3) {
96  return std::sqrt(x1*x1 + x2*x2 + x3*x3);
97 }
98 
99 } // namespace ecl
100 
101 #endif /* ECL_MATH_NORMS_HPP_ */
T euclidean_norm(const T &x1, const T &x2)
Function for euclidean norms of dimension 2.
Definition: norms.hpp:82
T operator()(const T &x1, const T &x2)


xbot_node
Author(s): Roc, wangpeng@droid.ac.cn
autogenerated on Sat Oct 10 2020 03:28:13