Point Cloud Library (PCL)  1.14.1-dev
norms.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  */
38 
39 #pragma once
40 
41 /**
42  * \file norms.h
43  * Define standard C methods to calculate different norms
44  * \ingroup common
45  */
46 
47 /*@{*/
48 namespace pcl
49 {
50  /** \brief Enum that defines all the types of norms available.
51  * \note Any new norm type should have its own enum value and its own case in the selectNorm () method
52  * \ingroup common
53  */
54  enum NormType {L1, L2_SQR, L2, LINF, JM, B, SUBLINEAR, CS, DIV, PF, K, KL, HIK};
55 
56  /** \brief Method that calculates any norm type available, based on the norm_type variable
57  * \note FloatVectorT is any type of vector with its values accessible via [ ]
58  * \ingroup common
59  * */
60  template <typename FloatVectorT> inline float
61  selectNorm (FloatVectorT A, FloatVectorT B, int dim, NormType norm_type);
62 
63  /** \brief Compute the L1 norm of the vector between two points
64  * \param A the first point
65  * \param B the second point
66  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
67  * \note FloatVectorT is any type of vector with its values accessible via [ ]
68  * \ingroup common
69  */
70  template <typename FloatVectorT> inline float
71  L1_Norm (FloatVectorT A, FloatVectorT B, int dim);
72 
73  /** \brief Compute the squared L2 norm of the vector between two points
74  * \param A the first point
75  * \param B the second point
76  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
77  * \note FloatVectorT is any type of vector with its values accessible via [ ]
78  * \ingroup common
79  */
80  template <typename FloatVectorT> inline float
81  L2_Norm_SQR (FloatVectorT A, FloatVectorT B, int dim);
82 
83  /** \brief Compute the L2 norm of the vector between two points
84  * \param A the first point
85  * \param B the second point
86  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
87  * \note FloatVectorT is any type of vector with its values accessible via [ ]
88  * \ingroup common
89  */
90  template <typename FloatVectorT> inline float
91  L2_Norm (FloatVectorT A, FloatVectorT B, int dim);
92 
93  /** \brief Compute the L-infinity norm of the vector between two points
94  * \param A the first point
95  * \param B the second point
96  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
97  * \note FloatVectorT is any type of vector with its values accessible via [ ]
98  * \ingroup common
99  */
100  template <typename FloatVectorT> inline float
101  Linf_Norm (FloatVectorT A, FloatVectorT B, int dim);
102 
103  /** \brief Compute the JM norm of the vector between two points
104  * \param A the first point
105  * \param B the second point
106  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
107  * \note FloatVectorT is any type of vector with its values accessible via [ ]
108  * \ingroup common
109  */
110  template <typename FloatVectorT> inline float
111  JM_Norm (FloatVectorT A, FloatVectorT B, int dim);
112 
113  /** \brief Compute the B norm of the vector between two points
114  * \param A the first point
115  * \param B the second point
116  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
117  * \note FloatVectorT is any type of vector with its values accessible via [ ]
118  * \ingroup common
119  */
120  template <typename FloatVectorT> inline float
121  B_Norm (FloatVectorT A, FloatVectorT B, int dim);
122 
123  /** \brief Compute the sublinear norm of the vector between two points
124  * \param A the first point
125  * \param B the second point
126  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
127  * \note FloatVectorT is any type of vector with its values accessible via [ ]
128  * \ingroup common
129  */
130  template <typename FloatVectorT> inline float
131  Sublinear_Norm (FloatVectorT A, FloatVectorT B, int dim);
132 
133  /** \brief Compute the CS norm of the vector between two points
134  * \param A the first point
135  * \param B the second point
136  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
137  * \note FloatVectorT is any type of vector with its values accessible via [ ]
138  * \ingroup common
139  */
140  template <typename FloatVectorT> inline float
141  CS_Norm (FloatVectorT A, FloatVectorT B, int dim);
142 
143  /** \brief Compute the div norm of the vector between two points
144  * \param A the first point
145  * \param B the second point
146  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
147  * \note FloatVectorT is any type of vector with its values accessible via [ ]
148  * \ingroup common
149  */
150  template <typename FloatVectorT> inline float
151  Div_Norm (FloatVectorT A, FloatVectorT B, int dim);
152 
153  /** \brief Compute the PF norm of the vector between two points
154  * \param A the first point
155  * \param B the second point
156  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
157  * \param P1 the first parameter
158  * \param P2 the second parameter
159  * \note FloatVectorT is any type of vector with its values accessible via [ ]
160  * \ingroup common
161  */
162  template <typename FloatVectorT> inline float
163  PF_Norm (FloatVectorT A, FloatVectorT B, int dim, float P1, float P2);
164 
165  /** \brief Compute the K norm of the vector between two points
166  * \param A the first point
167  * \param B the second point
168  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
169  * \param P1 the first parameter
170  * \param P2 the second parameter
171  * \note FloatVectorT is any type of vector with its values accessible via [ ]
172  * \ingroup common
173  */
174  template <typename FloatVectorT> inline float
175  K_Norm (FloatVectorT A, FloatVectorT B, int dim, float P1, float P2);
176 
177  /** \brief Compute the KL between two discrete probability density functions
178  * \param A the first discrete PDF
179  * \param B the second discrete PDF
180  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
181  * \note FloatVectorT is any type of vector with its values accessible via [ ]
182  * \ingroup common
183  */
184  template <typename FloatVectorT> inline float
185  KL_Norm (FloatVectorT A, FloatVectorT B, int dim);
186 
187  /** \brief Compute the HIK norm of the vector between two points
188  * \param A the first point
189  * \param B the second point
190  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
191  * \note FloatVectorT is any type of vector with its values accessible via [ ]
192  * \ingroup common
193  */
194  template <typename FloatVectorT> inline float
195  HIK_Norm (FloatVectorT A, FloatVectorT B, int dim);
196 }
197 /*@}*/
198 #include <pcl/common/impl/norms.hpp>
float selectNorm(FloatVectorT a, FloatVectorT b, int dim, NormType norm_type)
Method that calculates any norm type available, based on the norm_type variable.
Definition: norms.hpp:50
float B_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the B norm of the vector between two points.
Definition: norms.hpp:140
float KL_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the KL between two discrete probability density functions.
Definition: norms.hpp:219
float JM_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the JM norm of the vector between two points.
Definition: norms.hpp:128
float K_Norm(FloatVectorT a, FloatVectorT b, int dim, float P1, float P2)
Compute the K norm of the vector between two points.
Definition: norms.hpp:208
float L1_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the L1 norm of the vector between two points.
Definition: norms.hpp:88
float Linf_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the L-infinity norm of the vector between two points.
Definition: norms.hpp:118
float L2_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the L2 norm of the vector between two points.
Definition: norms.hpp:111
float CS_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the CS norm of the vector between two points.
Definition: norms.hpp:169
float HIK_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the HIK norm of the vector between two points.
Definition: norms.hpp:233
NormType
Enum that defines all the types of norms available.
Definition: norms.h:54
float Sublinear_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the sublinear norm of the vector between two points.
Definition: norms.hpp:157
float Div_Norm(FloatVectorT a, FloatVectorT b, int dim)
Compute the div norm of the vector between two points.
Definition: norms.hpp:183
float L2_Norm_SQR(FloatVectorT a, FloatVectorT b, int dim)
Compute the squared L2 norm of the vector between two points.
Definition: norms.hpp:98
float PF_Norm(FloatVectorT a, FloatVectorT b, int dim, float P1, float P2)
Compute the PF norm of the vector between two points.
Definition: norms.hpp:197
@ HIK
Definition: norms.h:54
@ SUBLINEAR
Definition: norms.h:54
@ PF
Definition: norms.h:54
@ K
Definition: norms.h:54
@ LINF
Definition: norms.h:54
@ L2
Definition: norms.h:54
@ DIV
Definition: norms.h:54
@ KL
Definition: norms.h:54
@ L2_SQR
Definition: norms.h:54
@ B
Definition: norms.h:54
@ L1
Definition: norms.h:54
@ CS
Definition: norms.h:54
@ JM
Definition: norms.h:54