mirror of https://github.com/CGAL/cgal
equality test added
This commit is contained in:
parent
8fa25be650
commit
af69ad7b6c
|
|
@ -61,7 +61,6 @@ deterministically or using the seed functions as described below.
|
|||
values for \ccc{init} result in equal sequences of random
|
||||
numbers.}
|
||||
|
||||
|
||||
% -----------------------------------------------------------------------------
|
||||
\ccOperations
|
||||
|
||||
|
|
@ -70,12 +69,12 @@ deterministically or using the seed functions as described below.
|
|||
|
||||
\ccMemberFunction{ int get_int( int lower, int upper);}{
|
||||
returns a random \ccc{int} from the interval
|
||||
$[$\ccc{lower}$,$\ccc{upper}$)$.}
|
||||
$[\mbox{\ccc{lower},\ccc{upper}})$.}
|
||||
|
||||
\ccMemberFunction{ double get_double( double lower = 0.0,
|
||||
double upper = 1.0);}{
|
||||
returns a random \ccc{double} from the interval
|
||||
$[$\ccc{lower}$,$\ccc{upper}$)$.}
|
||||
$[\mbox{\ccc{lower},\ccc{upper}})$.}
|
||||
|
||||
\ccMemberFunction{ int operator() ( int upper);}{
|
||||
returns \ccVar\ccc{.get_int( 0, upper)}.}
|
||||
|
|
@ -89,6 +88,13 @@ deterministically or using the seed functions as described below.
|
|||
\ccMemberFunction{ void restore_seed( Seed const& seed);}{
|
||||
restores the internal seed from \ccc{seed}.}
|
||||
|
||||
% -----------------------------------------------------------------------------
|
||||
\ccHeading{Equality Test}
|
||||
|
||||
\ccMemberFunction{ bool operator == ( CGAL_Random const& random2) const;}{
|
||||
returns \ccc{true}, iff \ccVar\ and \ccc{random2} have equal
|
||||
internal seeds.}
|
||||
|
||||
% -----------------------------------------------------------------------------
|
||||
\ccImplementation
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ deterministically or using the seed functions as described below.
|
|||
values for \ccc{init} result in equal sequences of random
|
||||
numbers.}
|
||||
|
||||
|
||||
% -----------------------------------------------------------------------------
|
||||
\ccOperations
|
||||
|
||||
|
|
@ -70,12 +69,12 @@ deterministically or using the seed functions as described below.
|
|||
|
||||
\ccMemberFunction{ int get_int( int lower, int upper);}{
|
||||
returns a random \ccc{int} from the interval
|
||||
$[$\ccc{lower}$,$\ccc{upper}$)$.}
|
||||
$[\mbox{\ccc{lower},\ccc{upper}})$.}
|
||||
|
||||
\ccMemberFunction{ double get_double( double lower = 0.0,
|
||||
double upper = 1.0);}{
|
||||
returns a random \ccc{double} from the interval
|
||||
$[$\ccc{lower}$,$\ccc{upper}$)$.}
|
||||
$[\mbox{\ccc{lower},\ccc{upper}})$.}
|
||||
|
||||
\ccMemberFunction{ int operator() ( int upper);}{
|
||||
returns \ccVar\ccc{.get_int( 0, upper)}.}
|
||||
|
|
@ -89,6 +88,13 @@ deterministically or using the seed functions as described below.
|
|||
\ccMemberFunction{ void restore_seed( Seed const& seed);}{
|
||||
restores the internal seed from \ccc{seed}.}
|
||||
|
||||
% -----------------------------------------------------------------------------
|
||||
\ccHeading{Equality Test}
|
||||
|
||||
\ccMemberFunction{ bool operator == ( CGAL_Random const& random2) const;}{
|
||||
returns \ccc{true}, iff \ccVar\ and \ccc{random2} have equal
|
||||
internal seeds.}
|
||||
|
||||
% -----------------------------------------------------------------------------
|
||||
\ccImplementation
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
@article
|
||||
|
||||
\setlength{\parskip}{1ex}
|
||||
\addtolength{\textheight}{5ex}
|
||||
|
||||
@! ============================================================================
|
||||
@! Title
|
||||
|
|
@ -127,8 +128,12 @@ section, so we do not comment on it here.
|
|||
|
||||
int operator () ( int upper);
|
||||
|
||||
// seed functions
|
||||
void save_seed( Seed & seed) const;
|
||||
void restore_seed( Seed const& seed);
|
||||
|
||||
// equality test
|
||||
bool operator == ( CGAL_Random const& rnd) const;
|
||||
@end
|
||||
|
||||
|
||||
|
|
@ -206,6 +211,8 @@ uniformly chosen from the interval $[\ccc{0.0},\ccc{1.0})$.
|
|||
The result is converted to a number in the given range.
|
||||
|
||||
@macro <Random operations> = @begin
|
||||
#include <stdlib.h>
|
||||
|
||||
inline
|
||||
bool
|
||||
CGAL_Random::
|
||||
|
|
@ -266,6 +273,24 @@ seed variable, respectively.
|
|||
}
|
||||
@end
|
||||
|
||||
|
||||
\subsection{Equality Test}
|
||||
|
||||
The equality test compares the internal seeds of the two operands.
|
||||
|
||||
@macro <Random equality test> = @begin
|
||||
inline
|
||||
bool
|
||||
CGAL_Random::
|
||||
operator == ( CGAL_Random const& rnd) const
|
||||
{
|
||||
return( CGAL_static_cast( bool,
|
||||
( _seed[ 0] == rnd._seed[ 0]) &&
|
||||
( _seed[ 1] == rnd._seed[ 1]) &&
|
||||
( _seed[ 2] == rnd._seed[ 2]) ) );
|
||||
}
|
||||
@end
|
||||
|
||||
@! ============================================================================
|
||||
@! Test
|
||||
@! ============================================================================
|
||||
|
|
@ -318,12 +343,14 @@ numbers.
|
|||
assert( CGAL_random.get_bool() == rnd.get_bool() );
|
||||
assert( CGAL_random.get_int( -100,100) == rnd.get_int( -100,100));
|
||||
assert( CGAL_random.get_double() == rnd.get_double() );
|
||||
assert( CGAL_random == rnd );
|
||||
|
||||
long init = CGAL_random( 9999);
|
||||
CGAL_Random rnd1( init), rnd2( init);
|
||||
assert( rnd1.get_bool() == rnd2.get_bool() );
|
||||
assert( rnd1.get_int( -100,100) == rnd2.get_int( -100,100));
|
||||
assert( rnd1.get_double() == rnd2.get_double() );
|
||||
assert( rnd1 == rnd2 );
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
@ -350,7 +377,6 @@ numbers.
|
|||
#ifndef CGAL_BASIC_H
|
||||
# include <CGAL/basic.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
|
||||
@<Random interface>
|
||||
|
||||
|
|
@ -365,6 +391,8 @@ numbers.
|
|||
// operations
|
||||
@<Random operations>
|
||||
|
||||
@<Random equality test>
|
||||
|
||||
#endif // CGAL_RANDOM_H
|
||||
|
||||
@<end of file line>
|
||||
|
|
|
|||
Loading…
Reference in New Issue