Point Cloud Library (PCL)  1.7.0
norms.h
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 #ifndef PCL_COMMON_NORMS_H_
40 #define PCL_COMMON_NORMS_H_
41 
42 /**
43  * \file norms.h
44  * Define standard C methods to calculate different norms
45  * \ingroup common
46  */
47 
48 /*@{*/
49 namespace pcl
50 {
51  /** \brief Enum that defines all the types of norms available.
52  * \note Any new norm type should have its own enum value and its own case in the selectNorm () method
53  * \ingroup common
54  */
55  enum NormType {L1, L2_SQR, L2, LINF, JM, B, SUBLINEAR, CS, DIV, PF, K, KL, HIK};
56 
57  /** \brief Method that calculates any norm type available, based on the norm_type variable
58  * \note FloatVectorT is any type of vector with its values accessible via [ ]
59  * \ingroup common
60  * */
61  template <typename FloatVectorT> inline float
62  selectNorm (FloatVectorT A, FloatVectorT B, int dim, NormType norm_type);
63 
64  /** \brief Compute the L1 norm of the vector between two points
65  * \param A the first point
66  * \param B the second point
67  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
68  * \note FloatVectorT is any type of vector with its values accessible via [ ]
69  * \ingroup common
70  */
71  template <typename FloatVectorT> inline float
72  L1_Norm (FloatVectorT A, FloatVectorT B, int dim);
73 
74  /** \brief Compute the squared L2 norm of the vector between two points
75  * \param A the first point
76  * \param B the second point
77  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
78  * \note FloatVectorT is any type of vector with its values accessible via [ ]
79  * \ingroup common
80  */
81  template <typename FloatVectorT> inline float
82  L2_Norm_SQR (FloatVectorT A, FloatVectorT B, int dim);
83 
84  /** \brief Compute the L2 norm of the vector between two points
85  * \param A the first point
86  * \param B the second point
87  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
88  * \note FloatVectorT is any type of vector with its values accessible via [ ]
89  * \ingroup common
90  */
91  template <typename FloatVectorT> inline float
92  L2_Norm (FloatVectorT A, FloatVectorT B, int dim);
93 
94  /** \brief Compute the L-infinity norm of the vector between two points
95  * \param A the first point
96  * \param B the second point
97  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
98  * \note FloatVectorT is any type of vector with its values accessible via [ ]
99  * \ingroup common
100  */
101  template <typename FloatVectorT> inline float
102  Linf_Norm (FloatVectorT A, FloatVectorT B, int dim);
103 
104  /** \brief Compute the JM norm of the vector between two points
105  * \param A the first point
106  * \param B the second point
107  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
108  * \note FloatVectorT is any type of vector with its values accessible via [ ]
109  * \ingroup common
110  */
111  template <typename FloatVectorT> inline float
112  JM_Norm (FloatVectorT A, FloatVectorT B, int dim);
113 
114  /** \brief Compute the B norm of the vector between two points
115  * \param A the first point
116  * \param B the second point
117  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
118  * \note FloatVectorT is any type of vector with its values accessible via [ ]
119  * \ingroup common
120  */
121  template <typename FloatVectorT> inline float
122  B_Norm (FloatVectorT A, FloatVectorT B, int dim);
123 
124  /** \brief Compute the sublinear norm of the vector between two points
125  * \param A the first point
126  * \param B the second point
127  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
128  * \note FloatVectorT is any type of vector with its values accessible via [ ]
129  * \ingroup common
130  */
131  template <typename FloatVectorT> inline float
132  Sublinear_Norm (FloatVectorT A, FloatVectorT B, int dim);
133 
134  /** \brief Compute the CS norm of the vector between two points
135  * \param A the first point
136  * \param B the second point
137  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
138  * \note FloatVectorT is any type of vector with its values accessible via [ ]
139  * \ingroup common
140  */
141  template <typename FloatVectorT> inline float
142  CS_Norm (FloatVectorT A, FloatVectorT B, int dim);
143 
144  /** \brief Compute the div norm of the vector between two points
145  * \param A the first point
146  * \param B the second point
147  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
148  * \note FloatVectorT is any type of vector with its values accessible via [ ]
149  * \ingroup common
150  */
151  template <typename FloatVectorT> inline float
152  Div_Norm (FloatVectorT A, FloatVectorT B, int dim);
153 
154  /** \brief Compute the PF norm of the vector between two points
155  * \param A the first point
156  * \param B the second point
157  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
158  * \param P1 the first parameter
159  * \param P2 the second parameter
160  * \note FloatVectorT is any type of vector with its values accessible via [ ]
161  * \ingroup common
162  */
163  template <typename FloatVectorT> inline float
164  PF_Norm (FloatVectorT A, FloatVectorT B, int dim, float P1, float P2);
165 
166  /** \brief Compute the K norm of the vector between two points
167  * \param A the first point
168  * \param B the second point
169  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
170  * \param P1 the first parameter
171  * \param P2 the second parameter
172  * \note FloatVectorT is any type of vector with its values accessible via [ ]
173  * \ingroup common
174  */
175  template <typename FloatVectorT> inline float
176  K_Norm (FloatVectorT A, FloatVectorT B, int dim, float P1, float P2);
177 
178  /** \brief Compute the KL between two discrete probability density functions
179  * \param A the first discrete PDF
180  * \param B the second discrete PDF
181  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
182  * \note FloatVectorT is any type of vector with its values accessible via [ ]
183  * \ingroup common
184  */
185  template <typename FloatVectorT> inline float
186  KL_Norm (FloatVectorT A, FloatVectorT B, int dim);
187 
188  /** \brief Compute the HIK norm of the vector between two points
189  * \param A the first point
190  * \param B the second point
191  * \param dim the number of dimensions in \a A and \a B (dimensions must match)
192  * \note FloatVectorT is any type of vector with its values accessible via [ ]
193  * \ingroup common
194  */
195  template <typename FloatVectorT> inline float
196  HIK_Norm (FloatVectorT A, FloatVectorT B, int dim);
197 }
198 /*@}*/
199 #include <pcl/common/impl/norms.hpp>
200 
201 #endif //#ifndef PCL_NORMS_H_