cisst-saw
Loading...
Searching...
No Matches
cmnRandomSequence.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4/*
5
6 Author(s): Ofri Sadowsky, Anton Deguet
7 Created on: 2003-06-09
8
9 (C) Copyright 2003-2013 Johns Hopkins University (JHU), All Rights
10 Reserved.
11
12--- begin cisst license - do not edit ---
13
14This software is provided "as is" under an open source license, with
15no warranty. The complete license can be found in license.txt and
16http://www.cisst.org/cisst/license.txt.
17
18--- end cisst license ---
19
20*/
21
22
27#pragma once
28
29#ifndef _cmnRandomSequence_h
30#define _cmnRandomSequence_h
31
33
34#include <stdlib.h>
35#include <cstddef>
36
38
67{
68public:
71 typedef unsigned int SeedType;
72
76
79 typedef unsigned long SequenceCounterType;
80
83 static const SeedType DefaultSeed;
84
88
92
93protected:
101
106 cmnRandomSequence(const SeedType seed, const SequenceCounterType position = 0) {
107 SetSeed(seed);
108 SetSequencePosition(position);
109 }
110
119
124 SetSeed(other.GetSeed());
126 return *this;
127 }
128
133
134public:
139 return RandomInstance;
140 }
141
145 SeedType GetSeed(void) const {
146 return Seed;
147 }
148
152 void SetSeed(const SeedType seed) {
153 Seed = seed;
154 SequencePosition = 0;
155 srand(Seed);
156 }
157
162 return SequencePosition;
163 }
164
170 SetSeed(GetSeed());
171 while (GetSequencePosition() < position) {
173 }
174 }
175
176
181 ++SequencePosition;
182 return rand();
183 }
184
186
189 template <typename _valueType>
190 void ExtractRandomValue(_valueType & result);
191
192 template <typename _valueType>
193 inline void ExtractRandomValue(const _valueType min, const _valueType max, _valueType & result);
194
195 template <typename _valueType>
196 inline void ExtractRandomValueArray(const _valueType min, const _valueType max, _valueType * array,
197 const size_t arraySize);
199
201 float ExtractRandomFloat(void) {
203 float myPosition = static_cast<float>(randomNumber) - static_cast<float>(LowerRandomBound);
204 float randomFloat = myPosition / (static_cast<float>(UpperRandomBound) - static_cast<float>(LowerRandomBound) + 1);
205 return randomFloat;
206 }
207
208 float ExtractRandomFloat(const float min, const float max) {
209 const float randomFloat = ExtractRandomFloat();
210 return (randomFloat * (max - min)) + min;
211 }
212 void ExtractRandomFloatArray(const float min, const float max, float * array,
213 const size_t arraySize) {
214 for (size_t i = 0; i < arraySize; ++i, ++array) {
215 *array = ExtractRandomFloat(min, max);
216 }
217 }
218
220 double ExtractRandomDouble(void) {
221 return (static_cast<double>(ExtractRandomElement()) - static_cast<double>(LowerRandomBound)) / (static_cast<double>(UpperRandomBound) - static_cast<double>(LowerRandomBound) + 1);
222 }
223
224 double ExtractRandomDouble(const double min, const double max) {
225 const double randomDouble = ExtractRandomDouble();
226 return (randomDouble * (max - min)) + min;
227 }
228 void ExtractRandomDoubleArray(const double min, const double max, double *array,
229 const size_t arraySize) {
230 for (size_t i = 0; i < arraySize; ++i, ++array) {
231 *array = ExtractRandomDouble(min, max);
232 }
233 }
234
236 return ExtractRandomElement();
237 }
238 int ExtractRandomInt(const int min, const int max) {
239 const float randomFloat = ExtractRandomFloat();
240 return static_cast<int>((randomFloat * (max - min)) + min); }
241
242 void ExtractRandomIntArray(const int min, const int max, int *array,
243 const size_t arraySize) {
244 for (size_t i = 0; i < arraySize; ++i, ++array) {
245 *array = ExtractRandomInt(min, max);
246 }
247 }
248
249 unsigned int ExtractRandomUnsignedInt(void) {
250 int randomInt = ExtractRandomElement();
251 return static_cast<unsigned int>(randomInt);
252 }
253 unsigned int ExtractRandomUnsignedInt(const unsigned int min, const unsigned int max) {
254 const float randomFloat = ExtractRandomFloat();
255 return static_cast<unsigned int>((randomFloat * (max - min)) + min);
256 }
257 void ExtractRandomUnsignedIntArray(const unsigned int min, const unsigned int max, unsigned int *array,
258 const size_t arraySize) {
259 for (size_t i = 0; i < arraySize; ++i, ++array) {
260 *array = ExtractRandomUnsignedInt(min, max);
261 }
262 }
263
264 short ExtractRandomShort(void) {
265 return static_cast<short>(ExtractRandomElement()&0xffff);
266 }
267 short ExtractRandomShort(const short min, const short max) {
268 const float randomFloat = ExtractRandomFloat();
269 return static_cast<short>((randomFloat * (max - min)) + min);
270 }
271 void ExtractRandomShortArray(const short min, const short max, short *array,
272 const size_t arraySize) {
273 for (size_t i = 0; i < arraySize; ++i, ++array) {
274 *array = ExtractRandomShort(min, max);
275 }
276 }
277
278 unsigned short ExtractRandomUnsignedShort(void) {
279 int randomInt = ExtractRandomElement();
280 return static_cast<unsigned short>((0xff) & randomInt);
281 }
282 unsigned short ExtractRandomUnsignedShort(const unsigned short min, const unsigned short max) {
283 const float randomFloat = ExtractRandomFloat();
284 return static_cast<unsigned short>((randomFloat * (max - min)) + min);
285 }
286 void ExtractRandomUnsignedShortArray(const unsigned short min, const unsigned short max, unsigned short *array,
287 const size_t arraySize) {
288 for (size_t i = 0; i < arraySize; ++i, ++array) {
289 *array = ExtractRandomUnsignedShort(min, max);
290 }
291 }
292
293 inline long ExtractRandomLong(void) {
294#if (CISST_DATA_MODEL == CISST_LP64)
295 // long are 64 bits so we can cast from long long
296 return ExtractRandomLongLong();
297#else
298 // long are 32 bits so we can cast from int
299 return ExtractRandomInt();
300#endif
301 }
302 inline long ExtractRandomLong(const long min, const long max) {
303 const float randomFloat = ExtractRandomFloat();
304 return static_cast<long>((randomFloat * (max - min)) + min);
305 }
306 inline void ExtractRandomLongArray(const long min, const long max, long * array,
307 const size_t arraySize) {
308 for (size_t i = 0; i < arraySize; ++i, ++array)
309 *array = ExtractRandomLong(min, max);
310 }
311
312 inline unsigned long ExtractRandomUnsignedLong(void) {
313#if (CISST_DATA_MODEL == CISST_LP64)
314 // long are 64 bits so we can cast from long long
316#else
317 // long are 32 bits so we can cast from int
319#endif
320
321 }
322 inline unsigned long ExtractRandomUnsignedLong(const unsigned long min, const unsigned long max) {
323 const double randomDouble = ExtractRandomDouble();
324 return static_cast<unsigned long >((randomDouble * (max - min)) + min);
325 }
326 inline void ExtractRandomUnsignedLongArray(const unsigned long min, const unsigned long max, unsigned long * array,
327 const size_t arraySize) {
328 for (size_t i = 0; i < arraySize; ++i, ++array) {
329 *array = ExtractRandomUnsignedLong(min, max);
330 }
331 }
332
333 inline long long ExtractRandomLongLong(void) {
334 // create 64 random bits
335 long long int result;
336 int * part = reinterpret_cast<int *>(&result);
337 *part = ExtractRandomElement();
338 part++;
339 *part = ExtractRandomElement();
340 return result;
341
342 }
343 inline long ExtractRandomLongLong(const long long min, const long long max) {
344 const float randomFloat = ExtractRandomFloat();
345 return static_cast<long long>((randomFloat * (max - min)) + min);
346 }
347 inline void ExtractRandomLongLongArray(const long long min, const long long max, long long * array,
348 const size_t arraySize) {
349 for (size_t i = 0; i < arraySize; ++i, ++array) {
350 *array = ExtractRandomLongLong(min, max);
351 }
352 }
353
354 inline unsigned long long ExtractRandomUnsignedLongLong(void) {
355 // create 64 random bits
356 unsigned long long int result;
357 int * part = reinterpret_cast<int *>(&result);
358 *part = ExtractRandomElement();
359 part++;
360 *part = ExtractRandomElement();
361 return result;
362 }
363 inline unsigned long long ExtractRandomUnsignedLongLong(const unsigned long long min, const unsigned long long max) {
364 const double randomDouble = ExtractRandomDouble();
365 return static_cast<unsigned long long >((randomDouble * (max - min)) + min);
366 }
367 inline void ExtractRandomUnsignedLongLongArray(const unsigned long long min, const unsigned long long max, unsigned long long * array,
368 const size_t arraySize) {
369 for (size_t i = 0; i < arraySize; ++i, ++array) {
370 *array = ExtractRandomUnsignedLongLong(min, max);
371 }
372 }
373
374 char ExtractRandomChar(void) {
375 int randomInt = ExtractRandomElement();
376 return static_cast<char>((0xff) & randomInt);
377 }
378 char ExtractRandomChar(const char min, const char max) {
379 const float randomFloat = ExtractRandomFloat();
380 return static_cast<char>((randomFloat * (max - min)) + min);
381 }
382 void ExtractRandomCharArray(const char min, const char max, char *array,
383 const size_t arraySize) {
384 for (size_t i = 0; i < arraySize; ++i, ++array) {
385 *array = ExtractRandomChar(min, max);
386 }
387 }
388
389 unsigned char ExtractRandomUnsignedChar(void) {
390 int randomInt = ExtractRandomElement();
391 return static_cast<unsigned char>((0xff) & randomInt);
392 }
393 unsigned char ExtractRandomUnsignedChar(const unsigned char min, const unsigned char max) {
394 const float randomFloat = ExtractRandomFloat();
395 return static_cast<unsigned char>((randomFloat * (max - min)) + min);
396 }
397 void ExtractRandomUnsignedCharArray(const unsigned char min, const unsigned char max, unsigned char *array,
398 const size_t arraySize) {
399 for (size_t i = 0; i < arraySize; ++i, ++array) {
400 *array = ExtractRandomUnsignedChar(min, max);
401 }
402 }
403
405 void ExtractRandomPermutation(const size_t length, size_t * array);
406
415 size_t ExtractRandomSizeT(const size_t min, const size_t max) {
416 const float randomFloat = ExtractRandomFloat();
417 return static_cast<size_t>((randomFloat * (max - min)) + min);
418 }
419 void ExtractRandomSizeTArray(const size_t min, const size_t max, size_t * array,
420 const size_t arraySize) {
421 for (size_t i = 0; i < arraySize; ++i, ++array) {
422 *array = ExtractRandomSizeT(min, max);
423 }
424 }
425
426 ptrdiff_t ExtractRandomPtrdiffT(const ptrdiff_t min, const ptrdiff_t max) {
427 const float randomFloat = ExtractRandomFloat();
428 return static_cast<ptrdiff_t>((randomFloat * (max - min)) + min);
429 }
430 void ExtractRandomPtrdiffTArray(const ptrdiff_t min, const ptrdiff_t max, ptrdiff_t * array,
431 const size_t arraySize) {
432 for (size_t i = 0; i < arraySize; ++i, ++array) {
433 *array = ExtractRandomPtrdiffT(min, max);
434 }
435 }
436
437
438private:
441 SeedType Seed;
442
445 SequenceCounterType SequencePosition;
446
447};
448
449
450/* Specializations of cmnRandomSequence::ExtractRandomValue */
451#ifndef DOXYGEN
452/* --- float --- */
456void cmnRandomSequence::ExtractRandomValue<float>(const float min, const float max, float & result);
458void cmnRandomSequence::ExtractRandomValueArray<float>(const float min, const float max, float * array,
459 const size_t arraySize);
460
461/* --- double --- */
465void cmnRandomSequence::ExtractRandomValue<double>(const double min, const double max, double & result);
467void cmnRandomSequence::ExtractRandomValueArray<double>(const double min, const double max, double * array,
468 const size_t arraySize);
469
470/* --- int --- */
474void cmnRandomSequence::ExtractRandomValue<int>(const int min, const int max, int & result);
476void cmnRandomSequence::ExtractRandomValueArray<int>(const int min, const int max, int * array,
477 const size_t arraySize);
478/* --- unsigned int --- */
482void cmnRandomSequence::ExtractRandomValue<unsigned int>(const unsigned int min, const unsigned int max, unsigned int & result);
484void cmnRandomSequence::ExtractRandomValueArray<unsigned int>(const unsigned int min, const unsigned int max, unsigned int * array,
485 const size_t arraySize);
486
487/* --- short --- */
491void cmnRandomSequence::ExtractRandomValue<short>(const short min, const short max, short & result);
493void cmnRandomSequence::ExtractRandomValueArray<short>(const short min, const short max, short * array,
494 const size_t arraySize);
495/* --- unsigned short --- */
499void cmnRandomSequence::ExtractRandomValue<unsigned short>(const unsigned short min, const unsigned short max, unsigned short & result);
501void cmnRandomSequence::ExtractRandomValueArray<unsigned short>(const unsigned short min, const unsigned short max, unsigned short * array,
502 const size_t arraySize);
503
504/* --- long --- */
508void cmnRandomSequence::ExtractRandomValue<long>(const long min, const long max, long & result);
510void cmnRandomSequence::ExtractRandomValueArray<long>(const long min, const long max, long * array,
511 const size_t arraySize);
512
513/* --- unsigned long --- */
517void cmnRandomSequence::ExtractRandomValue<unsigned long>(const unsigned long min, const unsigned long max, unsigned long & result);
519void cmnRandomSequence::ExtractRandomValueArray<unsigned long>(const unsigned long min, const unsigned long max, unsigned long * array,
520 const size_t arraySize);
521
522/* --- long long --- */
526void cmnRandomSequence::ExtractRandomValue<long long>(const long long min, const long long max, long long & result);
528void cmnRandomSequence::ExtractRandomValueArray<long long>(const long long min, const long long max, long long * array,
529 const size_t arraySize);
530
531/* --- unsigned long long --- */
533void cmnRandomSequence::ExtractRandomValue<unsigned long long>(unsigned long long & result);
535void cmnRandomSequence::ExtractRandomValue<unsigned long long>(const unsigned long long min, const unsigned long long max, unsigned long long & result);
537void cmnRandomSequence::ExtractRandomValueArray<unsigned long long>(const unsigned long long min, const unsigned long long max, unsigned long long * array,
538 const size_t arraySize);
539
540/* --- char --- */
544void cmnRandomSequence::ExtractRandomValue<char>(const char min, const char max, char & result);
546void cmnRandomSequence::ExtractRandomValueArray<char>(const char min, const char max, char * array,
547 const size_t arraySize);
548
549/* --- unsigned char --- */
553void cmnRandomSequence::ExtractRandomValue<unsigned char>(const unsigned char min, const unsigned char max, unsigned char & result);
555void cmnRandomSequence::ExtractRandomValueArray<unsigned char>(const unsigned char min, const unsigned char max, unsigned char * array,
556 const size_t arraySize);
557
558/* --- bool --- */
562void cmnRandomSequence::ExtractRandomValue<bool>(const bool min, const bool max, bool & result);
564void cmnRandomSequence::ExtractRandomValueArray<bool>(const bool min, const bool max, bool * array,
565 const size_t arraySize);
566
567
568/* --- float ---*/
570inline void cmnRandomSequence::ExtractRandomValue(float & result) {
571 result = ExtractRandomFloat();
572}
574inline void cmnRandomSequence::ExtractRandomValue(const float min, const float max, float & result) {
575 result = ExtractRandomFloat(min, max);
576}
578inline void cmnRandomSequence::ExtractRandomValueArray(const float min, const float max, float * array,
579 const size_t arraySize) {
580 ExtractRandomFloatArray(min, max, array, arraySize);
581}
582
583/* --- double ---*/
585inline void cmnRandomSequence::ExtractRandomValue(double & result) {
586 result = ExtractRandomDouble();
587}
589inline void cmnRandomSequence::ExtractRandomValue(const double min, const double max, double & result) {
590 result = ExtractRandomDouble(min, max);
591}
593inline void cmnRandomSequence::ExtractRandomValueArray(const double min, const double max, double * array,
594 const size_t arraySize) {
595 ExtractRandomDoubleArray(min, max, array, arraySize);
596}
597
598/* --- int ---*/
600inline void cmnRandomSequence::ExtractRandomValue(int & result) {
601 result = ExtractRandomInt();
602}
604inline void cmnRandomSequence::ExtractRandomValue(const int min, const int max, int & result) {
605 result = ExtractRandomInt(min, max);
606}
608inline void cmnRandomSequence::ExtractRandomValueArray(const int min, const int max, int * array,
609 const size_t arraySize) {
610 ExtractRandomIntArray(min, max, array, arraySize);
611}
612/* --- unsigned int ---*/
614inline void cmnRandomSequence::ExtractRandomValue(unsigned int & result) {
615 result = ExtractRandomUnsignedInt();
616}
618inline void cmnRandomSequence::ExtractRandomValue(const unsigned int min, const unsigned int max, unsigned int & result) {
619 result = ExtractRandomUnsignedInt(min, max);
620}
622inline void cmnRandomSequence::ExtractRandomValueArray(const unsigned int min, const unsigned int max, unsigned int * array,
623 const size_t arraySize) {
624 ExtractRandomUnsignedIntArray(min, max, array, arraySize);
625}
626
627/* --- long ---*/
629inline void cmnRandomSequence::ExtractRandomValue(long & result) {
630 result = ExtractRandomLong();
631}
633inline void cmnRandomSequence::ExtractRandomValue(const long min, const long max, long & result) {
634 result = ExtractRandomLong(min, max);
635}
637inline void cmnRandomSequence::ExtractRandomValueArray(const long min, const long max, long * array,
638 const size_t arraySize) {
639 ExtractRandomLongArray(min, max, array, arraySize);
640}
641/* --- unsigned long ---*/
643inline void cmnRandomSequence::ExtractRandomValue(unsigned long & result) {
644 result = ExtractRandomUnsignedLong();
645}
647inline void cmnRandomSequence::ExtractRandomValue(const unsigned long min, const unsigned long max, unsigned long & result) {
648 result = ExtractRandomUnsignedLong(min, max);
649}
651inline void cmnRandomSequence::ExtractRandomValueArray(const unsigned long min, const unsigned long max, unsigned long * array,
652 const size_t arraySize) {
653 ExtractRandomUnsignedLongArray(min, max, array, arraySize);
654}
655
656/* --- long long ---*/
658inline void cmnRandomSequence::ExtractRandomValue(long long & result) {
659 result = ExtractRandomLongLong();
660}
662inline void cmnRandomSequence::ExtractRandomValue(const long long min, const long long max, long long & result) {
663 result = ExtractRandomLongLong(min, max);
664}
666inline void cmnRandomSequence::ExtractRandomValueArray(const long long min, const long long max, long long * array,
667 const size_t arraySize) {
668 ExtractRandomLongLongArray(min, max, array, arraySize);
669}
670/* --- unsigned long long ---*/
672inline void cmnRandomSequence::ExtractRandomValue(unsigned long long & result) {
674}
676inline void cmnRandomSequence::ExtractRandomValue(const unsigned long long min, const unsigned long long max, unsigned long long & result) {
677 result = ExtractRandomUnsignedLongLong(min, max);
678}
680inline void cmnRandomSequence::ExtractRandomValueArray(const unsigned long long min, const unsigned long long max, unsigned long long * array,
681 const size_t arraySize) {
682 ExtractRandomUnsignedLongLongArray(min, max, array, arraySize);
683}
684
685
686/* --- short ---*/
688inline void cmnRandomSequence::ExtractRandomValue(short & result) {
689 result = ExtractRandomShort();
690}
692inline void cmnRandomSequence::ExtractRandomValue(const short min, const short max, short & result) {
693 result = ExtractRandomShort(min, max);
694}
696inline void cmnRandomSequence::ExtractRandomValueArray(const short min, const short max, short * array,
697 const size_t arraySize) {
698 ExtractRandomShortArray(min, max, array, arraySize);
699}
700/* --- unsigned short ---*/
702inline void cmnRandomSequence::ExtractRandomValue(unsigned short & result) {
704}
706inline void cmnRandomSequence::ExtractRandomValue(const unsigned short min, const unsigned short max, unsigned short & result) {
707 result = ExtractRandomUnsignedShort(min, max);
708}
710inline void cmnRandomSequence::ExtractRandomValueArray(const unsigned short min, const unsigned short max, unsigned short * array,
711 const size_t arraySize) {
712 ExtractRandomUnsignedShortArray(min, max, array, arraySize);
713}
714
715/* --- char --- */
717inline void cmnRandomSequence::ExtractRandomValue(char & result) {
718 result = ExtractRandomChar();
719}
721inline void cmnRandomSequence::ExtractRandomValue(const char min, const char max, char & result) {
722 result = ExtractRandomChar(min, max);
723}
725inline void cmnRandomSequence::ExtractRandomValueArray(const char min, const char max, char * array, const size_t arraySize) {
726 ExtractRandomCharArray(min, max, array, arraySize);
727}
728/* --- unsigned char --- */
730inline void cmnRandomSequence::ExtractRandomValue(unsigned char & result) {
731 result = ExtractRandomUnsignedChar();
732}
734inline void cmnRandomSequence::ExtractRandomValue(const unsigned char min, const unsigned char max, unsigned char & result) {
735 result = ExtractRandomUnsignedChar(min, max);
736}
738inline void cmnRandomSequence::ExtractRandomValueArray(const unsigned char min, const unsigned char max, unsigned char * array,
739 const size_t arraySize) {
740 ExtractRandomUnsignedCharArray(min, max, array, arraySize);
741}
742
743/* --- bool --- */
745inline void cmnRandomSequence::ExtractRandomValue(bool & result) {
746 int value = ExtractRandomInt(0, 1024);
747 result = value & 1;
748}
750inline void cmnRandomSequence::ExtractRandomValue(const bool min, const bool max, bool & result) {
751 if (min == max) {
752 result = min;
753 } else {
754 ExtractRandomValue(result);
755 }
756}
758inline void cmnRandomSequence::ExtractRandomValueArray(const bool min, const bool max, bool * array,
759 const size_t arraySize) {
760 for (size_t i = 0; i < arraySize; ++i, ++array) {
761 ExtractRandomValue(min, max, *array);
762 }
763}
764
765#endif // DOXYGEN
766
767#endif // _cmnRandomSequence_h
static cmnRandomSequence RandomInstance
Definition cmnRandomSequence.h:132
void ExtractRandomFloatArray(const float min, const float max, float *array, const size_t arraySize)
Definition cmnRandomSequence.h:212
void ExtractRandomSizeTArray(const size_t min, const size_t max, size_t *array, const size_t arraySize)
Definition cmnRandomSequence.h:419
void ExtractRandomUnsignedCharArray(const unsigned char min, const unsigned char max, unsigned char *array, const size_t arraySize)
Definition cmnRandomSequence.h:397
SeedType GetSeed(void) const
Definition cmnRandomSequence.h:145
void ExtractRandomCharArray(const char min, const char max, char *array, const size_t arraySize)
Definition cmnRandomSequence.h:382
void ExtractRandomUnsignedShortArray(const unsigned short min, const unsigned short max, unsigned short *array, const size_t arraySize)
Definition cmnRandomSequence.h:286
unsigned char ExtractRandomUnsignedChar(void)
Definition cmnRandomSequence.h:389
void ExtractRandomUnsignedLongLongArray(const unsigned long long min, const unsigned long long max, unsigned long long *array, const size_t arraySize)
Definition cmnRandomSequence.h:367
void ExtractRandomLongArray(const long min, const long max, long *array, const size_t arraySize)
Definition cmnRandomSequence.h:306
unsigned long ExtractRandomUnsignedLong(void)
Definition cmnRandomSequence.h:312
static const ElementaryRandomNumber LowerRandomBound
Definition cmnRandomSequence.h:87
cmnRandomSequence(const SeedType seed, const SequenceCounterType position=0)
Definition cmnRandomSequence.h:106
void ExtractRandomValue(const _valueType min, const _valueType max, _valueType &result)
void ExtractRandomDoubleArray(const double min, const double max, double *array, const size_t arraySize)
Definition cmnRandomSequence.h:228
static const ElementaryRandomNumber UpperRandomBound
Definition cmnRandomSequence.h:91
int ExtractRandomInt(void)
Definition cmnRandomSequence.h:235
int ElementaryRandomNumber
Definition cmnRandomSequence.h:75
unsigned short ExtractRandomUnsignedShort(const unsigned short min, const unsigned short max)
Definition cmnRandomSequence.h:282
double ExtractRandomDouble(const double min, const double max)
Definition cmnRandomSequence.h:224
void ExtractRandomPermutation(const size_t length, size_t *array)
long long ExtractRandomLongLong(void)
Definition cmnRandomSequence.h:333
long ExtractRandomLong(void)
Definition cmnRandomSequence.h:293
cmnRandomSequence & operator=(const cmnRandomSequence &other)
Definition cmnRandomSequence.h:123
unsigned short ExtractRandomUnsignedShort(void)
Definition cmnRandomSequence.h:278
void SetSeed(const SeedType seed)
Definition cmnRandomSequence.h:152
char ExtractRandomChar(const char min, const char max)
Definition cmnRandomSequence.h:378
unsigned int ExtractRandomUnsignedInt(void)
Definition cmnRandomSequence.h:249
unsigned int SeedType
Definition cmnRandomSequence.h:71
long ExtractRandomLong(const long min, const long max)
Definition cmnRandomSequence.h:302
void ExtractRandomLongLongArray(const long long min, const long long max, long long *array, const size_t arraySize)
Definition cmnRandomSequence.h:347
void ExtractRandomIntArray(const int min, const int max, int *array, const size_t arraySize)
Definition cmnRandomSequence.h:242
float ExtractRandomFloat(void)
Definition cmnRandomSequence.h:201
double ExtractRandomDouble(void)
Definition cmnRandomSequence.h:220
long ExtractRandomLongLong(const long long min, const long long max)
Definition cmnRandomSequence.h:343
unsigned long ExtractRandomUnsignedLong(const unsigned long min, const unsigned long max)
Definition cmnRandomSequence.h:322
unsigned char ExtractRandomUnsignedChar(const unsigned char min, const unsigned char max)
Definition cmnRandomSequence.h:393
void ExtractRandomUnsignedIntArray(const unsigned int min, const unsigned int max, unsigned int *array, const size_t arraySize)
Definition cmnRandomSequence.h:257
unsigned long long ExtractRandomUnsignedLongLong(const unsigned long long min, const unsigned long long max)
Definition cmnRandomSequence.h:363
static cmnRandomSequence & GetInstance(void)
Definition cmnRandomSequence.h:138
void ExtractRandomValue(_valueType &result)
static const SeedType DefaultSeed
Definition cmnRandomSequence.h:83
void SetSequencePosition(const SequenceCounterType position)
Definition cmnRandomSequence.h:169
void ExtractRandomUnsignedLongArray(const unsigned long min, const unsigned long max, unsigned long *array, const size_t arraySize)
Definition cmnRandomSequence.h:326
size_t ExtractRandomSizeT(const size_t min, const size_t max)
Definition cmnRandomSequence.h:415
cmnRandomSequence(const cmnRandomSequence &other)
Definition cmnRandomSequence.h:115
short ExtractRandomShort(void)
Definition cmnRandomSequence.h:264
float ExtractRandomFloat(const float min, const float max)
Definition cmnRandomSequence.h:208
cmnRandomSequence()
Definition cmnRandomSequence.h:98
unsigned long SequenceCounterType
Definition cmnRandomSequence.h:79
char ExtractRandomChar(void)
Definition cmnRandomSequence.h:374
unsigned int ExtractRandomUnsignedInt(const unsigned int min, const unsigned int max)
Definition cmnRandomSequence.h:253
ptrdiff_t ExtractRandomPtrdiffT(const ptrdiff_t min, const ptrdiff_t max)
Definition cmnRandomSequence.h:426
int ExtractRandomInt(const int min, const int max)
Definition cmnRandomSequence.h:238
void ExtractRandomShortArray(const short min, const short max, short *array, const size_t arraySize)
Definition cmnRandomSequence.h:271
unsigned long long ExtractRandomUnsignedLongLong(void)
Definition cmnRandomSequence.h:354
void ExtractRandomPtrdiffTArray(const ptrdiff_t min, const ptrdiff_t max, ptrdiff_t *array, const size_t arraySize)
Definition cmnRandomSequence.h:430
SequenceCounterType GetSequencePosition(void) const
Definition cmnRandomSequence.h:161
ElementaryRandomNumber ExtractRandomElement(void)
Definition cmnRandomSequence.h:180
void ExtractRandomValueArray(const _valueType min, const _valueType max, _valueType *array, const size_t arraySize)
Definition cmnRandomSequence.h:578
short ExtractRandomShort(const short min, const short max)
Definition cmnRandomSequence.h:267
Macros to export the symbols of cisstCommon (in a Dll).
#define CISST_EXPORT
Definition cmnExportMacros.h:50
Portability across compilers and operating systems tools.
#define CISST_DECLARE_TEMPLATE_FUNCTION_SPECIALIZATION
Definition cmnPortability.h:468
#define CISST_DEFINE_TEMPLATE_FUNCTION_SPECIALIZATION
Definition cmnPortability.h:469