source:
src/tests/random.c
@
a797e2b1
Last change on this file since a797e2b1 was ed0e67a, checked in by , 8 years ago | |
---|---|
|
|
File size: 1.2 KB |
Rev | Line | |
---|---|---|
[ed0e67a] | 1 | // |
2 | // Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo | |
3 | // | |
4 | // The contents of this file are covered under the licence agreement in the | |
5 | // file "LICENCE" distributed with Cforall. | |
6 | // | |
7 | // random.c -- | |
8 | // | |
9 | // Author : Peter A. Buhr | |
10 | // Created On : Tue Jul 5 21:29:30 2016 | |
11 | // Last Modified By : Peter A. Buhr | |
12 | // Last Modified On : Tue Jul 5 21:29:54 2016 | |
13 | // Update Count : 1 | |
14 | // | |
[5721a6d] | 15 | |
16 | #include <fstream> | |
[bd85400] | 17 | #include <stdlib> // random |
[ed0e67a] | 18 | #include <unistd.h> // getpid |
[5721a6d] | 19 | |
20 | int main() { | |
[0438091] | 21 | rand48seed( getpid() ); // set random seed |
[5721a6d] | 22 | |
23 | // test polymorphic calls to random and stream | |
[0438091] | 24 | char c = rand48(); |
[5721a6d] | 25 | sout | c | endl; |
[0438091] | 26 | int i = rand48(); |
[5721a6d] | 27 | sout | i | endl; |
[0438091] | 28 | unsigned int ui = rand48(); |
[5721a6d] | 29 | sout | ui | endl; |
[0438091] | 30 | long int li = rand48(); |
[5721a6d] | 31 | sout | li | endl; |
[0438091] | 32 | unsigned long int uli = rand48(); |
[5721a6d] | 33 | sout | uli | endl; |
[0438091] | 34 | float f = rand48(); |
[5721a6d] | 35 | sout | f | endl; |
[0438091] | 36 | double d = rand48(); |
[5721a6d] | 37 | sout | d | endl; |
[0438091] | 38 | float _Complex fc = rand48(); |
[5721a6d] | 39 | sout | fc | endl; |
[0438091] | 40 | double _Complex dc = rand48(); |
[5721a6d] | 41 | sout | dc | endl; |
[0438091] | 42 | long double _Complex ldc = rand48(); |
[5721a6d] | 43 | sout | ldc | endl; |
44 | } // main | |
45 | ||
46 | // Local Variables: // | |
47 | // tab-width: 4 // | |
48 | // compile-command: "cfa random.c" // | |
49 | // End: // |
Note: See TracBrowser
for help on using the repository browser.