예제 #1
0
    static void Init()
    {
        //set up seed
        uint seed = TMath.Seed();

        //overide
        //seed = 809171303;

        System.Console.WriteLine(seed.ToString());

        var gen = new XorShift128Generator(seed);

        for (int i = 0; i < 3; i++) // Becuase of bug in RNG, make sure we are completely pseudo-random
        {
            gen.Next();
        }
        GoRogue.Random.SingletonRandom.DefaultRNG = gen;

        MapGen generator = new MapGen(BuildBlob9());

        ArrayMap <Cell> map = generator.GenerateMap(9);

        var console = new Console(map.Width, map.Height, map);

        SadConsole.Global.CurrentScreen = console;
    }
 /// <summary>
 ///   Initializes a new instance of the <see cref="BinomialDistribution"/> class, using a
 ///   <see cref="XorShift128Generator"/> with the specified seed value.
 /// </summary>
 /// <param name="seed">
 ///   An unsigned number used to calculate a starting value for the pseudo-random number sequence.
 /// </param>
 /// <param name="valueCount">
 ///   The parameter valueCount which is used for generation of binomial distributed random
 ///   numbers by setting the number of equi-distributed "weights" the distribution will have.
 /// </param>
 /// <exception cref="ArgumentOutOfRangeException">
 ///   <paramref name="valueCount"/> is less than or equal to zero.
 /// </exception>
 public CategoricalDistribution(uint seed, int valueCount) : this(new XorShift128Generator(seed), valueCount)
 {
     Debug.Assert(Generator is XorShift128Generator);
     Debug.Assert(Generator.Seed == seed);
     Debug.Assert(Equals(Weights.Count, valueCount));
     Debug.Assert(Weights.All(w => TMath.AreEqual(w, 1.0 / valueCount)));
 }
        public override void ProcessTriggers(TriggersSet triggersSet)
        {
            //if: player has eaten Love Love Fruit and...
            //if: Empty hand, eaten fruit, not in water, and (using mouse -> can use mouse)
            if (player.GetModPlayer <DevilFruitUser>().eatenDevilFruit == 2 && player.HeldItem.type == ItemID.None && !(player.wet && !(player.honeyWet || player.lavaWet)) && (!Equals(DevilFruitMod.UsePowers1Hotkey.GetAssignedKeys(InputMode.Keyboard)[0], "Mouse1") || (Main.hasFocus && !Main.LocalPlayer.mouseInterface && !Main.drawingPlayerChat && !Main.editSign && !Main.editChest && !Main.blockInput && !Main.mapFullscreen && !Main.HoveringOverAnNPC && Main.LocalPlayer.talkNPC == -1)))
            {
                //Getting the shooting trajectory
                Vector2 dir = TMath.CalculateTrajectory();

                if (DevilFruitMod.MiscHotkey.JustPressed)
                {
                    LoveLoveMisc();
                }

                if (DevilFruitMod.UsePowers1Hotkey.JustPressed)
                {
                    LoveLovePowers(dir.X, dir.Y, 0);
                }

                if (DevilFruitMod.UsePowers2Hotkey.JustPressed)
                {
                    LoveLovePowers(dir.X, dir.Y, 1);
                }

                if (DevilFruitMod.UsePowers3Hotkey.JustPressed)
                {
                    LoveLovePowers(dir.X, dir.Y, 2);
                }
            }
        }
예제 #4
0
        public void Doubles_MaxValue_SameOutputAsNextDouble()
        {
            var max      = Rand.Next() + 1; // To avoid zero
            var otherGen = GetGenerator(_generator.Seed);

            Assert.True(_generator.Doubles(max).Take(Iterations).All(x => TMath.AreEqual(x, otherGen.NextDouble(max))));
        }
        /// <summary>
        ///   Prepares parameters for <see cref="TRandom"/>.
        /// </summary>
        /// <param name="weightsCount">The number of weights.</param>
        /// <param name="weights">Weights, or null.</param>
        /// <param name="cdf">The output cdf.</param>
        /// <remarks>
        ///   Also remember to change <see cref="UpdateHelpers"/> when changing this method.
        /// </remarks>
        internal static void SetUp(int weightsCount, IEnumerable <double> weights, out double[] cdf)
        {
            var weightsList = (weights == null) ? Ones(weightsCount) : weights.ToList();
            var weightsSum  = weightsList.Sum(); // It will store the sum of all UNNORMALIZED weights.

            cdf = new double[weightsList.Count]; // It will store NORMALIZED cdf.
            var maxW = 0.0;                      // It will store max weight (all weights are positive).

            // Let's normalize all weights, if necessary.
            if (!TMath.AreEqual(weightsSum, 1.0))
            {
                for (var i = 0; i < weightsList.Count; ++i)
                {
                    weightsList[i] /= weightsSum;
                }
                Debug.Assert(TMath.AreEqual(weightsList.Sum(), 1.0));
            }

            weightsSum = 0.0; // Reset weight sum to use it for cdf.

            // One big loop to compute all helpers needed by this distribution.
            for (var i = 0; i < weightsList.Count; ++i)
            {
                var w = weightsList[i];
                weightsSum += w;
                cdf[i]      = weightsSum;
                if (w > maxW)
                {
                    maxW = w;
                }
            }
        }
예제 #6
0
        public void Doubles_SameOutputAsNextDouble_AfterReset()
        {
            var otherGen = GetGenerator(_generator.Seed);

            Assert.True(_generator.Doubles().Take(Iterations).All(x => TMath.AreEqual(x, otherGen.NextDouble())));
            _generator.Reset();
            otherGen.Reset();
            Assert.True(_generator.Doubles().Take(Iterations).All(x => TMath.AreEqual(x, otherGen.NextDouble())));
        }
        /// <summary>
        ///   Computes the unnormalized cumulative distribution function and other attributes for the
        ///   distribution (like mean, variance, and so on).
        /// </summary>
        /// <remarks>
        ///   Also remember to change <see cref="SetUp(int, IEnumerable{double}, out double[])"/>
        ///   when changing this method.
        /// </remarks>
        private void UpdateHelpers()
        {
            var weightsSum = _weights.Sum();             // It will store the sum of all UNNORMALIZED weights.
            var cdf        = new double[_weights.Count]; // It will store NORMALIZED cdf.
            var tmpMean    = 0.0;
            var maxW       = 0.0;                        // It will store max weight (all weights are positive).
            var maxI       = 0;                          // It will store max weight index.

            // Let's normalize all weights, if necessary.
            if (!TMath.AreEqual(weightsSum, 1.0))
            {
                for (var i = 0; i < _weights.Count; ++i)
                {
                    _weights[i] /= weightsSum;
                }
                Debug.Assert(TMath.AreEqual(_weights.Sum(), 1.0));
            }

            weightsSum = 0.0; // Reset weight sum to use it for cdf.

            // One big loop to compute all helpers needed by this distribution.
            for (var i = 0; i < _weights.Count; ++i)
            {
                var w = _weights[i];
                weightsSum += w;
                cdf[i]      = weightsSum;
                tmpMean    += w * (i + 1.0); // Plus one because it is zero-based.
                if (w > maxW)
                {
                    maxW = w;
                    maxI = i;
                }
            }

            // Finalize some results...
            _cdf = cdf;
            Mean = tmpMean - 1.0; // Minus one to make it zero-based.
            Mode = new double[] { maxI };

            var halfWeightsSum = weightsSum / 2.0;
            var tmpMedian      = double.NaN;
            var tmpVar         = 0.0;

            // We still need another loop to compute variance; as for the mean, the plus/minus one is needed.
            for (var i = 0; i < _weights.Count; ++i)
            {
                if (double.IsNaN(tmpMedian) && _cdf[i] >= halfWeightsSum)
                {
                    tmpMedian = i;
                }
                tmpVar += _weights[i] * TMath.Square(i + 1 - Mean);
            }

            // Finalize last results...
            Median   = tmpMedian;
            Variance = tmpVar - 1.0;
        }
예제 #8
0
 void Update()
 {
     if (Time.time <= 1)
     {
         ball.transform.position = trajectory.Lerp(Time.time).ToVector();
     }
     else
     {
         ball.transform.position += trajectory.Reflect(TMath.Cross(plane.v, plane.u)).ToVector() * Time.deltaTime * 15;
     }
 }
예제 #9
0
        public override void ProcessTriggers(TriggersSet triggersSet)
        {
            /* UPON ADDING A NEW FRUIT:
             * 1. Change DFTemplateDFTemplate to the name of the Devil Fruit being added in this and other files in the folder
             * 2. Add moves
             * 3. If needed, update sounds in the sounds file by following the template named DFTemplateDFTemplateSound.cs
             * 4. Update merchant information (DFGlobalNPC.cs)
             * 5. Update Silvers Rayleigh information (Silvers.cs)
             * 6. Upon finishing and testing the fruit, update build.txt and description.txt before publishing
             *
             * RESOURCES:
             * Example Mod: https://github.com/tModLoader/tModLoader/tree/master/ExampleMod
             * AI Types: https://tconfig.fandom.com/wiki/List_of_Projectile_AI_Styles
             * Audio: https://terraria.fandom.com/wiki/Category:Sound_effects?filefrom=Dd2+sky+dragons+fury+swing+0.wav#mw-category-media (Refer to the audio files labeled "Item #.wav")
             */

            //if: player has eaten DFTemplate-DFTemplate Fruit and...
            //if: Empty hand, eaten fruit, not in water, and (using mouse -> can use mouse)
            //UPDATE eatenDevilFruit VALUE!!
            if (player.GetModPlayer <DevilFruitUser>().eatenDevilFruit == 99 && player.HeldItem.type == ItemID.None && !(player.wet && !(player.honeyWet || player.lavaWet)) && (!Equals(DevilFruitMod.UsePowers1Hotkey.GetAssignedKeys(InputMode.Keyboard)[0], "Mouse1") || (Main.hasFocus && !Main.LocalPlayer.mouseInterface && !Main.drawingPlayerChat && !Main.editSign && !Main.editChest && !Main.blockInput && !Main.mapFullscreen && !Main.HoveringOverAnNPC && Main.LocalPlayer.talkNPC == -1)))
            {
                //Getting the shooting trajectory
                Vector2 dir = TMath.CalculateTrajectory();

                if (DevilFruitMod.MiscHotkey.JustPressed)
                {
                    DFTemplateDFTemplateMisc();
                }

                if (DevilFruitMod.UsePowers1Hotkey.JustPressed)
                {
                    DFTemplateDFTemplatePowers(dir.X, dir.Y, 0);
                }

                if (DevilFruitMod.UsePowers2Hotkey.JustPressed)
                {
                    DFTemplateDFTemplatePowers(dir.X, dir.Y, 1);
                }

                if (DevilFruitMod.UsePowers3Hotkey.JustPressed)
                {
                    DFTemplateDFTemplatePowers(dir.X, dir.Y, 2);
                }

                /*
                 * if (DevilFruitMod.UsePowers3Hotkey.JustReleased)
                 * {
                 *
                 * }
                 */
            }
        }
예제 #10
0
        // sigma >= 0, better keep it low
        private double GetSigma(ISigmaDistribution <double> d)
        {
            if (d != null)
            {
                return(d.Sigma);
            }
            double s;

            do
            {
                s = Rand.NextDouble();
            } while (TMath.IsZero(s));
            return(s);
        }
예제 #11
0
    public float IntersectsAt(PlaneMath plane)
    {
        Coords N  = TMath.Cross(plane.u, plane.v);
        Coords AB = plane.A - A;

        if (TMath.Dot(N, v) == 0)
        {
            return(float.NaN);
        }

        float t = TMath.Dot(N, AB) / TMath.Dot(N, v);

        return(t);
    }
예제 #12
0
    public Coords Reflect(Coords normal)
    {
        //R = A - 2(A.N)N
        Coords norm  = normal.GetNormal();
        Coords vnorm = v.GetNormal();

        float d = TMath.Dot(norm, vnorm) * 2;

        if (d == 0)
        {
            return(v);
        }

        return(vnorm - norm * d);
    }
예제 #13
0
        public override void PreUpdate()
        {
            //GumGumGatling loop, see ProcessTriggers
            if (gatlingPressed)
            {
                if (timer == 0)
                {
                    if (player.HeldItem.type == 0 && !(player.wet && !(player.honeyWet || player.lavaWet)) && (!Equals(DevilFruitMod.UsePowers1Hotkey.GetAssignedKeys(InputMode.Keyboard)[0], "Mouse1") || (Main.hasFocus && !Main.LocalPlayer.mouseInterface && !Main.drawingPlayerChat && !Main.editSign && !Main.editChest && !Main.blockInput && !Main.mapFullscreen && !Main.HoveringOverAnNPC && Main.LocalPlayer.talkNPC == -1)))
                    {
                        //Getting the shooting trajectory
                        Vector2 dir = TMath.CalculateTrajectory();

                        GumGumPowers(dir.X, dir.Y, 2);
                    }
                }
                timer++;
                if (timer > 10)
                {
                    timer = 0;
                }
            }

            if (player.GetModPlayer <DevilFruitUser>().eatenDevilFruit > 0 && player.wet && !(player.honeyWet || player.lavaWet))
            {
                player.AddBuff(ModContent.BuffType <Buffs.waterStun>(), 60, true);
            }
            //No fall damage if eaten Gum Gum Fruit
            if (player.GetModPlayer <DevilFruitUser>().eatenDevilFruit == 1)
            {
                player.noFallDmg = true;

                //"Boing" if fallen instead of damage
                if (!falling && ((player.gravDir == 1 && player.velocity.Y > 10) || (player.gravDir == -1 && player.velocity.Y < 10)))
                {
                    falling = true;
                }
                if (falling && ((player.gravDir == 1 && player.velocity.Y <= 0) || (player.gravDir == -1 && player.velocity.Y >= 0)))
                {
                    falling = false;
                    if ((player.gravDir == 1 && ((int)((player.position.Y) / 16) - player.fallStart) > (25 + player.extraFall)) || (player.gravDir == -1 && player.fallStart < -(25 + player.extraFall)))
                    {
                        CombatText.NewText(player.getRect(), Color.White, "Boing");
                    }
                }
            }
        }
예제 #14
0
    public float IntersectsAt(Line l)
    {
        if (TMath.Dot(Coords.Perp(l.v), v) == 0)
        {
            return(float.NaN);
        }

        Coords c = l.A - this.A;
        float  t = TMath.Dot(Coords.Perp(l.v), c) / TMath.Dot(Coords.Perp(l.v), v);

        if (t < 0 || t > 1 && type == LINETYPE.SEGMENT)
        {
            return(float.NaN);
        }

        return(t);
    }
예제 #15
0
        public override void ProcessTriggers(TriggersSet triggersSet)
        {
            //if: player has eaten Gum Gum Fruit and...
            //if: Empty hand, eaten fruit, not in water, and (using mouse -> can use mouse)
            if (player.GetModPlayer <DevilFruitUser>().eatenDevilFruit == 1 && player.HeldItem.type == ItemID.None && !(player.wet && !(player.honeyWet || player.lavaWet)) && (!Equals(DevilFruitMod.UsePowers1Hotkey.GetAssignedKeys(InputMode.Keyboard)[0], "Mouse1") || (Main.hasFocus && !Main.LocalPlayer.mouseInterface && !Main.drawingPlayerChat && !Main.editSign && !Main.editChest && !Main.blockInput && !Main.mapFullscreen && !Main.HoveringOverAnNPC && Main.LocalPlayer.talkNPC == -1)))
            {
                //Getting the shooting trajectory
                Vector2 dir = TMath.CalculateTrajectory();

                if (DevilFruitMod.MiscHotkey.JustPressed)
                {
                    GumGumMisc(dir.X, dir.Y);
                }

                if (DevilFruitMod.UsePowers1Hotkey.JustPressed)
                {
                    GumGumPowers(dir.X, dir.Y, 0);
                }

                if (DevilFruitMod.UsePowers2Hotkey.JustPressed)
                {
                    GumGumPowers(dir.X, dir.Y, 1);
                }

                if (DevilFruitMod.UsePowers3Hotkey.JustPressed)
                {
                    //if: No hands in use, Empty hand, eaten fruit, not in water, and (using mouse -> can use mouse)
                    if (DevilFruitMod.hands == 0)
                    {
                        gatlingPressed       = true; //refer to PreUpdate()
                        timer                = 0;
                        DevilFruitMod.hands += 2;
                    }
                }

                if (DevilFruitMod.UsePowers3Hotkey.JustReleased)
                {
                    if (gatlingPressed == true)
                    {
                        gatlingPressed       = false;
                        DevilFruitMod.hands -= 2;
                    }
                }
            }
        }
        /// <summary>
        ///   Returns a floating point random number within the specified range.
        /// </summary>
        /// <param name="minValue">The inclusive lower bound of the random number to be generated.</param>
        /// <param name="maxValue">The exclusive upper bound of the random number to be generated.</param>
        /// <returns>
        ///   A double-precision floating point number greater than or equal to
        ///   <paramref name="minValue"/>, and less than <paramref name="maxValue"/>; that is, the
        ///   range of return values includes <paramref name="minValue"/> but not <paramref name="maxValue"/>.
        /// </returns>
        /// <exception cref="ArgumentOutOfRangeException">
        ///   <paramref name="maxValue"/> must be greater than or equal to <paramref name="minValue"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///   The difference between <paramref name="maxValue"/> and <paramref name="minValue"/>
        ///   cannot be <see cref="double.PositiveInfinity"/>.
        /// </exception>
        public double NextDouble(double minValue, double maxValue)
        {
            // Preconditions
            if (minValue > maxValue)
            {
                throw new ArgumentOutOfRangeException(nameof(minValue), ErrorMessages.MinValueGreaterThanMaxValue);
            }
            if (double.IsPositiveInfinity(maxValue - minValue))
            {
                throw new ArgumentException(ErrorMessages.InfiniteMaxValueMinusMinValue, nameof(minValue));
            }

            var result = minValue + NextDouble() * (maxValue - minValue);

            // Postconditions
            Debug.Assert((TMath.AreEqual(result, minValue) && TMath.AreEqual(minValue, maxValue)) || (result >= minValue && result < maxValue));
            return(result);
        }
예제 #17
0
        public static void Main()
        {
            // 1) Use TRandom to generate a few random numbers - via IGenerator methods.
            Console.WriteLine("TRandom in action, used as an IGenerator");
            var trandom = new TRandom();

            Console.WriteLine(trandom.Next() - trandom.Next(5) + trandom.Next(3, 5));
            Console.WriteLine(trandom.NextDouble() * trandom.NextDouble(5.5) * trandom.NextDouble(10.1, 21.9));
            Console.WriteLine(trandom.NextBoolean());

            Console.WriteLine();

            // 2) Use TRandom to generate a few random numbers - via extension methods.
            Console.WriteLine("TRandom in action, used as an IGenerator augmented with extension methods");
            Console.WriteLine(string.Join(", ", trandom.Integers().Take(10)));
            Console.WriteLine(string.Join(", ", trandom.Doubles().Take(10)));
            Console.WriteLine(string.Join(", ", trandom.Booleans().Take(10)));

            Console.WriteLine();

            // 3) Use TRandom to generate a few distributed numbers.
            Console.WriteLine("TRandom in action, used as to get distributed numbers");
            Console.WriteLine(trandom.Normal(1.0, 0.1));
            Console.WriteLine(string.Join(", ", trandom.NormalSamples(1.0, 0.1).Take(20)));
            Console.WriteLine(trandom.Poisson(5));
            Console.WriteLine(string.Join(", ", trandom.PoissonSamples(5).Take(20)));

            Console.WriteLine();

            // 4) There are many generators available - XorShift128 is the default.
            var alf = new ALFGenerator(TMath.Seed());
            var nr3 = new NR3Generator();
            var std = new StandardGenerator(127);

            // 5) You can also use distribution directly, even with custom generators.
            Console.WriteLine("Showcase of some distributions");
            Console.WriteLine("Static sample for Normal: " + NormalDistribution.Sample(alf, 1.0, 0.1));
            Console.WriteLine("New instance for Normal: " + new NormalDistribution(1.0, 0.1).NextDouble());

            Console.WriteLine();
        }
예제 #18
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="NR3Generator"/> class, using a
 ///   time-dependent default seed value.
 /// </summary>
 public NR3Generator() : base(TMath.Seed())
 {
 }
 static GenericOperatorMath()
 {
     if (object.ReferenceEquals(typeof(T), typeof(Int16)))
     {
         Add                  = CastDelegate <TMath>((Func <Int16, Int16, Int16>)((Int16 a, Int16 b) => (Int16)(a + b)));;
         Subtract             = CastDelegate <TMath>((Func <Int16, Int16, Int16>)((Int16 a, Int16 b) => (Int16)(a - b)));
         Multiply             = CastDelegate <TMath>((Func <Int16, Int16, Int16>)((Int16 a, Int16 b) => (Int16)(a * b)));
         LessThan             = CastDelegate <TMathBoolean>((Func <Int16, Int16, bool>)((Int16 a, Int16 b) => a < b));
         GreaterThan          = CastDelegate <TMathBoolean>((Func <Int16, Int16, bool>)((Int16 a, Int16 b) => a > b));
         LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <Int16, Int16, bool>)((Int16 a, Int16 b) => a <= b));
         GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <Int16, Int16, bool>)((Int16 a, Int16 b) => a >= b));
         ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <Int16, double>)((Int16 v) => Convert.ToDouble(v)));
         ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, Int16>)((double v) => Convert.ToInt16(v)));
     }
     else if (object.ReferenceEquals(typeof(T), typeof(Int32)))
     {
         Add                  = CastDelegate <TMath>((Func <Int32, Int32, Int32>)((Int32 a, Int32 b) => a + b));;
         Subtract             = CastDelegate <TMath>((Func <Int32, Int32, Int32>)((Int32 a, Int32 b) => a - b));
         Multiply             = CastDelegate <TMath>((Func <Int32, Int32, Int32>)((Int32 a, Int32 b) => a * b));
         LessThan             = CastDelegate <TMathBoolean>((Func <Int32, Int32, bool>)((Int32 a, Int32 b) => a < b));
         GreaterThan          = CastDelegate <TMathBoolean>((Func <Int32, Int32, bool>)((Int32 a, Int32 b) => a > b));
         LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <Int32, Int32, bool>)((Int32 a, Int32 b) => a <= b));
         GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <Int32, Int32, bool>)((Int32 a, Int32 b) => a >= b));
         ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <Int32, double>)((Int32 v) => Convert.ToDouble(v)));
         ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, Int32>)((double v) => Convert.ToInt32(v)));
     }
     else if (object.ReferenceEquals(typeof(T), typeof(Int64)))
     {
         Add                  = CastDelegate <TMath>((Func <Int64, Int64, Int64>)((Int64 a, Int64 b) => a + b));;
         Subtract             = CastDelegate <TMath>((Func <Int64, Int64, Int64>)((Int64 a, Int64 b) => a - b));
         Multiply             = CastDelegate <TMath>((Func <Int64, Int64, Int64>)((Int64 a, Int64 b) => a * b));
         LessThan             = CastDelegate <TMathBoolean>((Func <Int64, Int64, bool>)((Int64 a, Int64 b) => a < b));
         GreaterThan          = CastDelegate <TMathBoolean>((Func <Int64, Int64, bool>)((Int64 a, Int64 b) => a > b));
         LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <Int64, Int64, bool>)((Int64 a, Int64 b) => a <= b));
         GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <Int64, Int64, bool>)((Int64 a, Int64 b) => a >= b));
         ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <Int64, double>)((Int64 v) => Convert.ToDouble(v)));
         ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, Int64>)((double v) => Convert.ToInt64(v)));
     }
     else if (object.ReferenceEquals(typeof(T), typeof(UInt16)))
     {
         Add                  = CastDelegate <TMath>((Func <UInt16, UInt16, UInt16>)((UInt16 a, UInt16 b) => (UInt16)(a + b)));
         Subtract             = CastDelegate <TMath>((Func <UInt16, UInt16, UInt16>)((UInt16 a, UInt16 b) => (UInt16)(a - b)));
         Multiply             = CastDelegate <TMath>((Func <UInt16, UInt16, UInt16>)((UInt16 a, UInt16 b) => (UInt16)(a * b)));
         LessThan             = CastDelegate <TMathBoolean>((Func <UInt16, UInt16, bool>)((UInt16 a, UInt16 b) => a < b));
         GreaterThan          = CastDelegate <TMathBoolean>((Func <UInt16, UInt16, bool>)((UInt16 a, UInt16 b) => a > b));
         LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <UInt16, UInt16, bool>)((UInt16 a, UInt16 b) => a <= b));
         GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <UInt16, UInt16, bool>)((UInt16 a, UInt16 b) => a >= b));
         ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <UInt16, double>)((UInt16 v) => Convert.ToDouble(v)));
         ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, UInt16>)((double v) => Convert.ToUInt16(v)));
     }
     else if (object.ReferenceEquals(typeof(T), typeof(UInt32)))
     {
         Add                  = CastDelegate <TMath>((Func <UInt32, UInt32, UInt32>)((UInt32 a, UInt32 b) => a + b));;
         Subtract             = CastDelegate <TMath>((Func <UInt32, UInt32, UInt32>)((UInt32 a, UInt32 b) => a - b));
         Multiply             = CastDelegate <TMath>((Func <UInt32, UInt32, UInt32>)((UInt32 a, UInt32 b) => a * b));
         LessThan             = CastDelegate <TMathBoolean>((Func <UInt32, UInt32, bool>)((UInt32 a, UInt32 b) => a < b));
         GreaterThan          = CastDelegate <TMathBoolean>((Func <UInt32, UInt32, bool>)((UInt32 a, UInt32 b) => a > b));
         LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <UInt32, UInt32, bool>)((UInt32 a, UInt32 b) => a <= b));
         GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <UInt32, UInt32, bool>)((UInt32 a, UInt32 b) => a >= b));
         ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <UInt32, double>)((UInt32 v) => Convert.ToDouble(v)));
         ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, UInt32>)((double v) => Convert.ToUInt32(v)));
     }
     else if (object.ReferenceEquals(typeof(T), typeof(UInt64)))
     {
         Add                  = CastDelegate <TMath>((Func <UInt64, UInt64, UInt64>)((UInt64 a, UInt64 b) => a + b));;
         Subtract             = CastDelegate <TMath>((Func <UInt64, UInt64, UInt64>)((UInt64 a, UInt64 b) => a - b));
         Multiply             = CastDelegate <TMath>((Func <UInt64, UInt64, UInt64>)((UInt64 a, UInt64 b) => a * b));
         LessThan             = CastDelegate <TMathBoolean>((Func <UInt64, UInt64, bool>)((UInt64 a, UInt64 b) => a < b));
         GreaterThan          = CastDelegate <TMathBoolean>((Func <UInt64, UInt64, bool>)((UInt64 a, UInt64 b) => a > b));
         LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <UInt64, UInt64, bool>)((UInt64 a, UInt64 b) => a <= b));
         GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <UInt64, UInt64, bool>)((UInt64 a, UInt64 b) => a >= b));
         ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <UInt64, double>)((UInt64 v) => Convert.ToDouble(v)));
         ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, UInt64>)((double v) => Convert.ToUInt64(v)));
     }
     else if (object.ReferenceEquals(typeof(T), typeof(float)))
     {
         Add                  = CastDelegate <TMath>((Func <float, float, float>)((float a, float b) => a + b));;
         Subtract             = CastDelegate <TMath>((Func <float, float, float>)((float a, float b) => a - b));
         Multiply             = CastDelegate <TMath>((Func <float, float, float>)((float a, float b) => a * b));
         LessThan             = CastDelegate <TMathBoolean>((Func <float, float, bool>)((float a, float b) => a < b));
         GreaterThan          = CastDelegate <TMathBoolean>((Func <float, float, bool>)((float a, float b) => a > b));
         LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <float, float, bool>)((float a, float b) => a <= b));
         GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <float, float, bool>)((float a, float b) => a >= b));
         ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <float, double>)((float v) => Convert.ToDouble(v)));
         ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, float>)((double v) => Convert.ToSingle(v)));
     }
     else if (object.ReferenceEquals(typeof(T), typeof(double)))
     {
         Add                  = CastDelegate <TMath>((Func <double, double, double>)((double a, double b) => a + b));;
         Subtract             = CastDelegate <TMath>((Func <double, double, double>)((double a, double b) => a - b));
         Multiply             = CastDelegate <TMath>((Func <double, double, double>)((double a, double b) => a * b));
         LessThan             = CastDelegate <TMathBoolean>((Func <double, double, bool>)((double a, double b) => a < b));
         GreaterThan          = CastDelegate <TMathBoolean>((Func <double, double, bool>)((double a, double b) => a > b));
         LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <double, double, bool>)((double a, double b) => a <= b));
         GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <double, double, bool>)((double a, double b) => a >= b));
         ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <double, double>)((double v) => v));
         ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, double>)((double v) => v));
     }
     else if (object.ReferenceEquals(typeof(T), typeof(decimal)))
     {
         Add                  = CastDelegate <TMath>((Func <decimal, decimal, decimal>)((decimal a, decimal b) => a + b));;
         Subtract             = CastDelegate <TMath>((Func <decimal, decimal, decimal>)((decimal a, decimal b) => a - b));
         Multiply             = CastDelegate <TMath>((Func <decimal, decimal, decimal>)((decimal a, decimal b) => a * b));
         LessThan             = CastDelegate <TMathBoolean>((Func <decimal, decimal, bool>)((decimal a, decimal b) => a < b));
         GreaterThan          = CastDelegate <TMathBoolean>((Func <decimal, decimal, bool>)((decimal a, decimal b) => a > b));
         LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <decimal, decimal, bool>)((decimal a, decimal b) => a <= b));
         GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <decimal, decimal, bool>)((decimal a, decimal b) => a >= b));
         ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <decimal, double>)((decimal v) => Convert.ToDouble(v)));
         ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, decimal>)((double v) => Convert.ToDecimal(v)));
     }
     else if (object.ReferenceEquals(typeof(T), typeof(sbyte)))
     {
         Add                  = CastDelegate <TMath>((Func <sbyte, sbyte, sbyte>)((sbyte a, sbyte b) => (sbyte)(a + b)));;
         Subtract             = CastDelegate <TMath>((Func <sbyte, sbyte, sbyte>)((sbyte a, sbyte b) => (sbyte)(a - b)));
         Multiply             = CastDelegate <TMath>((Func <sbyte, sbyte, sbyte>)((sbyte a, sbyte b) => (sbyte)(a * b)));
         LessThan             = CastDelegate <TMathBoolean>((Func <sbyte, sbyte, bool>)((sbyte a, sbyte b) => a < b));
         GreaterThan          = CastDelegate <TMathBoolean>((Func <sbyte, sbyte, bool>)((sbyte a, sbyte b) => a > b));
         LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <sbyte, sbyte, bool>)((sbyte a, sbyte b) => a <= b));
         GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <sbyte, sbyte, bool>)((sbyte a, sbyte b) => a >= b));
         ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <sbyte, double>)((sbyte v) => Convert.ToDouble(v)));
         ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, sbyte>)((double v) => Convert.ToSByte(v)));
     }
     else if (object.ReferenceEquals(typeof(T), typeof(byte)))
     {
         Add                  = CastDelegate <TMath>((Func <byte, byte, byte>)((byte a, byte b) => (byte)(a + b)));;
         Subtract             = CastDelegate <TMath>((Func <byte, byte, byte>)((byte a, byte b) => (byte)(a - b)));
         Multiply             = CastDelegate <TMath>((Func <byte, byte, byte>)((byte a, byte b) => (byte)(a * b)));
         LessThan             = CastDelegate <TMathBoolean>((Func <byte, byte, bool>)((byte a, byte b) => a < b));
         GreaterThan          = CastDelegate <TMathBoolean>((Func <byte, byte, bool>)((byte a, byte b) => a > b));
         LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <byte, byte, bool>)((byte a, byte b) => a <= b));
         GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <byte, byte, bool>)((byte a, byte b) => a >= b));
         ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <byte, double>)((byte v) => Convert.ToDouble(v)));
         ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, byte>)((double v) => Convert.ToByte(v)));
     }
 }
예제 #20
0
    public Coords GetNormal()
    {
        float magnitude = TMath.Distance(new Coords(0, 0, 0), new Coords(x, y, z));

        return(new Coords(x / magnitude, y / magnitude, z / magnitude));
    }
예제 #21
0
 public int GetBaseInt(CharType type)
 {
     return(TMath.Round(GetBaseFloat(type)));
 }
 /// <summary>
 ///   Initializes a new instance of the <see cref="CategoricalDistribution"/> class, using
 ///   the specified <see cref="IGenerator"/> as underlying random number generator.
 /// </summary>
 /// <param name="generator">An <see cref="IGenerator"/> object.</param>
 /// <exception cref="ArgumentNullException"><paramref name="generator"/> is <see langword="null"/>.</exception>
 public CategoricalDistribution(IGenerator generator) : this(generator, DefaultValueCount)
 {
     Debug.Assert(ReferenceEquals(Generator, generator));
     Debug.Assert(Equals(Weights.Count, DefaultValueCount));
     Debug.Assert(Weights.All(w => TMath.AreEqual(w, 1.0 / DefaultValueCount)));
 }
 /// <summary>
 ///   Initializes a new instance of the <see cref="BinomialDistribution"/> class, using a
 ///   <see cref="XorShift128Generator"/> as underlying random number generator.
 /// </summary>
 public CategoricalDistribution() : this(new XorShift128Generator(), DefaultValueCount)
 {
     Debug.Assert(Generator is XorShift128Generator);
     Debug.Assert(Equals(Weights.Count, DefaultValueCount));
     Debug.Assert(Weights.All(w => TMath.AreEqual(w, 1.0 / DefaultValueCount)));
 }
예제 #24
0
 public int GetCurrentInt(CharType type)
 {
     return(TMath.Round(GetCurrentFloat(type)));
 }
예제 #25
0
        public BMap(int sideCellCount, float hexRadius)
        {
            SideCellCount = sideCellCount;
            ArraySize = sideCellCount * 2 - 1;
            HexOutRadius = hexRadius;

            // Fill all
            Cells = new BMapCell[ArraySize, ArraySize];
            for (int row = 0; row < ArraySize; row++)
                for (int col = 0; col < ArraySize; col++)
                    Cells[col, row] = new BMapCell(col, row);

            int notNullCellsCount = ArraySize * ArraySize;
            // Remove top-left corner
            for (int row = 0; row < (sideCellCount - 1); row++)
                for (int col = 0; col < (sideCellCount - row - 1); col++)
                {
                    notNullCellsCount--;
                    Cells[col, row] = null;
                }

            // Remove bottom-right corner
            for (int row = sideCellCount; row < ArraySize; row++)
                for (int col = (ArraySize - row + sideCellCount - 1); col < ArraySize; col++)
                {
                    notNullCellsCount--;
                    Cells[col, row] = null;
                }

            _notNullCells = new BMapCell[notNullCellsCount];
            notNullCellsCount = 0;
            for (int row = 0; row < ArraySize; row++)
                for (int col = 0; col < ArraySize; col++)
                    if (Cells[col, row] != null)
                    {
                        _notNullCells[notNullCellsCount] = Cells[col, row];
                        notNullCellsCount++;
                    }


            // [X] [X] [ ] [ ] [ ]
            // [X] [ ] [ ] [ ] [ ]
            // [ ] [ ] [ ] [ ] [ ]
            // [ ] [ ] [ ] [ ] [X]
            // [ ] [ ] [ ] [X] [X]

            HexWidth = (float)Math.Sqrt(3) * HexOutRadius;
            HexInRadius = HexWidth / 2f;
            HexHeight = 2f * HexOutRadius;

            WidthSpacing = HexWidth;
            HeightSpacing = HexHeight * 3f / 4f;

            // Fill hexes
            List<BMapCell> neighs = new List<BMapCell>();
            for (int row = 0; row < ArraySize; row++)
            {
                for (int col = 0; col < ArraySize; col++)
                {
                    if (Cells[col, row] != null)
                    {
                        var hex = new Hex(
                            new PointF(
                                HexWidth + (col - (ArraySize - sideCellCount - 1)) * (WidthSpacing) + row * (HexInRadius), 
                                HexOutRadius + row * (HeightSpacing)
                                ), 
                                HexOutRadius);
                        Cells[col, row].Hex = hex;
                        Cells[col, row].ModelSize = new RectangleF(hex.Center.X - (HexWidth * 0.9f) / 2f, hex.Center.Y - (HexWidth * 0.9f) / 2f, HexWidth * 0.9f, HexWidth * 0.9f);
                        Cells[col, row].StepsSize = new RectangleF(hex.Center.X - (HexWidth * 0.4f) / 2f, hex.Center.Y - (HexWidth * 0.4f) / 2f, HexWidth * 0.4f, HexWidth * 0.4f);
                        neighs.Clear();
                        if ((col + 1).Between(-1, ArraySize) && (row + 0).Between(-1, ArraySize)) neighs.Add(Cells[col + 1, row + 0]); else neighs.Add(null);
                        if ((col + 1).Between(-1, ArraySize) && (row - 1).Between(-1, ArraySize)) neighs.Add(Cells[col + 1, row - 1]); else neighs.Add(null);
                        if ((col + 0).Between(-1, ArraySize) && (row - 1).Between(-1, ArraySize)) neighs.Add(Cells[col + 0, row - 1]); else neighs.Add(null);
                        if ((col - 1).Between(-1, ArraySize) && (row + 0).Between(-1, ArraySize)) neighs.Add(Cells[col - 1, row + 0]); else neighs.Add(null);
                        if ((col - 1).Between(-1, ArraySize) && (row + 1).Between(-1, ArraySize)) neighs.Add(Cells[col - 1, row + 1]); else neighs.Add(null);
                        if ((col + 0).Between(-1, ArraySize) && (row + 1).Between(-1, ArraySize)) neighs.Add(Cells[col + 0, row + 1]); else neighs.Add(null);
                        Cells[col, row].Neighbors = neighs.ToArray();
                    }
                }
            }
            neighs = null;

            // Prepare layout
            Width = TMath.Round(HexWidth * ArraySize + 1 + (ArraySize*5));
            Height = TMath.Round(HexHeight + HeightSpacing * (ArraySize - 1) + 1 + (ArraySize*5));

            Bitmap b = new Bitmap(Width, Height);
            Graphics g = Graphics.FromImage(b);
            //g.FillRectangle(Brushes.White, new Rectangle(0, 0, b.Width, b.Height));

            g.TextRenderingHint = TextRenderingHint.AntiAlias;
            for (int i = 0; i < _notNullCells.Length; i++)
            {
                g.FillPolygon(Brushes.Gainsboro, _notNullCells[i].Hex.K);
                var s = String.Format("{0}", _notNullCells[i].Axial); var w = g.MeasureString(s, _fnt).Width;
                g.DrawString(s, _fnt, _brush, _notNullCells[i].Hex.Center.X - w / 2, _notNullCells[i].Hex.Center.Y - 35, _drawFormat);
                s = String.Format("{0}", _notNullCells[i].Cube); w = g.MeasureString(s, _fnt).Width;
                g.DrawString(s, _fnt, _brush, _notNullCells[i].Hex.Center.X - w / 2, _notNullCells[i].Hex.Center.Y + 20, _drawFormat);
            }
            g.Flush();
            GridLayout = new Bitmap(b);
            g = null;
            b = null;

        }
        static GenericOperatorMath()
        {
            if (ReferenceEquals(typeof(T), typeof(Int16)))
            {
                Add                  = CastDelegate <TMath>((Func <Int16, Int16, Int16>)((Int16 a, Int16 b) => (Int16)(a + b)));
                Subtract             = CastDelegate <TMath>((Func <Int16, Int16, Int16>)((Int16 a, Int16 b) => (Int16)(a - b)));
                Multiply             = CastDelegate <TMath>((Func <Int16, Int16, Int16>)((Int16 a, Int16 b) => (Int16)(a * b)));
                LessThan             = CastDelegate <TMathBoolean>((Func <Int16, Int16, bool>)((Int16 a, Int16 b) => a < b));
                GreaterThan          = CastDelegate <TMathBoolean>((Func <Int16, Int16, bool>)((Int16 a, Int16 b) => a > b));
                LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <Int16, Int16, bool>)((Int16 a, Int16 b) => a <= b));
                GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <Int16, Int16, bool>)((Int16 a, Int16 b) => a >= b));
                ConvertToByte        = CastDelegate <ConvertTToByte>((Func <Int16, Byte>)((Int16 v) => Convert.ToByte(v)));
                ConvertToDecimal     = CastDelegate <ConvertTToDecimal>((Func <Int16, Decimal>)((Int16 v) => Convert.ToDecimal(v)));
                ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <Int16, Double>)((Int16 v) => Convert.ToDouble(v)));
                ConvertToInt16       = CastDelegate <ConvertTToInt16>((Func <Int16, Int16>)((Int16 v) => v));
                ConvertToInt32       = CastDelegate <ConvertTToInt32>((Func <Int16, Int32>)((Int16 v) => Convert.ToInt32(v)));
                ConvertToInt64       = CastDelegate <ConvertTToInt64>((Func <Int16, Int64>)((Int16 v) => Convert.ToInt64(v)));
                ConvertToSByte       = CastDelegate <ConvertTToSByte>((Func <Int16, SByte>)((Int16 v) => Convert.ToSByte(v)));
                ConvertToSingle      = CastDelegate <ConvertTToSingle>((Func <Int16, Single>)((Int16 v) => Convert.ToSingle(v)));
                ConvertToUInt16      = CastDelegate <ConvertTToUInt16>((Func <Int16, UInt16>)((Int16 v) => Convert.ToUInt16(v)));
                ConvertToUInt32      = CastDelegate <ConvertTToUInt32>((Func <Int16, UInt32>)((Int16 v) => Convert.ToUInt32(v)));
                ConvertToUInt64      = CastDelegate <ConvertTToUInt64>((Func <Int16, UInt64>)((Int16 v) => Convert.ToUInt64(v)));
                ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <Double, Int16>)((Double v) => Convert.ToInt16(v)));
                GetTypeCode          = CastDelegate <GetTTypeCode>((Func <TypeCode>)(() => TypeCode.Int16));
            }
            else if (ReferenceEquals(typeof(T), typeof(Int32)))
            {
                Add                  = CastDelegate <TMath>((Func <Int32, Int32, Int32>)((Int32 a, Int32 b) => a + b));
                Subtract             = CastDelegate <TMath>((Func <Int32, Int32, Int32>)((Int32 a, Int32 b) => a - b));
                Multiply             = CastDelegate <TMath>((Func <Int32, Int32, Int32>)((Int32 a, Int32 b) => a * b));
                LessThan             = CastDelegate <TMathBoolean>((Func <Int32, Int32, bool>)((Int32 a, Int32 b) => a < b));
                GreaterThan          = CastDelegate <TMathBoolean>((Func <Int32, Int32, bool>)((Int32 a, Int32 b) => a > b));
                LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <Int32, Int32, bool>)((Int32 a, Int32 b) => a <= b));
                GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <Int32, Int32, bool>)((Int32 a, Int32 b) => a >= b));
                ConvertToByte        = CastDelegate <ConvertTToByte>((Func <Int32, Byte>)((Int32 v) => Convert.ToByte(v)));
                ConvertToDecimal     = CastDelegate <ConvertTToDecimal>((Func <Int32, Decimal>)((Int32 v) => Convert.ToDecimal(v)));
                ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <Int32, Double>)((Int32 v) => Convert.ToDouble(v)));
                ConvertToInt16       = CastDelegate <ConvertTToInt16>((Func <Int32, Int16>)((Int32 v) => Convert.ToInt16(v)));
                ConvertToInt32       = CastDelegate <ConvertTToInt32>((Func <Int32, Int32>)((Int32 v) => v));
                ConvertToInt64       = CastDelegate <ConvertTToInt64>((Func <Int32, Int64>)((Int32 v) => Convert.ToInt64(v)));
                ConvertToSByte       = CastDelegate <ConvertTToSByte>((Func <Int32, SByte>)((Int32 v) => Convert.ToSByte(v)));
                ConvertToSingle      = CastDelegate <ConvertTToSingle>((Func <Int32, Single>)((Int32 v) => Convert.ToSingle(v)));
                ConvertToUInt16      = CastDelegate <ConvertTToUInt16>((Func <Int32, UInt16>)((Int32 v) => Convert.ToUInt16(v)));
                ConvertToUInt32      = CastDelegate <ConvertTToUInt32>((Func <Int32, UInt32>)((Int32 v) => Convert.ToUInt32(v)));
                ConvertToUInt64      = CastDelegate <ConvertTToUInt64>((Func <Int32, UInt64>)((Int32 v) => Convert.ToUInt64(v)));
                ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, Int32>)((double v) => Convert.ToInt32(v)));
                GetTypeCode          = CastDelegate <GetTTypeCode>((Func <TypeCode>)(() => TypeCode.Int32));
            }
            else if (ReferenceEquals(typeof(T), typeof(Int64)))
            {
                Add                  = CastDelegate <TMath>((Func <Int64, Int64, Int64>)((Int64 a, Int64 b) => a + b));
                Subtract             = CastDelegate <TMath>((Func <Int64, Int64, Int64>)((Int64 a, Int64 b) => a - b));
                Multiply             = CastDelegate <TMath>((Func <Int64, Int64, Int64>)((Int64 a, Int64 b) => a * b));
                LessThan             = CastDelegate <TMathBoolean>((Func <Int64, Int64, bool>)((Int64 a, Int64 b) => a < b));
                GreaterThan          = CastDelegate <TMathBoolean>((Func <Int64, Int64, bool>)((Int64 a, Int64 b) => a > b));
                LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <Int64, Int64, bool>)((Int64 a, Int64 b) => a <= b));
                GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <Int64, Int64, bool>)((Int64 a, Int64 b) => a >= b));
                ConvertToByte        = CastDelegate <ConvertTToByte>((Func <Int64, Byte>)((Int64 v) => Convert.ToByte(v)));
                ConvertToDecimal     = CastDelegate <ConvertTToDecimal>((Func <Int64, Decimal>)((Int64 v) => Convert.ToDecimal(v)));
                ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <Int64, Double>)((Int64 v) => Convert.ToDouble(v)));
                ConvertToInt16       = CastDelegate <ConvertTToInt16>((Func <Int64, Int16>)((Int64 v) => Convert.ToInt16(v)));
                ConvertToInt32       = CastDelegate <ConvertTToInt32>((Func <Int64, Int32>)((Int64 v) => Convert.ToInt32(v)));
                ConvertToInt64       = CastDelegate <ConvertTToInt64>((Func <Int64, Int64>)((Int64 v) => v));
                ConvertToSByte       = CastDelegate <ConvertTToSByte>((Func <Int64, SByte>)((Int64 v) => Convert.ToSByte(v)));
                ConvertToSingle      = CastDelegate <ConvertTToSingle>((Func <Int64, Single>)((Int64 v) => Convert.ToSingle(v)));
                ConvertToUInt16      = CastDelegate <ConvertTToUInt16>((Func <Int64, UInt16>)((Int64 v) => Convert.ToUInt16(v)));
                ConvertToUInt32      = CastDelegate <ConvertTToUInt32>((Func <Int64, UInt32>)((Int64 v) => Convert.ToUInt32(v)));
                ConvertToUInt64      = CastDelegate <ConvertTToUInt64>((Func <Int64, UInt64>)((Int64 v) => Convert.ToUInt64(v)));
                ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, Int64>)((double v) => Convert.ToInt64(v)));
                GetTypeCode          = CastDelegate <GetTTypeCode>((Func <TypeCode>)(() => TypeCode.Int64));
            }
            else if (ReferenceEquals(typeof(T), typeof(UInt16)))
            {
                Add                  = CastDelegate <TMath>((Func <UInt16, UInt16, UInt16>)((UInt16 a, UInt16 b) => (UInt16)(a + b)));
                Subtract             = CastDelegate <TMath>((Func <UInt16, UInt16, UInt16>)((UInt16 a, UInt16 b) => (UInt16)(a - b)));
                Multiply             = CastDelegate <TMath>((Func <UInt16, UInt16, UInt16>)((UInt16 a, UInt16 b) => (UInt16)(a * b)));
                LessThan             = CastDelegate <TMathBoolean>((Func <UInt16, UInt16, bool>)((UInt16 a, UInt16 b) => a < b));
                GreaterThan          = CastDelegate <TMathBoolean>((Func <UInt16, UInt16, bool>)((UInt16 a, UInt16 b) => a > b));
                LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <UInt16, UInt16, bool>)((UInt16 a, UInt16 b) => a <= b));
                GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <UInt16, UInt16, bool>)((UInt16 a, UInt16 b) => a >= b));
                ConvertToByte        = CastDelegate <ConvertTToByte>((Func <UInt16, Byte>)((UInt16 v) => Convert.ToByte(v)));
                ConvertToDecimal     = CastDelegate <ConvertTToDecimal>((Func <UInt16, Decimal>)((UInt16 v) => Convert.ToDecimal(v)));
                ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <UInt16, Double>)((UInt16 v) => Convert.ToDouble(v)));
                ConvertToInt16       = CastDelegate <ConvertTToInt16>((Func <UInt16, Int16>)((UInt16 v) => Convert.ToInt16(v)));
                ConvertToInt32       = CastDelegate <ConvertTToInt32>((Func <UInt16, Int32>)((UInt16 v) => Convert.ToInt32(v)));
                ConvertToInt64       = CastDelegate <ConvertTToInt64>((Func <UInt16, Int64>)((UInt16 v) => Convert.ToInt64(v)));
                ConvertToSByte       = CastDelegate <ConvertTToSByte>((Func <UInt16, SByte>)((UInt16 v) => Convert.ToSByte(v)));
                ConvertToSingle      = CastDelegate <ConvertTToSingle>((Func <UInt16, Single>)((UInt16 v) => Convert.ToSingle(v)));
                ConvertToUInt16      = CastDelegate <ConvertTToUInt16>((Func <UInt16, UInt16>)((UInt16 v) => v));
                ConvertToUInt32      = CastDelegate <ConvertTToUInt32>((Func <UInt16, UInt32>)((UInt16 v) => Convert.ToUInt32(v)));
                ConvertToUInt64      = CastDelegate <ConvertTToUInt64>((Func <UInt16, UInt64>)((UInt16 v) => Convert.ToUInt64(v)));
                ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, UInt16>)((double v) => Convert.ToUInt16(v)));
                GetTypeCode          = CastDelegate <GetTTypeCode>((Func <TypeCode>)(() => TypeCode.UInt16));
            }
            else if (ReferenceEquals(typeof(T), typeof(UInt32)))
            {
                Add                  = CastDelegate <TMath>((Func <UInt32, UInt32, UInt32>)((UInt32 a, UInt32 b) => a + b));
                Subtract             = CastDelegate <TMath>((Func <UInt32, UInt32, UInt32>)((UInt32 a, UInt32 b) => a - b));
                Multiply             = CastDelegate <TMath>((Func <UInt32, UInt32, UInt32>)((UInt32 a, UInt32 b) => a * b));
                LessThan             = CastDelegate <TMathBoolean>((Func <UInt32, UInt32, bool>)((UInt32 a, UInt32 b) => a < b));
                GreaterThan          = CastDelegate <TMathBoolean>((Func <UInt32, UInt32, bool>)((UInt32 a, UInt32 b) => a > b));
                LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <UInt32, UInt32, bool>)((UInt32 a, UInt32 b) => a <= b));
                GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <UInt32, UInt32, bool>)((UInt32 a, UInt32 b) => a >= b));
                ConvertToByte        = CastDelegate <ConvertTToByte>((Func <UInt32, Byte>)((UInt32 v) => Convert.ToByte(v)));
                ConvertToDecimal     = CastDelegate <ConvertTToDecimal>((Func <UInt32, Decimal>)((UInt32 v) => Convert.ToDecimal(v)));
                ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <UInt32, Double>)((UInt32 v) => Convert.ToDouble(v)));
                ConvertToInt16       = CastDelegate <ConvertTToInt16>((Func <UInt32, Int16>)((UInt32 v) => Convert.ToInt16(v)));
                ConvertToInt32       = CastDelegate <ConvertTToInt32>((Func <UInt32, Int32>)((UInt32 v) => Convert.ToInt32(v)));
                ConvertToInt64       = CastDelegate <ConvertTToInt64>((Func <UInt32, Int64>)((UInt32 v) => Convert.ToInt64(v)));
                ConvertToSByte       = CastDelegate <ConvertTToSByte>((Func <UInt32, SByte>)((UInt32 v) => Convert.ToSByte(v)));
                ConvertToSingle      = CastDelegate <ConvertTToSingle>((Func <UInt32, Single>)((UInt32 v) => Convert.ToSingle(v)));
                ConvertToUInt16      = CastDelegate <ConvertTToUInt16>((Func <UInt32, UInt16>)((UInt32 v) => Convert.ToUInt16(v)));
                ConvertToUInt32      = CastDelegate <ConvertTToUInt32>((Func <UInt32, UInt32>)((UInt32 v) => v));
                ConvertToUInt64      = CastDelegate <ConvertTToUInt64>((Func <UInt32, UInt64>)((UInt32 v) => Convert.ToUInt64(v)));
                ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, UInt32>)((double v) => Convert.ToUInt32(v)));
                GetTypeCode          = CastDelegate <GetTTypeCode>((Func <TypeCode>)(() => TypeCode.UInt32));
            }
            else if (ReferenceEquals(typeof(T), typeof(UInt64)))
            {
                Add                  = CastDelegate <TMath>((Func <UInt64, UInt64, UInt64>)((UInt64 a, UInt64 b) => a + b));
                Subtract             = CastDelegate <TMath>((Func <UInt64, UInt64, UInt64>)((UInt64 a, UInt64 b) => a - b));
                Multiply             = CastDelegate <TMath>((Func <UInt64, UInt64, UInt64>)((UInt64 a, UInt64 b) => a * b));
                LessThan             = CastDelegate <TMathBoolean>((Func <UInt64, UInt64, bool>)((UInt64 a, UInt64 b) => a < b));
                GreaterThan          = CastDelegate <TMathBoolean>((Func <UInt64, UInt64, bool>)((UInt64 a, UInt64 b) => a > b));
                LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <UInt64, UInt64, bool>)((UInt64 a, UInt64 b) => a <= b));
                GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <UInt64, UInt64, bool>)((UInt64 a, UInt64 b) => a >= b));
                ConvertToByte        = CastDelegate <ConvertTToByte>((Func <UInt64, Byte>)((UInt64 v) => Convert.ToByte(v)));
                ConvertToDecimal     = CastDelegate <ConvertTToDecimal>((Func <UInt64, Decimal>)((UInt64 v) => Convert.ToDecimal(v)));
                ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <UInt64, Double>)((UInt64 v) => Convert.ToDouble(v)));
                ConvertToInt16       = CastDelegate <ConvertTToInt16>((Func <UInt64, Int16>)((UInt64 v) => Convert.ToInt16(v)));
                ConvertToInt32       = CastDelegate <ConvertTToInt32>((Func <UInt64, Int32>)((UInt64 v) => Convert.ToInt32(v)));
                ConvertToInt64       = CastDelegate <ConvertTToInt64>((Func <UInt64, Int64>)((UInt64 v) => Convert.ToInt64(v)));
                ConvertToSByte       = CastDelegate <ConvertTToSByte>((Func <UInt64, SByte>)((UInt64 v) => Convert.ToSByte(v)));
                ConvertToSingle      = CastDelegate <ConvertTToSingle>((Func <UInt64, Single>)((UInt64 v) => Convert.ToSingle(v)));
                ConvertToUInt16      = CastDelegate <ConvertTToUInt16>((Func <UInt64, UInt16>)((UInt64 v) => Convert.ToUInt16(v)));
                ConvertToUInt32      = CastDelegate <ConvertTToUInt32>((Func <UInt64, UInt32>)((UInt64 v) => Convert.ToUInt32(v)));
                ConvertToUInt64      = CastDelegate <ConvertTToUInt64>((Func <UInt64, UInt64>)((UInt64 v) => v));
                ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, UInt64>)((double v) => Convert.ToUInt64(v)));
                GetTypeCode          = CastDelegate <GetTTypeCode>((Func <TypeCode>)(() => TypeCode.UInt64));
            }
            else if (ReferenceEquals(typeof(T), typeof(float)))
            {
                Add                  = CastDelegate <TMath>((Func <float, float, float>)((float a, float b) => a + b));
                Subtract             = CastDelegate <TMath>((Func <float, float, float>)((float a, float b) => a - b));
                Multiply             = CastDelegate <TMath>((Func <float, float, float>)((float a, float b) => a * b));
                LessThan             = CastDelegate <TMathBoolean>((Func <float, float, bool>)((float a, float b) => a < b));
                GreaterThan          = CastDelegate <TMathBoolean>((Func <float, float, bool>)((float a, float b) => a > b));
                LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <float, float, bool>)((float a, float b) => a <= b));
                GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <float, float, bool>)((float a, float b) => a >= b));
                ConvertToByte        = CastDelegate <ConvertTToByte>((Func <float, Byte>)((float v) => Convert.ToByte(v)));
                ConvertToDecimal     = CastDelegate <ConvertTToDecimal>((Func <float, Decimal>)((float v) => Convert.ToDecimal(v)));
                ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <float, Double>)((float v) => Convert.ToDouble(v)));
                ConvertToInt16       = CastDelegate <ConvertTToInt16>((Func <float, Int16>)((float v) => Convert.ToInt16(v)));
                ConvertToInt32       = CastDelegate <ConvertTToInt32>((Func <float, Int32>)((float v) => Convert.ToInt32(v)));
                ConvertToInt64       = CastDelegate <ConvertTToInt64>((Func <float, Int64>)((float v) => Convert.ToInt64(v)));
                ConvertToSByte       = CastDelegate <ConvertTToSByte>((Func <float, SByte>)((float v) => Convert.ToSByte(v)));
                ConvertToSingle      = CastDelegate <ConvertTToSingle>((Func <float, Single>)((float v) => v));
                ConvertToUInt16      = CastDelegate <ConvertTToUInt16>((Func <float, UInt16>)((float v) => Convert.ToUInt16(v)));
                ConvertToUInt32      = CastDelegate <ConvertTToUInt32>((Func <float, UInt32>)((float v) => Convert.ToUInt32(v)));
                ConvertToUInt64      = CastDelegate <ConvertTToUInt64>((Func <float, UInt64>)((float v) => Convert.ToUInt64(v)));
                ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, float>)((double v) => Convert.ToSingle(v)));
                GetTypeCode          = CastDelegate <GetTTypeCode>((Func <TypeCode>)(() => TypeCode.Single));
            }
            else if (ReferenceEquals(typeof(T), typeof(double)))
            {
                Add                  = CastDelegate <TMath>((Func <double, double, double>)((double a, double b) => a + b));
                Subtract             = CastDelegate <TMath>((Func <double, double, double>)((double a, double b) => a - b));
                Multiply             = CastDelegate <TMath>((Func <double, double, double>)((double a, double b) => a * b));
                LessThan             = CastDelegate <TMathBoolean>((Func <double, double, bool>)((double a, double b) => a < b));
                GreaterThan          = CastDelegate <TMathBoolean>((Func <double, double, bool>)((double a, double b) => a > b));
                LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <double, double, bool>)((double a, double b) => a <= b));
                GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <double, double, bool>)((double a, double b) => a >= b));
                ConvertToByte        = CastDelegate <ConvertTToByte>((Func <double, Byte>)((double v) => Convert.ToByte(v)));
                ConvertToDecimal     = CastDelegate <ConvertTToDecimal>((Func <double, Decimal>)((double v) => Convert.ToDecimal(v)));
                ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <double, Double>)((double v) => v));
                ConvertToInt16       = CastDelegate <ConvertTToInt16>((Func <double, Int16>)((double v) => Convert.ToInt16(v)));
                ConvertToInt32       = CastDelegate <ConvertTToInt32>((Func <double, Int32>)((double v) => Convert.ToInt32(v)));
                ConvertToInt64       = CastDelegate <ConvertTToInt64>((Func <double, Int64>)((double v) => Convert.ToInt64(v)));
                ConvertToSByte       = CastDelegate <ConvertTToSByte>((Func <double, SByte>)((double v) => Convert.ToSByte(v)));
                ConvertToSingle      = CastDelegate <ConvertTToSingle>((Func <double, Single>)((double v) => Convert.ToSingle(v)));
                ConvertToUInt16      = CastDelegate <ConvertTToUInt16>((Func <double, UInt16>)((double v) => Convert.ToUInt16(v)));
                ConvertToUInt32      = CastDelegate <ConvertTToUInt32>((Func <double, UInt32>)((double v) => Convert.ToUInt32(v)));
                ConvertToUInt64      = CastDelegate <ConvertTToUInt64>((Func <double, UInt64>)((double v) => Convert.ToUInt64(v)));
                ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, double>)((double v) => v));
                GetTypeCode          = CastDelegate <GetTTypeCode>((Func <TypeCode>)(() => TypeCode.Double));
            }
            else if (ReferenceEquals(typeof(T), typeof(decimal)))
            {
                Add                  = CastDelegate <TMath>((Func <decimal, decimal, decimal>)((decimal a, decimal b) => a + b));
                Subtract             = CastDelegate <TMath>((Func <decimal, decimal, decimal>)((decimal a, decimal b) => a - b));
                Multiply             = CastDelegate <TMath>((Func <decimal, decimal, decimal>)((decimal a, decimal b) => a * b));
                LessThan             = CastDelegate <TMathBoolean>((Func <decimal, decimal, bool>)((decimal a, decimal b) => a < b));
                GreaterThan          = CastDelegate <TMathBoolean>((Func <decimal, decimal, bool>)((decimal a, decimal b) => a > b));
                LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <decimal, decimal, bool>)((decimal a, decimal b) => a <= b));
                GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <decimal, decimal, bool>)((decimal a, decimal b) => a >= b));
                ConvertToByte        = CastDelegate <ConvertTToByte>((Func <decimal, Byte>)((decimal v) => Convert.ToByte(v)));
                ConvertToDecimal     = CastDelegate <ConvertTToDecimal>((Func <decimal, Decimal>)((decimal v) => v));
                ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <decimal, Double>)((decimal v) => Convert.ToDouble(v)));
                ConvertToInt16       = CastDelegate <ConvertTToInt16>((Func <decimal, Int16>)((decimal v) => Convert.ToInt16(v)));
                ConvertToInt32       = CastDelegate <ConvertTToInt32>((Func <decimal, Int32>)((decimal v) => Convert.ToInt32(v)));
                ConvertToInt64       = CastDelegate <ConvertTToInt64>((Func <decimal, Int64>)((decimal v) => Convert.ToInt64(v)));
                ConvertToSByte       = CastDelegate <ConvertTToSByte>((Func <decimal, SByte>)((decimal v) => Convert.ToSByte(v)));
                ConvertToSingle      = CastDelegate <ConvertTToSingle>((Func <decimal, Single>)((decimal v) => Convert.ToSingle(v)));
                ConvertToUInt16      = CastDelegate <ConvertTToUInt16>((Func <decimal, UInt16>)((decimal v) => Convert.ToUInt16(v)));
                ConvertToUInt32      = CastDelegate <ConvertTToUInt32>((Func <decimal, UInt32>)((decimal v) => Convert.ToUInt32(v)));
                ConvertToUInt64      = CastDelegate <ConvertTToUInt64>((Func <decimal, UInt64>)((decimal v) => Convert.ToUInt64(v)));
                ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, decimal>)((double v) => Convert.ToDecimal(v)));
                GetTypeCode          = CastDelegate <GetTTypeCode>((Func <TypeCode>)(() => TypeCode.Decimal));
            }
            else if (ReferenceEquals(typeof(T), typeof(sbyte)))
            {
                Add                  = CastDelegate <TMath>((Func <sbyte, sbyte, sbyte>)((sbyte a, sbyte b) => (sbyte)(a + b)));
                Subtract             = CastDelegate <TMath>((Func <sbyte, sbyte, sbyte>)((sbyte a, sbyte b) => (sbyte)(a - b)));
                Multiply             = CastDelegate <TMath>((Func <sbyte, sbyte, sbyte>)((sbyte a, sbyte b) => (sbyte)(a * b)));
                LessThan             = CastDelegate <TMathBoolean>((Func <sbyte, sbyte, bool>)((sbyte a, sbyte b) => a < b));
                GreaterThan          = CastDelegate <TMathBoolean>((Func <sbyte, sbyte, bool>)((sbyte a, sbyte b) => a > b));
                LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <sbyte, sbyte, bool>)((sbyte a, sbyte b) => a <= b));
                GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <sbyte, sbyte, bool>)((sbyte a, sbyte b) => a >= b));
                ConvertToByte        = CastDelegate <ConvertTToByte>((Func <sbyte, Byte>)((sbyte v) => Convert.ToByte(v)));
                ConvertToDecimal     = CastDelegate <ConvertTToDecimal>((Func <sbyte, Decimal>)((sbyte v) => Convert.ToDecimal(v)));
                ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <sbyte, Double>)((sbyte v) => Convert.ToDouble(v)));
                ConvertToInt16       = CastDelegate <ConvertTToInt16>((Func <sbyte, Int16>)((sbyte v) => Convert.ToInt16(v)));
                ConvertToInt32       = CastDelegate <ConvertTToInt32>((Func <sbyte, Int32>)((sbyte v) => Convert.ToInt32(v)));
                ConvertToInt64       = CastDelegate <ConvertTToInt64>((Func <sbyte, Int64>)((sbyte v) => Convert.ToInt64(v)));
                ConvertToSByte       = CastDelegate <ConvertTToSByte>((Func <sbyte, SByte>)((sbyte v) => v));
                ConvertToSingle      = CastDelegate <ConvertTToSingle>((Func <sbyte, Single>)((sbyte v) => Convert.ToSingle(v)));
                ConvertToUInt16      = CastDelegate <ConvertTToUInt16>((Func <sbyte, UInt16>)((sbyte v) => Convert.ToUInt16(v)));
                ConvertToUInt32      = CastDelegate <ConvertTToUInt32>((Func <sbyte, UInt32>)((sbyte v) => Convert.ToUInt32(v)));
                ConvertToUInt64      = CastDelegate <ConvertTToUInt64>((Func <sbyte, UInt64>)((sbyte v) => Convert.ToUInt64(v)));
                ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, sbyte>)((double v) => Convert.ToSByte(v)));
                GetTypeCode          = CastDelegate <GetTTypeCode>((Func <TypeCode>)(() => TypeCode.SByte));
            }
            else if (ReferenceEquals(typeof(T), typeof(byte)))
            {
                Add                  = CastDelegate <TMath>((Func <byte, byte, byte>)((byte a, byte b) => (byte)(a + b)));
                Subtract             = CastDelegate <TMath>((Func <byte, byte, byte>)((byte a, byte b) => (byte)(a - b)));
                Multiply             = CastDelegate <TMath>((Func <byte, byte, byte>)((byte a, byte b) => (byte)(a * b)));
                LessThan             = CastDelegate <TMathBoolean>((Func <byte, byte, bool>)((byte a, byte b) => a < b));
                GreaterThan          = CastDelegate <TMathBoolean>((Func <byte, byte, bool>)((byte a, byte b) => a > b));
                LessThanOrEqualTo    = CastDelegate <TMathBoolean>((Func <byte, byte, bool>)((byte a, byte b) => a <= b));
                GreaterThanOrEqualTo = CastDelegate <TMathBoolean>((Func <byte, byte, bool>)((byte a, byte b) => a >= b));
                ConvertToByte        = CastDelegate <ConvertTToByte>((Func <byte, Byte>)((byte v) => v));
                ConvertToDecimal     = CastDelegate <ConvertTToDecimal>((Func <byte, Decimal>)((byte v) => Convert.ToDecimal(v)));
                ConvertToDouble      = CastDelegate <ConvertTToDouble>((Func <byte, Double>)((byte v) => Convert.ToDouble(v)));
                ConvertToInt16       = CastDelegate <ConvertTToInt16>((Func <byte, Int16>)((byte v) => Convert.ToInt16(v)));
                ConvertToInt32       = CastDelegate <ConvertTToInt32>((Func <byte, Int32>)((byte v) => Convert.ToInt32(v)));
                ConvertToInt64       = CastDelegate <ConvertTToInt64>((Func <byte, Int64>)((byte v) => Convert.ToInt64(v)));
                ConvertToSByte       = CastDelegate <ConvertTToSByte>((Func <byte, SByte>)((byte v) => Convert.ToSByte(v)));
                ConvertToSingle      = CastDelegate <ConvertTToSingle>((Func <byte, Single>)((byte v) => Convert.ToSingle(v)));
                ConvertToUInt16      = CastDelegate <ConvertTToUInt16>((Func <byte, UInt16>)((byte v) => Convert.ToUInt16(v)));
                ConvertToUInt32      = CastDelegate <ConvertTToUInt32>((Func <byte, UInt32>)((byte v) => Convert.ToUInt32(v)));
                ConvertToUInt64      = CastDelegate <ConvertTToUInt64>((Func <byte, UInt64>)((byte v) => Convert.ToUInt64(v)));
                ConvertFromDouble    = CastDelegate <ConvertDoubleToT>((Func <double, byte>)((double v) => Convert.ToByte(v)));
                GetTypeCode          = CastDelegate <GetTTypeCode>((Func <TypeCode>)(() => TypeCode.Byte));
            }
            else
            {
#pragma warning disable CA1065 // Do not raise exceptions in unexpected locations
                throw new NotSupportedException();
#pragma warning restore CA1065 // Do not raise exceptions in unexpected locations
            }
        }
예제 #27
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="MT19937Generator"/> class, using a
 ///   time-dependent default seed value.
 /// </summary>
 public MT19937Generator() : base(TMath.Seed())
 {
 }
예제 #28
0
 public void SetUp()
 {
     _math = new TMath();
 }
예제 #29
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="ALFGenerator"/> class, using a
 ///   time-dependent default seed value.
 /// </summary>
 public ALFGenerator() : base(TMath.Seed())
 {
 }
예제 #30
0
 public static Axial ToAxial(this Cube a)
 {
     return(new Axial(TMath.Round(a.X), TMath.Round(a.Z)));
 }