Resolve/C++ Catalog
CT/Random/Uniform_1.h
Copyright © 2010, Reusable Software Research Group, The Ohio State University

//  /*-------------------------------------------------------------------*\
//  |   Concrete Template : Random_Uniform_1
//  \*-------------------------------------------------------------------*/

#ifndef CT_RANDOM_UNIFORM_1
#define CT_RANDOM_UNIFORM_1 1

///------------------------------------------------------------------------
/// Global Context --------------------------------------------------------
///------------------------------------------------------------------------

#include "AI/Random/Uniform.h"
/*!
    #include "AI/Random/Kernel.h"
!*/

///------------------------------------------------------------------------
/// Interface -------------------------------------------------------------
///------------------------------------------------------------------------

concrete_template <
	concrete_instance class Random_Base
	/*!
	    implements
		abstract_instance Random_Kernel
	!*/
    >
class Random_Uniform_1 :
    implements
	abstract_instance Random_Uniform,
    extends
	concrete_instance Random_Base
{
public:
    
    function_body Real Uniform_Real (
	    preserves Real a,
	    preserves Real b
	)
    {
	return a + (b - a) *
	    To_Real (self.Value ()) / To_Real (self.Limit ());
    }

    function_body Integer Uniform_Integer (
	    preserves Integer j,
	    preserves Integer k
	)
    {
	return j + To_Integer (self.Uniform_Real (0.0, To_Real (k+1-j)));
    }

};

#endif // CT_RANDOM_UNIFORM_1

Last modified: Thu Jan 11 17:05:57 EST 2007