00001 /* 00002 * Copyright (c) 1993 Martin Birgmeier 00003 * All rights reserved. 00004 * 00005 * You may redistribute unmodified or modified versions of this source 00006 * code provided that the above copyright notice and this and the 00007 * following conditions are retained. 00008 * 00009 * This software is provided ``as is'', and comes with no warranties 00010 * of any kind. I shall in no event be liable for anything that happens 00011 * to anyone/anything when using this software. 00012 */ 00013 00026 /* 00027 * source from NAMD Random.h, modified from C++ 00028 */ 00029 00030 #ifndef RANDOM_H 00031 #define RANDOM_H 00032 00033 #include "mdapi/mdtypes.h" 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 #ifdef _MSC_VER 00040 typedef __int64 int64; 00041 #else 00042 #if ( INT_MAX == 9223372036854775807LL ) 00043 typedef int int64; 00044 #elif ( LONG_MAX == 9223372036854775807LL ) 00045 typedef long int64; 00046 #else 00047 typedef long long int64; 00048 #endif 00049 #endif 00050 00056 typedef struct Random_tag { 00057 double second_gaussian; 00058 int64 second_gaussian_waiting; 00059 int64 rand48_seed; 00060 int64 rand48_mult; 00061 int64 rand48_add; 00062 } Random; 00063 00064 00069 void random_init(Random *r); 00070 00071 00078 void random_initseed(Random *r, unsigned long seed); 00079 00080 00089 void random_split(Random *r, int iStream, int numStreams); 00090 00091 00098 double random_uniform(Random *r); 00099 00100 00107 double random_gaussian(Random *r); 00108 00109 00116 MD_Dvec random_gaussian_vector(Random *r); 00117 00118 00125 long random_integer(Random *r); 00126 00127 #ifdef __cplusplus 00128 } 00129 #endif 00130 00131 #endif /* RANDOM_H */