Go to the documentation of this file.
8 #ifndef RTABMAP_CENTER_CHOOSER_H_
9 #define RTABMAP_CENTER_CHOOSER_H_
16 template <
typename Distance,
typename ElementType>
24 template <
typename ElementType>
31 template <
typename ElementType>
38 template <
typename ElementType>
46 template <
typename ElementType>
54 template <
typename ElementType>
62 template <
typename Distance>
65 typedef typename Distance::ElementType ElementType;
73 template <
typename Distance>
95 virtual void operator()(
int k,
int* indices,
int indices_length,
int* centers,
int& centers_length) = 0;
104 template <
typename Distance>
117 void operator()(
int k,
int* indices,
int indices_length,
int* centers,
int& centers_length)
122 for (index=0; index<k; ++index) {
123 bool duplicate =
true;
129 centers_length = index;
135 for (
int j=0;
j<index; ++
j) {
144 centers_length = index;
153 template <
typename Distance>
167 void operator()(
int k,
int* indices,
int indices_length,
int* centers,
int& centers_length)
169 int n = indices_length;
172 assert(rnd >=0 && rnd <
n);
177 for (index=1; index<k; ++index) {
181 for (
int j=0;
j<
n; ++
j) {
183 for (
int i=1;
i<index; ++
i) {
194 if (best_index!=-1) {
195 centers[index] =
indices[best_index];
201 centers_length = index;
210 template <
typename Distance>
224 void operator()(
int k,
int* indices,
int indices_length,
int* centers,
int& centers_length)
226 int n = indices_length;
228 double currentPot = 0;
233 assert(index >=0 && index <
n);
238 for (
int i = 0;
i <
n;
i++) {
240 closestDistSq[
i] = ensureSquareDistance<Distance>( closestDistSq[
i] );
241 currentPot += closestDistSq[
i];
245 const int numLocalTries = 1;
249 for (centerCount = 1; centerCount < k; centerCount++) {
252 double bestNewPot = -1;
253 int bestNewIndex = 0;
254 for (
int localTrial = 0; localTrial < numLocalTries; localTrial++) {
259 for (index = 0; index <
n-1; index++) {
260 if (randVal <= closestDistSq[index])
break;
261 else randVal -= closestDistSq[index];
266 for (
int i = 0;
i <
n;
i++) {
268 newPot +=
std::min( ensureSquareDistance<Distance>(
dist), closestDistSq[
i] );
272 if ((bestNewPot < 0)||(newPot < bestNewPot)) {
274 bestNewIndex = index;
279 centers[centerCount] =
indices[bestNewIndex];
280 currentPot = bestNewPot;
281 for (
int i = 0;
i <
n;
i++) {
283 closestDistSq[
i] =
std::min( ensureSquareDistance<Distance>(
dist), closestDistSq[
i] );
287 centers_length = centerCount;
289 delete[] closestDistSq;
306 template <
typename Distance>
320 void operator()(
int k,
int* indices,
int indices_length,
int* centers,
int& centers_length)
322 const float kSpeedUpFactor = 1.3f;
324 int n = indices_length;
330 assert(index >=0 && index <
n);
333 for (
int i = 0;
i <
n;
i++) {
340 for (centerCount = 1; centerCount < k; centerCount++) {
343 double bestNewPot = -1;
344 int bestNewIndex = 0;
346 for (index = 0; index <
n; index++) {
349 if( closestDistSq[index] > kSpeedUpFactor * (
float)furthest ) {
353 for (
int i = 0;
i <
n;
i++) {
355 , closestDistSq[
i] );
359 if ((bestNewPot < 0)||(newPot <= bestNewPot)) {
361 bestNewIndex = index;
362 furthest = closestDistSq[index];
368 centers[centerCount] =
indices[bestNewIndex];
369 for (
int i = 0;
i <
n;
i++) {
371 , closestDistSq[
i] );
375 centers_length = centerCount;
377 delete[] closestDistSq;
GLM_FUNC_DECL genType min(genType const &x, genType const &y)
Distance::ElementType ElementType
void operator()(int k, int *indices, int indices_length, int *centers, int ¢ers_length)
ResultType operator()(ResultType dist)
Distance::ResultType ResultType
Distance::ElementType ElementType
Distance::ResultType DistanceType
L2< ElementType >::ResultType ResultType
Distance::ElementType ElementType
Distance::ElementType ElementType
ResultType operator()(ResultType dist)
CenterChooser(const Distance &distance, const std::vector< ElementType * > &points)
int rand_int(int high=RAND_MAX, int low=0)
Distance::ResultType DistanceType
virtual void operator()(int k, int *indices, int indices_length, int *centers, int ¢ers_length)=0
L2_3D< ElementType >::ResultType ResultType
Distance::ResultType DistanceType
GonzalesCenterChooser(const Distance &distance, const std::vector< ElementType * > &points)
Distance::ResultType ensureSquareDistance(typename Distance::ResultType dist)
ResultType operator()(ResultType dist)
void operator()(int k, int *indices, int indices_length, int *centers, int ¢ers_length)
KMeansppCenterChooser(const Distance &distance, const std::vector< ElementType * > &points)
Distance::ResultType DistanceType
double rand_double(double high=1.0, double low=0)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
ChiSquareDistance< ElementType >::ResultType ResultType
Distance::ElementType ElementType
HellingerDistance< ElementType >::ResultType ResultType
ResultType operator()(ResultType dist)
const std::vector< ElementType * > & points_
void setDataSize(size_t cols)
Distance::ResultType DistanceType
ResultType operator()(ResultType dist)
ResultType operator()(ResultType dist)
Double_ distance(const OrientedPlane3_ &p)
void operator()(int k, int *indices, int indices_length, int *centers, int ¢ers_length)
GroupWiseCenterChooser(const Distance &distance, const std::vector< ElementType * > &points)
void operator()(int k, int *indices, int indices_length, int *centers, int ¢ers_length)
RandomCenterChooser(const Distance &distance, const std::vector< ElementType * > &points)
L2_Simple< ElementType >::ResultType ResultType
rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:07