Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Random Number

Duane Labreche edited this page Sep 21, 2018 · 9 revisions

headers: Kokkos_Core.hpp, Kokkos_Complex.hpp

template<class Generator> struct rand<Generator, gen_data_type>

  • KOKKOS_INLINE_FUNCTION static gen_func_type max(){return type_value}

  • KOKKOS_INLINE_FUNCTION static gen_func_type draw(Generator& gen) {return gen_data_type((gen.rand()&gen_return_value)}

  • KOKKOS_INLINE_FUNCTION static gen_func_type draw(Generator& gen, const gen_data_type& range) {return gen_data_type((gen.rand(range));}

  • KOKKOS_INLINE_FUNCTION static gen_func_type draw(Generator& gen, const gen_data_type& start, const gen_data_type& end) {return gen_data_type(gen.rand(start,end));}

Function specializations for gen_data_type, gen_func_type and type_value

All functions and classes listed here are part of the Kokkos:: namespace.

gen_data_type gen_func_type type_value gen_return_value ---
char short 127 (&0xff+256)%256
short short 32767 (&0xffff+65536)%32768
int int MAX_RAND ?
uint uint MAX_URAND ?
long long MAX_RAND or MAX_RAND64 ?
ulong ulong MAX_RAND or MAX_RAND64 ?
long long long long MAX_RAND64 ?
ulong long ulong long MAX_URAND64 ?
float float 1.0f ?
double double 1.0 ?
complex complex 1.0,1.0 ?
complex complex 1.0,1.0 ?

where the maximum values of the XorShift function values are given by the following enums.

  • enum {MAX_URAND = 0xffffffffU};
  • enum {MAX_URAND64 = 0xffffffffffffffffULL-1};
  • enum {MAX_RAND = static_cast(0xffffffffU/2)};
  • enum {MAX_RAND64 = static_cast<int64_t>(0xffffffffffffffffULL/2-1)};
Clone this wiki locally