Esempio n. 1
0
 public sbyte3x2(sbyte m00, sbyte m01,
                 sbyte m10, sbyte m11,
                 sbyte m20, sbyte m21)
 {
     this.c0 = new sbyte3(m00, m10, m20);
     this.c1 = new sbyte3(m01, m11, m21);
 }
Esempio n. 2
0
 public sbyte3x4(sbyte v)
 {
     this.c0 = v;
     this.c1 = v;
     this.c2 = v;
     this.c3 = v;
 }
Esempio n. 3
0
        public sbyte8(sbyte2 x01, sbyte3 x234, sbyte3 x567)
        {
            if (Sse2.IsSse2Supported)
            {
                v128 mid = Sse2.bslli_si128(x234, 2 * sizeof(sbyte));
                v128 hi  = Sse2.bslli_si128(x567, 5 * sizeof(sbyte));

                hi = Mask.BlendV(mid, hi, new byte8(0, 0, 0, 0, 0, 255, 255, 255));

                if (Sse4_1.IsSse41Supported)
                {
                    this = Sse4_1.blend_epi16(x01, hi, 0b1110);
                }
                else
                {
                    this = Mask.BlendEpi16_SSE2(x01, hi, 0b1110);
                }
            }
            else
            {
                this.x0 = x01.x;
                this.x1 = x01.y;
                this.x2 = x234.x;
                this.x3 = x234.y;
                this.x4 = x234.z;
                this.x5 = x567.x;
                this.x6 = x567.y;
                this.x7 = x567.z;
            }
        }
Esempio n. 4
0
 public sbyte3x4(sbyte3 c0, sbyte3 c1, sbyte3 c2, sbyte3 c3)
 {
     this.c0 = c0;
     this.c1 = c1;
     this.c2 = c2;
     this.c3 = c3;
 }
Esempio n. 5
0
        public sbyte8(sbyte3 x012, sbyte2 x34, sbyte3 x567)
        {
            if (Sse2.IsSse2Supported)
            {
                v128 hi = Sse2.bslli_si128(x567, 2 * sizeof(sbyte));
                if (Sse4_1.IsSse41Supported)
                {
                    hi = Sse4_1.blend_epi16(x34, hi, 0b0110);
                }
                else
                {
                    hi = Mask.BlendEpi16_SSE2(x34, hi, 0b0110);
                }
                hi = Sse2.bslli_si128(hi, 3 * sizeof(sbyte));

                this = Mask.BlendV(x012, hi, new byte8(0, 0, 0, 255, 255, 255, 255, 255));
            }
            else
            {
                this.x0 = x012.x;
                this.x1 = x012.y;
                this.x2 = x012.z;
                this.x3 = x34.x;
                this.x4 = x34.y;
                this.x5 = x567.x;
                this.x6 = x567.y;
                this.x7 = x567.z;
            }
        }
Esempio n. 6
0
        public sbyte8(sbyte3 x012, sbyte3 x345, sbyte2 x67)
        {
            if (Sse2.IsSse2Supported)
            {
                v128 mid = Sse2.bslli_si128(x345, 3 * sizeof(sbyte));
                v128 hi  = Sse2.bslli_si128(x67, 6 * sizeof(sbyte));

                mid = Mask.BlendV(x012, mid, new byte8(0, 0, 0, 255, 255, 255, 0, 0));

                if (Sse4_1.IsSse41Supported)
                {
                    this = Sse4_1.blend_epi16(mid, hi, 0b1000);
                }
                else
                {
                    this = Mask.BlendEpi16_SSE2(mid, hi, 0b1000);
                }
            }
            else
            {
                this.x0 = x012.x;
                this.x1 = x012.y;
                this.x2 = x012.z;
                this.x3 = x345.x;
                this.x4 = x345.y;
                this.x5 = x345.z;
                this.x6 = x67.x;
                this.x7 = x67.y;
            }
        }
Esempio n. 7
0
        public static byte3 lcm(sbyte3 x, sbyte3 y)
        {
            byte3 absX = (byte3)abs(x);
            byte3 absY = (byte3)abs(y);

            return((absX / gcd(absX, absY)) * absY);
        }
Esempio n. 8
0
        public static bool3 isdivisible(sbyte3 dividend, sbyte3 divisor)
        {
            Assert.AreNotEqual(0, divisor.x);
            Assert.AreNotEqual(0, divisor.y);
            Assert.AreNotEqual(0, divisor.z);

            return(dividend % divisor == 0);
        }
Esempio n. 9
0
        public static void Constructor_SByte_SByte2()
        {
            sbyte3 x = new sbyte3(TestData_LHS[0].x, new sbyte2(TestData_LHS[0].y, TestData_LHS[0].z));

            Assert.AreEqual(x.x == TestData_LHS[0].x &
                            x.y == TestData_LHS[0].y &
                            x.z == TestData_LHS[0].z, true);
        }
Esempio n. 10
0
 public sbyte3x3(sbyte m00, sbyte m01, sbyte m02,
                 sbyte m10, sbyte m11, sbyte m12,
                 sbyte m20, sbyte m21, sbyte m22)
 {
     this.c0 = new sbyte3(m00, m10, m20);
     this.c1 = new sbyte3(m01, m11, m21);
     this.c2 = new sbyte3(m02, m12, m22);
 }
Esempio n. 11
0
 public sbyte3x4(sbyte m00, sbyte m01, sbyte m02, sbyte m03,
                 sbyte m10, sbyte m11, sbyte m12, sbyte m13,
                 sbyte m20, sbyte m21, sbyte m22, sbyte m23)
 {
     this.c0 = new sbyte3(m00, m10, m20);
     this.c1 = new sbyte3(m01, m11, m21);
     this.c2 = new sbyte3(m02, m12, m22);
     this.c3 = new sbyte3(m03, m13, m23);
 }
Esempio n. 12
0
        internal static sbyte3 vdiv_sbyte(sbyte3 dividend, sbyte3 divisor)
        {
            Assert.AreNotEqual(divisor.x, 0);
            Assert.AreNotEqual(divisor.y, 0);
            Assert.AreNotEqual(divisor.z, 0);

            v128 floatResult = vdiv_byte_quotient((int3)dividend, (int3)divisor);

            return((sbyte3)(*(float3 *)&floatResult));
        }
Esempio n. 13
0
 public static quarter3 asquarter(sbyte3 x)
 {
     if (Sse.IsSseSupported)
     {
         return((v128)x);
     }
     else
     {
         return(*(quarter3 *)&x);
     }
 }
Esempio n. 14
0
        public static void sbyte3()
        {
            Random8 rng = new Random8(135);

            for (int i = 0; i < 64; i++)
            {
                sbyte3 x = rng.NextSByte3();

                Assert.AreEqual(new sbyte3((sbyte)maxmath.lzcnt(x.x), (sbyte)maxmath.lzcnt(x.y), (sbyte)maxmath.lzcnt(x.z)), maxmath.lzcnt(x));
            }
        }
Esempio n. 15
0
 public static sbyte3 subadd(sbyte3 a, sbyte3 b)
 {
     if (Ssse3.IsSsse3Supported)
     {
         return(a + Ssse3.sign_epi8(b, new byte4(255, 1, 255, 1)));
     }
     else
     {
         return(a - select(b, -b, new bool3(false, true, false)));
     }
 }
Esempio n. 16
0
        public static void sbyte3()
        {
            Random8 rng = new Random8(135);

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

                Assert.AreEqual(new byte3((byte)_gcd(x.x, y.x), (byte)_gcd(x.y, y.y), (byte)_gcd(x.z, y.z)), maxmath.gcd(x, y));
            }
        }
Esempio n. 17
0
 public static sbyte3 divrem(sbyte3 dividend, sbyte divisor, out sbyte3 remainder)
 {
     if (Constant.IsConstantExpression(divisor))
     {
         remainder = dividend % divisor;
         return(dividend / divisor);
     }
     else
     {
         return(divrem(dividend, (sbyte3)divisor, out remainder));
     }
 }
Esempio n. 18
0
        public static void sbyte3()
        {
            Random8 rng = new Random8(135);

            for (int i = 0; i < 64; i++)
            {
                sbyte3 x = rng.NextSByte3();
                byte3  n = rng.NextByte3();

                Assert.AreEqual(new sbyte3((sbyte)_intpow(x.x, n.x), (sbyte)_intpow(x.y, n.y), (sbyte)_intpow(x.z, n.z)), maxmath.intpow(x, n));
            }
        }
Esempio n. 19
0
 public static sbyte3 divrem(sbyte3 dividend, sbyte3 divisor, out sbyte3 remainder)
 {
     if (Sse2.IsSse2Supported)
     {
         return(Operator.vdivrem_sbyte(dividend, divisor, out remainder));
     }
     else
     {
         remainder = dividend % divisor;
         return(dividend / divisor);
     }
 }
Esempio n. 20
0
        internal static sbyte3 vrem_sbyte(sbyte3 dividend, sbyte3 divisor)
        {
            Assert.AreNotEqual(divisor.x, 0);
            Assert.AreNotEqual(divisor.y, 0);
            Assert.AreNotEqual(divisor.z, 0);

            int3 castDividend = dividend;
            int3 castDivisor  = divisor;
            v128 floatResult  = vdiv_byte_quotient(castDividend, castDivisor);

            return((sbyte3)(castDividend - ((int3)(*(float3 *)&floatResult) * castDivisor)));
        }
Esempio n. 21
0
        public static sbyte cmin(sbyte3 x)
        {
            if (Ssse3.IsSsse3Supported)
            {
                x = min(x, x.zyz);

                return(min(x, x.yyy).x);
            }
            else
            {
                return((sbyte)math.min((int)x.x, math.min((int)x.y, (int)x.z)));
            }
        }
Esempio n. 22
0
        public static sbyte3 rol(sbyte3 x, sbyte3 n)
        {
            if (Sse2.IsSse2Supported)
            {
                n &= 7;

                return((sbyte3)(shl((byte3)x, (byte3)n) | shrl((byte3)x, (byte3)(-n & 7))));
            }
            else
            {
                return(new sbyte3(rol(x.x, n.x), rol(x.y, n.y), rol(x.z, n.z)));
            }
        }
Esempio n. 23
0
        internal static sbyte3 vdivrem_sbyte(sbyte3 dividend, sbyte3 divisor, out sbyte3 remainder)
        {
            Assert.AreNotEqual(divisor.x, 0);
            Assert.AreNotEqual(divisor.y, 0);
            Assert.AreNotEqual(divisor.z, 0);

            int3 castDividend = dividend;
            int3 castDivisor  = divisor;
            v128 floatResult  = vdiv_byte_quotient(castDividend, castDivisor);
            int3 quotientCast = (int3)(*(float3 *)&floatResult);

            remainder = (sbyte3)(castDividend - quotientCast * castDivisor);
            return((sbyte3)quotientCast);
        }
Esempio n. 24
0
 public static bool3 ispow2(sbyte3 x)
 {
     if (Sse2.IsSse2Supported)
     {
         v128 result = Sse2.and_si128(Sse2.and_si128(Sse2.cmpgt_epi8(x, default(v128)),
                                                     Sse2.cmpeq_epi8(default(v128), x & (x - 1))),
                                      new sbyte16(1));
         return(*(bool3 *)&result);
     }
     else
     {
         return(new bool3(math.ispow2(x.x), math.ispow2(x.y), math.ispow2(x.z)));
     }
 }
Esempio n. 25
0
        public static void Cast_ToSByte()
        {
            bool result = true;

            for (int i = 0; i < NUM_TESTS; i++)
            {
                sbyte3 x = (sbyte3)TestData_LHS[i];

                result &= x.x == (sbyte)TestData_LHS[i].x &
                          x.y == (sbyte)TestData_LHS[i].y &
                          x.z == (sbyte)TestData_LHS[i].z;
            }

            Assert.AreEqual(true, result);
        }
Esempio n. 26
0
        public static void Remainder()
        {
            bool result = true;

            for (int i = 0; i < NUM_TESTS; i++)
            {
                sbyte3 x = TestData_LHS[i] % TestData_RHS[i];

                result &= x.x == (sbyte)(TestData_LHS[i].x % TestData_RHS[i].x) &
                          x.y == (sbyte)(TestData_LHS[i].y % TestData_RHS[i].y) &
                          x.z == (sbyte)(TestData_LHS[i].z % TestData_RHS[i].z);
            }

            Assert.AreEqual(true, result);
        }
Esempio n. 27
0
        public static void SByte3()
        {
            bool result = true;

            for (int i = 0; i < Tests.SByte3.NUM_TESTS; i++)
            {
                sbyte3 t = maxmath.sign(Tests.SByte3.TestData_LHS[i]);

                result &= t.x == ((Tests.SByte3.TestData_LHS[i].x == 0) ? 0 : ((Tests.SByte3.TestData_LHS[i].x < 0) ? -1 : 1));
                result &= t.y == ((Tests.SByte3.TestData_LHS[i].y == 0) ? 0 : ((Tests.SByte3.TestData_LHS[i].y < 0) ? -1 : 1));
                result &= t.z == ((Tests.SByte3.TestData_LHS[i].z == 0) ? 0 : ((Tests.SByte3.TestData_LHS[i].z < 0) ? -1 : 1));
            }

            Assert.AreEqual(true, result);
        }
Esempio n. 28
0
        public static void NOT()
        {
            bool result = true;

            for (int i = 0; i < NUM_TESTS; i++)
            {
                sbyte3 x = ~TestData_LHS[i];

                result &= x.x == (sbyte)(~TestData_LHS[i].x) &
                          x.y == (sbyte)(~TestData_LHS[i].y) &
                          x.z == (sbyte)(~TestData_LHS[i].z);
            }

            Assert.AreEqual(true, result);
        }
Esempio n. 29
0
 public static sbyte3 max(sbyte3 a, sbyte3 b)
 {
     if (Sse4_1.IsSse41Supported)
     {
         return(Sse4_1.max_epi8(a, b));
     }
     else if (Sse2.IsSse2Supported)
     {
         return(Mask.BlendV(a, b, Sse2.cmpgt_epi8(b, a)));
     }
     else
     {
         return(new sbyte3((sbyte)math.max(a.x, b.x), (sbyte)math.max(a.y, b.y), (sbyte)math.max(a.z, b.z)));
     }
 }
Esempio n. 30
0
        public static void SByte3()
        {
            bool     result = true;
            Random32 x      = new Random32(47);

            for (int i = 0; i < Tests.SByte3.NUM_TESTS; i++)
            {
                bool3  b = x.NextBool3();
                sbyte3 a = maxmath.negate(Tests.SByte3.TestData_LHS[i], b);

                result &= math.all(a == (maxmath.select(Tests.SByte3.TestData_LHS[i], -Tests.SByte3.TestData_LHS[i], b)));
            }

            Assert.AreEqual(true, result);
        }
Esempio n. 31
0
	public static extern sbyte mono_return_sbyte3 (sbyte3 s, int addend);