YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
RandVector.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
8#include <yarp/sig/Vector.h>
9
10using namespace yarp::sig;
11using namespace yarp::math;
12using namespace yarp::math::impl;
13
14RandVector::RandVector(int s)
15{
16 data.resize(s);
17}
18
20{
21 data.resize(s);
22}
23
25{
26 rnd.init();
27}
28
29void RandVector::init(int seed)
30{
31 rnd.init(seed);
32}
33
35{
36 for (size_t k=0;k<data.size(); k++)
37 {
38 data[k]=rnd.get();
39 }
40
41 return data;
42}
43
44const Vector &RandVector::get(const Vector &min, const Vector &max)
45{
46 for (size_t k=0;k<data.size(); k++)
47 {
48 data[k]=rnd.get(min[k], max[k]);
49 }
50
51 return data;
52}
contains the definition of a Vector type
void init()
Initialize the random generator using current time (time(0)).
double get()
Generate a random number from a uniform distribution.
const yarp::sig::Vector & get()
void resize(size_t size) override
Resize the vector.
Definition Vector.h:221
size_t size() const
Definition Vector.h:341