4 // Rodrigo Kumpera (rkumpera@novell.com)
6 // (C) 2008 Novell, Inc. (http://www.novell.com)
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 using System.Runtime.InteropServices;
32 [Obsolete ("Use the types in the System.Numerics.Vectors namespace")]
33 [StructLayout(LayoutKind.Explicit, Pack = 1, Size = 16)]
35 public struct Vector16sb
70 public Vector16sb (sbyte v0, sbyte v1, sbyte v2, sbyte v3, sbyte v4, sbyte v5, sbyte v6, sbyte v7, sbyte v8, sbyte v9, sbyte v10, sbyte v11, sbyte v12, sbyte v13, sbyte v14, sbyte v15)
90 public Vector16sb (sbyte sb)
110 public sbyte V0 { get { return v0; } set { v0 = value; } }
111 public sbyte V1 { get { return v1; } set { v1 = value; } }
112 public sbyte V2 { get { return v2; } set { v2 = value; } }
113 public sbyte V3 { get { return v3; } set { v3 = value; } }
114 public sbyte V4 { get { return v4; } set { v4 = value; } }
115 public sbyte V5 { get { return v5; } set { v5 = value; } }
116 public sbyte V6 { get { return v6; } set { v6 = value; } }
117 public sbyte V7 { get { return v7; } set { v7 = value; } }
118 public sbyte V8 { get { return v8; } set { v8 = value; } }
119 public sbyte V9 { get { return v9; } set { v9 = value; } }
120 public sbyte V10 { get { return v10; } set { v10 = value; } }
121 public sbyte V11 { get { return v11; } set { v11 = value; } }
122 public sbyte V12 { get { return v12; } set { v12 = value; } }
123 public sbyte V13 { get { return v13; } set { v13 = value; } }
124 public sbyte V14 { get { return v14; } set { v14 = value; } }
125 public sbyte V15 { get { return v15; } set { v15 = value; } }
127 public static Vector16sb One
129 get { return new Vector16sb (1); }
132 public static Vector16sb Zero
134 get { return new Vector16sb (0); }
137 public static Vector16sb MinusOne
139 get { return new Vector16sb (-1); }
142 [System.Runtime.CompilerServices.IndexerName ("Component")]
143 public unsafe sbyte this [int index]
146 if ((index | 0xF) != 0xF) //index < 0 || index > 15
147 throw new ArgumentOutOfRangeException ("index");
148 fixed (sbyte *v = &v0) {
153 if ( (index | 0xF) != 0xF) //index < 0 || index > 15
154 throw new ArgumentOutOfRangeException ("index");
155 fixed (sbyte *v = &v0) {
156 *(v + index) = value;
161 [Acceleration (AccelMode.SSE2)]
162 public static unsafe Vector16sb operator + (Vector16sb va, Vector16sb vb)
164 Vector16sb res = new Vector16sb ();
168 for (int i = 0; i < 16; ++i)
169 *c++ = (sbyte)(*a++ + *b++);
173 [Acceleration (AccelMode.SSE2)]
174 public static unsafe Vector16sb operator - (Vector16sb va, Vector16sb vb)
176 Vector16sb res = new Vector16sb ();
180 for (int i = 0; i < 16; ++i)
181 *c++ = (sbyte)(*a++ - *b++);
185 [Acceleration (AccelMode.SSE2)]
186 public static unsafe Vector16sb operator & (Vector16sb va, Vector16sb vb)
188 Vector16sb res = new Vector16sb ();
189 uint *a = (uint*) &va.v0;
190 uint *b = (uint*) &vb.v0;
191 uint *c = (uint*) &res.v0;
199 [Acceleration (AccelMode.SSE2)]
200 public static unsafe Vector16sb operator | (Vector16sb va, Vector16sb vb)
202 Vector16sb res = new Vector16sb ();
203 uint *a = (uint*) &va.v0;
204 uint *b = (uint*) &vb.v0;
205 uint *c = (uint*) &res.v0;
213 [Acceleration (AccelMode.SSE2)]
214 public static unsafe Vector16sb operator ^ (Vector16sb va, Vector16sb vb)
216 Vector16sb res = new Vector16sb ();
217 uint *a = (uint*) &va.v0;
218 uint *b = (uint*) &vb.v0;
219 uint *c = (uint*) &res.v0;
227 [Acceleration (AccelMode.SSE2)]
228 public unsafe static bool operator ==(Vector16sb va, Vector16sb vb)
232 for (int i = 0; i < 16; ++i)
238 [Acceleration (AccelMode.SSE2)]
239 public unsafe static bool operator !=(Vector16sb va, Vector16sb vb)
243 for (int i = 0; i < 16; ++i)
249 [Acceleration (AccelMode.SSE1)]
250 public static unsafe explicit operator Vector2d (Vector16sb v)
252 Vector2d* p = (Vector2d*)&v;
256 [Acceleration (AccelMode.SSE1)]
257 public static unsafe explicit operator Vector4f (Vector16sb v)
259 Vector4f* p = (Vector4f*)&v;
263 [Acceleration (AccelMode.SSE1)]
264 public static unsafe explicit operator Vector2l (Vector16sb v)
266 Vector2l* p = (Vector2l*)&v;
270 [Acceleration (AccelMode.SSE1)]
271 public static unsafe explicit operator Vector2ul (Vector16sb v)
273 Vector2ul* p = (Vector2ul*)&v;
277 [Acceleration (AccelMode.SSE1)]
278 public static unsafe explicit operator Vector4i (Vector16sb v)
280 Vector4i* p = (Vector4i*)&v;
284 [Acceleration (AccelMode.SSE1)]
285 public static unsafe explicit operator Vector4ui (Vector16sb v)
287 Vector4ui* p = (Vector4ui*)&v;
291 [Acceleration (AccelMode.SSE1)]
292 public static unsafe explicit operator Vector8s (Vector16sb v)
294 Vector8s* p = (Vector8s*)&v;
298 [Acceleration (AccelMode.SSE1)]
299 public static unsafe explicit operator Vector8us (Vector16sb v)
301 Vector8us* p = (Vector8us*)&v;
305 [Acceleration (AccelMode.SSE1)]
306 public static unsafe explicit operator Vector16b (Vector16sb v)
308 Vector16b* p = (Vector16b*)&v;
312 [Acceleration (AccelMode.SSE1)]
313 public static Vector16sb LoadAligned (ref Vector16sb v)
318 [Acceleration (AccelMode.SSE1)]
319 public static void StoreAligned (ref Vector16sb res, Vector16sb val)
324 [Acceleration (AccelMode.SSE1)]
325 public static unsafe Vector16sb LoadAligned (Vector16sb *v)
330 [Acceleration (AccelMode.SSE1)]
331 public static unsafe void StoreAligned (Vector16sb *res, Vector16sb val)
336 [Acceleration (AccelMode.SSE1)]
337 [CLSCompliant(false)]
338 public static void PrefetchTemporalAllCacheLevels (ref Vector16sb res)
342 [Acceleration (AccelMode.SSE1)]
343 [CLSCompliant(false)]
344 public static void PrefetchTemporal1stLevelCache (ref Vector16sb res)
348 [Acceleration (AccelMode.SSE1)]
349 [CLSCompliant(false)]
350 public static void PrefetchTemporal2ndLevelCache (ref Vector16sb res)
354 [Acceleration (AccelMode.SSE1)]
355 [CLSCompliant(false)]
356 public static void PrefetchNonTemporal (ref Vector16sb res)
360 [Acceleration (AccelMode.SSE1)]
361 [CLSCompliant(false)]
362 public static unsafe void PrefetchTemporalAllCacheLevels (Vector16sb *res)
366 [Acceleration (AccelMode.SSE1)]
367 [CLSCompliant(false)]
368 public static unsafe void PrefetchTemporal1stLevelCache (Vector16sb *res)
372 [Acceleration (AccelMode.SSE1)]
373 [CLSCompliant(false)]
374 public static unsafe void PrefetchTemporal2ndLevelCache (Vector16sb *res)
378 [Acceleration (AccelMode.SSE1)]
379 [CLSCompliant(false)]
380 public static unsafe void PrefetchNonTemporal (Vector16sb *res)
384 public override string ToString()
386 return "<" + v0 + ", " + v1 + ", " + v2 + ", " + v3 + ", " +
387 v4 + ", " + v5 + ", " + v6 + ", " + v7 + ", " +
388 + v8 + ", " + v9 + ", " + v10 + ", " + v11 + ", " +
389 v12 + ", " + v13 + ", " + v14 + ", " + v15 + ">";