[CLSCompliant(false)]
public struct Vector8us
{
- private ushort v0, v1, v2, v3, v4, v5, v6, v7;
+ internal ushort v0, v1, v2, v3, v4, v5, v6, v7;
public Vector8us (ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7)
{
this.v0 = v0;
return false;
}
- [Acceleration (AccelMode.SSE2)]
- public static unsafe Vector8us UnpackLow (Vector8us va, Vector8us vb)
- {
- return new Vector8us (va.v0, vb.v0, va.v1, vb.v1, va.v2, vb.v2, va.v3, vb.v3);
- }
-
- [Acceleration (AccelMode.SSE2)]
- public static unsafe Vector8us UnpackHigh (Vector8us va, Vector8us vb)
- {
- return new Vector8us (va.v4, vb.v4, va.v5, vb.v5, va.v6, vb.v6, va.v7, vb.v7);
- }
-
- [Acceleration (AccelMode.SSE2)]
- public static unsafe Vector8us ArithmeticRightShift (Vector8us va, int amount)
- {
- Vector8us res = new Vector8us ();
- ushort *a = &va.v0;
- ushort *b = &res.v0;
- for (int i = 0; i < 8; ++i)
- *b++ = (ushort)((short)(*a++) >> amount);
- return res;
- }
-
- [Acceleration (AccelMode.SSE2)]
- public static unsafe Vector8us AddWithSaturation (Vector8us va, Vector8us vb) {
- Vector8us res = new Vector8us ();
- ushort *a = &va.v0;
- ushort *b = &vb.v0;
- ushort *c = &res.v0;
- for (int i = 0; i < 8; ++i)
- *c++ = (ushort) System.Math.Min (*a++ + *b++, ushort.MaxValue);
- return res;
- }
-
- [Acceleration (AccelMode.SSE2)]
- public static unsafe Vector8us SubtractWithSaturation (Vector8us va, Vector8us vb) {
- Vector8us res = new Vector8us ();
- ushort *a = &va.v0;
- ushort *b = &vb.v0;
- ushort *c = &res.v0;
- for (int i = 0; i < 8; ++i)
- *c++ = (ushort) System.Math.Max (*a++ - *b++, 0);
- return res;
- }
-
- [Acceleration (AccelMode.SSE2)]
- public static unsafe Vector8us Average (Vector8us va, Vector8us vb) {
- Vector8us res = new Vector8us ();
- ushort *a = &va.v0;
- ushort *b = &vb.v0;
- ushort *c = &res.v0;
- for (int i = 0; i < 8; ++i)
- *c++ = (ushort) ((*a++ + *b++ + 1) >> 1);
- return res;
- }
-
- [Acceleration (AccelMode.SSE41)]
- public static unsafe Vector8us Max (Vector8us va, Vector8us vb) {
- Vector8us res = new Vector8us ();
- ushort *a = &va.v0;
- ushort *b = &vb.v0;
- ushort *c = &res.v0;
- for (int i = 0; i < 8; ++i)
- *c++ = (ushort) System.Math.Max (*a++, *b++);
- return res;
- }
-
- [Acceleration (AccelMode.SSE41)]
- public static unsafe Vector8us Min (Vector8us va, Vector8us vb) {
- Vector8us res = new Vector8us ();
- ushort *a = &va.v0;
- ushort *b = &vb.v0;
- ushort *c = &res.v0;
- for (int i = 0; i < 8; ++i)
- *c++ = (ushort) System.Math.Min (*a++, *b++);
- return res;
- }
-
- [Acceleration (AccelMode.SSE2)]
- public static unsafe Vector8us ShuffleHigh (Vector8us va, ShuffleSel sel)
- {
- ushort *ptr = ((ushort*)&va) + 4;
- int idx = (int)sel;
- return new Vector8us (va.v0, va.v1, va.v2, va.v3, *(ptr + ((idx >> 0) & 0x3)), *(ptr + ((idx >> 2) & 0x3)), *(ptr + ((idx >> 4) & 0x3)), *(ptr + ((idx >> 6) & 0x3)));
- }
-
- [Acceleration (AccelMode.SSE2)]
- public static unsafe Vector8us ShuffleLow (Vector8us va, ShuffleSel sel)
- {
- ushort *ptr = ((ushort*)&va);
- int idx = (int)sel;
- return new Vector8us (*(ptr + ((idx >> 0) & 0x3)), *(ptr + ((idx >> 2) & 0x3)), *(ptr + ((idx >> 4) & 0x3)), *(ptr + ((idx >> 6) & 0x3)), va.v4, va.v5, va.v6, va.v7);
- }
-
- [Acceleration (AccelMode.SSE2)]
- public static unsafe Vector8us CompareEqual (Vector8us va, Vector8us vb) {
- Vector8us res = new Vector8us ();
- ushort *a = &va.v0;
- ushort *b = &vb.v0;
- ushort *c = &res.v0;
- for (int i = 0; i < 8; ++i)
- *c++ = (ushort) (*a++ == *b++ ? -1 : 0);
- return res;
- }
-
- [Acceleration (AccelMode.SSE2)]
- public static unsafe Vector8us MultiplyStoreHigh (Vector8us va, Vector8us vb) {
- Vector8us res = new Vector8us ();
- ushort *a = &va.v0;
- ushort *b = &vb.v0;
- ushort *c = &res.v0;
- for (int i = 0; i < 8; ++i)
- *c++ = (ushort)((uint)*a++ * (uint)*b++ >> 16);
- return res;
- }
-
- /*This function performs a packuswb, which treats the source as a signed value */
- [Acceleration (AccelMode.SSE2)]
- public static unsafe Vector16b SignedPackWithUnsignedSaturation (Vector8us va, Vector8us vb) {
- Vector16b res = new Vector16b ();
- short *a = (short*)&va;
- short *b = (short*)&vb;
- byte *c = (byte*)&res;
- for (int i = 0; i < 8; ++i)
- *c++ = (byte)System.Math.Max (0, System.Math.Min ((int)*a++, byte.MaxValue));
- for (int i = 0; i < 8; ++i)
- *c++ = (byte)System.Math.Max (0, System.Math.Min ((int)*b++, byte.MaxValue));
- return res;
- }
-
- /*This function performs a packsswb, which treats the source as a signed value */
- [Acceleration (AccelMode.SSE2)]
- public static unsafe Vector16sb SignedPackWithSignedSaturation (Vector8us va, Vector8us vb) {
- Vector16sb res = new Vector16sb ();
- short *a = (short*)&va;
- short *b = (short*)&vb;
- sbyte *c = (sbyte*)&res;
- for (int i = 0; i < 8; ++i)
- *c++ = (sbyte)System.Math.Max (System.Math.Min ((int)*a++, sbyte.MaxValue), sbyte.MinValue);
- for (int i = 0; i < 8; ++i)
- *c++ = (sbyte)System.Math.Max (System.Math.Min ((int)*b++, sbyte.MaxValue), sbyte.MinValue);
- return res;
- }
-
[Acceleration (AccelMode.SSE1)]
public static unsafe explicit operator Vector2d (Vector8us v)
{
return res;
}
+ [Acceleration (AccelMode.SSE2)]
+ public static unsafe Vector8us ArithmeticRightShift (this Vector8us va, int amount)
+ {
+ Vector8us res = new Vector8us ();
+ ushort *a = &va.v0;
+ ushort *b = &res.v0;
+ for (int i = 0; i < 8; ++i)
+ *b++ = (ushort)((short)(*a++) >> amount);
+ return res;
+ }
+
[Acceleration (AccelMode.SSE2)]
public static unsafe Vector2l LogicalRightShift (this Vector2l v1, int amount)
{
return res;
}
+ [Acceleration (AccelMode.SSE2)]
+ public static unsafe Vector8us AddWithSaturation (this Vector8us va, Vector8us vb) {
+ Vector8us res = new Vector8us ();
+ ushort *a = &va.v0;
+ ushort *b = &vb.v0;
+ ushort *c = &res.v0;
+ for (int i = 0; i < 8; ++i)
+ *c++ = (ushort) System.Math.Min (*a++ + *b++, ushort.MaxValue);
+ return res;
+ }
+
[Acceleration (AccelMode.SSE2)]
public static unsafe Vector8s SubtractWithSaturation (this Vector8s va, Vector8s vb) {
Vector8s res = new Vector8s ();
return res;
}
+ [Acceleration (AccelMode.SSE2)]
+ public static unsafe Vector8us SubtractWithSaturation (this Vector8us va, Vector8us vb) {
+ Vector8us res = new Vector8us ();
+ ushort *a = &va.v0;
+ ushort *b = &vb.v0;
+ ushort *c = &res.v0;
+ for (int i = 0; i < 8; ++i)
+ *c++ = (ushort) System.Math.Max (*a++ - *b++, 0);
+ return res;
+ }
+
[Acceleration (AccelMode.SSE2)]
public static unsafe Vector8s MultiplyStoreHigh (this Vector8s va, Vector8s vb) {
Vector8s res = new Vector8s ();
return res;
}
+ [Acceleration (AccelMode.SSE2)]
+ public static unsafe Vector8us MultiplyStoreHigh (this Vector8us va, Vector8us vb) {
+ Vector8us res = new Vector8us ();
+ ushort *a = &va.v0;
+ ushort *b = &vb.v0;
+ ushort *c = &res.v0;
+ for (int i = 0; i < 8; ++i)
+ *c++ = (ushort)((uint)*a++ * (uint)*b++ >> 16);
+ return res;
+ }
+
[Acceleration (AccelMode.SSE1)]
public static Vector4f Sqrt (this Vector4f v1)
{
return new Vector4f (1.0f / v1.x, 1.0f / v1.y, 1.0f / v1.z, 1.0f / v1.w);
}
+ [Acceleration (AccelMode.SSE2)]
+ public static unsafe Vector8us Average (this Vector8us va, Vector8us vb) {
+ Vector8us res = new Vector8us ();
+ ushort *a = &va.v0;
+ ushort *b = &vb.v0;
+ ushort *c = &res.v0;
+ for (int i = 0; i < 8; ++i)
+ *c++ = (ushort) ((*a++ + *b++ + 1) >> 1);
+ return res;
+ }
+
[Acceleration (AccelMode.SSE1)]
public static Vector4f Max (this Vector4f v1, Vector4f v2)
{
return res;
}
+ [Acceleration (AccelMode.SSE41)]
+ public static unsafe Vector8us Max (this Vector8us va, Vector8us vb) {
+ Vector8us res = new Vector8us ();
+ ushort *a = &va.v0;
+ ushort *b = &vb.v0;
+ ushort *c = &res.v0;
+ for (int i = 0; i < 8; ++i)
+ *c++ = (ushort) System.Math.Max (*a++, *b++);
+ return res;
+ }
+
[Acceleration (AccelMode.SSE1)]
public static Vector4f Min (this Vector4f v1, Vector4f v2)
{
return res;
}
+ [Acceleration (AccelMode.SSE41)]
+ public static unsafe Vector8us Min (this Vector8us va, Vector8us vb) {
+ Vector8us res = new Vector8us ();
+ ushort *a = &va.v0;
+ ushort *b = &vb.v0;
+ ushort *c = &res.v0;
+ for (int i = 0; i < 8; ++i)
+ *c++ = (ushort) System.Math.Min (*a++, *b++);
+ return res;
+ }
/* ==== Horizontal operations ==== */
return res;
}
+ [Acceleration (AccelMode.SSE2)]
+ public static unsafe Vector8us CompareEqual (this Vector8us va, Vector8us vb) {
+ Vector8us res = new Vector8us ();
+ ushort *a = &va.v0;
+ ushort *b = &vb.v0;
+ ushort *c = &res.v0;
+ for (int i = 0; i < 8; ++i)
+ *c++ = (ushort) (*a++ == *b++ ? -1 : 0);
+ return res;
+ }
+
/*Same as a < b. */
[Acceleration (AccelMode.SSE1)]
public unsafe static Vector4f CompareLessThan (this Vector4f v1, Vector4f v2)
return new Vector8s (va.v0, vb.v0, va.v1, vb.v1, va.v2, vb.v2, va.v3, vb.v3);
}
+ [Acceleration (AccelMode.SSE2)]
+ public static unsafe Vector8us UnpackLow (this Vector8us va, Vector8us vb)
+ {
+ return new Vector8us (va.v0, vb.v0, va.v1, vb.v1, va.v2, vb.v2, va.v3, vb.v3);
+ }
+
[Acceleration (AccelMode.SSE2)]
public static Vector2l UnpackHigh (this Vector2l v1, Vector2l v2)
{
return new Vector8s (va.v4, vb.v4, va.v5, vb.v5, va.v6, vb.v6, va.v7, vb.v7);
}
+ [Acceleration (AccelMode.SSE2)]
+ public static unsafe Vector8us UnpackHigh (this Vector8us va, Vector8us vb)
+ {
+ return new Vector8us (va.v4, vb.v4, va.v5, vb.v5, va.v6, vb.v6, va.v7, vb.v7);
+ }
+
[Acceleration (AccelMode.SSE2)]
public static unsafe Vector4f Shuffle (this Vector4f v1, ShuffleSel sel)
{
return new Vector8s (va.v0, va.v1, va.v2, va.v3, *(ptr + ((idx >> 0) & 0x3)), *(ptr + ((idx >> 2) & 0x3)), *(ptr + ((idx >> 4) & 0x3)), *(ptr + ((idx >> 6) & 0x3)));
}
+ [Acceleration (AccelMode.SSE2)]
+ public static unsafe Vector8us ShuffleHigh (this Vector8us va, ShuffleSel sel)
+ {
+ ushort *ptr = ((ushort*)&va) + 4;
+ int idx = (int)sel;
+ return new Vector8us (va.v0, va.v1, va.v2, va.v3, *(ptr + ((idx >> 0) & 0x3)), *(ptr + ((idx >> 2) & 0x3)), *(ptr + ((idx >> 4) & 0x3)), *(ptr + ((idx >> 6) & 0x3)));
+ }
+
[Acceleration (AccelMode.SSE2)]
public static unsafe Vector8s ShuffleLow (this Vector8s va, ShuffleSel sel)
{
return new Vector8s (*(ptr + ((idx >> 0) & 0x3)), *(ptr + ((idx >> 2) & 0x3)), *(ptr + ((idx >> 4) & 0x3)), *(ptr + ((idx >> 6) & 0x3)), va.v4, va.v5, va.v6, va.v7);
}
+ [Acceleration (AccelMode.SSE2)]
+ public static unsafe Vector8us ShuffleLow (this Vector8us va, ShuffleSel sel)
+ {
+ ushort *ptr = ((ushort*)&va);
+ int idx = (int)sel;
+ return new Vector8us (*(ptr + ((idx >> 0) & 0x3)), *(ptr + ((idx >> 2) & 0x3)), *(ptr + ((idx >> 4) & 0x3)), *(ptr + ((idx >> 6) & 0x3)), va.v4, va.v5, va.v6, va.v7);
+ }
+
[CLSCompliant(false)]
[Acceleration (AccelMode.SSE41)]
public static unsafe Vector8us PackWithUnsignedSaturation (this Vector4i va, Vector4i vb) {
return res;
}
+ /*This function performs a packuswb, which treats the source as a signed value */
+ [Acceleration (AccelMode.SSE2)]
+ public static unsafe Vector16b SignedPackWithUnsignedSaturation (this Vector8us va, Vector8us vb) {
+ Vector16b res = new Vector16b ();
+ short *a = (short*)&va;
+ short *b = (short*)&vb;
+ byte *c = (byte*)&res;
+ for (int i = 0; i < 8; ++i)
+ *c++ = (byte)System.Math.Max (0, System.Math.Min ((int)*a++, byte.MaxValue));
+ for (int i = 0; i < 8; ++i)
+ *c++ = (byte)System.Math.Max (0, System.Math.Min ((int)*b++, byte.MaxValue));
+ return res;
+ }
+
/* This function performs a packssdw, which treats the source as a signed value*/
[Acceleration (AccelMode.SSE2)]
public static unsafe Vector8s SignedPackWithSignedSaturation (this Vector4ui va, Vector4ui vb) {
*c++ = (short)System.Math.Max (System.Math.Min ((int)*b++, short.MaxValue), short.MinValue);
return res;
}
+
+ /*This function performs a packsswb, which treats the source as a signed value */
+ [Acceleration (AccelMode.SSE2)]
+ public static unsafe Vector16sb SignedPackWithSignedSaturation (this Vector8us va, Vector8us vb) {
+ Vector16sb res = new Vector16sb ();
+ short *a = (short*)&va;
+ short *b = (short*)&vb;
+ sbyte *c = (sbyte*)&res;
+ for (int i = 0; i < 8; ++i)
+ *c++ = (sbyte)System.Math.Max (System.Math.Min ((int)*a++, sbyte.MaxValue), sbyte.MinValue);
+ for (int i = 0; i < 8; ++i)
+ *c++ = (sbyte)System.Math.Max (System.Math.Min ((int)*b++, sbyte.MaxValue), sbyte.MinValue);
+ return res;
+ }
}
}
\ No newline at end of file