Point Cloud Library (PCL)
1.9.1
|
39 #ifndef PCL_COMMON_NORMS_IMPL_HPP_
40 #define PCL_COMMON_NORMS_IMPL_HPP_
42 #include <pcl/pcl_macros.h>
43 #include <pcl/console/print.h>
48 template <
typename FloatVectorT>
inline float
80 PCL_ERROR (
"[pcl::selectNorm] For PF and K norms you have to explicitly call the method, as they need additional parameters\n");
86 template <
typename FloatVectorT>
inline float
87 L1_Norm (FloatVectorT a, FloatVectorT b,
int dim)
90 for (
int i = 0; i < dim; ++i)
91 norm += fabsf(a[i] - b[i]);
96 template <
typename FloatVectorT>
inline float
100 for (
int i = 0; i < dim; ++i)
102 float diff = a[i] - b[i];
109 template <
typename FloatVectorT>
inline float
110 L2_Norm (FloatVectorT a, FloatVectorT b,
int dim)
116 template <
typename FloatVectorT>
inline float
120 for (
int i = 0; i < dim; ++i)
121 norm = (std::max)(fabsf(a[i] - b[i]), norm);
126 template <
typename FloatVectorT>
inline float
127 JM_Norm (FloatVectorT a, FloatVectorT b,
int dim)
131 for (
int i = 0; i < dim; ++i)
132 norm += (std::sqrt (a[i]) - std::sqrt (b[i])) * (std::sqrt (a[i]) - std::sqrt (b[i]));
134 return std::sqrt (norm);
138 template <
typename FloatVectorT>
inline float
139 B_Norm (FloatVectorT a, FloatVectorT b,
int dim)
141 float norm = 0.0, result;
143 for (
int i = 0; i < dim; ++i)
144 norm += std::sqrt (a[i] * b[i]);
147 result = -logf (norm);
155 template <
typename FloatVectorT>
inline float
160 for (
int i = 0; i < dim; ++i)
161 norm += std::sqrt (fabsf (a[i] - b[i]));
167 template <
typename FloatVectorT>
inline float
168 CS_Norm (FloatVectorT a, FloatVectorT b,
int dim)
172 for (
int i = 0; i < dim; ++i)
173 if ((a[i] + b[i]) != 0)
174 norm += (a[i] - b[i]) * (a[i] - b[i]) / (a[i] + b[i]);
181 template <
typename FloatVectorT>
inline float
186 for (
int i = 0; i < dim; ++i)
187 if ((a[i] / b[i]) > 0)
188 norm += (a[i] - b[i]) * logf (a[i] / b[i]);
195 template <
typename FloatVectorT>
inline float
196 PF_Norm (FloatVectorT a, FloatVectorT b,
int dim,
float P1,
float P2)
200 for (
int i = 0; i < dim; ++i)
201 norm += (P1 * a[i] - P2 * b[i]) * (P1 * a[i] - P2 * b[i]);
202 return std::sqrt (norm);
206 template <
typename FloatVectorT>
inline float
207 K_Norm (FloatVectorT a, FloatVectorT b,
int dim,
float P1,
float P2)
211 for (
int i = 0; i < dim; ++i)
212 norm += fabsf (P1 * a[i] - P2 * b[i]);
217 template <
typename FloatVectorT>
inline float
218 KL_Norm (FloatVectorT a, FloatVectorT b,
int dim)
222 for (
int i = 0; i < dim; ++i)
223 if ( (b[i] != 0) && ((a[i] / b[i]) > 0) )
224 norm += a[i] * logf (a[i] / b[i]);
231 template <
typename FloatVectorT>
inline float
235 for (
int i = 0; i < dim; ++i)
236 norm += (std::min)(a[i], b[i]);
float CS_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the CS norm of the vector between two points.
This file defines compatibility wrappers for low level I/O functions.
float Sublinear_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the sublinear norm of the vector between two points.
float JM_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the JM norm of the vector between two points.
float HIK_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the HIK norm of the vector between two points.
float B_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the B norm of the vector between two points.
float PF_Norm(FloatVectorT a, FloatVectorT b, int dim, float P1, float P2)
Compute the PF norm of the vector between two points.
float L2_Norm_SQR(FloatVectorT a, FloatVectorT b, int dim)
Compute the squared L2 norm of the vector between two points.
float K_Norm(FloatVectorT a, FloatVectorT b, int dim, float P1, float P2)
Compute the K norm of the vector between two points.
float selectNorm(FloatVectorT a, FloatVectorT b, int dim, NormType norm_type)
Method that calculates any norm type available, based on the norm_type variable.
float Linf_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the L-infinity norm of the vector between two points.
float L1_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the L1 norm of the vector between two points.
float Div_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the div norm of the vector between two points.
NormType
Enum that defines all the types of norms available.
float KL_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the KL between two discrete probability density functions.
float L2_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the L2 norm of the vector between two points.