packages/Utils/rng/RNG_Control.cc
//---------------------------------------------------------------------------//
/*!
 * \brief Spawn a new random number object.
 *
 * \param random valid SPRNG random number object
 * \return SPRNG random number object
 *
 * This function spawns a new, independent random number object from an
 * existing SPRNG random number object.  The new SPRNG random number state
 * has as its index the index of the parent SPRNG object from which it has
 * been spawned.
 *
 * Memory control of the spawned stream is given to the returned SPRNG
 * object.  The spawned object is--from this point on--independent of the
 * stream from which it spawned.  This class is used to guarantee
 * reproducibility in random number codes.  By spawning only from existing
 * random number states, reproducibility in numeric operations can be
 * achieved.
*/
\brief Spawn a new random number object.
\param random valid SPRNG random number object
\return SPRNG random number object

This function spawns a new, independent random number object from an
existing SPRNG random number object.  The new SPRNG random number state
has as its index the index of the parent SPRNG object from which it has
been spawned.

Memory control of the spawned stream is given to the returned SPRNG
object.  The spawned object is--from this point on--independent of the
stream from which it spawned.  This class is used to guarantee
reproducibility in random number codes.  By spawning only from existing
random number states, reproducibility in numeric operations can be
achieved.
\ brief Spawn a new random number object . \ param random valid SPRNG random number object \ return SPRNG random number object This function spawns a new independent random number object from an existing SPRNG random number object . The new SPRNG random number state has as its index the index of the parent SPRNG object from which it has been spawned . Memory control of the spawned stream is given to the returned SPRNG object . The spawned object is -- from this point on -- independent of the stream from which it spawned . This class is used to guarantee reproducibility in random number codes . By spawning only from existing random number states reproducibility in numeric operations can be achieved .
RNG_Control::RNG_t RNG_Control::spawn(const RNG_t &random) const
{
    int **newstream;
    spawn_sprng(random.get_id(), 1, &newstream);
    RNG ran(newstream[0], random.get_num());
    std::free(newstream);
    return ran;
}
RNG_Control :: RNG_t RNG_Control :: spawn ( const RNG_t & random ) const { int * * newstream ; spawn_sprng ( random . get_id ( ) , 1 , & newstream ) ; RNG ran ( newstream [ 0 ] , random . get_num ( ) ) ; std :: free ( newstream ) ; return ran ; }
\brief Spawn a new random number object.
\ brief Spawn a new random number object .
// declare variables necessary to spawn a stream // spawn a new stream // create a new SPRNG random number object with new stream // free the memory // return the new random object