예제 #1
0
 public short3x4(short v)
 {
     this.c0 = v;
     this.c1 = v;
     this.c2 = v;
     this.c3 = v;
 }
예제 #2
0
 public short3x2(short m00, short m01,
                 short m10, short m11,
                 short m20, short m21)
 {
     this.c0 = new short3(m00, m10, m20);
     this.c1 = new short3(m01, m11, m21);
 }
예제 #3
0
파일: short8.cs 프로젝트: csritter/MaxMath
        public short8(short3 x012, short3 x345, short2 x67)
        {
            if (Sse2.IsSse2Supported)
            {
                v128 mid = Sse2.bslli_si128(x345, 3 * sizeof(short));
                v128 hi  = Sse2.bslli_si128(x67, 6 * sizeof(short));

                if (Sse4_1.IsSse41Supported)
                {
                    mid = Sse4_1.blend_epi16(x012, mid, 0b0011_1000);

                    this = Sse4_1.blend_epi16(mid, hi, 0b1100_0000);
                }
                else
                {
                    mid = Mask.BlendEpi16_SSE2(x012, mid, 0b0011_1000);

                    this = Mask.BlendEpi16_SSE2(mid, hi, 0b1100_0000);
                }
            }
            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;
            }
        }
예제 #4
0
파일: short8.cs 프로젝트: csritter/MaxMath
        public short8(short3 x012, short2 x34, short3 x567)
        {
            if (Sse2.IsSse2Supported)
            {
                v128 hi = Sse2.bslli_si128(x567, 2 * sizeof(short));

                if (Sse4_1.IsSse41Supported)
                {
                    hi = Sse4_1.blend_epi16(x34, hi, 0b0001_1100);
                    hi = Sse2.bslli_si128(hi, 3 * sizeof(short));

                    this = Sse4_1.blend_epi16(x012, hi, 0b1111_1000);
                }
                else
                {
                    hi = Mask.BlendEpi16_SSE2(x34, hi, 0b0001_1100);
                    hi = Sse2.bslli_si128(hi, 3 * sizeof(short));

                    this = Mask.BlendEpi16_SSE2(x012, hi, 0b1111_1000);
                }
            }
            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;
            }
        }
예제 #5
0
 public short3x4(short3 c0, short3 c1, short3 c2, short3 c3)
 {
     this.c0 = c0;
     this.c1 = c1;
     this.c2 = c2;
     this.c3 = c3;
 }
예제 #6
0
        public static ushort3 lcm(short3 x, short3 y)
        {
            ushort3 absX = (ushort3)abs(x);
            ushort3 absY = (ushort3)abs(y);

            return((absX / gcd(absX, absY)) * absY);
        }
예제 #7
0
파일: short8.cs 프로젝트: csritter/MaxMath
        public short8(short2 x01, short3 x234, short3 x567)
        {
            if (Sse2.IsSse2Supported)
            {
                v128 mid = Sse2.bslli_si128(x234, 2 * sizeof(short));
                v128 hi  = Sse2.bslli_si128(x567, 5 * sizeof(short));

                if (Sse4_1.IsSse41Supported)
                {
                    hi = Sse4_1.blend_epi16(mid, hi, 0b1110_0000);

                    this = Sse4_1.blend_epi16(x01, hi, 0b1111_1100);
                }
                else
                {
                    hi = Mask.BlendEpi16_SSE2(mid, hi, 0b1110_0000);

                    this = Mask.BlendEpi16_SSE2(x01, hi, 0b1111_1100);
                }
            }
            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;
            }
        }
예제 #8
0
        public void Short3_ParseFromString(short v0, short v1, short v2)
        {
            string s  = NormalFormat.F(v0, v1, v2);
            short3 n  = new short3(v0, v1, v2);
            short3 ns = short3.Parse(s);

            Assert.That(ns, Is.EqualTo(n));
        }
예제 #9
0
        public void Short3_GetIndices(short v0, short v1, short v2)
        {
            short3 n = new short3(v0, v1, v2);

            Assert.That(n[0], Is.EqualTo(v0));
            Assert.That(n[1], Is.EqualTo(v1));
            Assert.That(n[2], Is.EqualTo(v2));
        }
예제 #10
0
        public void Short3_GetFields(short v0, short v1, short v2)
        {
            short3 n = new short3(v0, v1, v2);

            Assert.That(n.x, Is.EqualTo(v0));
            Assert.That(n.y, Is.EqualTo(v1));
            Assert.That(n.z, Is.EqualTo(v2));
        }
예제 #11
0
        public static void Constructor_Short_Short2()
        {
            short3 x = new short3(TestData_LHS[0].x, new short2(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);
        }
예제 #12
0
        public void Short3_WriteToString(short v0, short v1, short v2)
        {
            string s  = NormalFormat.F(v0, v1, v2);
            short3 n  = new short3(v0, v1, v2);
            string sn = n.ToString();

            Assert.That(sn, Is.EqualTo(s));
        }
예제 #13
0
        public static bool3 isdivisible(short3 dividend, short3 divisor)
        {
            Assert.AreNotEqual(0, divisor.x);
            Assert.AreNotEqual(0, divisor.y);
            Assert.AreNotEqual(0, divisor.z);

            return(dividend % divisor == 0);
        }
예제 #14
0
        public static void Constructor_Short()
        {
            short3 x = new short3(TestData_LHS[0].x);

            Assert.AreEqual(x.x == TestData_LHS[0].x &
                            x.y == TestData_LHS[0].x &
                            x.z == TestData_LHS[0].x, true);
        }
예제 #15
0
 public short3x3(short m00, short m01, short m02,
                 short m10, short m11, short m12,
                 short m20, short m21, short m22)
 {
     this.c0 = new short3(m00, m10, m20);
     this.c1 = new short3(m01, m11, m21);
     this.c2 = new short3(m02, m12, m22);
 }
예제 #16
0
 public short3x4(short m00, short m01, short m02, short m03,
                 short m10, short m11, short m12, short m13,
                 short m20, short m21, short m22, short m23)
 {
     this.c0 = new short3(m00, m10, m20);
     this.c1 = new short3(m01, m11, m21);
     this.c2 = new short3(m02, m12, m22);
     this.c3 = new short3(m03, m13, m23);
 }
예제 #17
0
        public void Short3_TryParse(short v0, short v1, short v2)
        {
            string s = NormalFormat.F(v0, v1, v2);
            short3 n = new short3(v0, v1, v2);
            short3 ns;

            Assert.IsTrue(short3.TryParse(s, out ns));
            Assert.That(ns, Is.EqualTo(n));
        }
예제 #18
0
 public void Short3_ParseFromString_ArbitarySpace(short v0, short v1, short v2)
 {
     foreach (string fmt in ArbitaryWhiteSpaceFormat)
     {
         string s  = fmt.F(v0, v1, v2);
         short3 n  = new short3(v0, v1, v2);
         short3 ns = short3.Parse(s);
         Assert.That(ns, Is.EqualTo(n));
     }
 }
예제 #19
0
 public static bool all_eq(short3 c)
 {
     if (Sse2.IsSse2Supported)
     {
         return(c.xxx.Equals(c));
     }
     else
     {
         return(c.x == c.y & c.x == c.z);
     }
 }
예제 #20
0
파일: lzcnt.cs 프로젝트: csritter/MaxMath
        public static void short3()
        {
            Random16 rng = new Random16(135);

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

                Assert.AreEqual(new short3((short)maxmath.lzcnt(x.x), (short)maxmath.lzcnt(x.y), (short)maxmath.lzcnt(x.z)), maxmath.lzcnt(x));
            }
        }
예제 #21
0
파일: Sign.cs 프로젝트: csritter/MaxMath
 public static short3 sign(short3 x)
 {
     if (Ssse3.IsSsse3Supported)
     {
         return(Ssse3.sign_epi16(new short4(1), x));
     }
     else
     {
         return((x >> 15) | (short3)((ushort3)(-x) >> 15));
     }
 }
예제 #22
0
파일: Any.cs 프로젝트: csritter/MaxMath
 public static bool any(short3 x)
 {
     if (Sse2.IsSse2Supported)
     {
         return(0 != (bitmask64(48ul) & ((v128)x).ULong0));
     }
     else
     {
         return(math.any(x != 0));
     }
 }
예제 #23
0
파일: Max.cs 프로젝트: csritter/MaxMath
 public static short3 max(short3 a, short3 b)
 {
     if (Sse2.IsSse2Supported)
     {
         return(Sse2.max_epi16(a, b));
     }
     else
     {
         return(new short3((short)math.max(a.x, b.x), (short)math.max(a.y, b.y), (short)math.max(a.z, b.z)));
     }
 }
예제 #24
0
 public static short3 subadd(short3 a, short3 b)
 {
     if (Ssse3.IsSsse3Supported)
     {
         return(a + Ssse3.sign_epi16(b, new ushort4(ushort.MaxValue, 1, ushort.MaxValue, 1)));
     }
     else
     {
         return(a - select(b, -b, new bool3(false, true, false)));
     }
 }
예제 #25
0
        public void Short3_SetIndices(short v0, short v1, short v2)
        {
            short3 n = new short3();

            n[0] = v0;
            n[1] = v1;
            n[2] = v2;
            Assert.That(n[0], Is.EqualTo(v0));
            Assert.That(n[1], Is.EqualTo(v1));
            Assert.That(n[2], Is.EqualTo(v2));
        }
예제 #26
0
파일: All.cs 프로젝트: csritter/MaxMath
 public static bool all(short3 x)
 {
     if (Sse2.IsSse2Supported)
     {
         return(0 == (bitmask64(48ul) & Sse2.cmpeq_epi16(x, default(v128)).ULong0));
     }
     else
     {
         return(math.all(x != 0));
     }
 }
예제 #27
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));
            }
        }
예제 #28
0
        public static void short3()
        {
            Random16 rng = new Random16(135);

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

                Assert.AreEqual(new short3((short)_intpow(x.x, n.x), (short)_intpow(x.y, n.y), (short)_intpow(x.z, n.z)), maxmath.intpow(x, n));
            }
        }
예제 #29
0
 public static short3 divrem(short3 dividend, short divisor, out short3 remainder)
 {
     if (Constant.IsConstantExpression(divisor))
     {
         remainder = dividend % divisor;
         return(dividend / divisor);
     }
     else
     {
         return(divrem(dividend, (short3)divisor, out remainder));
     }
 }
예제 #30
0
        public static short cmin(short3 x)
        {
            if (Sse2.IsSse2Supported)
            {
                x = min(x, x.zyz);

                return(min(x, x.yyy).x);
            }
            else
            {
                return((short)math.min((int)x.x, math.min((int)x.y, (int)x.z)));
            }
        }
예제 #31
0
 public static extern CUResult cuMemcpyDtoH_v2(ref short3 dstHost, CUdeviceptr srcDevice, SizeT ByteCount);
예제 #32
0
	public static extern short3 mono_return_short3 (short3 s, int addend);