Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9287


Ignore:
Timestamp:
03/05/13 18:45:44 (11 years ago)
Author:
mkommend
Message:

#2007: Adapated rng of AlgLib 3.7.0 to the changes in #1968.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.ALGLIB/3.7.0/ALGLIB-3.7.0/ap.cs

    r9268 r9287  
    570570    public class math
    571571    {
    572         //public static System.Random RndObject = new System.Random(System.DateTime.Now.Millisecond);
    573         public static System.Random rndobject = new System.Random(System.DateTime.Now.Millisecond + 1000*System.DateTime.Now.Second + 60*1000*System.DateTime.Now.Minute);
     572      //public static System.Random RndObject = new System.Random(System.DateTime.Now.Millisecond);
     573      [ThreadStatic] //mkommend: added thread static attribute to RNG to have a separate instance per thread and allow modification of the seed
     574      public static System.Random rndobject;
    574575
    575576        public const double machineepsilon = 5E-16;
     
    579580        public static bool isfinite(double d)
    580581        {
     582            if (rndobject == null) rndobject = new System.Random(System.DateTime.Now.Millisecond + 1000 * System.DateTime.Now.Second + 60 * 1000 * System.DateTime.Now.Minute);
    581583            return !System.Double.IsNaN(d) && !System.Double.IsInfinity(d);
    582584        }
     
    585587        {
    586588            double r = 0;
     589            if (rndobject == null) rndobject = new System.Random(System.DateTime.Now.Millisecond + 1000 * System.DateTime.Now.Second + 60 * 1000 * System.DateTime.Now.Minute);
    587590            lock(rndobject){ r = rndobject.NextDouble(); }
    588591            return r;
     
    591594        {
    592595            int r = 0;
     596            if (rndobject == null) rndobject = new System.Random(System.DateTime.Now.Millisecond + 1000 * System.DateTime.Now.Second + 60 * 1000 * System.DateTime.Now.Minute);
    593597            lock(rndobject){ r = rndobject.Next(N); }
    594598            return r;
Note: See TracChangeset for help on using the changeset viewer.