コード例 #1
0
            public static double[] GExp(int n, int s, int AlgIndex)
            {
                double[] mass = new double[s];

                double[] x = new double[s];

                switch (AlgIndex)
                {
                case (-1):
                case (0):
                    x = Algs.CSRandom(s);
                    break;

                case (1):
                    x = Algs.SCongruence(n, s);
                    break;

                case (2):
                    x = Algs.Lehmer(s);
                    break;
                }

                for (int i = 0; i < s; i++)
                {
                    mass[i] = Math.Pow(-Math.Log(x[i]) / 1, 1.3);
                }

                return(mass);
            }
コード例 #2
0
 public void AddElement(string value)
 {
     string[] arr = GetModel <string[]>();
     Algs.IncreseArray(ref arr, arr.Length + 1);
     arr[arr.Length - 1] = value;
     SetModel(arr);
 }
コード例 #3
0
            public static double[] Triangle(int n, int s, int AlgIndex)
            {
                double[] mass = new double[s];

                int b = n / 2;

                double[] x = new double[s * 2];

                switch (AlgIndex)
                {
                case (-1):
                case (0):
                    x = Algs.CSRandom(s * 2);
                    break;

                case (1):
                    x = Algs.SCongruence(n, s * 2);
                    break;

                case (2):
                    x = Algs.Lehmer(s * 2);
                    break;
                }

                for (int i = 0; i < s; i++)
                {
                    x[i]     = x[i] * b;
                    x[s + i] = b - x[s + i] * b;

                    mass[i] = x[i] + x[s + i];
                }

                return(mass);
            }
コード例 #4
0
 public RsaSignHash(Algs alg, byte[] value)
 {
     Code = (byte[])RsaSignHash.codes[alg];
     Info = new byte[Code.Length + value.Length];
     Code.CopyTo(Info, 0);
     value.CopyTo(Info, Code.Length);
 }
コード例 #5
0
        private void button16_Click(object sender, EventArgs e)
        {
            int    size           = Convert.ToInt32(textBox29.Text);
            int    countIntervals = Convert.ToInt32(textBox31.Text);
            int    countSeries    = Convert.ToInt32(textBox30.Text);
            int    k = Convert.ToInt32(textBox24.Text);
            double L = Convert.ToInt32(textBox32.Text);

            Series[] seriesMass = new Series[countSeries];
            for (int s = 0; s < countSeries; s++)
            {
                seriesMass[s] = new Series {
                    Name = "Испытание " + (countErlSeries + 1)
                };
                countErlSeries++;

                double[] values = Algs.Erl(countIntervals, size, k, L, listBox5.SelectedIndex);
                int[]    arr    = new int[countIntervals];

                foreach (var value in values)
                {
                    arr[(int)value]++;
                }

                // Добавление данных в серию
                for (int i = 0; i < countIntervals; i++)
                {
                    seriesMass[s].Points.AddXY(i + 1, arr[i]);
                }
                // Добавление серии в гистограмму
                chartErl.Series.Add(seriesMass[s]);
            }
        }
コード例 #6
0
            public static double[] Trapezoid(int n, int s, int v, int AlgIndex)
            {
                double[] mass = new double[s];

                int b = (n / 2) - (v / 2);
                int c = (n / 2) + (v / 2);

                double[] x = new double[s * 2];

                switch (AlgIndex)
                {
                case (-1):
                case (0):
                    x = Algs.CSRandom(s * 2);
                    break;

                case (1):
                    x = Algs.SCongruence(n, s * 2);
                    break;

                case (2):
                    x = Algs.Lehmer(s * 2);
                    break;
                }

                for (int i = 0; i < s; i++)
                {
                    x[i]    *= b;
                    x[s + i] = x[s + i] * -c + c;

                    mass[i] = x[i] + x[s + i];
                }

                return(mass);
            }
コード例 #7
0
        private void button22_Click(object sender, EventArgs e)
        {
            int size           = Convert.ToInt32(textBox35.Text);
            int countIntervals = Convert.ToInt32(textBox38.Text);
            int countSeries    = Convert.ToInt32(textBox37.Text);

            Series[] seriesMass = new Series[countSeries];
            for (int s = 0; s < countSeries; s++)
            {
                seriesMass[s] = new Series {
                    Name = "Испытание " + (countNormalSeries + 1)
                };
                countNormalSeries++;

                double[] values = Algs.Muller(countIntervals, size, listBox8.SelectedIndex);
                int[]    arr    = new int[countIntervals];

                foreach (var value in values)
                {
                    if (value > 0 && value < countIntervals)
                    {
                        arr[(int)value]++;
                    }
                }

                // Добавление данных в серию
                for (int i = 0; i < countIntervals; i++)
                {
                    seriesMass[s].Points.AddXY(i + 1, arr[i]);
                }

                // Добавление серии в гистограмму
                chartM.Series.Add(seriesMass[s]);
            }
        }
コード例 #8
0
        // Построить Гиперэксп
        private void button18_Click(object sender, EventArgs e)
        {
            chartGExp.Series.Clear();
            int    size           = Convert.ToInt32(textBox34.Text);
            int    countIntervals = Convert.ToInt32(textBox36.Text);
            Series s = new Series {
                Name = "Испытание"
            };

            countGExpSeries++;

            double[] arr = Algs.GExp(countIntervals, size, listBox6.SelectedIndex);


            // Добавление данных в серию
            for (int i = 0; i < size; i++)
            {
                s.Points.AddXY(arr[i], 1);
            }
            // Добавление серии в гистограмму
            chartGExp.Series.Add(s);
            double interval = (arr.Max() - arr.Min()) / (double)countIntervals;

            chartGExp.DataManipulator.Sort(PointSortOrder.Ascending, "X", "Испытание");
            chartGExp.DataManipulator.Group("Count", interval, IntervalType.Number, "Испытание");
        }
コード例 #9
0
        // Труегольник
        private void button10_Click(object sender, EventArgs e)
        {
            int size           = Convert.ToInt32(textBox17.Text);
            int countSeries    = Convert.ToInt32(textBox14.Text);
            int shift          = Convert.ToInt32(textBox15.Text);
            int countIntervals = Convert.ToInt32(textBox16.Text);

            Series[] seriesMass = new Series[countSeries];

            for (int s = 0; s < countSeries; s++)
            {
                seriesMass[s] = new Series {
                    Name = "Испытание " + (countTriangleSeries + 1)
                };
                countTriangleSeries++;

                double[] values = Algs.Triangle(countIntervals, size, listBox2.SelectedIndex);
                int[]    arr    = new int[countIntervals];

                foreach (var value in values)
                {
                    arr[(int)value]++;
                }

                // Добавление данных в серию
                for (int i = 0; i < countIntervals; i++)
                {
                    seriesMass[s].Points.AddXY(i + 1 + shift, arr[i]);
                }

                // Добавление серии в гистограмму
                chartTriangle.Series.Add(seriesMass[s]);
            }
        }
コード例 #10
0
 public RsaSignHash(byte[] info)
 {
     foreach (DictionaryEntry de in codes)
     {
         bool sr = true;
         int  i  = 0;
         foreach (byte b in (byte[])de.Value)
         {
             if (info[i++] != b)
             {
                 sr = false; break;
             }
         }
         if (sr == true)
         {
             Alg   = (Algs)de.Key;
             Value = new byte[info.Length - i];
             int j = 0;
             while (i < info.Length)
             {
                 Value[j++] = info[i++];
             }
             break;
         }
     }
 }
コード例 #11
0
        public static void GenerateShips(IEnumerable <ShipSystemModel> ships, IEnumerable <ShipDriver> drivers, Vector3 position, Quaternion rotation, Vector3 up, Vector3 right, Vector3 forward, DistributionCube cube, ICollection <ShipController> outGeneratedShips)
        {
            int shipsAmount = drivers.Count();

            int[] shipsDistribution = Algs.Split(shipsAmount, Enumerable.Range(0, cube.cubesAmount).Select(i => UnityEngine.Random.value).ToArray());
            int   n = 0;

            var driver = drivers.GetEnumerator();
            var ship   = ships.GetEnumerator();

            foreach (var pos in cube.Distribute(position, up, right, forward))
            {
                for (int m = 0; m < shipsDistribution[n]; m++)
                {
                    driver.MoveNext();
                    ship.MoveNext();

                    var oldShip = driver.Current.ship;
                    var s       = new CustomShipInitializerModel(ship.Current, driver.Current)
                                  .Init(pos + right * (20 * m), rotation);

                    outGeneratedShips.Add(s);
                }

                n++;
            }
        }
コード例 #12
0
            public static double[] Muller(int n, int s, int AlgIndex)
            {
                double[] mass = new double[s];

                double[] x = new double[s * 2];

                switch (AlgIndex)
                {
                case (-1):
                case (0):
                    x = Algs.CSRandom(s * 2);
                    break;

                case (1):
                    x = Algs.SCongruence(n, s * 2);
                    break;

                case (2):
                    x = Algs.Lehmer(s * 2);
                    break;
                }

                for (int i = 0; i < s - 1; i++)
                {
                    for (int j = i * 2; j < (i + 1) * 2; j++)
                    {
                        mass[i] = (-6 + Math.Sqrt(-2 * Math.Log(x[j]))) * (-6 + Math.Sin(2 * Math.PI * x[j + 1]));
                    }
                }

                return(mass);
            }
コード例 #13
0
        // Метод Лемера
        private void button4_Click(object sender, EventArgs e)
        {
            int size           = Convert.ToInt32(textBox7.Text);
            int countIntervals = Convert.ToInt32(textBox8.Text);
            int countSeries    = Convert.ToInt32(textBox9.Text);

            Series[] seriesMass = new Series[countSeries];

            for (int s = 0; s < countSeries; s++)
            {
                seriesMass[s] = new Series {
                    Name = "Испытание " + (countLehmerSeries + 1)
                };
                countLehmerSeries++;

                double[] values = Algs.Lehmer(size);
                int[]    arr    = new int[countIntervals];

                foreach (var value in values)
                {
                    arr[(int)(value * countIntervals)]++;
                }

                // Добавление данных в серию
                for (int i = 0; i < countIntervals; i++)
                {
                    seriesMass[s].Points.AddXY(i + 1, arr[i]);
                }

                // Добавление серии в гистограмму
                chartLehmer.Series.Add(seriesMass[s]);
            }
        }
コード例 #14
0
ファイル: NeTernRelObj.cs プロジェクト: cell-lang/csharp
        public override TernRelIter GetTernRelIterByCol12(Obj val1, Obj val2)
        {
            int[] firstAndCount = Algs.BinSearchRange(col1, col2, val1, val2);
            int   first         = firstAndCount[0];
            int   count         = firstAndCount[1];

            return(new TernRelIter(col1, col2, col3, null, first, first + count - 1));
        }
コード例 #15
0
ファイル: NeTernRelObj.cs プロジェクト: cell-lang/csharp
 public override bool Contains13(Obj val1, Obj val3)
 {
     if (idxs312 == null)
     {
         idxs312 = Algs.SortedIndexes(col3, col1, col2);
     }
     return(Algs.BinSearchRange(idxs312, col3, col1, val3, val1)[1] > 0);
 }
コード例 #16
0
 public override bool Contains2(Obj obj)
 {
     if (revIdxs == null)
     {
         revIdxs = Algs.SortedIndexes(col2, col1);
     }
     return(Algs.BinSearchRange(revIdxs, col2, obj)[1] > 0);
 }
コード例 #17
0
    Color[] GenerateTexture(int width, int height)
    {
        var random = ConcurrentRandomProvider.GetRandom();

        Color[] usecs = Enumerable.Range(0, random.Next(2, 5)).Select(i => new Color((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble())).ToArray();

        return(Algs.GenerateColorArray(usecs, width, height, 2, random));
    }
コード例 #18
0
ファイル: NeTernRelObj.cs プロジェクト: cell-lang/csharp
 public override bool Contains23(Obj val2, Obj val3)
 {
     if (idxs231 == null)
     {
         idxs231 = Algs.SortedIndexes(col2, col3, col1);
     }
     return(Algs.BinSearchRange(idxs231, col2, col3, val2, val3)[1] > 0);
 }
コード例 #19
0
ファイル: SunBehaviour.cs プロジェクト: Danil20-8/FlyOn
    Texture2D GenerateTexture(Color[] colors, int size)
    {
        Texture2D tex = new Texture2D(size, size);

        var random = ConcurrentRandomProvider.GetRandom();

        tex.SetPixels(Algs.GenerateColorArray(colors, size, size, 1, random));
        tex.Apply();
        return(tex);
    }
コード例 #20
0
        public override BinRelIter GetBinRelIterByCol2(Obj obj)
        {
            if (revIdxs == null)
            {
                revIdxs = Algs.SortedIndexes(col2, col1);
            }
            int[] firstAndCount = Algs.BinSearchRange(revIdxs, col2, obj);
            int   first         = firstAndCount[0];
            int   count         = firstAndCount[1];

            return(new BinRelIter(col1, col2, revIdxs, first, first + count - 1));
        }
コード例 #21
0
ファイル: NeTernRelObj.cs プロジェクト: cell-lang/csharp
        public override TernRelIter GetTernRelIterByCol23(Obj val2, Obj val3)
        {
            if (idxs231 == null)
            {
                idxs231 = Algs.SortedIndexes(col2, col3, col1);
            }
            int[] firstAndCount = Algs.BinSearchRange(idxs231, col2, col3, val2, val3);
            int   first         = firstAndCount[0];
            int   count         = firstAndCount[1];

            return(new TernRelIter(col1, col2, col3, idxs231, first, first + count - 1));
        }
コード例 #22
0
        public Form1()
        {
            InitializeComponent();

            openFileDialog1.Filter = ".jpg|*.jpg";
            saveFileDialog1.Filter = ".jpg|*.jpg";

            currAlg             = Algs.Grayscale;
            rbGrayscale.Checked = true;

            threshold1 = 100;
            threshold2 = 100;
            tbMonochromeThreshold.Text  = threshold1.ToString();
            tbDetectEdgesThreshold.Text = threshold2.ToString();
        }
コード例 #23
0
ファイル: SunBehaviour.cs プロジェクト: Danil20-8/FlyOn
    Color[][] GenerateAnimation(Color color, int size)
    {
        Color[] usecs = new Color[] { color * .8f, color, color *(2f * .8f) };

        Color[][] animation = new Color[animation_frames][];

        var random = ConcurrentRandomProvider.GetRandom();

        Color[] origin = Algs.GenerateColorArray(usecs, size, size, 1, random);
        Color[] final  = Algs.GenerateColorArray(usecs, size, size, 1, random);

        for (int i = 1; i < animation_frames - 1; i++)
        {
            animation[i] = LerpColorArray(origin, final, ((float)i) / animation_frames);
        }

        animation[0] = origin;
        animation[animation_frames - 1] = final;

        return(animation);
    }
コード例 #24
0
            public static double[] Erl(int n, int s, int k, double L, int AlgIndex)
            {
                double[] mass = new double[s];

                double[] x = new double[s * k];

                x = Algs.Exp(n, s * k, L, AlgIndex);
                double S = 0;

                for (int i = 0; i < s; i++)
                {
                    S = 0;
                    for (int j = i * k; j < (i + 1) * k; j++)
                    {
                        S += x[j];
                    }

                    mass[i] = S;
                }

                return(mass);
            }
コード例 #25
0
ファイル: NeTernRelObj.cs プロジェクト: cell-lang/csharp
        public override bool Contains(Obj obj1, Obj obj2, Obj obj3)
        {
            int[] firstAndCount = Algs.BinSearchRange(col1, 0, col1.Length, obj1);
            int   first         = firstAndCount[0];
            int   count         = firstAndCount[1];

            if (count == 0)
            {
                return(false);
            }

            firstAndCount = Algs.BinSearchRange(col2, first, count, obj2);
            first         = firstAndCount[0];
            count         = firstAndCount[1];
            if (count == 0)
            {
                return(false);
            }

            int idx = Algs.BinSearch(col3, first, count, obj3);

            return(idx != -1);
        }
コード例 #26
0
            public static double[] Normal(int n, int s, int Mx, int sigma, int AlgIndex)
            {
                double[] mass = new double[s];
                double   m    = n;

                double[] x = new double[s * n];

                switch (AlgIndex)
                {
                case (-1):
                case (0):
                    x = Algs.CSRandom(s * n);
                    break;

                case (1):
                    x = Algs.SCongruence(n, s * n);
                    break;

                case (2):
                    x = Algs.Lehmer(s * n);
                    break;
                }

                for (int i = 0; i < s; i++)
                {
                    double S = 0;

                    for (int j = n * i; j < n * (i + 1); j++)
                    {
                        S += x[j];
                    }

                    mass[i] = Mx + (sigma * (Math.Sqrt(12 / m) * (S - (m / 2))));
                }

                return(mass);
            }
コード例 #27
0
ファイル: BillboardShots.cs プロジェクト: Danil20-8/FlyOn
    public void Fire(IShot shot, Vector3 start, Vector3 dir, float speed, float lifeTime, ShipController friend)
    {
        if (count == shots.Length)
        {
            int l  = shots.Length;
            int wl = shots.Length * 2 + 1;
            Algs.IncreseArray(ref shots, wl);
            Algs.IncreseArray(ref verts, wl * size);
            Algs.IncreseArray(ref uvs, wl * size);

            for (int i = l; i < wl; i++)
            {
                shots[i] = new SShot();
            }
        }

        shots[count].pos      = start;
        shots[count].back     = shots[count].pos;
        shots[count].velocity = dir * speed;
        shots[count].dead     = Time.time + lifeTime;
        shots[count].friend   = friend;
        shots[count].shot     = shot;
        count++;
    }
コード例 #28
0
 Color[] GenerateColorArray(System.Random random)
 {
     Color[] usecs = Enumerable.Range(0, random.Next(2, 5)).Select(i => RandomTColor(random)).ToArray();
     return(Algs.GenerateColorArray(usecs, size, size, 1, random));
 }
コード例 #29
0
 void UpdateBehabiours()
 {
     RecalcWeights();
     Algs.ShakerSort(behaviours, _behaviourWeights);
 }
コード例 #30
0
        public static ShipSystemModel[] GenerateShipModels(ShipSystemModel[] models, int amount, float[] classWeights, IEnumerable <ShipIndexPair> specialShips = null)
        {
            var ships = models
                        .GroupBy(s => GameResources.GetShipHull(s.hull.hullName).shipClass)
                        .Where(s => s.Key > 0 && s.Key < 4)
                        .OrderBy(s => s.Key)
                        .Select(s => s.ToArray()).ToArray();

            int[] kShips = Algs.Split(amount, classWeights);

            var result = new LimitedRandomList <MyRandom <ShipSystemModel> >(ships
                                                                             .Select(kShips, (s, k) => new LimitedProperty <MyRandom <ShipSystemModel> >(new MyRandom <ShipSystemModel>(s), k)).ToArray()
                                                                             ).Select(v => (ShipSystemModel)v).ToArray();

            if (specialShips != null)
            {
                foreach (var s in specialShips)
                {
                    int             specialShipClass = s.GetShipClass(ships);
                    ShipSystemModel specialShipModel = s.GetModel(ships);

                    if (result[s.index] == specialShipModel)
                    {
                        continue;
                    }
                    else
                    {
                        //looking for same model in other position
                        for (int i = 0; i < amount; i++)
                        {
                            // next if index used by other special model
                            if (specialShips.Any(p => p.index == i))
                            {
                                continue;
                            }

                            if (result[i] == specialShipModel)
                            {
                                var t = result[i];
                                result[i]       = result[s.index];
                                result[s.index] = t;
                                goto NEXT;
                            }
                        }
                    }

                    if (GetShipClass(ships, result[s.index]) == specialShipClass)
                    {
                        result[s.index] = specialShipModel;
                        continue;
                    }
                    else
                    {
                        //looking for same model class in other position;
                        for (int i = 0; i < amount; i++)
                        {
                            // next if index used by other special model
                            if (specialShips.Any(p => p.index == i))
                            {
                                continue;
                            }

                            if (GetShipClass(ships, result[i]) == specialShipClass)
                            {
                                result[i]       = result[s.index];
                                result[s.index] = specialShipModel;
                                goto NEXT;
                            }
                        }
                    }
                    //Brute setting model
                    result[s.index] = specialShipModel;

NEXT:
                    continue;
                }
            }

            return(result);
        }