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
|
values for \ccc{init} result in equal sequences of random
|
||||||
numbers.}
|
numbers.}
|
||||||
|
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccOperations
|
\ccOperations
|
||||||
|
|
||||||
|
|
@ -70,12 +69,12 @@ deterministically or using the seed functions as described below.
|
||||||
|
|
||||||
\ccMemberFunction{ int get_int( int lower, int upper);}{
|
\ccMemberFunction{ int get_int( int lower, int upper);}{
|
||||||
returns a random \ccc{int} from the interval
|
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,
|
\ccMemberFunction{ double get_double( double lower = 0.0,
|
||||||
double upper = 1.0);}{
|
double upper = 1.0);}{
|
||||||
returns a random \ccc{double} from the interval
|
returns a random \ccc{double} from the interval
|
||||||
$[$\ccc{lower}$,$\ccc{upper}$)$.}
|
$[\mbox{\ccc{lower},\ccc{upper}})$.}
|
||||||
|
|
||||||
\ccMemberFunction{ int operator() ( int upper);}{
|
\ccMemberFunction{ int operator() ( int upper);}{
|
||||||
returns \ccVar\ccc{.get_int( 0, 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);}{
|
\ccMemberFunction{ void restore_seed( Seed const& seed);}{
|
||||||
restores the internal seed from \ccc{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
|
\ccImplementation
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,6 @@ deterministically or using the seed functions as described below.
|
||||||
values for \ccc{init} result in equal sequences of random
|
values for \ccc{init} result in equal sequences of random
|
||||||
numbers.}
|
numbers.}
|
||||||
|
|
||||||
|
|
||||||
% -----------------------------------------------------------------------------
|
% -----------------------------------------------------------------------------
|
||||||
\ccOperations
|
\ccOperations
|
||||||
|
|
||||||
|
|
@ -70,12 +69,12 @@ deterministically or using the seed functions as described below.
|
||||||
|
|
||||||
\ccMemberFunction{ int get_int( int lower, int upper);}{
|
\ccMemberFunction{ int get_int( int lower, int upper);}{
|
||||||
returns a random \ccc{int} from the interval
|
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,
|
\ccMemberFunction{ double get_double( double lower = 0.0,
|
||||||
double upper = 1.0);}{
|
double upper = 1.0);}{
|
||||||
returns a random \ccc{double} from the interval
|
returns a random \ccc{double} from the interval
|
||||||
$[$\ccc{lower}$,$\ccc{upper}$)$.}
|
$[\mbox{\ccc{lower},\ccc{upper}})$.}
|
||||||
|
|
||||||
\ccMemberFunction{ int operator() ( int upper);}{
|
\ccMemberFunction{ int operator() ( int upper);}{
|
||||||
returns \ccVar\ccc{.get_int( 0, 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);}{
|
\ccMemberFunction{ void restore_seed( Seed const& seed);}{
|
||||||
restores the internal seed from \ccc{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
|
\ccImplementation
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,7 @@
|
||||||
@article
|
@article
|
||||||
|
|
||||||
\setlength{\parskip}{1ex}
|
\setlength{\parskip}{1ex}
|
||||||
|
\addtolength{\textheight}{5ex}
|
||||||
|
|
||||||
@! ============================================================================
|
@! ============================================================================
|
||||||
@! Title
|
@! Title
|
||||||
|
|
@ -127,8 +128,12 @@ section, so we do not comment on it here.
|
||||||
|
|
||||||
int operator () ( int upper);
|
int operator () ( int upper);
|
||||||
|
|
||||||
|
// seed functions
|
||||||
void save_seed( Seed & seed) const;
|
void save_seed( Seed & seed) const;
|
||||||
void restore_seed( Seed const& seed);
|
void restore_seed( Seed const& seed);
|
||||||
|
|
||||||
|
// equality test
|
||||||
|
bool operator == ( CGAL_Random const& rnd) const;
|
||||||
@end
|
@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.
|
The result is converted to a number in the given range.
|
||||||
|
|
||||||
@macro <Random operations> = @begin
|
@macro <Random operations> = @begin
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
inline
|
inline
|
||||||
bool
|
bool
|
||||||
CGAL_Random::
|
CGAL_Random::
|
||||||
|
|
@ -266,6 +273,24 @@ seed variable, respectively.
|
||||||
}
|
}
|
||||||
@end
|
@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
|
@! Test
|
||||||
@! ============================================================================
|
@! ============================================================================
|
||||||
|
|
@ -315,15 +340,17 @@ numbers.
|
||||||
{
|
{
|
||||||
CGAL_random.restore_seed( seed); // `CGAL_Random' and `rnd'
|
CGAL_random.restore_seed( seed); // `CGAL_Random' and `rnd'
|
||||||
CGAL_Random rnd( seed); // have the same seed now
|
CGAL_Random rnd( seed); // have the same seed now
|
||||||
assert( CGAL_random.get_bool() == rnd.get_bool());
|
assert( CGAL_random.get_bool() == rnd.get_bool() );
|
||||||
assert( CGAL_random.get_int( -100,100) == rnd.get_int( -100,100));
|
assert( CGAL_random.get_int( -100,100) == rnd.get_int( -100,100));
|
||||||
assert( CGAL_random.get_double() == rnd.get_double());
|
assert( CGAL_random.get_double() == rnd.get_double() );
|
||||||
|
assert( CGAL_random == rnd );
|
||||||
|
|
||||||
long init = CGAL_random( 9999);
|
long init = CGAL_random( 9999);
|
||||||
CGAL_Random rnd1( init), rnd2( init);
|
CGAL_Random rnd1( init), rnd2( init);
|
||||||
assert( rnd1.get_bool() == rnd2.get_bool());
|
assert( rnd1.get_bool() == rnd2.get_bool() );
|
||||||
assert( rnd1.get_int( -100,100) == rnd2.get_int( -100,100));
|
assert( rnd1.get_int( -100,100) == rnd2.get_int( -100,100));
|
||||||
assert( rnd1.get_double() == rnd2.get_double());
|
assert( rnd1.get_double() == rnd2.get_double() );
|
||||||
|
assert( rnd1 == rnd2 );
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
@ -350,7 +377,6 @@ numbers.
|
||||||
#ifndef CGAL_BASIC_H
|
#ifndef CGAL_BASIC_H
|
||||||
# include <CGAL/basic.h>
|
# include <CGAL/basic.h>
|
||||||
#endif
|
#endif
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
@<Random interface>
|
@<Random interface>
|
||||||
|
|
||||||
|
|
@ -365,6 +391,8 @@ numbers.
|
||||||
// operations
|
// operations
|
||||||
@<Random operations>
|
@<Random operations>
|
||||||
|
|
||||||
|
@<Random equality test>
|
||||||
|
|
||||||
#endif // CGAL_RANDOM_H
|
#endif // CGAL_RANDOM_H
|
||||||
|
|
||||||
@<end of file line>
|
@<end of file line>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue