ViennaCL - The Vienna Computing Library
1.6.1
Free open-source GPU-accelerated linear algebra and solver library.
Random.hpp
Go to the documentation of this file.
1
2
/* =========================================================================
3
Copyright (c) 2010-2014, Institute for Microelectronics,
4
Institute for Analysis and Scientific Computing,
5
TU Wien.
6
Portions of this software are copyright by UChicago Argonne, LLC.
7
8
-----------------
9
ViennaCL - The Vienna Computing Library
10
-----------------
11
12
Project Head: Karl Rupp rupp@iue.tuwien.ac.at
13
14
(A list of authors and contributors can be found in the PDF manual)
15
16
License: MIT (X11), see file LICENSE in the base directory
17
============================================================================= */
18
19
#ifndef _RANDOM_HPP_
20
#define _RANDOM_HPP_
21
22
#include <time.h>
23
#include <stdlib.h>
24
25
inline
void
init
()
26
{
27
static
bool
init
=
false
;
28
if
(!init)
29
{
30
srand( (
unsigned
int
)time(NULL) );
31
init =
true
;
32
}
33
}
34
35
template
<
class
TYPE>
36
TYPE
random
();
37
38
template
<>
39
double
random<double>
()
40
{
41
init
();
42
return
static_cast<
double
>
(rand()) / static_cast<double>(RAND_MAX);
43
}
44
45
template
<>
46
float
random<float>
()
47
{
48
init
();
49
return
static_cast<
float
>
(
random<double>
());
50
}
51
52
#endif
53
random< float >
float random< float >()
Definition:
Random.hpp:46
random< double >
double random< double >()
Definition:
Random.hpp:39
init
void init()
Definition:
Random.hpp:25
random
TYPE random()
tests
src
Random.hpp
Generated on Thu Nov 20 2014 15:15:30 for ViennaCL - The Vienna Computing Library by
1.8.8