Example #1
0
        static int TestBool()
        {
            Random random = new Random(13);
            byte[] arr1 = GenerateByteArray(64, random);
            byte[] arr2 = GenerateByteArray(64, random);
            var a = new System.Numerics.Vector<byte>(arr1);
            var b = new System.Numerics.Vector<byte>(arr2);

            var xorR = a ^ b;
            var andR = a & b;
            var orR = a | b;
            int Count = System.Numerics.Vector<byte>.Count;
            for (int i = 0; i < Count; ++i)
            {
                int d = a[i] ^ b[i];
                if (xorR[i] != d)
                {
                    return 0;
                }
                d = a[i] & b[i];
                if (andR[i] != d)
                {
                    return 0;
                }
                d = a[i] | b[i];
                if (orR[i] != d)
                {
                    return 0;
                }
            }
            return 100;
        }
Example #2
0
 static int TestDouble()
 {
     Random random = new Random(11);
     double[] arr1 = new double[] { NextFloat(random), NextFloat(random), NextFloat(random), NextFloat(random) };
     double[] arr2 = new double[] { NextFloat(random), NextFloat(random), NextFloat(random), NextFloat(random) };
     var a = new System.Numerics.Vector<double>(arr1);
     var b = new System.Numerics.Vector<double>(arr2);
     var xorR = a ^ b;
     var andR = a & b;
     var orR = a | b;
     int Count = System.Numerics.Vector<double>.Count;
     for (int i = 0; i < Count; ++i)
     {
         Int64 f = BitConverter.DoubleToInt64Bits(a[i]);
         Int64 s = BitConverter.DoubleToInt64Bits(b[i]);
         Int64 r = f ^ s;
         double d = BitConverter.Int64BitsToDouble(r);
         if (xorR[i] != d)
         {
             return 0;
         }
         r = f & s;
         d = BitConverter.Int64BitsToDouble(r);
         if (andR[i] != d)
         {
             return 0;
         }
         r = f | s;
         d = BitConverter.Int64BitsToDouble(r);
         if (orR[i] != d && d == d)
         {
             return 0;
         }
     }
     return 100;
 }
Example #3
0
 public static System.Numerics.Vector <T> Equals <T>(System.Numerics.Vector <T> left, System.Numerics.Vector <T> right) where T : struct
 {
     throw null;
 }
Example #4
0
 public static System.Numerics.Vector <System.Int64> Equals(System.Numerics.Vector <System.Int64> left, System.Numerics.Vector <System.Int64> right)
 {
     throw null;
 }
Example #5
0
 public static System.Numerics.Vector <System.UInt32> ConvertToUInt32(System.Numerics.Vector <System.Single> value)
 {
     throw null;
 }
Example #6
0
 public static System.Numerics.Vector <T> ConditionalSelect <T>(System.Numerics.Vector <T> condition, System.Numerics.Vector <T> left, System.Numerics.Vector <T> right) where T : struct
 {
     throw null;
 }
Example #7
0
 public static void Widen(System.Numerics.Vector <System.Single> source, out System.Numerics.Vector <System.Double> dest1, out System.Numerics.Vector <System.Double> dest2)
 {
     throw null;
 }
Example #8
0
 public static System.Numerics.Vector <System.UInt32> Narrow(System.Numerics.Vector <System.UInt64> source1, System.Numerics.Vector <System.UInt64> source2)
 {
     throw null;
 }
Example #9
0
 public static System.Numerics.Vector <System.Single> Narrow(System.Numerics.Vector <System.Double> source1, System.Numerics.Vector <System.Double> source2)
 {
     throw null;
 }
Example #10
0
 public static System.Numerics.Vector <System.SByte> AsVectorSByte <T>(System.Numerics.Vector <T> value) where T : struct
 {
     throw null;
 }
Example #11
0
 [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] public static System.Numerics.Vector <T> Xor <T>(System.Numerics.Vector <T> left, System.Numerics.Vector <T> right) where T : struct
 {
     throw null;
 }
Example #12
0
 public static void Widen(System.Numerics.Vector <System.UInt32> source, out System.Numerics.Vector <System.UInt64> low, out System.Numerics.Vector <System.UInt64> high)
 {
     low = default(System.Numerics.Vector <ulong>); high = default(System.Numerics.Vector <ulong>);
 }
Example #13
0
 public static void Widen(System.Numerics.Vector <System.UInt16> source, out System.Numerics.Vector <System.UInt32> low, out System.Numerics.Vector <System.UInt32> high)
 {
     low = default(System.Numerics.Vector <uint>); high = default(System.Numerics.Vector <uint>);
 }
Example #14
0
 public static void Widen(System.Numerics.Vector <System.Single> source, out System.Numerics.Vector <System.Double> low, out System.Numerics.Vector <System.Double> high)
 {
     low = default(System.Numerics.Vector <double>); high = default(System.Numerics.Vector <double>);
 }
Example #15
0
 public static void Widen(System.Numerics.Vector <System.SByte> source, out System.Numerics.Vector <System.Int16> low, out System.Numerics.Vector <System.Int16> high)
 {
     low = default(System.Numerics.Vector <short>); high = default(System.Numerics.Vector <short>);
 }
Example #16
0
 public static System.Numerics.Vector <System.UInt32> Narrow(System.Numerics.Vector <System.UInt64> low, System.Numerics.Vector <System.UInt64> high)
 {
     throw null;
 }
Example #17
0
 public static System.Numerics.Vector <System.Int64> LessThanOrEqual(System.Numerics.Vector <System.Int64> left, System.Numerics.Vector <System.Int64> right)
 {
     throw null;
 }
Example #18
0
 [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] public static System.Numerics.Vector <System.Single> AsVectorSingle <T>(System.Numerics.Vector <T> value) where T : struct
 {
     throw null;
 }
Example #19
0
 public static System.Numerics.Vector <System.Byte> Narrow(System.Numerics.Vector <System.UInt16> source1, System.Numerics.Vector <System.UInt16> source2)
 {
     throw null;
 }
Example #20
0
 public static System.Numerics.Vector <System.UInt32> AsVectorUInt32 <T>(System.Numerics.Vector <T> value) where T : struct
 {
     throw null;
 }
Example #21
0
 public static void Widen(System.Numerics.Vector <System.SByte> source, out System.Numerics.Vector <System.Int16> dest1, out System.Numerics.Vector <System.Int16> dest2)
 {
     throw null;
 }
Example #22
0
        ///////////////////////////////////
        /////////Расчет на основе векторов
        public static int[,] FileVect()
        {
            string[] stchar;
            int      i = 0, j = 0;

            int[,] cliArr = new int[9, 5];
            int[,] ordArr = new int[9, 5];
            int stout;

            ///////Читаем файлы
            var FileCli = System.IO.File.ReadAllLines("clients.txt");
            var FileOrd = System.IO.File.ReadAllLines("orders.txt");

            foreach (var sttr in FileCli)
            {
                stchar = sttr.Split("\t");
                j      = 0;

                foreach (var stch in stchar)
                {
                    if (int.TryParse(stch, out stout) == false)
                    {
                        continue;
                    }
                    cliArr[i, j] = stout;
                    j++;
                }
                i++;
            }

            //    ///////Заполняем 4 вектора
            //    //string[] ColA = FileOrd.Where(entry =>
            //    //(entry?.Split("\t")[2] == "A"))?.ToArray();

            //    //string[] ColB = FileOrd.Where(entry =>
            //    //(entry?.Split("\t")[2] == "B"))?.ToArray();

            //    //string[] ColC = FileOrd.Where(entry =>
            //    //(entry?.Split("\t")[2] == "C"))?.ToArray();

            //    //string[] ColD = FileOrd.Where(entry =>
            //    //(entry?.Split("\t")[2] == "D"))?.ToArray();

            //    ////////Переписываю с форами и молотилкой привидения к виду
            Array.Sort(FileOrd);

            //    ////////Все ABCD для ячейки C1, C1 b A, C1 s A, C1 b B, C1 b
            //    //////за один такт нужно посчитать минимум 4 ячейки

            //    ////Получаем значения для одномерки
            //    ////Будет форыч основанный на счетчиках, будем шагать при смене буквы и ячейки, при этом сразу считать.
            //    ////координаты это счетчики
            int  M = 0; int mstep = 0;
            bool flagS = false;
            int  strNum = 0; int oldstrNum = 0;
            int  colNum = 0; int oldcolNum = 0;

            int[] CalcMassive = new int[800];
            int[] resArr      = new int[4];
            int   SUMM        = 0;
            int   Dollars     = 0;

            //float[] resArr2 = new float[2];

            System.Diagnostics.Stopwatch swatch = new System.Diagnostics.Stopwatch();
            swatch.Start();

            foreach (var sttr in FileOrd)
            //for (i=0; i <= FileOrd.Length; i++)
            {
                //String sttr = FileOrd[i];
                stchar = sttr.Split("\t");
                //flagS = false;
                ////////Запоминаем текущую строку, как только меняется + и обновляем
                if (strNum != int.Parse(stchar[0].Substring(1)) - 1 ||
                    colNum != (int)Char.Parse(stchar[2]) - 65)
                {
                    strNum = int.Parse(stchar[0].Substring(1)) - 1;
                    colNum = (int)Char.Parse(stchar[2]) - 65;

                    int Znak = 0;
                    if (stchar[1] == "b")
                    {
                        Znak = 1;
                    }
                    else
                    {
                        Znak = -1;
                    }
                    Dollars = Dollars + int.Parse(stchar[4]) * Znak;

                    //Console.WriteLine(CalcMassive.Sum());
                    //////Вычисляем кратность 8 количества элементов, будет происходить смещение на 4 индекса,
                    //////разложил для удобства
                    if (mstep % 8 != 0)
                    {
                        M = ((((mstep / 8) + 1) * 8) + 4);
                    }
                    else
                    {
                        M = mstep + 4;
                    }
                    //////Начиная с четырех элементов с шагом в 8 будет 4-8, 0-4; 12-16, 8-12
                    for (i = 4; i <= M; i += System.Numerics.Vector <int> .Count + 4)
                    {
                        //////Заполняем первые 8

                        System.Numerics.Vector <int> aSimd = new System.Numerics.Vector <int>(CalcMassive, i);
                        System.Numerics.Vector <int> bSimd = new System.Numerics.Vector <int>(CalcMassive, i - 4);

                        System.Numerics.Vector <int> cSimd = aSimd + bSimd;

                        cSimd.CopyTo(resArr);

                        int arrsum = resArr.Sum();

                        SUMM = SUMM + arrsum;
                    }

                    Array.Clear(CalcMassive, 0, mstep);
                    Array.Clear(resArr, 0, resArr.Length);

                    //////////Сумму ячейки считаем мы
                    cliArr[oldstrNum, oldcolNum] = cliArr[oldstrNum, oldcolNum] + SUMM;
                    cliArr[oldstrNum, 4]         = cliArr[oldstrNum, 4] + Dollars;
                    oldstrNum = strNum;
                    oldcolNum = colNum;
                    Dollars   = 0;
                    SUMM      = 0;
                    mstep     = 0;
                }
                else
                {
                    int Znak = 0;
                    if (stchar[1] == "b")
                    {
                        Znak = 1;
                    }
                    else
                    {
                        Znak = -1;
                    }
                    CalcMassive[mstep] = int.Parse(stchar[3]) * Znak;
                    Dollars            = Dollars + int.Parse(stchar[4]) * Znak;
                    mstep++;
                }
            }

            swatch.Stop();
            Console.WriteLine(swatch.Elapsed);
            return(cliArr);
        }
Example #23
0
 public static void Widen(System.Numerics.Vector <System.UInt32> source, out System.Numerics.Vector <System.UInt64> dest1, out System.Numerics.Vector <System.UInt64> dest2)
 {
     throw null;
 }
Example #24
0
        private void GetAndMoveToFrontDecode()
        {
            byte[] yy = new byte[256];
            int    nextSym;

            int limitLast = BZip2Constants.BaseBlockSize * blockSize100k;

            origPtr = BsGetIntVS(24);

            RecvDecodingTables();
            int EOB      = nInUse + 1;
            int groupNo  = -1;
            int groupPos = 0;

            /*--
             * Setting up the unzftab entries here is not strictly
             * necessary, but it does save having to do it later
             * in a separate pass, and so saves a block's worth of
             * cache misses.
             * --*/
            for (int i = 0; i <= 255; i++)
            {
                unzftab[i] = 0;
            }

            for (int i = 0; i <= 255; i++)
            {
                yy[i] = (byte)i;
            }

            last = -1;

            if (groupPos == 0)
            {
                groupNo++;
                groupPos = BZip2Constants.GroupSize;
            }

            groupPos--;
            int zt   = selector[groupNo];
            int zn   = minLens[zt];
            int zvec = BsR(zn);
            int zj;

            while (zvec > limit[zt][zn])
            {
                if (zn > 20)
                {                 // the longest code
                    throw new BZip2Exception("Bzip data error");
                }
                zn++;
                while (bsLive < 1)
                {
                    FillBuffer();
                }
                zj = (bsBuff >> (bsLive - 1)) & 1;
                bsLive--;
                zvec = (zvec << 1) | zj;
            }
            if (zvec - baseArray[zt][zn] < 0 || zvec - baseArray[zt][zn] >= BZip2Constants.MaximumAlphaSize)
            {
                throw new BZip2Exception("Bzip data error");
            }
            nextSym = perm[zt][zvec - baseArray[zt][zn]];

            while (true)
            {
                if (nextSym == EOB)
                {
                    break;
                }

                if (nextSym == BZip2Constants.RunA || nextSym == BZip2Constants.RunB)
                {
                    int s = -1;
                    int n = 1;
                    do
                    {
                        if (nextSym == BZip2Constants.RunA)
                        {
                            s += (0 + 1) * n;
                        }
                        else if (nextSym == BZip2Constants.RunB)
                        {
                            s += (1 + 1) * n;
                        }

                        n <<= 1;

                        if (groupPos == 0)
                        {
                            groupNo++;
                            groupPos = BZip2Constants.GroupSize;
                        }

                        groupPos--;

                        zt   = selector[groupNo];
                        zn   = minLens[zt];
                        zvec = BsR(zn);

                        while (zvec > limit[zt][zn])
                        {
                            zn++;
                            while (bsLive < 1)
                            {
                                FillBuffer();
                            }
                            zj = (bsBuff >> (bsLive - 1)) & 1;
                            bsLive--;
                            zvec = (zvec << 1) | zj;
                        }
                        nextSym = perm[zt][zvec - baseArray[zt][zn]];
                    } while (nextSym == BZip2Constants.RunA || nextSym == BZip2Constants.RunB);

                    s++;
                    byte ch = seqToUnseq[yy[0]];
                    unzftab[ch] += s;

                    while (s > 0)
                    {
                        last++;
                        ll8[last] = ch;
                        s--;
                    }

                    if (last >= limitLast)
                    {
                        BlockOverrun();
                    }
                    continue;
                }
                else
                {
                    last++;
                    if (last >= limitLast)
                    {
                        BlockOverrun();
                    }

                    byte tmp = yy[nextSym - 1];
                    unzftab[seqToUnseq[tmp]]++;
                    ll8[last] = seqToUnseq[tmp];

                    var j = nextSym - 1;

#if !NETSTANDARD2_0 && !NETFRAMEWORK
                    // This is vectorized memory move. Going from the back, we're taking chunks of array
                    // and write them at the new location shifted by one. Since chunks are VectorSize long,
                    // at the end we have to move "tail" (or head actually) of the array using a plain loop.
                    // If System.Numerics.Vector API is not available, the plain loop is used to do the whole copying.

                    while (j >= VectorSize)
                    {
                        var arrayPart = new System.Numerics.Vector <byte>(yy, j - VectorSize);
                        arrayPart.CopyTo(yy, j - VectorSize + 1);
                        j -= VectorSize;
                    }
#endif

                    while (j > 0)
                    {
                        yy[j] = yy[--j];
                    }

                    yy[0] = tmp;

                    if (groupPos == 0)
                    {
                        groupNo++;
                        groupPos = BZip2Constants.GroupSize;
                    }

                    groupPos--;
                    zt   = selector[groupNo];
                    zn   = minLens[zt];
                    zvec = BsR(zn);
                    while (zvec > limit[zt][zn])
                    {
                        zn++;
                        while (bsLive < 1)
                        {
                            FillBuffer();
                        }
                        zj = (bsBuff >> (bsLive - 1)) & 1;
                        bsLive--;
                        zvec = (zvec << 1) | zj;
                    }
                    nextSym = perm[zt][zvec - baseArray[zt][zn]];
                    continue;
                }
            }
        }
Example #25
0
 public static System.Numerics.Vector <T> Abs <T>(System.Numerics.Vector <T> value) where T : struct
 {
     throw null;
 }
Example #26
0
 static void ntt1(ref Span <uint> a, bool rev = false)
 {
     var alen = a.Length; if (alen == 1)
     {
         return;
     }
     var halfn = alen >> 1; Span <uint> b = new uint[alen]; var s = pow1(root1, rev ? (mod1 - 1 - (mod1 - 1) / (uint)alen) : (mod1 - 1) / (uint)alen); int i, j, k, l, r; var regLength = System.Numerics.Vector <uint> .Count; Span <uint> mods = stackalloc uint[regLength]; mods.Fill(mod1); var modV = new System.Numerics.Vector <uint>(mods); var kp = new uint[halfn + 1]; ref uint kpref = ref kp[0]; kpref = 1; for (l = 0; l < halfn; ++l)
Example #27
0
 public static System.Numerics.Vector <System.UInt64> ConvertToUInt64(System.Numerics.Vector <System.Double> value)
 {
     throw null;
 }
Example #28
0
 public static System.Numerics.Vector <System.Double> ConditionalSelect(System.Numerics.Vector <System.Int64> condition, System.Numerics.Vector <System.Double> left, System.Numerics.Vector <System.Double> right)
 {
     throw null;
 }
Example #29
0
 public static System.Numerics.Vector <System.Int32> Equals(System.Numerics.Vector <System.Single> left, System.Numerics.Vector <System.Single> right)
 {
     throw null;
 }
Example #30
0
 public static System.Numerics.Vector <System.Int32> GreaterThanOrEqual(System.Numerics.Vector <System.Single> left, System.Numerics.Vector <System.Single> right)
 {
     throw null;
 }
Example #31
0
 public static System.Numerics.Vector <System.Int64> GreaterThan(System.Numerics.Vector <System.Double> left, System.Numerics.Vector <System.Double> right)
 {
     throw null;
 }
Example #32
0
 public static System.Numerics.Vector <System.Int32> LessThan(System.Numerics.Vector <System.Int32> left, System.Numerics.Vector <System.Int32> right)
 {
     throw null;
 }