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 = 0, Size = 16)]
34 public struct Vector2l
41 public long X { get { return x; } set { x = value; } }
42 public long Y { get { return y; } set { y = value; } }
44 public static Vector2l One
46 get { return new Vector2l (1); }
49 public static Vector2l Zero
51 get { return new Vector2l (0); }
54 public static Vector2l MinusOne
56 get { return new Vector2l (-1); }
59 [System.Runtime.CompilerServices.IndexerName ("Component")]
60 public unsafe long this [int index]
63 if ((index | 0x1) != 0x1) //index < 0 || index > 1
64 throw new ArgumentOutOfRangeException ("index");
65 fixed (long *v = &x) {
70 if ( (index | 0x1) != 0x1) //index < 0 || index > 1
71 throw new ArgumentOutOfRangeException ("index");
72 fixed (long *v = &x) {
73 * (v + index) = value;
78 public Vector2l (long x, long y)
84 public Vector2l (long l)
90 [Acceleration (AccelMode.SSE2)]
91 public static Vector2l operator + (Vector2l v1, Vector2l v2)
93 return new Vector2l (v1.x + v2.x, v1.y + v2.y);
96 [Acceleration (AccelMode.SSE2)]
97 public static Vector2l operator - (Vector2l v1, Vector2l v2)
99 return new Vector2l (v1.x - v2.x, v1.y - v2.y);
102 [Acceleration (AccelMode.SSE2)]
103 public static unsafe Vector2l operator << (Vector2l v1, int amount)
105 return new Vector2l (v1.x << amount, v1.y << amount);
108 [Acceleration (AccelMode.SSE2)]
109 public static Vector2l operator & (Vector2l v1, Vector2l v2)
111 return new Vector2l (v1.x & v2.x, v1.y & v2.y);
114 [Acceleration (AccelMode.SSE2)]
115 public static Vector2l operator | (Vector2l v1, Vector2l v2)
117 return new Vector2l (v1.x | v2.x, v1.y | v2.y);
120 [Acceleration (AccelMode.SSE2)]
121 public static Vector2l operator ^ (Vector2l v1, Vector2l v2)
123 return new Vector2l (v1.x ^ v2.x, v1.y ^ v2.y);
126 [Acceleration (AccelMode.SSE1)]
127 public static unsafe explicit operator Vector2d (Vector2l v)
129 Vector2d* p = (Vector2d*)&v;
133 [Acceleration (AccelMode.SSE1)]
134 public static unsafe explicit operator Vector4f (Vector2l v)
136 Vector4f* p = (Vector4f*)&v;
140 [Acceleration (AccelMode.SSE1)]
141 [CLSCompliant(false)]
142 public static unsafe explicit operator Vector2ul (Vector2l v)
144 Vector2ul* p = (Vector2ul*)&v;
148 [Acceleration (AccelMode.SSE1)]
149 public static unsafe explicit operator Vector4i (Vector2l v)
151 Vector4i* p = (Vector4i*)&v;
155 [Acceleration (AccelMode.SSE1)]
156 [CLSCompliant(false)]
157 public static unsafe explicit operator Vector4ui (Vector2l v)
159 Vector4ui* p = (Vector4ui*)&v;
163 [Acceleration (AccelMode.SSE1)]
164 public static unsafe explicit operator Vector8s (Vector2l v)
166 Vector8s* p = (Vector8s*)&v;
170 [Acceleration (AccelMode.SSE1)]
171 [CLSCompliant(false)]
172 public static unsafe explicit operator Vector8us (Vector2l v)
174 Vector8us* p = (Vector8us*)&v;
178 [Acceleration (AccelMode.SSE1)]
179 [CLSCompliant(false)]
180 public static unsafe explicit operator Vector16sb (Vector2l v)
182 Vector16sb* p = (Vector16sb*)&v;
186 [Acceleration (AccelMode.SSE1)]
187 public static unsafe explicit operator Vector16b (Vector2l v)
189 Vector16b* p = (Vector16b*)&v;
193 [Acceleration (AccelMode.SSE1)]
194 public static Vector2l LoadAligned (ref Vector2l v)
199 [Acceleration (AccelMode.SSE1)]
200 public static void StoreAligned (ref Vector2l res, Vector2l val)
205 [CLSCompliant(false)]
206 [Acceleration (AccelMode.SSE1)]
207 public static unsafe Vector2l LoadAligned (Vector2l *v)
212 [CLSCompliant(false)]
213 [Acceleration (AccelMode.SSE1)]
214 public static unsafe void StoreAligned (Vector2l *res, Vector2l val)
219 [Acceleration (AccelMode.SSE1)]
220 [CLSCompliant(false)]
221 public static void PrefetchTemporalAllCacheLevels (ref Vector2l res)
225 [Acceleration (AccelMode.SSE1)]
226 [CLSCompliant(false)]
227 public static void PrefetchTemporal1stLevelCache (ref Vector2l res)
231 [Acceleration (AccelMode.SSE1)]
232 [CLSCompliant(false)]
233 public static void PrefetchTemporal2ndLevelCache (ref Vector2l res)
237 [Acceleration (AccelMode.SSE1)]
238 [CLSCompliant(false)]
239 public static void PrefetchNonTemporal (ref Vector2l res)
243 [Acceleration (AccelMode.SSE1)]
244 [CLSCompliant(false)]
245 public static unsafe void PrefetchTemporalAllCacheLevels (Vector2l *res)
249 [Acceleration (AccelMode.SSE1)]
250 [CLSCompliant(false)]
251 public static unsafe void PrefetchTemporal1stLevelCache (Vector2l *res)
255 [Acceleration (AccelMode.SSE1)]
256 [CLSCompliant(false)]
257 public static unsafe void PrefetchTemporal2ndLevelCache (Vector2l *res)
261 [Acceleration (AccelMode.SSE1)]
262 [CLSCompliant(false)]
263 public static unsafe void PrefetchNonTemporal (Vector2l *res)
267 public override string ToString()
269 return "<" + x + ", " + y + ">";