Main MRPT website > C++ reference for MRPT 1.9.9
model_search.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "base-precomp.h" // Precompiled headers
11 
12 #include <mrpt/math/model_search.h>
13 
14 using namespace mrpt;
15 using namespace mrpt::math;
16 
17 //----------------------------------------------------------------------
18 //! Select random (unique) indices from the 0..p_size sequence
20  size_t p_size, size_t p_pick, vector_size_t& p_ind)
21 {
22  ASSERT_(p_size >= p_pick);
23 
24  vector_size_t a(p_size);
25  for (size_t i = 0; i < p_size; i++) a[i] = i;
26 
27  std::random_shuffle(a.begin(), a.end());
28  p_ind.resize(p_pick);
29  for (size_t i = 0; i < p_pick; i++) p_ind[i] = a[i];
30 }
31 
32 //----------------------------------------------------------------------
33 //! Select random (unique) indices from the set.
34 //! The set is destroyed during pick
36  std::set<size_t> p_set, size_t p_pick, vector_size_t& p_ind)
37 {
38  p_ind.resize(p_pick);
39  vector_size_t inds(p_set.begin(), p_set.end());
40 
41  std::random_shuffle(inds.begin(), inds.end());
42  p_ind.resize(p_pick);
43  for (size_t i = 0; i < p_pick; i++) p_ind[i] = inds[i];
44 }
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void pickRandomIndex(size_t p_size, size_t p_pick, vector_size_t &p_ind)
Select random (unique) indices from the 0..p_size sequence.
#define ASSERT_(f)
std::vector< size_t > vector_size_t
Definition: types_simple.h:26
GLubyte GLubyte GLubyte a
Definition: glext.h:6279



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019