Source: uniform_01
Keywords: source: uniform_01 source

| Prev | Next |  |  |  |  |  | uniform_01.hpp | Headings

Source: uniform_01
`# ifndef CPPAD_UNIFORM_01_HPP `
` # define CPPAD_UNIFORM_01_HPP

    # include <cstdlib>

    namespace CppAD {
    	inline void uniform_01(size_t seed)
    	{	std::srand( (unsigned int) seed); }

    	template <class Vector>
    	void uniform_01(size_t n, Vector &x)
    	{	static double factor = 1. / double(RAND_MAX);
    		while(n--)
    			x[n] = std::rand() * factor;
    	}
    }

# endif`

Input File: omh/uniform_01_hpp.omh