C# (CSharp) SharpNeat.Utility Пространство имен

Классы

Имя Описание
FastRandom A fast random number generator for .NET Colin Green, January 2005 Key points: 1) Based on a simple and fast xor-shift pseudo random number generator (RNG) specified in: Marsaglia, George. (2003). Xorshift RNGs. http://www.jstatsoft.org/v08/i14/paper This particular implementation of xorshift has a period of 2^128-1. See the above paper to see how this can be easily extened if you need a longer period. At the time of writing I could find no information on the period of System.Random for comparison. 2) Faster than System.Random. Up to 8x faster, depending on which methods are called. 3) Direct replacement for System.Random. This class implements all of the methods that System.Random does plus some additional methods. The like named methods are functionally equivalent. 4) Allows fast re-initialisation with a seed, unlike System.Random which accepts a seed at construction time which then executes a relatively expensive initialisation routine. This provides a vast speed improvement if you need to reset the pseudo-random number sequence many times, e.g. if you want to re-generate the same sequence of random numbers many times. An alternative might be to cache random numbers in an array, but that approach is limited by memory capacity and the fact that you may also want a large number of different sequences cached. Each sequence can be represented by a single seed value (int) when using FastRandom. Notes. A further performance improvement can be obtained by declaring local variables as static, thus avoiding re-allocation of variables on each call. However care should be taken if multiple instances of FastRandom are in use or if being used in a multi-threaded environment. Colin Green, September 4th 2005 - Added NextBytesUnsafe() - commented out by default. - Fixed bug in Reinitialise() - y,z and w variables were not being reset. Colin Green, December 2008. - Fix to Next() - Was previously able to return int.MaxValue, contrary to the method's contract and comments. - Modified NextBool() to use _bitMask instead of a count of remaining bits. Also reset the bit buffer in Reinitialise(). Colin Green, 2011-08-31 - Added NextByte() method. - Added new statically declared seedRng FastRandom to allow easy creation of multiple FastRandoms with different seeds within a single clock tick. Colin Green, 2011-10-04 - Seeds are now hashed. Without this the first random sample for nearby seeds (1,2,3, etc.) are very similar (have a similar bit pattern). Thanks to Francois Guibert for identifying this problem.
KeyedCircularBuffer A generic circular buffer of KeyValuePairs. The values are retrievable by their key. Old key-value pairs are overwritten when the circular buffer runs out of empty elements to place items into, as this happens the internal dictionary that maintains the lookup ability is also updated to reflect only the items in the circular buffer.
Point2DDouble
UInt32IdGenerator Conveniently encapsulates a single UInt32, which is incremented to produce new IDs.
Utilities General purpose static utility methods.
XmlIoUtils Static helper methods for XML IO.