mac_drand48r.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Robot Group Leipzig                             *
00003  *    martius@informatik.uni-leipzig.de                                    *
00004  *    fhesse@informatik.uni-leipzig.de                                     *
00005  *    der@informatik.uni-leipzig.de                                        *
00006  *    joergweide84@aol.com (robot12)                                       *
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  *   This program is distributed in the hope that it will be useful,       *
00014  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00015  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00016  *   GNU General Public License for more details.                          *
00017  *                                                                         *
00018  *   You should have received a copy of the GNU General Public License     *
00019  *   along with this program; if not, write to the                         *
00020  *   Free Software Foundation, Inc.,                                       *
00021  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00022  *                                                                         *
00023  *   This is a copy of the stdlib version                                  *
00024  *                                                                         *
00025  *   $Log: mac_drand48r.h,v $
00026  *   Revision 1.8  2009/10/29 15:26:14  martius
00027  *   typo
00028  *
00029  *   Revision 1.7  2009/10/29 15:24:20  martius
00030  *   removed implementation, just declaration
00031  *
00032  *   Revision 1.6  2009/10/29 15:20:03  fhesse
00033  *   *** empty log message ***
00034  *
00035  *   Revision 1.5  2009/10/29 14:51:14  fhesse
00036  *   *** empty log message ***
00037  *
00038  *   Revision 1.4  2009/10/29 14:44:41  martius
00039  *   got ieee754 double back
00040  *
00041  *   Revision 1.3  2009/10/29 14:37:19  martius
00042  *   reduced to Little Endian
00043  *
00044  *   Revision 1.2  2009/10/29 14:33:24  martius
00045  *   hard coded little endian
00046  *
00047  *   Revision 1.1  2009/10/29 14:23:26  martius
00048  *   random gen also for mac (non-gnu)
00049  *
00050  *
00051  ***************************************************************************/
00052 #ifndef __MACDRAND48_R_H
00053 #define __MACDRAND48_R_H
00054 
00055 #include <stdlib.h>
00056 
00057 #include <limits.h>
00058 #include <mach/mach.h>
00059 
00060 
00061 union ieee754_double
00062   {
00063     double d;
00064 
00065     /* This is the IEEE 754 double-precision format.  */
00066     struct
00067       {
00068         /* Together these comprise the mantissa.  */
00069         unsigned int mantissa1:32;
00070         unsigned int mantissa0:20;
00071         unsigned int exponent:11;
00072         unsigned int negative:1;
00073       } ieee;
00074 
00075     /* This format makes it easier to see if a NaN is a signalling NaN.  */
00076     struct
00077       {
00078         /* Together these comprise the mantissa.  */
00079         unsigned int mantissa1:32;
00080         unsigned int mantissa0:19;
00081         unsigned int quiet_nan:1;
00082         unsigned int exponent:11;
00083         unsigned int negative:1;
00084       } ieee_nan;
00085   };
00086 
00087 #define IEEE754_DOUBLE_BIAS     0x3ff /* Added to exponent.  */
00088 
00089 
00090 struct drand48_data {
00091   unsigned short int __x[3];    /* Current state.  */
00092   unsigned short int __old_x[3]; /* Old state.  */
00093   unsigned short int __c;       /* Additive const. in congruential formula.  */
00094   unsigned short int __init;    /* Flag for initializing.  */
00095   unsigned long long int __a;   /* Factor in congruential formula.  */
00096 };
00097 
00098 
00099 int srand48_r (long int seedval, struct drand48_data *buffer);
00100 
00101 int drand48_r ( struct drand48_data *buffer, double *result);
00102 
00103 
00104 #endif

Generated on Fri Oct 30 16:29:01 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7