00001 00002 /****************************************************************************** 00003 * 00004 * Copyright (c) 2012 00005 * 00006 * SCHUNK GmbH & Co. KG 00007 * 00008 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00009 * 00010 * Project name: Drivers for "Amtec M5 Protocol" Electronics V4 00011 * 00012 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00013 * 00014 * Email:robotics@schunk.com 00015 * 00016 * ToDo: 00017 * 00018 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00019 * 00020 * Redistribution and use in source and binary forms, with or without 00021 * modification, are permitted provided that the following conditions are met: 00022 * 00023 * * Redistributions of source code must retain the above copyright 00024 * notice, this list of conditions and the following disclaimer. 00025 * * Redistributions in binary form must reproduce the above copyright 00026 * notice, this list of conditions and the following disclaimer in the 00027 * documentation and/or other materials provided with the distribution. 00028 * * Neither the name of SCHUNK GmbH & Co. KG nor the names of its 00029 * contributors may be used to endorse or promote products derived from 00030 * this software without specific prior written permission. 00031 * 00032 * This program is free software: you can redistribute it and/or modify 00033 * it under the terms of the GNU Lesser General Public License LGPL as 00034 * published by the Free Software Foundation, either version 3 of the 00035 * License, or (at your option) any later version. 00036 * 00037 * This program is distributed in the hope that it will be useful, 00038 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00039 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00040 * GNU Lesser General Public License LGPL for more details. 00041 * 00042 * You should have received a copy of the GNU Lesser General Public 00043 * License LGPL along with this program. 00044 * If not, see <http://www.gnu.org/licenses/>. 00045 * 00046 ******************************************************************************/ 00047 00048 00049 #ifndef UTIL_RANDOM_H 00050 #define UTIL_RANDOM_H 00051 00052 // ---- local includes ------------------------------------------------------ ; 00053 00054 #include "../Util/GlobalDefines.h" 00055 00056 // ---- global includes ----------------------------------------------------- ; 00057 00058 #if defined(_WIN32) 00059 #include <stdio.h> 00060 #include "Math.h" 00061 #include <stdlib.h> 00062 #include "Values.h" 00063 #include <time.h> 00064 static long fut_initRanG = -time((time_t *)0); 00065 #elif defined(__QNX__) 00066 #include <stdio.h> 00067 #include "Math.h" 00068 #include <stdlib.h> 00069 #include "Values.h" 00070 #include <unix.h> 00071 #else 00072 // extern "C" { 00073 #include <stdio.h> 00074 #include "Math.h" 00075 #include <stdlib.h> 00076 #include "Values.h" 00077 // } 00078 00079 extern "C" double drand48(void); 00080 extern "C" double erand48(unsigned short xsubi[3]); 00081 extern "C" long lrand48(void); 00082 extern "C" long nrand48(unsigned short xsubi[3]); 00083 extern "C" long mrand48(void); 00084 extern "C" long jrand48(unsigned short xsubi[3]); 00085 extern "C" void srand48(long seedval); 00086 extern "C" unsigned short *seed48(unsigned short seed16v[3]); 00087 extern "C" void lcong48(unsigned short param[7]); 00088 #endif 00089 00090 // ---- constants ----------------------------------------------------------- ; 00091 00092 // ---- typedefs ------------------------------------------------------------ ; 00093 00094 // ---- external functions -------------------------------------------------- ; 00095 00096 // ---- class definition ---------------------------------------------------- ; 00097 00098 // ---- extern I/O ---------------------------------------------------------- ; 00099 00100 // ---- local functions ---------------------------------------------------- ; 00101 00102 // \fsd{sets an entry point for random number generators} 00103 00104 void util_seedRandom(long seedValA); 00105 00106 // \fsd{generate uniformly distributed pseudo-random numbers} 00107 00108 double util_random(); 00109 00110 // \fsd{generate gaussian distributed pseudo-random numbers} 00111 00112 double util_gaussRandom(); 00113 00114 // -------------------------------------------------------------------------- ; 00115 00116 #endif // UTIL_RANDOM_H