00001 /* 00002 * Copyright (c) 2012 SCHUNK GmbH & Co. KG 00003 * Copyright (c) 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA) 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef UTIL_RANDOM_H 00019 #define UTIL_RANDOM_H 00020 00021 // ---- local includes ------------------------------------------------------ ; 00022 00023 #include "../Util/GlobalDefines.h" 00024 00025 // ---- global includes ----------------------------------------------------- ; 00026 00027 #if defined(_WIN32) 00028 #include <stdio.h> 00029 #include "Math.h" 00030 #include <stdlib.h> 00031 #include "Values.h" 00032 #include <time.h> 00033 static long fut_initRanG = -time((time_t *)0); 00034 #elif defined(__QNX__) 00035 #include <stdio.h> 00036 #include "Math.h" 00037 #include <stdlib.h> 00038 #include "Values.h" 00039 #include <unix.h> 00040 #else 00041 // extern "C" { 00042 #include <stdio.h> 00043 #include "Math.h" 00044 #include <stdlib.h> 00045 #include "Values.h" 00046 // } 00047 00048 extern "C" double drand48(void); 00049 extern "C" double erand48(unsigned short xsubi[3]); 00050 extern "C" long lrand48(void); 00051 extern "C" long nrand48(unsigned short xsubi[3]); 00052 extern "C" long mrand48(void); 00053 extern "C" long jrand48(unsigned short xsubi[3]); 00054 extern "C" void srand48(long seedval); 00055 extern "C" unsigned short *seed48(unsigned short seed16v[3]); 00056 extern "C" void lcong48(unsigned short param[7]); 00057 #endif 00058 00059 // ---- constants ----------------------------------------------------------- ; 00060 00061 // ---- typedefs ------------------------------------------------------------ ; 00062 00063 // ---- external functions -------------------------------------------------- ; 00064 00065 // ---- class definition ---------------------------------------------------- ; 00066 00067 // ---- extern I/O ---------------------------------------------------------- ; 00068 00069 // ---- local functions ---------------------------------------------------- ; 00070 00071 // \fsd{sets an entry point for random number generators} 00072 00073 void util_seedRandom(long seedValA); 00074 00075 // \fsd{generate uniformly distributed pseudo-random numbers} 00076 00077 double util_random(); 00078 00079 // \fsd{generate gaussian distributed pseudo-random numbers} 00080 00081 double util_gaussRandom(); 00082 00083 // -------------------------------------------------------------------------- ; 00084 00085 #endif // UTIL_RANDOM_H