xam_uniform_01.cpp

View page source

Example and Test of uniform_01

# include <ctime>
# include <cmpad/uniform_01.hpp>

bool xam_uniform_01(void)
{  //
   // ok
   bool ok = true;
   //
   // seed
   unsigned int seed = static_cast<unsigned int>( std::time(nullptr) );
   //
   // srand
   std::srand(seed);
   //
   // n, x
   size_t n = 10;
   cmpad::vector<double> x(n);
   for(size_t i = 0; i < n; ++i)
      x[i] = -1;
   //
   // x
   cmpad::uniform_01(x);
   //
   // ok
   for(size_t i = 0; i < n; ++i)
      ok &= 0.0 <= x[i] && x[i] <= 1.0;
   //
   return ok;
}