Пример #1
0
        public static void short16()
        {
            Random16 rng = new Random16(135);

            for (int i = 0; i < 64; i++)
            {
                short16  x = rng.NextShort16();
                ushort16 n = rng.NextUShort16();

                Assert.AreEqual(new short16((short)_intpow(x.x0, n.x0),
                                            (short)_intpow(x.x1, n.x1),
                                            (short)_intpow(x.x2, n.x2),
                                            (short)_intpow(x.x3, n.x3),
                                            (short)_intpow(x.x4, n.x4),
                                            (short)_intpow(x.x5, n.x5),
                                            (short)_intpow(x.x6, n.x6),
                                            (short)_intpow(x.x7, n.x7),
                                            (short)_intpow(x.x8, n.x8),
                                            (short)_intpow(x.x9, n.x9),
                                            (short)_intpow(x.x10, n.x10),
                                            (short)_intpow(x.x11, n.x11),
                                            (short)_intpow(x.x12, n.x12),
                                            (short)_intpow(x.x13, n.x13),
                                            (short)_intpow(x.x14, n.x14),
                                            (short)_intpow(x.x15, n.x15)),
                                maxmath.intpow(x, n));
            }
        }
Пример #2
0
        /// <exception cref="System.IO.IOException"/>
        public static void OutputRecords(OutputStream @out, bool useAscii, Unsigned16 firstRecordNumber
                                         , Unsigned16 recordsToGenerate, Unsigned16 checksum)
        {
            byte[]     row              = new byte[100];
            Unsigned16 recordNumber     = new Unsigned16(firstRecordNumber);
            Unsigned16 lastRecordNumber = new Unsigned16(firstRecordNumber);
            Checksum   crc              = new PureJavaCrc32();
            Unsigned16 tmp              = new Unsigned16();

            lastRecordNumber.Add(recordsToGenerate);
            Unsigned16 One  = new Unsigned16(1);
            Unsigned16 rand = Random16.SkipAhead(firstRecordNumber);

            while (!recordNumber.Equals(lastRecordNumber))
            {
                Random16.NextRand(rand);
                if (useAscii)
                {
                    GenerateAsciiRecord(row, rand, recordNumber);
                }
                else
                {
                    GenerateRecord(row, rand, recordNumber);
                }
                if (checksum != null)
                {
                    crc.Reset();
                    crc.Update(row, 0, row.Length);
                    tmp.Set(crc.GetValue());
                    checksum.Add(tmp);
                }
                recordNumber.Add(One);
                @out.Write(row);
            }
        }
Пример #3
0
        public static void ushort16()
        {
            Random16 rng = new Random16(135);

            for (int i = 0; i < 64; i++)
            {
                ushort16 x = rng.NextUShort16();

                Assert.AreEqual(new ushort16((ushort)_intsqrt(x.x0),
                                             (ushort)_intsqrt(x.x1),
                                             (ushort)_intsqrt(x.x2),
                                             (ushort)_intsqrt(x.x3),
                                             (ushort)_intsqrt(x.x4),
                                             (ushort)_intsqrt(x.x5),
                                             (ushort)_intsqrt(x.x6),
                                             (ushort)_intsqrt(x.x7),
                                             (ushort)_intsqrt(x.x8),
                                             (ushort)_intsqrt(x.x9),
                                             (ushort)_intsqrt(x.x10),
                                             (ushort)_intsqrt(x.x11),
                                             (ushort)_intsqrt(x.x12),
                                             (ushort)_intsqrt(x.x13),
                                             (ushort)_intsqrt(x.x14),
                                             (ushort)_intsqrt(x.x15)),
                                maxmath.intsqrt(x));
            }
        }
Пример #4
0
        public static void short16()
        {
            Random16 rng = new Random16(135);

            for (int i = 0; i < 64; i++)
            {
                short16 x = rng.NextShort16();

                Assert.AreEqual(new short16((short)maxmath.lzcnt(x.x0),
                                            (short)maxmath.lzcnt(x.x1),
                                            (short)maxmath.lzcnt(x.x2),
                                            (short)maxmath.lzcnt(x.x3),
                                            (short)maxmath.lzcnt(x.x4),
                                            (short)maxmath.lzcnt(x.x5),
                                            (short)maxmath.lzcnt(x.x6),
                                            (short)maxmath.lzcnt(x.x7),
                                            (short)maxmath.lzcnt(x.x8),
                                            (short)maxmath.lzcnt(x.x9),
                                            (short)maxmath.lzcnt(x.x10),
                                            (short)maxmath.lzcnt(x.x11),
                                            (short)maxmath.lzcnt(x.x12),
                                            (short)maxmath.lzcnt(x.x13),
                                            (short)maxmath.lzcnt(x.x14),
                                            (short)maxmath.lzcnt(x.x15)),
                                maxmath.lzcnt(x));
            }
        }
Пример #5
0
        public static void ushort16()
        {
            Random16 rng = new Random16(135);

            for (int i = 0; i < 64; i++)
            {
                ushort16 x = rng.NextUShort16();
                ushort16 y = rng.NextUShort16();

                Assert.AreEqual(new ushort16((ushort)_gcd(x.x0, y.x0),
                                             (ushort)_gcd(x.x1, y.x1),
                                             (ushort)_gcd(x.x2, y.x2),
                                             (ushort)_gcd(x.x3, y.x3),
                                             (ushort)_gcd(x.x4, y.x4),
                                             (ushort)_gcd(x.x5, y.x5),
                                             (ushort)_gcd(x.x6, y.x6),
                                             (ushort)_gcd(x.x7, y.x7),
                                             (ushort)_gcd(x.x8, y.x8),
                                             (ushort)_gcd(x.x9, y.x9),
                                             (ushort)_gcd(x.x10, y.x10),
                                             (ushort)_gcd(x.x11, y.x11),
                                             (ushort)_gcd(x.x12, y.x12),
                                             (ushort)_gcd(x.x13, y.x13),
                                             (ushort)_gcd(x.x14, y.x14),
                                             (ushort)_gcd(x.x15, y.x15)),
                                maxmath.gcd(x, y));
            }
        }
Пример #6
0
        public static void ushort4()
        {
            Random16 rng = new Random16(135);

            for (int i = 0; i < 64; i++)
            {
                ushort4 x = rng.NextUShort4();

                Assert.AreEqual(new ushort4((ushort)_intsqrt(x.x), (ushort)_intsqrt(x.y), (ushort)_intsqrt(x.z), (ushort)_intsqrt(x.w)), maxmath.intsqrt(x));
            }
        }
Пример #7
0
        public static void ushort3()
        {
            Random16 rng = new Random16(135);

            for (int i = 0; i < 64; i++)
            {
                ushort3 x = rng.NextUShort3();

                Assert.AreEqual(new ushort3((ushort)maxmath.lzcnt(x.x), (ushort)maxmath.lzcnt(x.y), (ushort)maxmath.lzcnt(x.z)), maxmath.lzcnt(x));
            }
        }
Пример #8
0
        public static void short4()
        {
            Random16 rng = new Random16(135);

            for (int i = 0; i < 64; i++)
            {
                short4 x = rng.NextShort4();

                Assert.AreEqual(new short4((short)maxmath.lzcnt(x.x), (short)maxmath.lzcnt(x.y), (short)maxmath.lzcnt(x.z), (short)maxmath.lzcnt(x.w)), maxmath.lzcnt(x));
            }
        }
Пример #9
0
        public static void ushort4()
        {
            Random16 rng = new Random16(135);

            for (int i = 0; i < 64; i++)
            {
                ushort4 x = rng.NextUShort4();
                ushort4 y = rng.NextUShort4();

                Assert.AreEqual(new ushort4((ushort)_gcd(x.x, y.x), (ushort)_gcd(x.y, y.y), (ushort)_gcd(x.z, y.z), (ushort)_gcd(x.w, y.w)), maxmath.gcd(x, y));
            }
        }
Пример #10
0
        public static void short3()
        {
            Random16 rng = new Random16(135);

            for (int i = 0; i < 64; i++)
            {
                short3 x = rng.NextShort3();
                short3 y = rng.NextShort3();

                Assert.AreEqual(new ushort3((ushort)_gcd(x.x, y.x), (ushort)_gcd(x.y, y.y), (ushort)_gcd(x.z, y.z)), maxmath.gcd(x, y));
            }
        }
Пример #11
0
        public static void short4()
        {
            Random16 rng = new Random16(135);

            for (int i = 0; i < 64; i++)
            {
                short4  x = rng.NextShort4();
                ushort4 n = rng.NextUShort4();

                Assert.AreEqual(new short4((short)_intpow(x.x, n.x), (short)_intpow(x.y, n.y), (short)_intpow(x.z, n.z), (short)_intpow(x.w, n.w)), maxmath.intpow(x, n));
            }
        }
Пример #12
0
        public static void ushort8()
        {
            Random16 rng = new Random16(135);

            for (int i = 0; i < 64; i++)
            {
                ushort8 x = rng.NextUShort8();

                Assert.AreEqual(new ushort8((ushort)maxmath.lzcnt(x.x0),
                                            (ushort)maxmath.lzcnt(x.x1),
                                            (ushort)maxmath.lzcnt(x.x2),
                                            (ushort)maxmath.lzcnt(x.x3),
                                            (ushort)maxmath.lzcnt(x.x4),
                                            (ushort)maxmath.lzcnt(x.x5),
                                            (ushort)maxmath.lzcnt(x.x6),
                                            (ushort)maxmath.lzcnt(x.x7)),
                                maxmath.lzcnt(x));
            }
        }
Пример #13
0
 /// <exception cref="System.IO.IOException"/>
 /// <exception cref="System.Exception"/>
 protected override void Map(LongWritable row, NullWritable ignored, Mapper.Context
                             context)
 {
     if (rand == null)
     {
         rowId           = new Unsigned16(row.Get());
         rand            = Random16.SkipAhead(rowId);
         checksumCounter = context.GetCounter(TeraGen.Counters.Checksum);
     }
     Random16.NextRand(rand);
     GenSort.GenerateRecord(buffer, rand, rowId);
     key.Set(buffer, 0, TeraInputFormat.KeyLength);
     value.Set(buffer, TeraInputFormat.KeyLength, TeraInputFormat.ValueLength);
     context.Write(key, value);
     crc32.Reset();
     crc32.Update(buffer, 0, TeraInputFormat.KeyLength + TeraInputFormat.ValueLength);
     checksum.Set(crc32.GetValue());
     total.Add(checksum);
     rowId.Add(One);
 }
Пример #14
0
        public static void ushort8()
        {
            Random16 rng = new Random16(135);

            for (int i = 0; i < 64; i++)
            {
                ushort8 x = rng.NextUShort8();
                ushort8 y = rng.NextUShort8();

                Assert.AreEqual(new ushort8((ushort)_gcd(x.x0, y.x0),
                                            (ushort)_gcd(x.x1, y.x1),
                                            (ushort)_gcd(x.x2, y.x2),
                                            (ushort)_gcd(x.x3, y.x3),
                                            (ushort)_gcd(x.x4, y.x4),
                                            (ushort)_gcd(x.x5, y.x5),
                                            (ushort)_gcd(x.x6, y.x6),
                                            (ushort)_gcd(x.x7, y.x7)),
                                maxmath.gcd(x, y));
            }
        }
Пример #15
0
        public static void short8()
        {
            Random16 rng = new Random16(135);

            for (int i = 0; i < 64; i++)
            {
                short8  x = rng.NextShort8();
                ushort8 n = rng.NextUShort8();

                Assert.AreEqual(new short8((short)_intpow(x.x0, n.x0),
                                           (short)_intpow(x.x1, n.x1),
                                           (short)_intpow(x.x2, n.x2),
                                           (short)_intpow(x.x3, n.x3),
                                           (short)_intpow(x.x4, n.x4),
                                           (short)_intpow(x.x5, n.x5),
                                           (short)_intpow(x.x6, n.x6),
                                           (short)_intpow(x.x7, n.x7)),
                                maxmath.intpow(x, n));
            }
        }