//===----------------------------------------------------------------------===// // // ΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚΚThe LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // template // RealType generate_canonical(URNG& g); #include #include #include int main() { { typedef std::minstd_rand0 E; typedef float F; E r; F f = std::generate_canonical(r); assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1))); } { typedef std::minstd_rand0 E; typedef float F; E r; F f = std::generate_canonical(r); assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1))); } { typedef std::minstd_rand0 E; typedef float F; E r; F f = std::generate_canonical::digits - 1>(r); assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1))); } { typedef std::minstd_rand0 E; typedef float F; E r; F f = std::generate_canonical::digits>(r); assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1))); } { typedef std::minstd_rand0 E; typedef float F; E r; F f = std::generate_canonical::digits + 1>(r); assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1))); } { typedef std::minstd_rand0 E; typedef double F; E r; F f = std::generate_canonical(r); assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1))); } { typedef std::minstd_rand0 E; typedef double F; E r; F f = std::generate_canonical(r); assert(f == (16807 - E::min()) / (E::max() - E::min() + F(1))); } { typedef std::minstd_rand0 E; typedef double F; E r; F f = std::generate_canonical::digits - 1>(r); assert(f == (16807 - E::min() + (282475249 - E::min()) * (E::max() - E::min() + F(1))) / ((E::max() - E::min() + F(1)) * (E::max() - E::min() + F(1)))); } { typedef std::minstd_rand0 E; typedef double F; E r; F f = std::generate_canonical::digits>(r); assert(f == (16807 - E::min() + (282475249 - E::min()) * (E::max() - E::min() + F(1))) / ((E::max() - E::min() + F(1)) * (E::max() - E::min() + F(1)))); } { typedef std::minstd_rand0 E; typedef double F; E r; F f = std::generate_canonical::digits + 1>(r); assert(f == (16807 - E::min() + (282475249 - E::min()) * (E::max() - E::min() + F(1))) / ((E::max() - E::min() + F(1)) * (E::max() - E::min() + F(1)))); } }