include.gens.using.m
上传用户:shenzhenrh
上传日期:2013-05-12
资源大小:2904k
文件大小:2k
源码类别:

信息检索与抽取

开发平台:

Unix_Linux

  1. // include.gens.using.m
  2. //
  3. // 
  4. // Common code for simple generators
  5. // Random version 0.8
  6. // 
  7. // USING
  8. -(BOOL) getAntithetic {
  9.    return antiThetic;
  10. }
  11. -(unsigned) getUnsignedMax {
  12.    return unsignedMax;
  13. }
  14. -(unsigned) lengthOfSeedVector {
  15.    return lengthOfSeedVector;
  16. }
  17. -(unsigned) getMaxSeedValue {
  18.    return 0xffffffff;
  19. }
  20. -(unsigned *) getMaxSeedValues {
  21.    return &(maxSeedValues[0]);
  22. }
  23. -(unsigned) getInitialSeed {
  24.    return initialSeed;
  25. }
  26. -(unsigned *) getInitialSeeds {
  27.    return &(initialSeeds[0]);
  28. }
  29. -(const char *) getName {
  30.    return SSTRDUP (genName);
  31. }
  32. -(unsigned) getMagic {
  33.    return genMagic;
  34. }
  35. -(unsigned long long int) getCurrentCount {
  36.    return currentCount;
  37. }
  38. -(unsigned) getStateSize {
  39.    return stateSize;
  40. }
  41. // ----- Get floating-point random values: -----
  42. // Change in version 0.75:
  43. // -getDoubleSample no longer calls -getLongDoubleSample,
  44. // since doing so made the method non-portable.
  45. -(float) getFloatSample {
  46.    double dd;
  47.    // One 32-bit unsigned random number is used
  48.    // to fill the 24-bit mantissa of a float
  49.    dd = invModMult * [self getUnsignedSample];
  50.    return (float) dd;
  51. }
  52. -(double) getThinDoubleSample {
  53.   double dd;
  54.   // *One single* 32-bit unsigned random number is used
  55.   // to fill the 53-bit mantissa of a double
  56.    dd = invModMult * [self getUnsignedSample];
  57.    return dd;
  58. }
  59. -(double) getDoubleSample {
  60.   double dd;
  61.    // Two 32-bit unsigned random numbers are used
  62.    // to fill the 53-bit mantissa of a double.
  63.    // dd = invModMult  * [self getUnsignedSample]
  64.    //   + invModMult2 * [self getUnsignedSample];
  65.   //use a cached selector to avoid lookup costs:
  66.   
  67.   dd = invModMult  * getUnsignedSample (self, M(getUnsignedSample))
  68.       + invModMult2 * getUnsignedSample (self, M(getUnsignedSample));
  69.    return dd;
  70. }
  71. // NOTE: since the size of a long double is machine dependent,
  72. // using this method may render the simulation non-portable!
  73. -(long double) getLongDoubleSample {
  74.    long double ld;
  75.    // Two 32-bit unsigned random numbers are used
  76.    // to fill the mantissa of a long double.
  77.    ld = (long double) invModMult  * [self getUnsignedSample]
  78.       + (long double) invModMult2 * [self getUnsignedSample];
  79.    return ld;
  80. }
  81. //
  82. // include.gens.using.m