public static unsafe Vector16sb operator + (Vector16sb va, Vector16sb vb) { Vector16sb res = new Vector16sb (); sbyte *a = &va.v0; sbyte *b = &vb.v0; sbyte *c = &res.v0; for (int i = 0; i < 16; ++i) *c++ = (sbyte)(*a++ + *b++); return res; }
public static unsafe Vector16sb SubtractWithSaturation(this Vector16sb va, Vector16sb vb) { Vector16sb res = new Vector16sb(); sbyte * a = &va.v0; sbyte * b = &vb.v0; sbyte * c = &res.v0; for (int i = 0; i < 16; ++i) { *c++ = (sbyte)System.Math.Max(System.Math.Min(*a++ - *b++, sbyte.MaxValue), sbyte.MinValue); } return(res); }
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); }
public static unsafe Vector8us SumOfAbsoluteDifferences(Vector16b va, Vector16sb vb) { Vector8us res = new Vector8us(); byte * a = &va.v0; sbyte * b = (sbyte *)&vb; int tmp = 0; for (int i = 0; i < 8; ++i) { tmp += System.Math.Abs((int)*a++ - (int)*b++); } res.V0 = (ushort)tmp; tmp = 0; for (int i = 0; i < 8; ++i) { tmp += System.Math.Abs((int)*a++ - (int)*b++); } res.V4 = (ushort)tmp; return(res); }
static int test_0_vector16sb_one_element_ctor () { Vector16sb a = new Vector16sb (99); if (a.V0 != 99) return 1; if (a.V1 != 99) return 2; if (a.V2 != 99) return 3; if (a.V3 != 99) return 4; if (a.V4 != 99) return 5; if (a.V5 != 99) return 6; if (a.V6 != 99) return 7; if (a.V7 != 99) return 8; if (a.V8 != 99) return 9; if (a.V9 != 99) return 10; if (a.V10 != 99) return 11; if (a.V11 != 99) return 12; if (a.V12 != 99) return 13; if (a.V13 != 99) return 14; if (a.V14 != 99) return 15; if (a.V15 != 99) return 16; return 0; }
public static unsafe int test_0_vector16sb_cmp_gt () { Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8); Vector16sb b = new Vector16sb (-100, 100,11,12,4,5,6,7,8,9,10,11,12,13,14,15); Vector16sb c = a.CompareGreaterThan (b); if (c.V0 != -1) return 1; if (c.V1 != 0) return 2; if (c.V2 != 0) return 3; if (c.V3 != 0) return 4; if (c.V4 != -1) return 5; if (c.V5 != -1) return 6; if (c.V6 != -1) return 7; return 0; }
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; }
public static unsafe void PrefetchTemporal2ndLevelCache (Vector16sb *res) { }
public static void PrefetchNonTemporal (ref Vector16sb res) { }
public static void PrefetchTemporalAllCacheLevels (ref Vector16sb res) { }
public static unsafe Vector16sb LoadAligned (Vector16sb *v) { return *v; }
public static void PrefetchNonTemporal(ref Vector16sb res) { }
public static void PrefetchTemporal2ndLevelCache(ref Vector16sb res) { }
public static void PrefetchTemporalAllCacheLevels(ref Vector16sb res) { }
public static unsafe void StoreAligned(Vector16sb *res, Vector16sb val) { *res = val; }
public static void StoreAligned(ref Vector16sb res, Vector16sb val) { res = val; }
public static Vector16sb LoadAligned(ref Vector16sb v) { return(v); }
public static unsafe Vector16sb UnpackHigh(Vector16sb va, Vector16sb vb) { return(new Vector16sb(va.v8, vb.v8, va.v9, vb.v9, va.v10, vb.v10, va.v11, vb.v11, va.v12, vb.v12, va.v13, vb.v13, va.v14, vb.v14, va.v15, vb.v15)); }
public static unsafe Vector16sb UnpackLow(Vector16sb va, Vector16sb vb) { return(new Vector16sb(va.v0, vb.v0, va.v1, vb.v1, va.v2, vb.v2, va.v3, vb.v3, va.v4, vb.v4, va.v5, vb.v5, va.v6, vb.v6, va.v7, vb.v7)); }
public static void StoreAligned (ref Vector16sb res, Vector16sb val) { res = val; }
public static unsafe Vector16sb SubtractWithSaturation (this Vector16sb va, Vector16sb vb) { Vector16sb res = new Vector16sb (); sbyte *a = &va.v0; sbyte *b = &vb.v0; sbyte *c = &res.v0; for (int i = 0; i < 16; ++i) *c++ = (sbyte) System.Math.Max (System.Math.Min (*a++ - *b++, sbyte.MaxValue), sbyte.MinValue); return res; }
public static unsafe void StoreAligned (Vector16sb *res, Vector16sb val) { *res = val; }
public static unsafe Vector8us SumOfAbsoluteDifferences (this Vector16b va, Vector16sb vb) { Vector8us res = new Vector8us (); byte *a = &va.v0; sbyte *b = (sbyte*)&vb; int tmp = 0; for (int i = 0; i < 8; ++i) tmp += System.Math.Abs ((int)*a++ - (int)*b++); res.V0 = (ushort)tmp; tmp = 0; for (int i = 0; i < 8; ++i) tmp += System.Math.Abs ((int)*a++ - (int)*b++); res.V4 = (ushort)tmp; return res; }
public static void PrefetchTemporal2ndLevelCache (ref Vector16sb res) { }
public static unsafe Vector16sb Min (this Vector16sb va, Vector16sb vb) { Vector16sb res = new Vector16sb (); sbyte *a = &va.v0; sbyte *b = &vb.v0; sbyte *c = &res.v0; for (int i = 0; i < 16; ++i) *c++ = (sbyte) System.Math.Min(*a++, *b++); return res; }
public static unsafe void PrefetchTemporalAllCacheLevels (Vector16sb *res) { }
public static unsafe Vector16sb CompareGreaterThan (this Vector16sb va, Vector16sb vb) { Vector16sb res = new Vector16sb (); sbyte *a = &va.v0; sbyte *b = &vb.v0; sbyte *c = &res.v0; for (int i = 0; i < 16; ++i) *c++ = (sbyte) (*a++ > *b++ ? -1 : 0); return res; }
public static unsafe void PrefetchNonTemporal (Vector16sb *res) { }
public static unsafe Vector16sb UnpackLow (this Vector16sb va, Vector16sb vb) { return new Vector16sb (va.v0, vb.v0, va.v1, vb.v1, va.v2, vb.v2, va.v3, vb.v3, va.v4, vb.v4, va.v5, vb.v5, va.v6, vb.v6, va.v7, vb.v7); }
public static unsafe int test_0_vector16sb_add_sat () { Vector16sb a = new Vector16sb (100,-100,11,12,13,14,15,0,1,2,3,4,5,6,7,8); Vector16sb b = new Vector16sb (100, -100,11,12,4,5,6,7,8,9,10,11,12,13,14,15); Vector16sb c = a.AddWithSaturation (b); if (c.V0 != 127) return 1; if (c.V1 != -128) return 2; if (c.V2 != 22) return 3; if (c.V3 != 24) return 4; if (c.V4 != 17) return 5; if (c.V5 != 19) return 6; if (c.V6 != 21) return 7; if (c.V7 != 7) return 8; return 0; }
public static unsafe Vector16sb operator ^ (Vector16sb va, Vector16sb vb) { Vector16sb res = new Vector16sb (); uint *a = (uint*) &va.v0; uint *b = (uint*) &vb.v0; uint *c = (uint*) &res.v0; *c++ = *a++ ^ *b++; *c++ = *a++ ^ *b++; *c++ = *a++ ^ *b++; *c = *a ^ *b; return res; }
public static int vector16b_sum_abs_diff () { Vector16b a = new Vector16b (100,20,20,20,0,0,0,0,0,0,0,0,0,0, 0, 0); Vector16sb b = new Vector16sb (0, 10,10,10,0,0,0,0,0,0,0,0,0,0,10,10); Vector8us c = a.SumOfAbsoluteDifferences (b); if (c.V0 != 130) return 1; if (c.V1 != 0) return 2; if (c.V2 != 0) return 3; if (c.V3 != 0) return 4; if (c.V4 != 20) return 5; if (c.V5 != 0) return 6; if (c.V6 != 0) return 7; if (c.V7 != 0) return 8; return 0; }
public static Vector16sb LoadAligned (ref Vector16sb v) { return v; }
public static unsafe Vector16sb UnpackHigh (this Vector16sb va, Vector16sb vb) { return new Vector16sb (va.v8, vb.v8, va.v9, vb.v9, va.v10, vb.v10, va.v11, vb.v11, va.v12, vb.v12, va.v13, vb.v13, va.v14, vb.v14, va.v15, vb.v15); }
public static unsafe int ExtractByteMask (Vector16sb va) { int res = 0; sbyte *a = (sbyte*)&va; for (int i = 0; i < 16; ++i) res |= (*a++ & 0x80) >> 7 << i; return res; }