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