proj home

Files   Classes   Functions   Hierarchy  

randomgenerator Class Reference

Generate a random uinteger. More...

#include <random.h>

List of all members.

Public Member Functions

uintc operator() () const
 Generate a random uinteger.
void randomize_start ()
void seed (uintc s=1)
 Initialize the state of the random number generator.

Static Public Member Functions

template<typename Q >
static boolc domain (point3< Q > const &p, boolc zero=true, boolc one=true)
 Test 3D point in interval 0 to 1 optionally with endpoints.
template<typename Q >
static boolc domain (point2< Q > const &p, boolc zero=true, boolc one=true)
 Test 2D point in interval 0 to 1 optionally with endpoints.
template<typename T >
static boolc domain (T const &x, boolc zero=true, boolc one=true)
 Test interval 0 to 1 optionally with end points.


Detailed Description

Generate a random uinteger.

The sample of random numbers generated is hundreds of times smaller than what is needed for robust applications. However it uses C functions so is convenient for small and not so accurate applications.

Definition at line 34 of file random.h.


Member Function Documentation

template<typename T >
boolc randomgenerator::domain ( T const &  x,
boolc  zero = true,
boolc  one = true 
) [inline, static]

Test interval 0 to 1 optionally with end points.

Definition at line 267 of file random.h.

References assertreturnfalse, and assertreturnfalseN.

00268 {
00269 //cout << SHOW(x) << endl;
00270   if (zero==false)
00271     assertreturnfalseN( x == (T)0 );
00272 
00273   if (one==false)
00274     assertreturnfalseN( x == (T)1 );
00275 
00276   assertreturnfalseN( x < (T)0 );
00277 
00278   assertreturnfalse( x <= (T)1 ); 
00279 
00280   return true;
00281 }

template<typename Q >
boolc randomgenerator::domain ( point2< Q > const &  p,
boolc  zero = true,
boolc  one = true 
) [inline, static]

Test 2D point in interval 0 to 1 optionally with endpoints.

Definition at line 285 of file random.h.

References domain(), point2< T >::x, and point2< T >::y.

00286 {
00287   bool res=true;
00288   if ( domain(p.x,zero,one) == false )
00289     res=false;
00290   if ( domain(p.y,zero,one) == false )
00291     res=false;
00292 
00293   return res;
00294 }

template<typename Q >
boolc randomgenerator::domain ( point3< Q > const &  p,
boolc  zero = true,
boolc  one = true 
) [inline, static]

Test 3D point in interval 0 to 1 optionally with endpoints.

Definition at line 297 of file random.h.

References point3< T >::x, point3< T >::y, and point3< T >::z.

Referenced by domain(), randomtest::domaintest(), vispointxml::handlecommand(), and randomtest::test05().

00298 {
00299   bool res=true;
00300   res &= domain(p.x,zero,one);
00301   res &= domain(p.y,zero,one);
00302   res &= domain(p.z,zero,one);
00303 
00304   return res;
00305 }

uintc randomgenerator::operator() (  )  const [inline]

Generate a random uinteger.

Definition at line 39 of file random.h.

00040     { return rand(); }

void randomgenerator::randomize_start (  )  [inline]

Definition at line 43 of file random.h.

00044     { srand( time(NULL) ); }

void randomgenerator::seed ( uintc  s = 1  ) 

Initialize the state of the random number generator.

Definition at line 3 of file random.cpp.

Referenced by main().

00004 {
00005   srand(s);
00006 }


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:12 2011 for Chelton Evans Source by  doxygen 1.5.8