1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
4 using System.Diagnostics;
6 using System.Runtime.CompilerServices;
7 using System.Runtime.InteropServices;
8 using System.Runtime.Intrinsics.X86;
10 namespace System.Runtime.Intrinsics
12 // We mark certain methods with AggressiveInlining to ensure that the JIT will
13 // inline them. The JIT would otherwise not inline the method since it, at the
14 // point it tries to determine inline profability, currently cannot determine
15 // that most of the code-paths will be optimized away as "dead code".
17 // We then manually inline cases (such as certain intrinsic code-paths) that
18 // will generate code small enough to make the AgressiveInlining profitable. The
19 // other cases (such as the software fallback) are placed in their own method.
20 // This ensures we get good codegen for the "fast-path" and allows the JIT to
21 // determine inline profitability of the other paths as it would normally.
23 // Many of the instance methods were moved to be extension methods as it results
24 // in overall better codegen. This is because instance methods require the C# compiler
25 // to generate extra locals as the `this` parameter has to be passed by reference.
26 // Having them be extension methods means that the `this` parameter can be passed by
27 // value instead, thus reducing the number of locals and helping prevent us from hitting
28 // the internal inlining limits of the JIT.
30 /// <summary>Provides a collection of static methods for creating, manipulating, and otherwise operting on 512-bit vectors.</summary>
31 public static unsafe class Vector512
33 internal const int Size = 64;
36 internal const int Alignment = 8;
38 internal const int Alignment = 16;
40 internal const int Alignment = 64;
43 /// <summary>Gets a value that indicates whether 512-bit vector operations are subject to hardware acceleration through JIT intrinsic support.</summary>
44 /// <value><see langword="true" /> if 512-bit vector operations are subject to hardware acceleration; otherwise, <see langword="false" />.</value>
45 /// <remarks>512-bit vector operations are subject to hardware acceleration on systems that support Single Instruction, Multiple Data (SIMD) instructions for 512-bit vectors and the RyuJIT just-in-time compiler is used to compile managed code.</remarks>
46 public static bool IsHardwareAccelerated
49 get => IsHardwareAccelerated;
52 /// <summary>Computes the absolute value of each element in a vector.</summary>
53 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
54 /// <param name="vector">The vector that will have its absolute value computed.</param>
55 /// <returns>A vector whose elements are the absolute value of the elements in <paramref name="vector" />.</returns>
56 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
58 [MethodImpl(MethodImplOptions.AggressiveInlining)]
59 public static Vector512<T> Abs<T>(Vector512<T> vector)
62 Vector256.Abs(vector._lower),
63 Vector256.Abs(vector._upper)
67 /// <summary>Adds two vectors to compute their sum.</summary>
68 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
69 /// <param name="left">The vector to add with <paramref name="right" />.</param>
70 /// <param name="right">The vector to add with <paramref name="left" />.</param>
71 /// <returns>The sum of <paramref name="left" /> and <paramref name="right" />.</returns>
72 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
74 [MethodImpl(MethodImplOptions.AggressiveInlining)]
75 public static Vector512<T> Add<T>(Vector512<T> left, Vector512<T> right) => left + right;
77 /// <summary>Computes the bitwise-and of a given vector and the ones complement of another vector.</summary>
78 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
79 /// <param name="left">The vector to bitwise-and with <paramref name="right" />.</param>
80 /// <param name="right">The vector to that is ones-complemented before being bitwise-and with <paramref name="left" />.</param>
81 /// <returns>The bitwise-and of <paramref name="left" /> and the ones-complement of <paramref name="right" />.</returns>
82 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
84 [MethodImpl(MethodImplOptions.AggressiveInlining)]
85 public static Vector512<T> AndNot<T>(Vector512<T> left, Vector512<T> right)
88 Vector256.AndNot(left._lower, right._lower),
89 Vector256.AndNot(left._upper, right._upper)
93 /// <summary>Reinterprets a <see cref="Vector512{TFrom}" /> as a new <see cref="Vector512{TTo}" />.</summary>
94 /// <typeparam name="TFrom">The type of the elements in the input vector.</typeparam>
95 /// <typeparam name="TTo">The type of the elements in the output vector.</typeparam>
96 /// <param name="vector">The vector to reinterpret.</param>
97 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{TTo}" />.</returns>
98 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="TFrom" />) or the type of the target (<typeparamref name="TTo" />) is not supported.</exception>
100 [MethodImpl(MethodImplOptions.AggressiveInlining)]
101 public static Vector512<TTo> As<TFrom, TTo>(this Vector512<TFrom> vector)
103 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<TFrom>();
104 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<TTo>();
106 return Unsafe.As<Vector512<TFrom>, Vector512<TTo>>(ref vector);
109 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{Byte}" />.</summary>
110 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
111 /// <param name="vector">The vector to reinterpret.</param>
112 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{Byte}" />.</returns>
113 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
115 [MethodImpl(MethodImplOptions.AggressiveInlining)]
116 public static Vector512<byte> AsByte<T>(this Vector512<T> vector) => vector.As<T, byte>();
118 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{Double}" />.</summary>
119 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
120 /// <param name="vector">The vector to reinterpret.</param>
121 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{Double}" />.</returns>
122 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
124 [MethodImpl(MethodImplOptions.AggressiveInlining)]
125 public static Vector512<double> AsDouble<T>(this Vector512<T> vector) => vector.As<T, double>();
127 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{Int16}" />.</summary>
128 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
129 /// <param name="vector">The vector to reinterpret.</param>
130 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{Int16}" />.</returns>
131 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
133 [MethodImpl(MethodImplOptions.AggressiveInlining)]
134 public static Vector512<short> AsInt16<T>(this Vector512<T> vector) => vector.As<T, short>();
136 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{Int32}" />.</summary>
137 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
138 /// <param name="vector">The vector to reinterpret.</param>
139 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{Int32}" />.</returns>
140 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
142 [MethodImpl(MethodImplOptions.AggressiveInlining)]
143 public static Vector512<int> AsInt32<T>(this Vector512<T> vector) => vector.As<T, int>();
145 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{Int64}" />.</summary>
146 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
147 /// <param name="vector">The vector to reinterpret.</param>
148 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{Int64}" />.</returns>
149 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
151 [MethodImpl(MethodImplOptions.AggressiveInlining)]
152 public static Vector512<long> AsInt64<T>(this Vector512<T> vector) => vector.As<T, long>();
154 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{IntPtr}" />.</summary>
155 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
156 /// <param name="vector">The vector to reinterpret.</param>
157 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{IntPtr}" />.</returns>
158 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
160 [MethodImpl(MethodImplOptions.AggressiveInlining)]
161 public static Vector512<nint> AsNInt<T>(this Vector512<T> vector) => vector.As<T, nint>();
163 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{UIntPtr}" />.</summary>
164 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
165 /// <param name="vector">The vector to reinterpret.</param>
166 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{UIntPtr}" />.</returns>
167 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
169 [CLSCompliant(false)]
170 [MethodImpl(MethodImplOptions.AggressiveInlining)]
171 public static Vector512<nuint> AsNUInt<T>(this Vector512<T> vector) => vector.As<T, nuint>();
173 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{SByte}" />.</summary>
174 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
175 /// <param name="vector">The vector to reinterpret.</param>
176 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{SByte}" />.</returns>
177 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
179 [CLSCompliant(false)]
180 [MethodImpl(MethodImplOptions.AggressiveInlining)]
181 public static Vector512<sbyte> AsSByte<T>(this Vector512<T> vector) => vector.As<T, sbyte>();
183 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{Single}" />.</summary>
184 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
185 /// <param name="vector">The vector to reinterpret.</param>
186 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{Single}" />.</returns>
187 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
189 [MethodImpl(MethodImplOptions.AggressiveInlining)]
190 public static Vector512<float> AsSingle<T>(this Vector512<T> vector) => vector.As<T, float>();
192 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{UInt16}" />.</summary>
193 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
194 /// <param name="vector">The vector to reinterpret.</param>
195 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{UInt16}" />.</returns>
196 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
198 [CLSCompliant(false)]
199 [MethodImpl(MethodImplOptions.AggressiveInlining)]
200 public static Vector512<ushort> AsUInt16<T>(this Vector512<T> vector) => vector.As<T, ushort>();
202 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{UInt32}" />.</summary>
203 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
204 /// <param name="vector">The vector to reinterpret.</param>
205 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{UInt32}" />.</returns>
206 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
208 [CLSCompliant(false)]
209 [MethodImpl(MethodImplOptions.AggressiveInlining)]
210 public static Vector512<uint> AsUInt32<T>(this Vector512<T> vector) => vector.As<T, uint>();
212 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{UInt64}" />.</summary>
213 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
214 /// <param name="vector">The vector to reinterpret.</param>
215 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{UInt64}" />.</returns>
216 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
218 [CLSCompliant(false)]
219 [MethodImpl(MethodImplOptions.AggressiveInlining)]
220 public static Vector512<ulong> AsUInt64<T>(this Vector512<T> vector) => vector.As<T, ulong>();
222 /// <summary>Reinterprets a <see cref="Vector{T}" /> as a new <see cref="Vector512{T}" />.</summary>
223 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
224 /// <param name="value">The vector to reinterpret.</param>
225 /// <returns><paramref name="value" /> reinterpreted as a new <see cref="Vector512{T}" />.</returns>
226 /// <exception cref="NotSupportedException">The type of <paramref name="value" /> (<typeparamref name="T" />) is not supported.</exception>
228 [MethodImpl(MethodImplOptions.AggressiveInlining)]
229 public static Vector512<T> AsVector512<T>(this Vector<T> value)
231 Debug.Assert(Vector512<T>.Count >= Vector<T>.Count);
232 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
234 Vector512<T> result = default;
235 Unsafe.WriteUnaligned(ref Unsafe.As<Vector512<T>, byte>(ref result), value);
239 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector{T}" />.</summary>
240 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
241 /// <param name="value">The vector to reinterpret.</param>
242 /// <returns><paramref name="value" /> reinterpreted as a new <see cref="Vector{T}" />.</returns>
243 /// <exception cref="NotSupportedException">The type of <paramref name="value" /> (<typeparamref name="T" />) is not supported.</exception>
245 [MethodImpl(MethodImplOptions.AggressiveInlining)]
246 public static Vector<T> AsVector<T>(this Vector512<T> value)
248 Debug.Assert(Vector512<T>.Count >= Vector<T>.Count);
249 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
251 ref byte address = ref Unsafe.As<Vector512<T>, byte>(ref value);
252 return Unsafe.ReadUnaligned<Vector<T>>(ref address);
255 /// <summary>Computes the bitwise-and of two vectors.</summary>
256 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
257 /// <param name="left">The vector to bitwise-and with <paramref name="right" />.</param>
258 /// <param name="right">The vector to bitwise-and with <paramref name="left" />.</param>
259 /// <returns>The bitwise-and of <paramref name="left" /> and <paramref name="right"/>.</returns>
260 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
262 [MethodImpl(MethodImplOptions.AggressiveInlining)]
263 public static Vector512<T> BitwiseAnd<T>(Vector512<T> left, Vector512<T> right) => left & right;
265 /// <summary>Computes the bitwise-or of two vectors.</summary>
266 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
267 /// <param name="left">The vector to bitwise-or with <paramref name="right" />.</param>
268 /// <param name="right">The vector to bitwise-or with <paramref name="left" />.</param>
269 /// <returns>The bitwise-or of <paramref name="left" /> and <paramref name="right"/>.</returns>
270 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
272 [MethodImpl(MethodImplOptions.AggressiveInlining)]
273 public static Vector512<T> BitwiseOr<T>(Vector512<T> left, Vector512<T> right) => left | right;
275 /// <summary>Computes the ceiling of each element in a vector.</summary>
276 /// <param name="vector">The vector that will have its ceiling computed.</param>
277 /// <returns>A vector whose elements are the ceiling of the elements in <paramref name="vector" />.</returns>
278 /// <seealso cref="MathF.Ceiling(float)" />
280 [MethodImpl(MethodImplOptions.AggressiveInlining)]
281 public static Vector512<float> Ceiling(Vector512<float> vector)
284 Vector256.Ceiling(vector._lower),
285 Vector256.Ceiling(vector._upper)
289 /// <summary>Computes the ceiling of each element in a vector.</summary>
290 /// <param name="vector">The vector that will have its ceiling computed.</param>
291 /// <returns>A vector whose elements are the ceiling of the elements in <paramref name="vector" />.</returns>
292 /// <seealso cref="Math.Ceiling(double)" />
294 [MethodImpl(MethodImplOptions.AggressiveInlining)]
295 public static Vector512<double> Ceiling(Vector512<double> vector)
298 Vector256.Ceiling(vector._lower),
299 Vector256.Ceiling(vector._upper)
303 /// <summary>Conditionally selects a value from two vectors on a bitwise basis.</summary>
304 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
305 /// <param name="condition">The mask that is used to select a value from <paramref name="left" /> or <paramref name="right" />.</param>
306 /// <param name="left">The vector that is selected when the corresponding bit in <paramref name="condition" /> is one.</param>
307 /// <param name="right">The vector that is selected when the corresponding bit in <paramref name="condition" /> is zero.</param>
308 /// <returns>A vector whose bits come from <paramref name="left" /> or <paramref name="right" /> based on the value of <paramref name="condition" />.</returns>
309 /// <exception cref="NotSupportedException">The type of <paramref name="condition" />, <paramref name="left" />, and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
311 [MethodImpl(MethodImplOptions.AggressiveInlining)]
312 public static Vector512<T> ConditionalSelect<T>(Vector512<T> condition, Vector512<T> left, Vector512<T> right)
315 Vector256.ConditionalSelect(condition._lower, left._lower, right._lower),
316 Vector256.ConditionalSelect(condition._upper, left._upper, right._upper)
320 /// <summary>Converts a <see cref="Vector512{Int64}" /> to a <see cref="Vector512{Double}" />.</summary>
321 /// <param name="vector">The vector to convert.</param>
322 /// <returns>The converted vector.</returns>
324 [MethodImpl(MethodImplOptions.AggressiveInlining)]
325 public static Vector512<double> ConvertToDouble(Vector512<long> vector)
328 Vector256.ConvertToDouble(vector._lower),
329 Vector256.ConvertToDouble(vector._upper)
333 /// <summary>Converts a <see cref="Vector512{UInt64}" /> to a <see cref="Vector512{Double}" />.</summary>
334 /// <param name="vector">The vector to convert.</param>
335 /// <returns>The converted vector.</returns>
337 [CLSCompliant(false)]
338 [MethodImpl(MethodImplOptions.AggressiveInlining)]
339 public static Vector512<double> ConvertToDouble(Vector512<ulong> vector)
342 Vector256.ConvertToDouble(vector._lower),
343 Vector256.ConvertToDouble(vector._upper)
347 /// <summary>Converts a <see cref="Vector512{Single}" /> to a <see cref="Vector512{Int32}" />.</summary>
348 /// <param name="vector">The vector to convert.</param>
349 /// <returns>The converted vector.</returns>
351 [MethodImpl(MethodImplOptions.AggressiveInlining)]
352 public static Vector512<int> ConvertToInt32(Vector512<float> vector)
355 Vector256.ConvertToInt32(vector._lower),
356 Vector256.ConvertToInt32(vector._upper)
360 /// <summary>Converts a <see cref="Vector512{Double}" /> to a <see cref="Vector512{Int64}" />.</summary>
361 /// <param name="vector">The vector to convert.</param>
362 /// <returns>The converted vector.</returns>
364 [MethodImpl(MethodImplOptions.AggressiveInlining)]
365 public static Vector512<long> ConvertToInt64(Vector512<double> vector)
368 Vector256.ConvertToInt64(vector._lower),
369 Vector256.ConvertToInt64(vector._upper)
373 /// <summary>Converts a <see cref="Vector512{Int32}" /> to a <see cref="Vector512{Single}" />.</summary>
374 /// <param name="vector">The vector to convert.</param>
375 /// <returns>The converted vector.</returns>
377 [MethodImpl(MethodImplOptions.AggressiveInlining)]
378 public static Vector512<float> ConvertToSingle(Vector512<int> vector)
381 Vector256.ConvertToSingle(vector._lower),
382 Vector256.ConvertToSingle(vector._upper)
386 /// <summary>Converts a <see cref="Vector512{UInt32}" /> to a <see cref="Vector512{Single}" />.</summary>
387 /// <param name="vector">The vector to convert.</param>
388 /// <returns>The converted vector.</returns>
390 [CLSCompliant(false)]
391 [MethodImpl(MethodImplOptions.AggressiveInlining)]
392 public static Vector512<float> ConvertToSingle(Vector512<uint> vector)
395 Vector256.ConvertToSingle(vector._lower),
396 Vector256.ConvertToSingle(vector._upper)
400 /// <summary>Converts a <see cref="Vector512{Single}" /> to a <see cref="Vector512{UInt32}" />.</summary>
401 /// <param name="vector">The vector to convert.</param>
402 /// <returns>The converted vector.</returns>
404 [CLSCompliant(false)]
405 [MethodImpl(MethodImplOptions.AggressiveInlining)]
406 public static Vector512<uint> ConvertToUInt32(Vector512<float> vector)
409 Vector256.ConvertToUInt32(vector._lower),
410 Vector256.ConvertToUInt32(vector._upper)
414 /// <summary>Converts a <see cref="Vector512{Double}" /> to a <see cref="Vector512{UInt64}" />.</summary>
415 /// <param name="vector">The vector to convert.</param>
416 /// <returns>The converted vector.</returns>
418 [CLSCompliant(false)]
419 [MethodImpl(MethodImplOptions.AggressiveInlining)]
420 public static Vector512<ulong> ConvertToUInt64(Vector512<double> vector)
423 Vector256.ConvertToUInt64(vector._lower),
424 Vector256.ConvertToUInt64(vector._upper)
428 /// <summary>Copies a <see cref="Vector512{T}" /> to a given array.</summary>
429 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
430 /// <param name="vector">The vector to be copied.</param>
431 /// <param name="destination">The array to which <paramref name="vector" /> is copied.</param>
432 /// <exception cref="ArgumentException">The length of <paramref name="destination" /> is less than <see cref="Vector512{T}.Count" />.</exception>
433 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
434 /// <exception cref="NullReferenceException"><paramref name="destination" /> is <c>null</c>.</exception>
435 public static void CopyTo<T>(this Vector512<T> vector, T[] destination)
437 // We explicitly don't check for `null` because historically this has thrown `NullReferenceException` for perf reasons
439 if (destination.Length < Vector512<T>.Count)
441 ThrowHelper.ThrowArgumentException_DestinationTooShort();
444 ref byte address = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetArrayDataReference(destination));
445 Unsafe.WriteUnaligned(ref address, vector);
448 /// <summary>Copies a <see cref="Vector512{T}" /> to a given array starting at the specified index.</summary>
449 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
450 /// <param name="vector">The vector to be copied.</param>
451 /// <param name="destination">The array to which <paramref name="vector" /> is copied.</param>
452 /// <param name="startIndex">The starting index of <paramref name="destination" /> which <paramref name="vector" /> will be copied to.</param>
453 /// <exception cref="ArgumentException">The length of <paramref name="destination" /> is less than <see cref="Vector512{T}.Count" />.</exception>
454 /// <exception cref="ArgumentOutOfRangeException"><paramref name="startIndex" /> is negative or greater than the length of <paramref name="destination" />.</exception>
455 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
456 /// <exception cref="NullReferenceException"><paramref name="destination" /> is <c>null</c>.</exception>
457 public static void CopyTo<T>(this Vector512<T> vector, T[] destination, int startIndex)
459 // We explicitly don't check for `null` because historically this has thrown `NullReferenceException` for perf reasons
461 if ((uint)startIndex >= (uint)destination.Length)
463 ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_IndexMustBeLess();
466 if ((destination.Length - startIndex) < Vector512<T>.Count)
468 ThrowHelper.ThrowArgumentException_DestinationTooShort();
471 ref byte address = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetArrayDataReference(destination));
472 Unsafe.WriteUnaligned(ref Unsafe.Add(ref address, startIndex), vector);
475 /// <summary>Copies a <see cref="Vector512{T}" /> to a given span.</summary>
476 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
477 /// <param name="vector">The vector to be copied.</param>
478 /// <param name="destination">The span to which the <paramref name="vector" /> is copied.</param>
479 /// <exception cref="ArgumentException">The length of <paramref name="destination" /> is less than <see cref="Vector512{T}.Count" />.</exception>
480 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
481 public static void CopyTo<T>(this Vector512<T> vector, Span<T> destination)
483 if ((uint)destination.Length < (uint)Vector512<T>.Count)
485 ThrowHelper.ThrowArgumentException_DestinationTooShort();
488 ref byte address = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination));
489 Unsafe.WriteUnaligned(ref address, vector);
492 /// <summary>Creates a new <see cref="Vector512{T}" /> instance with all elements initialized to the specified value.</summary>
493 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
494 /// <param name="value">The value that all elements will be initialized to.</param>
495 /// <returns>A new <see cref="Vector512{T}" /> with all elements initialized to <paramref name="value" />.</returns>
496 /// <exception cref="NotSupportedException">The type of <paramref name="value" /> (<typeparamref name="T" />) is not supported.</exception>
498 [MethodImpl(MethodImplOptions.AggressiveInlining)]
499 public static Vector512<T> Create<T>(T value)
501 Vector256<T> vector = Vector256.Create(value);
502 return Create(vector, vector);
505 /// <summary>Creates a new <see cref="Vector512{Byte}" /> instance with all elements initialized to the specified value.</summary>
506 /// <param name="value">The value that all elements will be initialized to.</param>
507 /// <returns>A new <see cref="Vector512{Byte}" /> with all elements initialized to <paramref name="value" />.</returns>
508 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi8</remarks>
510 [MethodImpl(MethodImplOptions.AggressiveInlining)]
511 public static Vector512<byte> Create(byte value) => Create<byte>(value);
513 /// <summary>Creates a new <see cref="Vector512{Double}" /> instance with all elements initialized to the specified value.</summary>
514 /// <param name="value">The value that all elements will be initialized to.</param>
515 /// <returns>A new <see cref="Vector512{Double}" /> with all elements initialized to <paramref name="value" />.</returns>
516 /// <remarks>On x86, this method corresponds to __m512d _mm512_set1_pd</remarks>
518 [MethodImpl(MethodImplOptions.AggressiveInlining)]
519 public static Vector512<double> Create(double value) => Create<double>(value);
521 /// <summary>Creates a new <see cref="Vector512{Int16}" /> instance with all elements initialized to the specified value.</summary>
522 /// <param name="value">The value that all elements will be initialized to.</param>
523 /// <returns>A new <see cref="Vector512{Int16}" /> with all elements initialized to <paramref name="value" />.</returns>
524 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi16</remarks>
526 [MethodImpl(MethodImplOptions.AggressiveInlining)]
527 public static Vector512<short> Create(short value) => Create<short>(value);
529 /// <summary>Creates a new <see cref="Vector512{Int32}" /> instance with all elements initialized to the specified value.</summary>
530 /// <param name="value">The value that all elements will be initialized to.</param>
531 /// <returns>A new <see cref="Vector512{Int32}" /> with all elements initialized to <paramref name="value" />.</returns>
532 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi32</remarks>
534 [MethodImpl(MethodImplOptions.AggressiveInlining)]
535 public static Vector512<int> Create(int value) => Create<int>(value);
537 /// <summary>Creates a new <see cref="Vector512{Int64}" /> instance with all elements initialized to the specified value.</summary>
538 /// <param name="value">The value that all elements will be initialized to.</param>
539 /// <returns>A new <see cref="Vector512{Int64}" /> with all elements initialized to <paramref name="value" />.</returns>
540 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi64x</remarks>
542 [MethodImpl(MethodImplOptions.AggressiveInlining)]
543 public static Vector512<long> Create(long value) => Create<long>(value);
545 /// <summary>Creates a new <see cref="Vector512{IntPtr}" /> instance with all elements initialized to the specified value.</summary>
546 /// <param name="value">The value that all elements will be initialized to.</param>
547 /// <returns>A new <see cref="Vector512{IntPtr}" /> with all elements initialized to <paramref name="value" />.</returns>
549 [MethodImpl(MethodImplOptions.AggressiveInlining)]
550 public static Vector512<nint> Create(nint value) => Create<nint>(value);
552 /// <summary>Creates a new <see cref="Vector512{UIntPtr}" /> instance with all elements initialized to the specified value.</summary>
553 /// <param name="value">The value that all elements will be initialized to.</param>
554 /// <returns>A new <see cref="Vector512{UIntPtr}" /> with all elements initialized to <paramref name="value" />.</returns>
556 [CLSCompliant(false)]
557 [MethodImpl(MethodImplOptions.AggressiveInlining)]
558 public static Vector512<nuint> Create(nuint value) => Create<nuint>(value);
560 /// <summary>Creates a new <see cref="Vector512{SByte}" /> instance with all elements initialized to the specified value.</summary>
561 /// <param name="value">The value that all elements will be initialized to.</param>
562 /// <returns>A new <see cref="Vector512{SByte}" /> with all elements initialized to <paramref name="value" />.</returns>
563 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi8</remarks>
565 [CLSCompliant(false)]
566 [MethodImpl(MethodImplOptions.AggressiveInlining)]
567 public static Vector512<sbyte> Create(sbyte value) => Create<sbyte>(value);
569 /// <summary>Creates a new <see cref="Vector512{Single}" /> instance with all elements initialized to the specified value.</summary>
570 /// <param name="value">The value that all elements will be initialized to.</param>
571 /// <returns>A new <see cref="Vector512{Single}" /> with all elements initialized to <paramref name="value" />.</returns>
572 /// <remarks>On x86, this method corresponds to __m512 _mm512_set1_ps</remarks>
574 [MethodImpl(MethodImplOptions.AggressiveInlining)]
575 public static Vector512<float> Create(float value) => Create<float>(value);
577 /// <summary>Creates a new <see cref="Vector512{UInt16}" /> instance with all elements initialized to the specified value.</summary>
578 /// <param name="value">The value that all elements will be initialized to.</param>
579 /// <returns>A new <see cref="Vector512{UInt16}" /> with all elements initialized to <paramref name="value" />.</returns>
580 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi16</remarks>
582 [CLSCompliant(false)]
583 [MethodImpl(MethodImplOptions.AggressiveInlining)]
584 public static Vector512<ushort> Create(ushort value) => Create<ushort>(value);
586 /// <summary>Creates a new <see cref="Vector512{UInt32}" /> instance with all elements initialized to the specified value.</summary>
587 /// <param name="value">The value that all elements will be initialized to.</param>
588 /// <returns>A new <see cref="Vector512{UInt32}" /> with all elements initialized to <paramref name="value" />.</returns>
589 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi32</remarks>
591 [CLSCompliant(false)]
592 [MethodImpl(MethodImplOptions.AggressiveInlining)]
593 public static Vector512<uint> Create(uint value) => Create<uint>(value);
595 /// <summary>Creates a new <see cref="Vector512{UInt64}" /> instance with all elements initialized to the specified value.</summary>
596 /// <param name="value">The value that all elements will be initialized to.</param>
597 /// <returns>A new <see cref="Vector512{UInt64}" /> with all elements initialized to <paramref name="value" />.</returns>
598 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi64x</remarks>
600 [CLSCompliant(false)]
601 [MethodImpl(MethodImplOptions.AggressiveInlining)]
602 public static Vector512<ulong> Create(ulong value) => Create<ulong>(value);
604 /// <summary>Creates a new <see cref="Vector512{T}" /> from a given array.</summary>
605 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
606 /// <param name="values">The array from which the vector is created.</param>
607 /// <returns>A new <see cref="Vector512{T}" /> with its elements set to the first <see cref="Vector512{T}.Count" /> elements from <paramref name="values" />.</returns>
608 /// <exception cref="ArgumentOutOfRangeException">The length of <paramref name="values" /> is less than <see cref="Vector512{T}.Count" />.</exception>
609 /// <exception cref="NotSupportedException">The type of <paramref name="values" /> (<typeparamref name="T" />) is not supported.</exception>
610 /// <exception cref="NullReferenceException"><paramref name="values" /> is <c>null</c>.</exception>
611 public static Vector512<T> Create<T>(T[] values)
613 // We explicitly don't check for `null` because historically this has thrown `NullReferenceException` for perf reasons
615 if (values.Length < Vector512<T>.Count)
617 ThrowHelper.ThrowArgumentOutOfRange_IndexMustBeLessOrEqualException();
620 ref byte address = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetArrayDataReference(values));
621 return Unsafe.ReadUnaligned<Vector512<T>>(ref address);
624 /// <summary>Creates a new <see cref="Vector512{T}" /> from a given array.</summary>
625 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
626 /// <param name="values">The array from which the vector is created.</param>
627 /// <param name="index">The index in <paramref name="values" /> at which to being reading elements.</param>
628 /// <returns>A new <see cref="Vector512{T}" /> with its elements set to the first <see cref="Vector256{T}.Count" /> elements from <paramref name="values" />.</returns>
629 /// <exception cref="ArgumentOutOfRangeException">The length of <paramref name="values" />, starting from <paramref name="index" />, is less than <see cref="Vector512{T}.Count" />.</exception>
630 /// <exception cref="NotSupportedException">The type of <paramref name="values" /> (<typeparamref name="T" />) is not supported.</exception>
631 /// <exception cref="NullReferenceException"><paramref name="values" /> is <c>null</c>.</exception>
632 public static Vector512<T> Create<T>(T[] values, int index)
634 // We explicitly don't check for `null` because historically this has thrown `NullReferenceException` for perf reasons
636 if ((index < 0) || ((values.Length - index) < Vector512<T>.Count))
638 ThrowHelper.ThrowArgumentOutOfRange_IndexMustBeLessOrEqualException();
641 ref byte address = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetArrayDataReference(values));
642 return Unsafe.ReadUnaligned<Vector512<T>>(ref Unsafe.Add(ref address, index));
645 /// <summary>Creates a new <see cref="Vector512{T}" /> from a given readonly span.</summary>
646 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
647 /// <param name="values">The readonly span from which the vector is created.</param>
648 /// <returns>A new <see cref="Vector512{T}" /> with its elements set to the first <see cref="Vector512{T}.Count" /> elements from <paramref name="values" />.</returns>
649 /// <exception cref="ArgumentOutOfRangeException">The length of <paramref name="values" /> is less than <see cref="Vector512{T}.Count" />.</exception>
650 /// <exception cref="NotSupportedException">The type of <paramref name="values" /> (<typeparamref name="T" />) is not supported.</exception>
651 [MethodImpl(MethodImplOptions.AggressiveInlining)]
652 public static Vector512<T> Create<T>(ReadOnlySpan<T> values)
654 if (values.Length < Vector512<T>.Count)
656 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.values);
659 ref byte address = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values));
660 return Unsafe.ReadUnaligned<Vector512<T>>(ref address);
663 /// <summary>Creates a new <see cref="Vector512{Byte}" /> instance with each element initialized to the corresponding specified value.</summary>
664 /// <param name="e0">The value that element 0 will be initialized to.</param>
665 /// <param name="e1">The value that element 1 will be initialized to.</param>
666 /// <param name="e2">The value that element 2 will be initialized to.</param>
667 /// <param name="e3">The value that element 3 will be initialized to.</param>
668 /// <param name="e4">The value that element 4 will be initialized to.</param>
669 /// <param name="e5">The value that element 5 will be initialized to.</param>
670 /// <param name="e6">The value that element 6 will be initialized to.</param>
671 /// <param name="e7">The value that element 7 will be initialized to.</param>
672 /// <param name="e8">The value that element 8 will be initialized to.</param>
673 /// <param name="e9">The value that element 9 will be initialized to.</param>
674 /// <param name="e10">The value that element 10 will be initialized to.</param>
675 /// <param name="e11">The value that element 11 will be initialized to.</param>
676 /// <param name="e12">The value that element 12 will be initialized to.</param>
677 /// <param name="e13">The value that element 13 will be initialized to.</param>
678 /// <param name="e14">The value that element 14 will be initialized to.</param>
679 /// <param name="e15">The value that element 15 will be initialized to.</param>
680 /// <param name="e16">The value that element 16 will be initialized to.</param>
681 /// <param name="e17">The value that element 17 will be initialized to.</param>
682 /// <param name="e18">The value that element 18 will be initialized to.</param>
683 /// <param name="e19">The value that element 19 will be initialized to.</param>
684 /// <param name="e20">The value that element 20 will be initialized to.</param>
685 /// <param name="e21">The value that element 21 will be initialized to.</param>
686 /// <param name="e22">The value that element 22 will be initialized to.</param>
687 /// <param name="e23">The value that element 23 will be initialized to.</param>
688 /// <param name="e24">The value that element 24 will be initialized to.</param>
689 /// <param name="e25">The value that element 25 will be initialized to.</param>
690 /// <param name="e26">The value that element 26 will be initialized to.</param>
691 /// <param name="e27">The value that element 27 will be initialized to.</param>
692 /// <param name="e28">The value that element 28 will be initialized to.</param>
693 /// <param name="e29">The value that element 29 will be initialized to.</param>
694 /// <param name="e30">The value that element 30 will be initialized to.</param>
695 /// <param name="e31">The value that element 31 will be initialized to.</param>
696 /// <param name="e32">The value that element 32 will be initialized to.</param>
697 /// <param name="e33">The value that element 33 will be initialized to.</param>
698 /// <param name="e34">The value that element 34 will be initialized to.</param>
699 /// <param name="e35">The value that element 35 will be initialized to.</param>
700 /// <param name="e36">The value that element 36 will be initialized to.</param>
701 /// <param name="e37">The value that element 37 will be initialized to.</param>
702 /// <param name="e38">The value that element 38 will be initialized to.</param>
703 /// <param name="e39">The value that element 39 will be initialized to.</param>
704 /// <param name="e40">The value that element 40 will be initialized to.</param>
705 /// <param name="e41">The value that element 41 will be initialized to.</param>
706 /// <param name="e42">The value that element 42 will be initialized to.</param>
707 /// <param name="e43">The value that element 43 will be initialized to.</param>
708 /// <param name="e44">The value that element 44 will be initialized to.</param>
709 /// <param name="e45">The value that element 45 will be initialized to.</param>
710 /// <param name="e46">The value that element 46 will be initialized to.</param>
711 /// <param name="e47">The value that element 47 will be initialized to.</param>
712 /// <param name="e48">The value that element 48 will be initialized to.</param>
713 /// <param name="e49">The value that element 49 will be initialized to.</param>
714 /// <param name="e50">The value that element 50 will be initialized to.</param>
715 /// <param name="e51">The value that element 51 will be initialized to.</param>
716 /// <param name="e52">The value that element 52 will be initialized to.</param>
717 /// <param name="e53">The value that element 53 will be initialized to.</param>
718 /// <param name="e54">The value that element 54 will be initialized to.</param>
719 /// <param name="e55">The value that element 55 will be initialized to.</param>
720 /// <param name="e56">The value that element 56 will be initialized to.</param>
721 /// <param name="e57">The value that element 57 will be initialized to.</param>
722 /// <param name="e58">The value that element 58 will be initialized to.</param>
723 /// <param name="e59">The value that element 59 will be initialized to.</param>
724 /// <param name="e60">The value that element 60 will be initialized to.</param>
725 /// <param name="e61">The value that element 61 will be initialized to.</param>
726 /// <param name="e62">The value that element 62 will be initialized to.</param>
727 /// <param name="e63">The value that element 63 will be initialized to.</param>
728 /// <returns>A new <see cref="Vector512{Byte}" /> with each element initialized to corresponding specified value.</returns>
729 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi8</remarks>
731 [MethodImpl(MethodImplOptions.AggressiveInlining)]
732 public static Vector512<byte> Create(byte e0, byte e1, byte e2, byte e3, byte e4, byte e5, byte e6, byte e7, byte e8, byte e9, byte e10, byte e11, byte e12, byte e13, byte e14, byte e15,
733 byte e16, byte e17, byte e18, byte e19, byte e20, byte e21, byte e22, byte e23, byte e24, byte e25, byte e26, byte e27, byte e28, byte e29, byte e30, byte e31,
734 byte e32, byte e33, byte e34, byte e35, byte e36, byte e37, byte e38, byte e39, byte e40, byte e41, byte e42, byte e43, byte e44, byte e45, byte e46, byte e47,
735 byte e48, byte e49, byte e50, byte e51, byte e52, byte e53, byte e54, byte e55, byte e56, byte e57, byte e58, byte e59, byte e60, byte e61, byte e62, byte e63)
738 Vector256.Create(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31),
739 Vector256.Create(e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63)
743 /// <summary>Creates a new <see cref="Vector512{Double}" /> instance with each element initialized to the corresponding specified value.</summary>
744 /// <param name="e0">The value that element 0 will be initialized to.</param>
745 /// <param name="e1">The value that element 1 will be initialized to.</param>
746 /// <param name="e2">The value that element 2 will be initialized to.</param>
747 /// <param name="e3">The value that element 3 will be initialized to.</param>
748 /// <param name="e4">The value that element 4 will be initialized to.</param>
749 /// <param name="e5">The value that element 5 will be initialized to.</param>
750 /// <param name="e6">The value that element 6 will be initialized to.</param>
751 /// <param name="e7">The value that element 7 will be initialized to.</param>
752 /// <returns>A new <see cref="Vector512{Double}" /> with each element initialized to corresponding specified value.</returns>
753 /// <remarks>On x86, this method corresponds to __m512d _mm512_setr_pd</remarks>
755 [MethodImpl(MethodImplOptions.AggressiveInlining)]
756 public static Vector512<double> Create(double e0, double e1, double e2, double e3, double e4, double e5, double e6, double e7)
759 Vector256.Create(e0, e1, e2, e3),
760 Vector256.Create(e4, e5, e6, e7)
764 /// <summary>Creates a new <see cref="Vector512{Int16}" /> instance with each element initialized to the corresponding specified value.</summary>
765 /// <param name="e0">The value that element 0 will be initialized to.</param>
766 /// <param name="e1">The value that element 1 will be initialized to.</param>
767 /// <param name="e2">The value that element 2 will be initialized to.</param>
768 /// <param name="e3">The value that element 3 will be initialized to.</param>
769 /// <param name="e4">The value that element 4 will be initialized to.</param>
770 /// <param name="e5">The value that element 5 will be initialized to.</param>
771 /// <param name="e6">The value that element 6 will be initialized to.</param>
772 /// <param name="e7">The value that element 7 will be initialized to.</param>
773 /// <param name="e8">The value that element 8 will be initialized to.</param>
774 /// <param name="e9">The value that element 9 will be initialized to.</param>
775 /// <param name="e10">The value that element 10 will be initialized to.</param>
776 /// <param name="e11">The value that element 11 will be initialized to.</param>
777 /// <param name="e12">The value that element 12 will be initialized to.</param>
778 /// <param name="e13">The value that element 13 will be initialized to.</param>
779 /// <param name="e14">The value that element 14 will be initialized to.</param>
780 /// <param name="e15">The value that element 15 will be initialized to.</param>
781 /// <param name="e16">The value that element 16 will be initialized to.</param>
782 /// <param name="e17">The value that element 17 will be initialized to.</param>
783 /// <param name="e18">The value that element 18 will be initialized to.</param>
784 /// <param name="e19">The value that element 19 will be initialized to.</param>
785 /// <param name="e20">The value that element 20 will be initialized to.</param>
786 /// <param name="e21">The value that element 21 will be initialized to.</param>
787 /// <param name="e22">The value that element 22 will be initialized to.</param>
788 /// <param name="e23">The value that element 23 will be initialized to.</param>
789 /// <param name="e24">The value that element 24 will be initialized to.</param>
790 /// <param name="e25">The value that element 25 will be initialized to.</param>
791 /// <param name="e26">The value that element 26 will be initialized to.</param>
792 /// <param name="e27">The value that element 27 will be initialized to.</param>
793 /// <param name="e28">The value that element 28 will be initialized to.</param>
794 /// <param name="e29">The value that element 29 will be initialized to.</param>
795 /// <param name="e30">The value that element 30 will be initialized to.</param>
796 /// <param name="e31">The value that element 31 will be initialized to.</param>
797 /// <returns>A new <see cref="Vector512{Int16}" /> with each element initialized to corresponding specified value.</returns>
798 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi16</remarks>
800 [MethodImpl(MethodImplOptions.AggressiveInlining)]
801 public static Vector512<short> Create(short e0, short e1, short e2, short e3, short e4, short e5, short e6, short e7, short e8, short e9, short e10, short e11, short e12, short e13, short e14, short e15,
802 short e16, short e17, short e18, short e19, short e20, short e21, short e22, short e23, short e24, short e25, short e26, short e27, short e28, short e29, short e30, short e31)
805 Vector256.Create(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15),
806 Vector256.Create(e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31)
810 /// <summary>Creates a new <see cref="Vector512{Int32}" /> instance with each element initialized to the corresponding specified value.</summary>
811 /// <param name="e0">The value that element 0 will be initialized to.</param>
812 /// <param name="e1">The value that element 1 will be initialized to.</param>
813 /// <param name="e2">The value that element 2 will be initialized to.</param>
814 /// <param name="e3">The value that element 3 will be initialized to.</param>
815 /// <param name="e4">The value that element 4 will be initialized to.</param>
816 /// <param name="e5">The value that element 5 will be initialized to.</param>
817 /// <param name="e6">The value that element 6 will be initialized to.</param>
818 /// <param name="e7">The value that element 7 will be initialized to.</param>
819 /// <param name="e8">The value that element 8 will be initialized to.</param>
820 /// <param name="e9">The value that element 9 will be initialized to.</param>
821 /// <param name="e10">The value that element 10 will be initialized to.</param>
822 /// <param name="e11">The value that element 11 will be initialized to.</param>
823 /// <param name="e12">The value that element 12 will be initialized to.</param>
824 /// <param name="e13">The value that element 13 will be initialized to.</param>
825 /// <param name="e14">The value that element 14 will be initialized to.</param>
826 /// <param name="e15">The value that element 15 will be initialized to.</param>
827 /// <returns>A new <see cref="Vector512{Int32}" /> with each element initialized to corresponding specified value.</returns>
828 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi32</remarks>
830 [MethodImpl(MethodImplOptions.AggressiveInlining)]
831 public static Vector512<int> Create(int e0, int e1, int e2, int e3, int e4, int e5, int e6, int e7, int e8, int e9, int e10, int e11, int e12, int e13, int e14, int e15)
834 Vector256.Create(e0, e1, e2, e3, e4, e5, e6, e7),
835 Vector256.Create(e8, e9, e10, e11, e12, e13, e14, e15)
839 /// <summary>Creates a new <see cref="Vector512{Int64}" /> instance with each element initialized to the corresponding specified value.</summary>
840 /// <param name="e0">The value that element 0 will be initialized to.</param>
841 /// <param name="e1">The value that element 1 will be initialized to.</param>
842 /// <param name="e2">The value that element 2 will be initialized to.</param>
843 /// <param name="e3">The value that element 3 will be initialized to.</param>
844 /// <param name="e4">The value that element 4 will be initialized to.</param>
845 /// <param name="e5">The value that element 5 will be initialized to.</param>
846 /// <param name="e6">The value that element 6 will be initialized to.</param>
847 /// <param name="e7">The value that element 7 will be initialized to.</param>
848 /// <returns>A new <see cref="Vector512{Int64}" /> with each element initialized to corresponding specified value.</returns>
849 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi64x</remarks>
851 [MethodImpl(MethodImplOptions.AggressiveInlining)]
852 public static Vector512<long> Create(long e0, long e1, long e2, long e3, long e4, long e5, long e6, long e7)
855 Vector256.Create(e0, e1, e2, e3),
856 Vector256.Create(e4, e5, e6, e7)
860 /// <summary>Creates a new <see cref="Vector512{SByte}" /> instance with each element initialized to the corresponding specified value.</summary>
861 /// <param name="e0">The value that element 0 will be initialized to.</param>
862 /// <param name="e1">The value that element 1 will be initialized to.</param>
863 /// <param name="e2">The value that element 2 will be initialized to.</param>
864 /// <param name="e3">The value that element 3 will be initialized to.</param>
865 /// <param name="e4">The value that element 4 will be initialized to.</param>
866 /// <param name="e5">The value that element 5 will be initialized to.</param>
867 /// <param name="e6">The value that element 6 will be initialized to.</param>
868 /// <param name="e7">The value that element 7 will be initialized to.</param>
869 /// <param name="e8">The value that element 8 will be initialized to.</param>
870 /// <param name="e9">The value that element 9 will be initialized to.</param>
871 /// <param name="e10">The value that element 10 will be initialized to.</param>
872 /// <param name="e11">The value that element 11 will be initialized to.</param>
873 /// <param name="e12">The value that element 12 will be initialized to.</param>
874 /// <param name="e13">The value that element 13 will be initialized to.</param>
875 /// <param name="e14">The value that element 14 will be initialized to.</param>
876 /// <param name="e15">The value that element 15 will be initialized to.</param>
877 /// <param name="e16">The value that element 16 will be initialized to.</param>
878 /// <param name="e17">The value that element 17 will be initialized to.</param>
879 /// <param name="e18">The value that element 18 will be initialized to.</param>
880 /// <param name="e19">The value that element 19 will be initialized to.</param>
881 /// <param name="e20">The value that element 20 will be initialized to.</param>
882 /// <param name="e21">The value that element 21 will be initialized to.</param>
883 /// <param name="e22">The value that element 22 will be initialized to.</param>
884 /// <param name="e23">The value that element 23 will be initialized to.</param>
885 /// <param name="e24">The value that element 24 will be initialized to.</param>
886 /// <param name="e25">The value that element 25 will be initialized to.</param>
887 /// <param name="e26">The value that element 26 will be initialized to.</param>
888 /// <param name="e27">The value that element 27 will be initialized to.</param>
889 /// <param name="e28">The value that element 28 will be initialized to.</param>
890 /// <param name="e29">The value that element 29 will be initialized to.</param>
891 /// <param name="e30">The value that element 30 will be initialized to.</param>
892 /// <param name="e31">The value that element 31 will be initialized to.</param>
893 /// <param name="e32">The value that element 32 will be initialized to.</param>
894 /// <param name="e33">The value that element 33 will be initialized to.</param>
895 /// <param name="e34">The value that element 34 will be initialized to.</param>
896 /// <param name="e35">The value that element 35 will be initialized to.</param>
897 /// <param name="e36">The value that element 36 will be initialized to.</param>
898 /// <param name="e37">The value that element 37 will be initialized to.</param>
899 /// <param name="e38">The value that element 38 will be initialized to.</param>
900 /// <param name="e39">The value that element 39 will be initialized to.</param>
901 /// <param name="e40">The value that element 40 will be initialized to.</param>
902 /// <param name="e41">The value that element 41 will be initialized to.</param>
903 /// <param name="e42">The value that element 42 will be initialized to.</param>
904 /// <param name="e43">The value that element 43 will be initialized to.</param>
905 /// <param name="e44">The value that element 44 will be initialized to.</param>
906 /// <param name="e45">The value that element 45 will be initialized to.</param>
907 /// <param name="e46">The value that element 46 will be initialized to.</param>
908 /// <param name="e47">The value that element 47 will be initialized to.</param>
909 /// <param name="e48">The value that element 48 will be initialized to.</param>
910 /// <param name="e49">The value that element 49 will be initialized to.</param>
911 /// <param name="e50">The value that element 50 will be initialized to.</param>
912 /// <param name="e51">The value that element 51 will be initialized to.</param>
913 /// <param name="e52">The value that element 52 will be initialized to.</param>
914 /// <param name="e53">The value that element 53 will be initialized to.</param>
915 /// <param name="e54">The value that element 54 will be initialized to.</param>
916 /// <param name="e55">The value that element 55 will be initialized to.</param>
917 /// <param name="e56">The value that element 56 will be initialized to.</param>
918 /// <param name="e57">The value that element 57 will be initialized to.</param>
919 /// <param name="e58">The value that element 58 will be initialized to.</param>
920 /// <param name="e59">The value that element 59 will be initialized to.</param>
921 /// <param name="e60">The value that element 60 will be initialized to.</param>
922 /// <param name="e61">The value that element 61 will be initialized to.</param>
923 /// <param name="e62">The value that element 62 will be initialized to.</param>
924 /// <param name="e63">The value that element 63 will be initialized to.</param>
925 /// <returns>A new <see cref="Vector512{SByte}" /> with each element initialized to corresponding specified value.</returns>
926 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi8</remarks>
928 [CLSCompliant(false)]
929 [MethodImpl(MethodImplOptions.AggressiveInlining)]
930 public static Vector512<sbyte> Create(sbyte e0, sbyte e1, sbyte e2, sbyte e3, sbyte e4, sbyte e5, sbyte e6, sbyte e7, sbyte e8, sbyte e9, sbyte e10, sbyte e11, sbyte e12, sbyte e13, sbyte e14, sbyte e15,
931 sbyte e16, sbyte e17, sbyte e18, sbyte e19, sbyte e20, sbyte e21, sbyte e22, sbyte e23, sbyte e24, sbyte e25, sbyte e26, sbyte e27, sbyte e28, sbyte e29, sbyte e30, sbyte e31,
932 sbyte e32, sbyte e33, sbyte e34, sbyte e35, sbyte e36, sbyte e37, sbyte e38, sbyte e39, sbyte e40, sbyte e41, sbyte e42, sbyte e43, sbyte e44, sbyte e45, sbyte e46, sbyte e47,
933 sbyte e48, sbyte e49, sbyte e50, sbyte e51, sbyte e52, sbyte e53, sbyte e54, sbyte e55, sbyte e56, sbyte e57, sbyte e58, sbyte e59, sbyte e60, sbyte e61, sbyte e62, sbyte e63)
936 Vector256.Create(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31),
937 Vector256.Create(e32, e33, e34, e35, e36, e37, e38, e39, e40, e41, e42, e43, e44, e45, e46, e47, e48, e49, e50, e51, e52, e53, e54, e55, e56, e57, e58, e59, e60, e61, e62, e63)
941 /// <summary>Creates a new <see cref="Vector512{Single}" /> instance with each element initialized to the corresponding specified value.</summary>
942 /// <param name="e0">The value that element 0 will be initialized to.</param>
943 /// <param name="e1">The value that element 1 will be initialized to.</param>
944 /// <param name="e2">The value that element 2 will be initialized to.</param>
945 /// <param name="e3">The value that element 3 will be initialized to.</param>
946 /// <param name="e4">The value that element 4 will be initialized to.</param>
947 /// <param name="e5">The value that element 5 will be initialized to.</param>
948 /// <param name="e6">The value that element 6 will be initialized to.</param>
949 /// <param name="e7">The value that element 7 will be initialized to.</param>
950 /// <param name="e8">The value that element 8 will be initialized to.</param>
951 /// <param name="e9">The value that element 9 will be initialized to.</param>
952 /// <param name="e10">The value that element 10 will be initialized to.</param>
953 /// <param name="e11">The value that element 11 will be initialized to.</param>
954 /// <param name="e12">The value that element 12 will be initialized to.</param>
955 /// <param name="e13">The value that element 13 will be initialized to.</param>
956 /// <param name="e14">The value that element 14 will be initialized to.</param>
957 /// <param name="e15">The value that element 15 will be initialized to.</param>
958 /// <returns>A new <see cref="Vector512{Single}" /> with each element initialized to corresponding specified value.</returns>
959 /// <remarks>On x86, this method corresponds to __m512 _mm512_setr_ps</remarks>
961 [MethodImpl(MethodImplOptions.AggressiveInlining)]
962 public static Vector512<float> Create(float e0, float e1, float e2, float e3, float e4, float e5, float e6, float e7, float e8, float e9, float e10, float e11, float e12, float e13, float e14, float e15)
965 Vector256.Create(e0, e1, e2, e3, e4, e5, e6, e7),
966 Vector256.Create(e8, e9, e10, e11, e12, e13, e14, e15)
970 /// <summary>Creates a new <see cref="Vector512{UInt16}" /> instance with each element initialized to the corresponding specified value.</summary>
971 /// <param name="e0">The value that element 0 will be initialized to.</param>
972 /// <param name="e1">The value that element 1 will be initialized to.</param>
973 /// <param name="e2">The value that element 2 will be initialized to.</param>
974 /// <param name="e3">The value that element 3 will be initialized to.</param>
975 /// <param name="e4">The value that element 4 will be initialized to.</param>
976 /// <param name="e5">The value that element 5 will be initialized to.</param>
977 /// <param name="e6">The value that element 6 will be initialized to.</param>
978 /// <param name="e7">The value that element 7 will be initialized to.</param>
979 /// <param name="e8">The value that element 8 will be initialized to.</param>
980 /// <param name="e9">The value that element 9 will be initialized to.</param>
981 /// <param name="e10">The value that element 10 will be initialized to.</param>
982 /// <param name="e11">The value that element 11 will be initialized to.</param>
983 /// <param name="e12">The value that element 12 will be initialized to.</param>
984 /// <param name="e13">The value that element 13 will be initialized to.</param>
985 /// <param name="e14">The value that element 14 will be initialized to.</param>
986 /// <param name="e15">The value that element 15 will be initialized to.</param>
987 /// <param name="e16">The value that element 16 will be initialized to.</param>
988 /// <param name="e17">The value that element 17 will be initialized to.</param>
989 /// <param name="e18">The value that element 18 will be initialized to.</param>
990 /// <param name="e19">The value that element 19 will be initialized to.</param>
991 /// <param name="e20">The value that element 20 will be initialized to.</param>
992 /// <param name="e21">The value that element 21 will be initialized to.</param>
993 /// <param name="e22">The value that element 22 will be initialized to.</param>
994 /// <param name="e23">The value that element 23 will be initialized to.</param>
995 /// <param name="e24">The value that element 24 will be initialized to.</param>
996 /// <param name="e25">The value that element 25 will be initialized to.</param>
997 /// <param name="e26">The value that element 26 will be initialized to.</param>
998 /// <param name="e27">The value that element 27 will be initialized to.</param>
999 /// <param name="e28">The value that element 28 will be initialized to.</param>
1000 /// <param name="e29">The value that element 29 will be initialized to.</param>
1001 /// <param name="e30">The value that element 30 will be initialized to.</param>
1002 /// <param name="e31">The value that element 31 will be initialized to.</param>
1003 /// <returns>A new <see cref="Vector512{UInt16}" /> with each element initialized to corresponding specified value.</returns>
1004 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi16</remarks>
1006 [CLSCompliant(false)]
1007 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1008 public static Vector512<ushort> Create(ushort e0, ushort e1, ushort e2, ushort e3, ushort e4, ushort e5, ushort e6, ushort e7, ushort e8, ushort e9, ushort e10, ushort e11, ushort e12, ushort e13, ushort e14, ushort e15,
1009 ushort e16, ushort e17, ushort e18, ushort e19, ushort e20, ushort e21, ushort e22, ushort e23, ushort e24, ushort e25, ushort e26, ushort e27, ushort e28, ushort e29, ushort e30, ushort e31)
1012 Vector256.Create(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15),
1013 Vector256.Create(e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31)
1017 /// <summary>Creates a new <see cref="Vector512{UInt32}" /> instance with each element initialized to the corresponding specified value.</summary>
1018 /// <param name="e0">The value that element 0 will be initialized to.</param>
1019 /// <param name="e1">The value that element 1 will be initialized to.</param>
1020 /// <param name="e2">The value that element 2 will be initialized to.</param>
1021 /// <param name="e3">The value that element 3 will be initialized to.</param>
1022 /// <param name="e4">The value that element 4 will be initialized to.</param>
1023 /// <param name="e5">The value that element 5 will be initialized to.</param>
1024 /// <param name="e6">The value that element 6 will be initialized to.</param>
1025 /// <param name="e7">The value that element 7 will be initialized to.</param>
1026 /// <param name="e8">The value that element 8 will be initialized to.</param>
1027 /// <param name="e9">The value that element 9 will be initialized to.</param>
1028 /// <param name="e10">The value that element 10 will be initialized to.</param>
1029 /// <param name="e11">The value that element 11 will be initialized to.</param>
1030 /// <param name="e12">The value that element 12 will be initialized to.</param>
1031 /// <param name="e13">The value that element 13 will be initialized to.</param>
1032 /// <param name="e14">The value that element 14 will be initialized to.</param>
1033 /// <param name="e15">The value that element 15 will be initialized to.</param>
1034 /// <returns>A new <see cref="Vector512{UInt32}" /> with each element initialized to corresponding specified value.</returns>
1035 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi32</remarks>
1037 [CLSCompliant(false)]
1038 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1039 public static Vector512<uint> Create(uint e0, uint e1, uint e2, uint e3, uint e4, uint e5, uint e6, uint e7, uint e8, uint e9, uint e10, uint e11, uint e12, uint e13, uint e14, uint e15)
1042 Vector256.Create(e0, e1, e2, e3, e4, e5, e6, e7),
1043 Vector256.Create(e8, e9, e10, e11, e12, e13, e14, e15)
1047 /// <summary>Creates a new <see cref="Vector512{UInt64}" /> instance with each element initialized to the corresponding specified value.</summary>
1048 /// <param name="e0">The value that element 0 will be initialized to.</param>
1049 /// <param name="e1">The value that element 1 will be initialized to.</param>
1050 /// <param name="e2">The value that element 2 will be initialized to.</param>
1051 /// <param name="e3">The value that element 3 will be initialized to.</param>
1052 /// <param name="e4">The value that element 4 will be initialized to.</param>
1053 /// <param name="e5">The value that element 5 will be initialized to.</param>
1054 /// <param name="e6">The value that element 6 will be initialized to.</param>
1055 /// <param name="e7">The value that element 7 will be initialized to.</param>
1056 /// <returns>A new <see cref="Vector512{UInt64}" /> with each element initialized to corresponding specified value.</returns>
1057 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi64x</remarks>
1059 [CLSCompliant(false)]
1060 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1061 public static Vector512<ulong> Create(ulong e0, ulong e1, ulong e2, ulong e3, ulong e4, ulong e5, ulong e6, ulong e7)
1064 Vector256.Create(e0, e1, e2, e3),
1065 Vector256.Create(e4, e5, e6, e7)
1069 /// <summary>Creates a new <see cref="Vector512{T}" /> instance from two <see cref="Vector256{T}" /> instances.</summary>
1070 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1071 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1072 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1073 /// <returns>A new <see cref="Vector512{T}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1074 /// <exception cref="NotSupportedException">The type of <paramref name="lower" /> and <paramref name="upper" /> (<typeparamref name="T" />) is not supported.</exception>
1075 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1076 public static Vector512<T> Create<T>(Vector256<T> lower, Vector256<T> upper)
1078 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
1079 Unsafe.SkipInit(out Vector512<T> result);
1081 result.SetLowerUnsafe(lower);
1082 result.SetUpperUnsafe(upper);
1087 /// <summary>Creates a new <see cref="Vector512{Byte}" /> instance from two <see cref="Vector256{Byte}" /> instances.</summary>
1088 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1089 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1090 /// <returns>A new <see cref="Vector512{Byte}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1091 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1092 public static Vector512<byte> Create(Vector256<byte> lower, Vector256<byte> upper) => Create<byte>(lower, upper);
1094 /// <summary>Creates a new <see cref="Vector512{Double}" /> instance from two <see cref="Vector256{Double}" /> instances.</summary>
1095 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1096 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1097 /// <returns>A new <see cref="Vector512{Double}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1098 /// <remarks>On x86, this method corresponds to __m512d _mm512_setr_m256d (__m256d lo, __m256d hi)</remarks>
1099 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1100 public static Vector512<double> Create(Vector256<double> lower, Vector256<double> upper) => Create<double>(lower, upper);
1102 /// <summary>Creates a new <see cref="Vector512{Int16}" /> instance from two <see cref="Vector256{Int16}" /> instances.</summary>
1103 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1104 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1105 /// <returns>A new <see cref="Vector512{Int16}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1106 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1107 public static Vector512<short> Create(Vector256<short> lower, Vector256<short> upper) => Create<short>(lower, upper);
1109 /// <summary>Creates a new <see cref="Vector512{Int32}" /> instance from two <see cref="Vector256{Int32}" /> instances.</summary>
1110 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1111 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1112 /// <returns>A new <see cref="Vector512{Int32}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1113 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_m256i (__m256i lo, __m256i hi)</remarks>
1114 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1115 public static Vector512<int> Create(Vector256<int> lower, Vector256<int> upper) => Create<int>(lower, upper);
1117 /// <summary>Creates a new <see cref="Vector512{Int64}" /> instance from two <see cref="Vector256{Int64}" /> instances.</summary>
1118 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1119 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1120 /// <returns>A new <see cref="Vector512{Int64}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1121 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1122 public static Vector512<long> Create(Vector256<long> lower, Vector256<long> upper) => Create<long>(lower, upper);
1124 /// <summary>Creates a new <see cref="Vector512{IntPtr}" /> instance from two <see cref="Vector256{IntPtr}" /> instances.</summary>
1125 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1126 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1127 /// <returns>A new <see cref="Vector512{IntPtr}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1128 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1129 public static Vector512<nint> Create(Vector256<nint> lower, Vector256<nint> upper) => Create<nint>(lower, upper);
1131 /// <summary>Creates a new <see cref="Vector512{UIntPtr}" /> instance from two <see cref="Vector256{UIntPtr}" /> instances.</summary>
1132 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1133 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1134 /// <returns>A new <see cref="Vector512{UIntPtr}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1135 [CLSCompliant(false)]
1136 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1137 public static Vector512<nuint> Create(Vector256<nuint> lower, Vector256<nuint> upper) => Create<nuint>(lower, upper);
1139 /// <summary>Creates a new <see cref="Vector512{SByte}" /> instance from two <see cref="Vector256{SByte}" /> instances.</summary>
1140 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1141 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1142 /// <returns>A new <see cref="Vector512{SByte}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1143 [CLSCompliant(false)]
1144 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1145 public static Vector512<sbyte> Create(Vector256<sbyte> lower, Vector256<sbyte> upper) => Create<sbyte>(lower, upper);
1147 /// <summary>Creates a new <see cref="Vector512{Single}" /> instance from two <see cref="Vector256{Single}" /> instances.</summary>
1148 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1149 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1150 /// <returns>A new <see cref="Vector512{Single}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1151 /// <remarks>On x86, this method corresponds to __m512 _mm512_setr_m256 (__m256 lo, __m256 hi)</remarks>
1152 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1153 public static Vector512<float> Create(Vector256<float> lower, Vector256<float> upper) => Create<float>(lower, upper);
1155 /// <summary>Creates a new <see cref="Vector512{UInt16}" /> instance from two <see cref="Vector256{UInt16}" /> instances.</summary>
1156 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1157 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1158 /// <returns>A new <see cref="Vector512{UInt16}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1159 [CLSCompliant(false)]
1160 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1161 public static Vector512<ushort> Create(Vector256<ushort> lower, Vector256<ushort> upper) => Create<ushort>(lower, upper);
1163 /// <summary>Creates a new <see cref="Vector512{UInt32}" /> instance from two <see cref="Vector256{UInt32}" /> instances.</summary>
1164 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1165 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1166 /// <returns>A new <see cref="Vector512{UInt32}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1167 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_m256i (__m256i lo, __m256i hi)</remarks>
1168 [CLSCompliant(false)]
1169 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1170 public static Vector512<uint> Create(Vector256<uint> lower, Vector256<uint> upper) => Create<uint>(lower, upper);
1172 /// <summary>Creates a new <see cref="Vector512{UInt64}" /> instance from two <see cref="Vector256{UInt64}" /> instances.</summary>
1173 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1174 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1175 /// <returns>A new <see cref="Vector512{UInt64}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1176 [CLSCompliant(false)]
1177 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1178 public static Vector512<ulong> Create(Vector256<ulong> lower, Vector256<ulong> upper) => Create<ulong>(lower, upper);
1180 /// <summary>Creates a new <see cref="Vector512{T}" /> instance with the first element initialized to the specified value and the remaining elements initialized to zero.</summary>
1181 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1182 /// <param name="value">The value that element 0 will be initialized to.</param>
1183 /// <returns>A new <see cref="Vector512{T}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements initialized to zero.</returns>
1184 /// <exception cref="NotSupportedException">The type of <paramref name="value" /> (<typeparamref name="T" />) is not supported.</exception>
1185 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1186 public static Vector512<T> CreateScalar<T>(T value) => Vector256.CreateScalar(value).ToVector512();
1188 /// <summary>Creates a new <see cref="Vector512{Byte}" /> instance with the first element initialized to the specified value and the remaining elements initialized to zero.</summary>
1189 /// <param name="value">The value that element 0 will be initialized to.</param>
1190 /// <returns>A new <see cref="Vector512{Byte}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements initialized to zero.</returns>
1191 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1192 public static Vector512<byte> CreateScalar(byte value) => CreateScalar<byte>(value);
1194 /// <summary>Creates a new <see cref="Vector512{Double}" /> instance with the first element initialized to the specified value and the remaining elements initialized to zero.</summary>
1195 /// <param name="value">The value that element 0 will be initialized to.</param>
1196 /// <returns>A new <see cref="Vector512{Double}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements initialized to zero.</returns>
1197 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1198 public static Vector512<double> CreateScalar(double value) => CreateScalar<double>(value);
1200 /// <summary>Creates a new <see cref="Vector512{Int16}" /> instance with the first element initialized to the specified value and the remaining elements initialized to zero.</summary>
1201 /// <param name="value">The value that element 0 will be initialized to.</param>
1202 /// <returns>A new <see cref="Vector512{Int16}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements initialized to zero.</returns>
1203 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1204 public static Vector512<short> CreateScalar(short value) => CreateScalar<short>(value);
1206 /// <summary>Creates a new <see cref="Vector512{Int32}" /> instance with the first element initialized to the specified value and the remaining elements initialized to zero.</summary>
1207 /// <param name="value">The value that element 0 will be initialized to.</param>
1208 /// <returns>A new <see cref="Vector512{Int32}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements initialized to zero.</returns>
1209 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1210 public static Vector512<int> CreateScalar(int value) => CreateScalar<int>(value);
1212 /// <summary>Creates a new <see cref="Vector512{Int64}" /> instance with the first element initialized to the specified value and the remaining elements initialized to zero.</summary>
1213 /// <param name="value">The value that element 0 will be initialized to.</param>
1214 /// <returns>A new <see cref="Vector512{Int64}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements initialized to zero.</returns>
1215 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1216 public static Vector512<long> CreateScalar(long value) => CreateScalar<long>(value);
1218 /// <summary>Creates a new <see cref="Vector512{IntPtr}" /> instance with the first element initialized to the specified value and the remaining elements initialized to zero.</summary>
1219 /// <param name="value">The value that element 0 will be initialized to.</param>
1220 /// <returns>A new <see cref="Vector512{IntPtr}" /> instance with the first element initialized to <paramref name="value"/> and the remaining elements initialized to zero.</returns>
1221 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1222 public static Vector512<nint> CreateScalar(nint value) => CreateScalar<nint>(value);
1224 /// <summary>Creates a new <see cref="Vector512{UIntPtr}" /> instance with the first element initialized to the specified value and the remaining elements initialized to zero.</summary>
1225 /// <param name="value">The value that element 0 will be initialized to.</param>
1226 /// <returns>A new <see cref="Vector512{UIntPtr}" /> instance with the first element initialized to <paramref name="value"/> and the remaining elements initialized to zero.</returns>
1227 [CLSCompliant(false)]
1228 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1229 public static Vector512<nuint> CreateScalar(nuint value) => CreateScalar<nuint>(value);
1231 /// <summary>Creates a new <see cref="Vector512{SByte}" /> instance with the first element initialized to the specified value and the remaining elements initialized to zero.</summary>
1232 /// <param name="value">The value that element 0 will be initialized to.</param>
1233 /// <returns>A new <see cref="Vector512{SByte}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements initialized to zero.</returns>
1234 [CLSCompliant(false)]
1235 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1236 public static Vector512<sbyte> CreateScalar(sbyte value) => CreateScalar<sbyte>(value);
1238 /// <summary>Creates a new <see cref="Vector512{Single}" /> instance with the first element initialized to the specified value and the remaining elements initialized to zero.</summary>
1239 /// <param name="value">The value that element 0 will be initialized to.</param>
1240 /// <returns>A new <see cref="Vector512{Single}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements initialized to zero.</returns>
1241 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1242 public static Vector512<float> CreateScalar(float value) => CreateScalar<float>(value);
1244 /// <summary>Creates a new <see cref="Vector512{UInt16}" /> instance with the first element initialized to the specified value and the remaining elements initialized to zero.</summary>
1245 /// <param name="value">The value that element 0 will be initialized to.</param>
1246 /// <returns>A new <see cref="Vector512{UInt16}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements initialized to zero.</returns>
1247 [CLSCompliant(false)]
1248 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1249 public static Vector512<ushort> CreateScalar(ushort value) => CreateScalar<ushort>(value);
1251 /// <summary>Creates a new <see cref="Vector512{UInt32}" /> instance with the first element initialized to the specified value and the remaining elements initialized to zero.</summary>
1252 /// <param name="value">The value that element 0 will be initialized to.</param>
1253 /// <returns>A new <see cref="Vector512{UInt32}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements initialized to zero.</returns>
1254 [CLSCompliant(false)]
1255 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1256 public static Vector512<uint> CreateScalar(uint value) => CreateScalar<uint>(value);
1258 /// <summary>Creates a new <see cref="Vector512{UInt64}" /> instance with the first element initialized to the specified value and the remaining elements initialized to zero.</summary>
1259 /// <param name="value">The value that element 0 will be initialized to.</param>
1260 /// <returns>A new <see cref="Vector512{UInt64}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements initialized to zero.</returns>
1261 [CLSCompliant(false)]
1262 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1263 public static Vector512<ulong> CreateScalar(ulong value) => CreateScalar<ulong>(value);
1265 /// <summary>Creates a new <see cref="Vector512{T}" /> instance with the first element initialized to the specified value and the remaining elements left uninitialized.</summary>
1266 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1267 /// <param name="value">The value that element 0 will be initialized to.</param>
1268 /// <returns>A new <see cref="Vector512{T}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1269 /// <exception cref="NotSupportedException">The type of <paramref name="value" /> (<typeparamref name="T" />) is not supported.</exception>
1271 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1272 public static Vector512<T> CreateScalarUnsafe<T>(T value)
1274 // This relies on us stripping the "init" flag from the ".locals"
1275 // declaration to let the upper bits be uninitialized.
1277 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
1278 Unsafe.SkipInit(out Vector512<T> result);
1280 result.SetElementUnsafe(0, value);
1284 /// <summary>Creates a new <see cref="Vector512{Byte}" /> instance with the first element initialized to the specified value and the remaining elements left uninitialized.</summary>
1285 /// <param name="value">The value that element 0 will be initialized to.</param>
1286 /// <returns>A new <see cref="Vector512{Byte}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1288 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1289 public static Vector512<byte> CreateScalarUnsafe(byte value) => CreateScalarUnsafe<byte>(value);
1291 /// <summary>Creates a new <see cref="Vector512{Double}" /> instance with the first element initialized to the specified value and the remaining elements left uninitialized.</summary>
1292 /// <param name="value">The value that element 0 will be initialized to.</param>
1293 /// <returns>A new <see cref="Vector512{Double}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1295 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1296 public static Vector512<double> CreateScalarUnsafe(double value) => CreateScalarUnsafe<double>(value);
1298 /// <summary>Creates a new <see cref="Vector512{Int16}" /> instance with the first element initialized to the specified value and the remaining elements left uninitialized.</summary>
1299 /// <param name="value">The value that element 0 will be initialized to.</param>
1300 /// <returns>A new <see cref="Vector512{Int16}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1302 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1303 public static Vector512<short> CreateScalarUnsafe(short value) => CreateScalarUnsafe<short>(value);
1305 /// <summary>Creates a new <see cref="Vector512{Int32}" /> instance with the first element initialized to the specified value and the remaining elements left uninitialized.</summary>
1306 /// <param name="value">The value that element 0 will be initialized to.</param>
1307 /// <returns>A new <see cref="Vector512{Int32}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1309 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1310 public static Vector512<int> CreateScalarUnsafe(int value) => CreateScalarUnsafe<int>(value);
1312 /// <summary>Creates a new <see cref="Vector512{Int64}" /> instance with the first element initialized to the specified value and the remaining elements left uninitialized.</summary>
1313 /// <param name="value">The value that element 0 will be initialized to.</param>
1314 /// <returns>A new <see cref="Vector512{Int64}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1316 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1317 public static Vector512<long> CreateScalarUnsafe(long value) => CreateScalarUnsafe<long>(value);
1319 /// <summary>Creates a new <see cref="Vector512{IntPtr}" /> instance with the first element initialized to the specified value and the remaining elements left uninitialized.</summary>
1320 /// <param name="value">The value that element 0 will be initialized to.</param>
1321 /// <returns>A new <see cref="Vector512{IntPtr}" /> instance with the first element initialized to <paramref name="value"/> and the remaining elements left uninitialized.</returns>
1323 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1324 public static Vector512<nint> CreateScalarUnsafe(nint value) => CreateScalarUnsafe<nint>(value);
1326 /// <summary>Creates a new <see cref="Vector512{UIntPtr}" /> instance with the first element initialized to the specified value and the remaining elements left uninitialized.</summary>
1327 /// <param name="value">The value that element 0 will be initialized to.</param>
1328 /// <returns>A new <see cref="Vector512{UIntPtr}" /> instance with the first element initialized to <paramref name="value"/> and the remaining elements left uninitialized.</returns>
1330 [CLSCompliant(false)]
1331 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1332 public static Vector512<nuint> CreateScalarUnsafe(nuint value) => CreateScalarUnsafe<nuint>(value);
1334 /// <summary>Creates a new <see cref="Vector512{SByte}" /> instance with the first element initialized to the specified value and the remaining elements left uninitialized.</summary>
1335 /// <param name="value">The value that element 0 will be initialized to.</param>
1336 /// <returns>A new <see cref="Vector512{SByte}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1338 [CLSCompliant(false)]
1339 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1340 public static Vector512<sbyte> CreateScalarUnsafe(sbyte value) => CreateScalarUnsafe<sbyte>(value);
1342 /// <summary>Creates a new <see cref="Vector512{Single}" /> instance with the first element initialized to the specified value and the remaining elements left uninitialized.</summary>
1343 /// <param name="value">The value that element 0 will be initialized to.</param>
1344 /// <returns>A new <see cref="Vector512{Single}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1346 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1347 public static Vector512<float> CreateScalarUnsafe(float value) => CreateScalarUnsafe<float>(value);
1349 /// <summary>Creates a new <see cref="Vector512{UInt16}" /> instance with the first element initialized to the specified value and the remaining elements left uninitialized.</summary>
1350 /// <param name="value">The value that element 0 will be initialized to.</param>
1351 /// <returns>A new <see cref="Vector512{UInt16}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1353 [CLSCompliant(false)]
1354 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1355 public static Vector512<ushort> CreateScalarUnsafe(ushort value) => CreateScalarUnsafe<ushort>(value);
1357 /// <summary>Creates a new <see cref="Vector512{UInt32}" /> instance with the first element initialized to the specified value and the remaining elements left uninitialized.</summary>
1358 /// <param name="value">The value that element 0 will be initialized to.</param>
1359 /// <returns>A new <see cref="Vector512{UInt32}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1361 [CLSCompliant(false)]
1362 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1363 public static Vector512<uint> CreateScalarUnsafe(uint value) => CreateScalarUnsafe<uint>(value);
1365 /// <summary>Creates a new <see cref="Vector512{UInt64}" /> instance with the first element initialized to the specified value and the remaining elements left uninitialized.</summary>
1366 /// <param name="value">The value that element 0 will be initialized to.</param>
1367 /// <returns>A new <see cref="Vector512{UInt64}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1369 [CLSCompliant(false)]
1370 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1371 public static Vector512<ulong> CreateScalarUnsafe(ulong value) => CreateScalarUnsafe<ulong>(value);
1373 /// <summary>Divides two vectors to compute their quotient.</summary>
1374 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1375 /// <param name="left">The vector that will be divided by <paramref name="right" />.</param>
1376 /// <param name="right">The vector that will divide <paramref name="left" />.</param>
1377 /// <returns>The quotient of <paramref name="left" /> divided by <paramref name="right" />.</returns>
1378 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1380 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1381 public static Vector512<T> Divide<T>(Vector512<T> left, Vector512<T> right)
1384 Vector256.Divide(left._lower, right._lower),
1385 Vector256.Divide(left._upper, right._upper)
1389 /// <summary>Divides a vector by a scalar to compute the per-element quotient.</summary>
1390 /// <param name="left">The vector that will be divided by <paramref name="right" />.</param>
1391 /// <param name="right">The scalar that will divide <paramref name="left" />.</param>
1392 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1393 /// <returns>The quotient of <paramref name="left" /> divided by <paramref name="right" />.</returns>
1395 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1396 public static Vector512<T> Divide<T>(Vector512<T> left, T right) => left / right;
1398 /// <summary>Computes the dot product of two vectors.</summary>
1399 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1400 /// <param name="left">The vector that will be dotted with <paramref name="right" />.</param>
1401 /// <param name="right">The vector that will be dotted with <paramref name="left" />.</param>
1402 /// <returns>The dot product of <paramref name="left" /> and <paramref name="right" />.</returns>
1403 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1405 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1406 public static T Dot<T>(Vector512<T> left, Vector512<T> right)
1408 // Doing this as Dot(lower) + Dot(upper) is important for floating-point determinism
1409 // This is because the underlying dpps instruction on x86/x64 will do this equivalently
1410 // and otherwise the software vs accelerated implementations may differ in returned result.
1412 T result = Vector256.Dot(left._lower, right._lower);
1413 result = Scalar<T>.Add(result, Vector256.Dot(left._upper, right._upper));
1417 /// <summary>Compares two vectors to determine if they are equal on a per-element basis.</summary>
1418 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1419 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1420 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1421 /// <returns>A vector whose elements are all-bits-set or zero, depending on if the corresponding elements in <paramref name="left" /> and <paramref name="right" /> were equal.</returns>
1422 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1424 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1425 public static Vector512<T> Equals<T>(Vector512<T> left, Vector512<T> right)
1428 Vector256.Equals(left._lower, right._lower),
1429 Vector256.Equals(left._upper, right._upper)
1433 /// <summary>Compares two vectors to determine if all elements are equal.</summary>
1434 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1435 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1436 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1437 /// <returns><c>true</c> if all elements in <paramref name="left" /> were equal to the corresponding element in <paramref name="right" />.</returns>
1438 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1440 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1441 public static bool EqualsAll<T>(Vector512<T> left, Vector512<T> right) => left == right;
1443 /// <summary>Compares two vectors to determine if any elements are equal.</summary>
1444 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1445 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1446 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1447 /// <returns><c>true</c> if any elements in <paramref name="left" /> was equal to the corresponding element in <paramref name="right" />.</returns>
1448 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1450 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1451 public static bool EqualsAny<T>(Vector512<T> left, Vector512<T> right)
1453 return Vector256.EqualsAny(left._lower, right._lower)
1454 || Vector256.EqualsAny(left._upper, right._upper);
1457 /// <summary>Extracts the most significant bit from each element in a vector.</summary>
1458 /// <param name="vector">The vector whose elements should have their most significant bit extracted.</param>
1459 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1460 /// <returns>The packed most significant bits extracted from the elements in <paramref name="vector" />.</returns>
1461 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
1463 [CLSCompliant(false)]
1464 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1465 public static ulong ExtractMostSignificantBits<T>(this Vector512<T> vector)
1467 ulong result = vector._lower.ExtractMostSignificantBits();
1468 result |= (ulong)(vector._upper.ExtractMostSignificantBits()) << Vector256<T>.Count;
1472 /// <summary>Computes the floor of each element in a vector.</summary>
1473 /// <param name="vector">The vector that will have its floor computed.</param>
1474 /// <returns>A vector whose elements are the floor of the elements in <paramref name="vector" />.</returns>
1475 /// <seealso cref="MathF.Floor(float)" />
1477 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1478 public static Vector512<float> Floor(Vector512<float> vector)
1481 Vector256.Floor(vector._lower),
1482 Vector256.Floor(vector._upper)
1486 /// <summary>Computes the floor of each element in a vector.</summary>
1487 /// <param name="vector">The vector that will have its floor computed.</param>
1488 /// <returns>A vector whose elements are the floor of the elements in <paramref name="vector" />.</returns>
1489 /// <seealso cref="Math.Floor(double)" />
1491 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1492 public static Vector512<double> Floor(Vector512<double> vector)
1495 Vector256.Floor(vector._lower),
1496 Vector256.Floor(vector._upper)
1500 /// <summary>Gets the element at the specified index.</summary>
1501 /// <typeparam name="T">The type of the input vector.</typeparam>
1502 /// <param name="vector">The vector to get the element from.</param>
1503 /// <param name="index">The index of the element to get.</param>
1504 /// <returns>The value of the element at <paramref name="index" />.</returns>
1505 /// <exception cref="ArgumentOutOfRangeException"><paramref name="index" /> was less than zero or greater than the number of elements.</exception>
1506 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
1508 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1509 public static T GetElement<T>(this Vector512<T> vector, int index)
1511 if ((uint)(index) >= (uint)(Vector512<T>.Count))
1513 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index);
1516 return vector.GetElementUnsafe(index);
1519 /// <summary>Gets the value of the lower 256-bits as a new <see cref="Vector256{T}" />.</summary>
1520 /// <typeparam name="T">The type of the input vector.</typeparam>
1521 /// <param name="vector">The vector to get the lower 256-bits from.</param>
1522 /// <returns>The value of the lower 256-bits as a new <see cref="Vector256{T}" />.</returns>
1523 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
1525 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1526 public static Vector256<T> GetLower<T>(this Vector512<T> vector)
1528 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
1529 return vector._lower;
1532 /// <summary>Gets the value of the upper 256-bits as a new <see cref="Vector256{T}" />.</summary>
1533 /// <typeparam name="T">The type of the input vector.</typeparam>
1534 /// <param name="vector">The vector to get the upper 256-bits from.</param>
1535 /// <returns>The value of the upper 256-bits as a new <see cref="Vector256{T}" />.</returns>
1536 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
1538 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1539 public static Vector256<T> GetUpper<T>(this Vector512<T> vector)
1541 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
1542 return vector._upper;
1545 /// <summary>Compares two vectors to determine which is greater on a per-element basis.</summary>
1546 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1547 /// <param name="left">The vector to compare with <paramref name="left" />.</param>
1548 /// <param name="right">The vector to compare with <paramref name="right" />.</param>
1549 /// <returns>A vector whose elements are all-bits-set or zero, depending on if which of the corresponding elements in <paramref name="left" /> and <paramref name="right" /> were greater.</returns>
1550 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1552 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1553 public static Vector512<T> GreaterThan<T>(Vector512<T> left, Vector512<T> right)
1556 Vector256.GreaterThan(left._lower, right._lower),
1557 Vector256.GreaterThan(left._upper, right._upper)
1561 /// <summary>Compares two vectors to determine if all elements are greater.</summary>
1562 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1563 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1564 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1565 /// <returns><c>true</c> if all elements in <paramref name="left" /> were greater than the corresponding element in <paramref name="right" />.</returns>
1566 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1568 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1569 public static bool GreaterThanAll<T>(Vector512<T> left, Vector512<T> right)
1571 return Vector256.GreaterThanAll(left._lower, right._lower)
1572 && Vector256.GreaterThanAll(left._upper, right._upper);
1575 /// <summary>Compares two vectors to determine if any elements are greater.</summary>
1576 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1577 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1578 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1579 /// <returns><c>true</c> if any elements in <paramref name="left" /> was greater than the corresponding element in <paramref name="right" />.</returns>
1580 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1582 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1583 public static bool GreaterThanAny<T>(Vector512<T> left, Vector512<T> right)
1585 return Vector256.GreaterThanAny(left._lower, right._lower)
1586 || Vector256.GreaterThanAny(left._upper, right._upper);
1589 /// <summary>Compares two vectors to determine which is greater or equal on a per-element basis.</summary>
1590 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1591 /// <param name="left">The vector to compare with <paramref name="left" />.</param>
1592 /// <param name="right">The vector to compare with <paramref name="right" />.</param>
1593 /// <returns>A vector whose elements are all-bits-set or zero, depending on if which of the corresponding elements in <paramref name="left" /> and <paramref name="right" /> were greater or equal.</returns>
1594 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1596 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1597 public static Vector512<T> GreaterThanOrEqual<T>(Vector512<T> left, Vector512<T> right)
1600 Vector256.GreaterThanOrEqual(left._lower, right._lower),
1601 Vector256.GreaterThanOrEqual(left._upper, right._upper)
1605 /// <summary>Compares two vectors to determine if all elements are greater or equal.</summary>
1606 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1607 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1608 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1609 /// <returns><c>true</c> if all elements in <paramref name="left" /> were greater than or equal to the corresponding element in <paramref name="right" />.</returns>
1610 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1612 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1613 public static bool GreaterThanOrEqualAll<T>(Vector512<T> left, Vector512<T> right)
1615 return Vector256.GreaterThanOrEqualAll(left._lower, right._lower)
1616 && Vector256.GreaterThanOrEqualAll(left._upper, right._upper);
1619 /// <summary>Compares two vectors to determine if any elements are greater or equal.</summary>
1620 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1621 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1622 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1623 /// <returns><c>true</c> if any elements in <paramref name="left" /> was greater than or equal to the corresponding element in <paramref name="right" />.</returns>
1624 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1626 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1627 public static bool GreaterThanOrEqualAny<T>(Vector512<T> left, Vector512<T> right)
1629 return Vector256.GreaterThanOrEqualAny(left._lower, right._lower)
1630 || Vector256.GreaterThanOrEqualAny(left._upper, right._upper);
1633 /// <summary>Compares two vectors to determine which is less on a per-element basis.</summary>
1634 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1635 /// <param name="left">The vector to compare with <paramref name="left" />.</param>
1636 /// <param name="right">The vector to compare with <paramref name="right" />.</param>
1637 /// <returns>A vector whose elements are all-bits-set or zero, depending on if which of the corresponding elements in <paramref name="left" /> and <paramref name="right" /> were less.</returns>
1638 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1640 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1641 public static Vector512<T> LessThan<T>(Vector512<T> left, Vector512<T> right)
1644 Vector256.LessThan(left._lower, right._lower),
1645 Vector256.LessThan(left._upper, right._upper)
1649 /// <summary>Compares two vectors to determine if all elements are less.</summary>
1650 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1651 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1652 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1653 /// <returns><c>true</c> if all elements in <paramref name="left" /> were less than the corresponding element in <paramref name="right" />.</returns>
1654 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1656 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1657 public static bool LessThanAll<T>(Vector512<T> left, Vector512<T> right)
1659 return Vector256.LessThanAll(left._lower, right._lower)
1660 && Vector256.LessThanAll(left._upper, right._upper);
1663 /// <summary>Compares two vectors to determine if any elements are less.</summary>
1664 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1665 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1666 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1667 /// <returns><c>true</c> if any elements in <paramref name="left" /> was less than the corresponding element in <paramref name="right" />.</returns>
1668 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1670 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1671 public static bool LessThanAny<T>(Vector512<T> left, Vector512<T> right)
1673 return Vector256.LessThanAny(left._lower, right._lower)
1674 || Vector256.LessThanAny(left._upper, right._upper);
1677 /// <summary>Compares two vectors to determine which is less or equal on a per-element basis.</summary>
1678 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1679 /// <param name="left">The vector to compare with <paramref name="left" />.</param>
1680 /// <param name="right">The vector to compare with <paramref name="right" />.</param>
1681 /// <returns>A vector whose elements are all-bits-set or zero, depending on if which of the corresponding elements in <paramref name="left" /> and <paramref name="right" /> were less or equal.</returns>
1682 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1684 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1685 public static Vector512<T> LessThanOrEqual<T>(Vector512<T> left, Vector512<T> right)
1688 Vector256.LessThanOrEqual(left._lower, right._lower),
1689 Vector256.LessThanOrEqual(left._upper, right._upper)
1693 /// <summary>Compares two vectors to determine if all elements are less or equal.</summary>
1694 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1695 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1696 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1697 /// <returns><c>true</c> if all elements in <paramref name="left" /> were less than or equal to the corresponding element in <paramref name="right" />.</returns>
1698 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1700 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1701 public static bool LessThanOrEqualAll<T>(Vector512<T> left, Vector512<T> right)
1703 return Vector256.LessThanOrEqualAll(left._lower, right._lower)
1704 && Vector256.LessThanOrEqualAll(left._upper, right._upper);
1707 /// <summary>Compares two vectors to determine if any elements are less or equal.</summary>
1708 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1709 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1710 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1711 /// <returns><c>true</c> if any elements in <paramref name="left" /> was less than or equal to the corresponding element in <paramref name="right" />.</returns>
1712 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1714 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1715 public static bool LessThanOrEqualAny<T>(Vector512<T> left, Vector512<T> right)
1717 return Vector256.LessThanOrEqualAny(left._lower, right._lower)
1718 || Vector256.LessThanOrEqualAny(left._upper, right._upper);
1721 #pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T')
1722 /// <summary>Loads a vector from the given source.</summary>
1723 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1724 /// <param name="source">The source from which the vector will be loaded.</param>
1725 /// <returns>The vector loaded from <paramref name="source" />.</returns>
1726 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> (<typeparamref name="T" />) is not supported.</exception>
1728 [CLSCompliant(false)]
1729 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1730 public static Vector512<T> Load<T>(T* source) => LoadUnsafe(ref *source);
1732 /// <summary>Loads a vector from the given aligned source.</summary>
1733 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1734 /// <param name="source">The aligned source from which the vector will be loaded.</param>
1735 /// <returns>The vector loaded from <paramref name="source" />.</returns>
1736 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> (<typeparamref name="T" />) is not supported.</exception>
1738 [CLSCompliant(false)]
1739 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1740 public static Vector512<T> LoadAligned<T>(T* source)
1742 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
1744 if (((nuint)(source) % Alignment) != 0)
1746 ThrowHelper.ThrowAccessViolationException();
1749 return *(Vector512<T>*)(source);
1752 /// <summary>Loads a vector from the given aligned source.</summary>
1753 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1754 /// <param name="source">The aligned source from which the vector will be loaded.</param>
1755 /// <returns>The vector loaded from <paramref name="source" />.</returns>
1756 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> (<typeparamref name="T" />) is not supported.</exception>
1757 /// <remarks>This method may bypass the cache on certain platforms.</remarks>
1759 [CLSCompliant(false)]
1760 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1761 public static Vector512<T> LoadAlignedNonTemporal<T>(T* source) => LoadAligned(source);
1762 #pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T')
1764 /// <summary>Loads a vector from the given source.</summary>
1765 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1766 /// <param name="source">The source from which the vector will be loaded.</param>
1767 /// <returns>The vector loaded from <paramref name="source" />.</returns>
1768 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> (<typeparamref name="T" />) is not supported.</exception>
1770 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1771 public static Vector512<T> LoadUnsafe<T>(ref readonly T source)
1773 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
1774 ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.AsRef(in source));
1775 return Unsafe.ReadUnaligned<Vector512<T>>(in address);
1778 /// <summary>Loads a vector from the given source and element offset.</summary>
1779 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1780 /// <param name="source">The source to which <paramref name="elementOffset" /> will be added before loading the vector.</param>
1781 /// <param name="elementOffset">The element offset from <paramref name="source" /> from which the vector will be loaded.</param>
1782 /// <returns>The vector loaded from <paramref name="source" /> plus <paramref name="elementOffset" />.</returns>
1783 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> (<typeparamref name="T" />) is not supported.</exception>
1785 [CLSCompliant(false)]
1786 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1787 public static Vector512<T> LoadUnsafe<T>(ref readonly T source, nuint elementOffset)
1789 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
1790 ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.Add(ref Unsafe.AsRef(in source), (nint)elementOffset));
1791 return Unsafe.ReadUnaligned<Vector512<T>>(in address);
1794 /// <summary>Loads a vector from the given source and reinterprets it as <see cref="ushort"/>.</summary>
1795 /// <param name="source">The source from which the vector will be loaded.</param>
1796 /// <returns>The vector loaded from <paramref name="source" />.</returns>
1797 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1798 internal static Vector512<ushort> LoadUnsafe(ref char source) =>
1799 LoadUnsafe(ref Unsafe.As<char, ushort>(ref source));
1801 /// <summary>Loads a vector from the given source and element offset and reinterprets it as <see cref="ushort"/>.</summary>
1802 /// <param name="source">The source to which <paramref name="elementOffset" /> will be added before loading the vector.</param>
1803 /// <param name="elementOffset">The element offset from <paramref name="source" /> from which the vector will be loaded.</param>
1804 /// <returns>The vector loaded from <paramref name="source" /> plus <paramref name="elementOffset" />.</returns>
1805 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1806 internal static Vector512<ushort> LoadUnsafe(ref char source, nuint elementOffset) =>
1807 LoadUnsafe(ref Unsafe.As<char, ushort>(ref source), elementOffset);
1809 /// <summary>Computes the maximum of two vectors on a per-element basis.</summary>
1810 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1811 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1812 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1813 /// <returns>A vector whose elements are the maximum of the corresponding elements in <paramref name="left" /> and <paramref name="right" />.</returns>
1814 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1816 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1817 public static Vector512<T> Max<T>(Vector512<T> left, Vector512<T> right)
1820 Vector256.Max(left._lower, right._lower),
1821 Vector256.Max(left._upper, right._upper)
1825 /// <summary>Computes the minimum of two vectors on a per-element basis.</summary>
1826 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1827 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1828 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1829 /// <returns>A vector whose elements are the minimum of the corresponding elements in <paramref name="left" /> and <paramref name="right" />.</returns>
1830 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1832 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1833 public static Vector512<T> Min<T>(Vector512<T> left, Vector512<T> right)
1836 Vector256.Min(left._lower, right._lower),
1837 Vector256.Min(left._upper, right._upper)
1841 /// <summary>Multiplies two vectors to compute their element-wise product.</summary>
1842 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1843 /// <param name="left">The vector to multiply with <paramref name="right" />.</param>
1844 /// <param name="right">The vector to multiply with <paramref name="left" />.</param>
1845 /// <returns>The element-wise product of <paramref name="left" /> and <paramref name="right" />.</returns>
1846 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1848 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1849 public static Vector512<T> Multiply<T>(Vector512<T> left, Vector512<T> right) => left * right;
1851 /// <summary>Multiplies a vector by a scalar to compute their product.</summary>
1852 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1853 /// <param name="left">The vector to multiply with <paramref name="right" />.</param>
1854 /// <param name="right">The scalar to multiply with <paramref name="left" />.</param>
1855 /// <returns>The product of <paramref name="left" /> and <paramref name="right" />.</returns>
1856 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1858 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1859 public static Vector512<T> Multiply<T>(Vector512<T> left, T right) => left * right;
1861 /// <summary>Multiplies a vector by a scalar to compute their product.</summary>
1862 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1863 /// <param name="left">The scalar to multiply with <paramref name="right" />.</param>
1864 /// <param name="right">The vector to multiply with <paramref name="left" />.</param>
1865 /// <returns>The product of <paramref name="left" /> and <paramref name="right" />.</returns>
1866 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1868 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1869 public static Vector512<T> Multiply<T>(T left, Vector512<T> right) => left * right;
1871 /// <summary>Narrows two <see cref="Vector512{Double}"/> instances into one <see cref="Vector512{Single}" />.</summary>
1872 /// <param name="lower">The vector that will be narrowed to the lower half of the result vector.</param>
1873 /// <param name="upper">The vector that will be narrowed to the upper half of the result vector.</param>
1874 /// <returns>A <see cref="Vector512{Single}"/> containing elements narrowed from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1876 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1877 public static Vector512<float> Narrow(Vector512<double> lower, Vector512<double> upper)
1880 Vector256.Narrow(lower._lower, lower._upper),
1881 Vector256.Narrow(upper._lower, upper._upper)
1885 /// <summary>Narrows two <see cref="Vector512{Int16}"/> instances into one <see cref="Vector512{SByte}" />.</summary>
1886 /// <param name="lower">The vector that will be narrowed to the lower half of the result vector.</param>
1887 /// <param name="upper">The vector that will be narrowed to the upper half of the result vector.</param>
1888 /// <returns>A <see cref="Vector512{SByte}"/> containing elements narrowed from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1890 [CLSCompliant(false)]
1891 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1892 public static Vector512<sbyte> Narrow(Vector512<short> lower, Vector512<short> upper)
1895 Vector256.Narrow(lower._lower, lower._upper),
1896 Vector256.Narrow(upper._lower, upper._upper)
1900 /// <summary>Narrows two <see cref="Vector512{Int32}"/> instances into one <see cref="Vector512{Int16}" />.</summary>
1901 /// <param name="lower">The vector that will be narrowed to the lower half of the result vector.</param>
1902 /// <param name="upper">The vector that will be narrowed to the upper half of the result vector.</param>
1903 /// <returns>A <see cref="Vector512{Int16}"/> containing elements narrowed from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1905 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1906 public static Vector512<short> Narrow(Vector512<int> lower, Vector512<int> upper)
1909 Vector256.Narrow(lower._lower, lower._upper),
1910 Vector256.Narrow(upper._lower, upper._upper)
1914 /// <summary>Narrows two <see cref="Vector512{Int64}"/> instances into one <see cref="Vector512{Int32}" />.</summary>
1915 /// <param name="lower">The vector that will be narrowed to the lower half of the result vector.</param>
1916 /// <param name="upper">The vector that will be narrowed to the upper half of the result vector.</param>
1917 /// <returns>A <see cref="Vector512{Int32}"/> containing elements narrowed from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1919 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1920 public static Vector512<int> Narrow(Vector512<long> lower, Vector512<long> upper)
1923 Vector256.Narrow(lower._lower, lower._upper),
1924 Vector256.Narrow(upper._lower, upper._upper)
1928 /// <summary>Narrows two <see cref="Vector512{UInt16}"/> instances into one <see cref="Vector512{Byte}" />.</summary>
1929 /// <param name="lower">The vector that will be narrowed to the lower half of the result vector.</param>
1930 /// <param name="upper">The vector that will be narrowed to the upper half of the result vector.</param>
1931 /// <returns>A <see cref="Vector512{Byte}"/> containing elements narrowed from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1933 [CLSCompliant(false)]
1934 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1935 public static Vector512<byte> Narrow(Vector512<ushort> lower, Vector512<ushort> upper)
1938 Vector256.Narrow(lower._lower, lower._upper),
1939 Vector256.Narrow(upper._lower, upper._upper)
1943 /// <summary>Narrows two <see cref="Vector512{UInt32}"/> instances into one <see cref="Vector512{UInt16}" />.</summary>
1944 /// <param name="lower">The vector that will be narrowed to the lower half of the result vector.</param>
1945 /// <param name="upper">The vector that will be narrowed to the upper half of the result vector.</param>
1946 /// <returns>A <see cref="Vector512{UInt16}"/> containing elements narrowed from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1948 [CLSCompliant(false)]
1949 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1950 public static Vector512<ushort> Narrow(Vector512<uint> lower, Vector512<uint> upper)
1953 Vector256.Narrow(lower._lower, lower._upper),
1954 Vector256.Narrow(upper._lower, upper._upper)
1958 /// <summary>Narrows two <see cref="Vector512{UInt64}"/> instances into one <see cref="Vector512{UInt32}" />.</summary>
1959 /// <param name="lower">The vector that will be narrowed to the lower half of the result vector.</param>
1960 /// <param name="upper">The vector that will be narrowed to the upper half of the result vector.</param>
1961 /// <returns>A <see cref="Vector512{UInt32}"/> containing elements narrowed from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1963 [CLSCompliant(false)]
1964 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1965 public static Vector512<uint> Narrow(Vector512<ulong> lower, Vector512<ulong> upper)
1968 Vector256.Narrow(lower._lower, lower._upper),
1969 Vector256.Narrow(upper._lower, upper._upper)
1973 /// <summary>Negates a vector.</summary>
1974 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1975 /// <param name="vector">The vector to negate.</param>
1976 /// <returns>A vector whose elements are the negation of the corresponding elements in <paramref name="vector" />.</returns>
1977 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
1979 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1980 public static Vector512<T> Negate<T>(Vector512<T> vector) => -vector;
1982 /// <summary>Computes the ones-complement of a vector.</summary>
1983 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1984 /// <param name="vector">The vector whose ones-complement is to be computed.</param>
1985 /// <returns>A vector whose elements are the ones-complement of the corresponding elements in <paramref name="vector" />.</returns>
1986 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
1988 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1989 public static Vector512<T> OnesComplement<T>(Vector512<T> vector)
1992 Vector256.OnesComplement(vector._lower),
1993 Vector256.OnesComplement(vector._upper)
1997 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
1998 /// <param name="vector">The vector whose elements are to be shifted.</param>
1999 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2000 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2002 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2003 public static Vector512<byte> ShiftLeft(Vector512<byte> vector, int shiftCount)
2006 Vector256.ShiftLeft(vector._lower, shiftCount),
2007 Vector256.ShiftLeft(vector._upper, shiftCount)
2011 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2012 /// <param name="vector">The vector whose elements are to be shifted.</param>
2013 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2014 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2016 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2017 public static Vector512<short> ShiftLeft(Vector512<short> vector, int shiftCount)
2020 Vector256.ShiftLeft(vector._lower, shiftCount),
2021 Vector256.ShiftLeft(vector._upper, shiftCount)
2025 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2026 /// <param name="vector">The vector whose elements are to be shifted.</param>
2027 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2028 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2030 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2031 public static Vector512<int> ShiftLeft(Vector512<int> vector, int shiftCount)
2034 Vector256.ShiftLeft(vector._lower, shiftCount),
2035 Vector256.ShiftLeft(vector._upper, shiftCount)
2039 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2040 /// <param name="vector">The vector whose elements are to be shifted.</param>
2041 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2042 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2044 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2045 public static Vector512<long> ShiftLeft(Vector512<long> vector, int shiftCount)
2048 Vector256.ShiftLeft(vector._lower, shiftCount),
2049 Vector256.ShiftLeft(vector._upper, shiftCount)
2053 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2054 /// <param name="vector">The vector whose elements are to be shifted.</param>
2055 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2056 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2058 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2059 public static Vector512<nint> ShiftLeft(Vector512<nint> vector, int shiftCount)
2062 Vector256.ShiftLeft(vector._lower, shiftCount),
2063 Vector256.ShiftLeft(vector._upper, shiftCount)
2067 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2068 /// <param name="vector">The vector whose elements are to be shifted.</param>
2069 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2070 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2072 [CLSCompliant(false)]
2073 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2074 public static Vector512<nuint> ShiftLeft(Vector512<nuint> vector, int shiftCount)
2077 Vector256.ShiftLeft(vector._lower, shiftCount),
2078 Vector256.ShiftLeft(vector._upper, shiftCount)
2082 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2083 /// <param name="vector">The vector whose elements are to be shifted.</param>
2084 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2085 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2087 [CLSCompliant(false)]
2088 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2089 public static Vector512<sbyte> ShiftLeft(Vector512<sbyte> vector, int shiftCount)
2092 Vector256.ShiftLeft(vector._lower, shiftCount),
2093 Vector256.ShiftLeft(vector._upper, shiftCount)
2097 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2098 /// <param name="vector">The vector whose elements are to be shifted.</param>
2099 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2100 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2102 [CLSCompliant(false)]
2103 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2104 public static Vector512<ushort> ShiftLeft(Vector512<ushort> vector, int shiftCount)
2107 Vector256.ShiftLeft(vector._lower, shiftCount),
2108 Vector256.ShiftLeft(vector._upper, shiftCount)
2112 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2113 /// <param name="vector">The vector whose elements are to be shifted.</param>
2114 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2115 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2117 [CLSCompliant(false)]
2118 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2119 public static Vector512<uint> ShiftLeft(Vector512<uint> vector, int shiftCount)
2122 Vector256.ShiftLeft(vector._lower, shiftCount),
2123 Vector256.ShiftLeft(vector._upper, shiftCount)
2127 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2128 /// <param name="vector">The vector whose elements are to be shifted.</param>
2129 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2130 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2132 [CLSCompliant(false)]
2133 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2134 public static Vector512<ulong> ShiftLeft(Vector512<ulong> vector, int shiftCount)
2137 Vector256.ShiftLeft(vector._lower, shiftCount),
2138 Vector256.ShiftLeft(vector._upper, shiftCount)
2142 /// <summary>Shifts (signed) each element of a vector right by the specified amount.</summary>
2143 /// <param name="vector">The vector whose elements are to be shifted.</param>
2144 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2145 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2147 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2148 public static Vector512<short> ShiftRightArithmetic(Vector512<short> vector, int shiftCount)
2151 Vector256.ShiftRightArithmetic(vector._lower, shiftCount),
2152 Vector256.ShiftRightArithmetic(vector._upper, shiftCount)
2156 /// <summary>Shifts (signed) each element of a vector right by the specified amount.</summary>
2157 /// <param name="vector">The vector whose elements are to be shifted.</param>
2158 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2159 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2161 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2162 public static Vector512<int> ShiftRightArithmetic(Vector512<int> vector, int shiftCount)
2165 Vector256.ShiftRightArithmetic(vector._lower, shiftCount),
2166 Vector256.ShiftRightArithmetic(vector._upper, shiftCount)
2170 /// <summary>Shifts (signed) each element of a vector right by the specified amount.</summary>
2171 /// <param name="vector">The vector whose elements are to be shifted.</param>
2172 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2173 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2175 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2176 public static Vector512<long> ShiftRightArithmetic(Vector512<long> vector, int shiftCount)
2179 Vector256.ShiftRightArithmetic(vector._lower, shiftCount),
2180 Vector256.ShiftRightArithmetic(vector._upper, shiftCount)
2184 /// <summary>Shifts (signed) each element of a vector right by the specified amount.</summary>
2185 /// <param name="vector">The vector whose elements are to be shifted.</param>
2186 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2187 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2189 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2190 public static Vector512<nint> ShiftRightArithmetic(Vector512<nint> vector, int shiftCount)
2193 Vector256.ShiftRightArithmetic(vector._lower, shiftCount),
2194 Vector256.ShiftRightArithmetic(vector._upper, shiftCount)
2198 /// <summary>Shifts (signed) each element of a vector right by the specified amount.</summary>
2199 /// <param name="vector">The vector whose elements are to be shifted.</param>
2200 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2201 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2203 [CLSCompliant(false)]
2204 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2205 public static Vector512<sbyte> ShiftRightArithmetic(Vector512<sbyte> vector, int shiftCount)
2208 Vector256.ShiftRightArithmetic(vector._lower, shiftCount),
2209 Vector256.ShiftRightArithmetic(vector._upper, shiftCount)
2213 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2214 /// <param name="vector">The vector whose elements are to be shifted.</param>
2215 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2216 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2218 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2219 public static Vector512<byte> ShiftRightLogical(Vector512<byte> vector, int shiftCount)
2222 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2223 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2227 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2228 /// <param name="vector">The vector whose elements are to be shifted.</param>
2229 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2230 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2232 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2233 public static Vector512<short> ShiftRightLogical(Vector512<short> vector, int shiftCount)
2236 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2237 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2241 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2242 /// <param name="vector">The vector whose elements are to be shifted.</param>
2243 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2244 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2246 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2247 public static Vector512<int> ShiftRightLogical(Vector512<int> vector, int shiftCount)
2250 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2251 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2255 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2256 /// <param name="vector">The vector whose elements are to be shifted.</param>
2257 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2258 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2260 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2261 public static Vector512<long> ShiftRightLogical(Vector512<long> vector, int shiftCount)
2264 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2265 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2269 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2270 /// <param name="vector">The vector whose elements are to be shifted.</param>
2271 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2272 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2274 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2275 public static Vector512<nint> ShiftRightLogical(Vector512<nint> vector, int shiftCount)
2278 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2279 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2283 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2284 /// <param name="vector">The vector whose elements are to be shifted.</param>
2285 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2286 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2288 [CLSCompliant(false)]
2289 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2290 public static Vector512<nuint> ShiftRightLogical(Vector512<nuint> vector, int shiftCount)
2293 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2294 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2298 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2299 /// <param name="vector">The vector whose elements are to be shifted.</param>
2300 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2301 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2303 [CLSCompliant(false)]
2304 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2305 public static Vector512<sbyte> ShiftRightLogical(Vector512<sbyte> vector, int shiftCount)
2308 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2309 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2313 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2314 /// <param name="vector">The vector whose elements are to be shifted.</param>
2315 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2316 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2318 [CLSCompliant(false)]
2319 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2320 public static Vector512<ushort> ShiftRightLogical(Vector512<ushort> vector, int shiftCount)
2323 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2324 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2328 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2329 /// <param name="vector">The vector whose elements are to be shifted.</param>
2330 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2331 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2333 [CLSCompliant(false)]
2334 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2335 public static Vector512<uint> ShiftRightLogical(Vector512<uint> vector, int shiftCount)
2338 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2339 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2343 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2344 /// <param name="vector">The vector whose elements are to be shifted.</param>
2345 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2346 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2348 [CLSCompliant(false)]
2349 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2350 public static Vector512<ulong> ShiftRightLogical(Vector512<ulong> vector, int shiftCount)
2353 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2354 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2358 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2359 /// <param name="vector">The input vector from which values are selected.</param>
2360 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2361 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2363 public static Vector512<byte> Shuffle(Vector512<byte> vector, Vector512<byte> indices)
2365 Unsafe.SkipInit(out Vector512<byte> result);
2367 for (int index = 0; index < Vector512<byte>.Count; index++)
2369 byte selectedIndex = indices.GetElementUnsafe(index);
2370 byte selectedValue = 0;
2372 if (selectedIndex < Vector512<byte>.Count)
2374 selectedValue = vector.GetElementUnsafe(selectedIndex);
2376 result.SetElementUnsafe(index, selectedValue);
2382 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2383 /// <param name="vector">The input vector from which values are selected.</param>
2384 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2385 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2387 [CLSCompliant(false)]
2388 public static Vector512<sbyte> Shuffle(Vector512<sbyte> vector, Vector512<sbyte> indices)
2390 Unsafe.SkipInit(out Vector512<sbyte> result);
2392 for (int index = 0; index < Vector512<sbyte>.Count; index++)
2394 byte selectedIndex = (byte)indices.GetElementUnsafe(index);
2395 sbyte selectedValue = 0;
2397 if (selectedIndex < Vector512<sbyte>.Count)
2399 selectedValue = vector.GetElementUnsafe(selectedIndex);
2401 result.SetElementUnsafe(index, selectedValue);
2407 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2408 /// <param name="vector">The input vector from which values are selected.</param>
2409 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2410 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2412 public static Vector512<short> Shuffle(Vector512<short> vector, Vector512<short> indices)
2414 Unsafe.SkipInit(out Vector512<short> result);
2416 for (int index = 0; index < Vector512<short>.Count; index++)
2418 ushort selectedIndex = (ushort)indices.GetElementUnsafe(index);
2419 short selectedValue = 0;
2421 if (selectedIndex < Vector512<short>.Count)
2423 selectedValue = vector.GetElementUnsafe(selectedIndex);
2425 result.SetElementUnsafe(index, selectedValue);
2431 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2432 /// <param name="vector">The input vector from which values are selected.</param>
2433 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2434 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2436 [CLSCompliant(false)]
2437 public static Vector512<ushort> Shuffle(Vector512<ushort> vector, Vector512<ushort> indices)
2439 Unsafe.SkipInit(out Vector512<ushort> result);
2441 for (int index = 0; index < Vector512<ushort>.Count; index++)
2443 ushort selectedIndex = indices.GetElementUnsafe(index);
2444 ushort selectedValue = 0;
2446 if (selectedIndex < Vector512<ushort>.Count)
2448 selectedValue = vector.GetElementUnsafe(selectedIndex);
2450 result.SetElementUnsafe(index, selectedValue);
2456 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2457 /// <param name="vector">The input vector from which values are selected.</param>
2458 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2459 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2461 public static Vector512<int> Shuffle(Vector512<int> vector, Vector512<int> indices)
2463 Unsafe.SkipInit(out Vector512<int> result);
2465 for (int index = 0; index < Vector512<int>.Count; index++)
2467 uint selectedIndex = (uint)indices.GetElementUnsafe(index);
2468 int selectedValue = 0;
2470 if (selectedIndex < Vector512<int>.Count)
2472 selectedValue = vector.GetElementUnsafe((int)selectedIndex);
2474 result.SetElementUnsafe(index, selectedValue);
2480 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2481 /// <param name="vector">The input vector from which values are selected.</param>
2482 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2483 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2485 [CLSCompliant(false)]
2486 public static Vector512<uint> Shuffle(Vector512<uint> vector, Vector512<uint> indices)
2488 Unsafe.SkipInit(out Vector512<uint> result);
2490 for (int index = 0; index < Vector512<uint>.Count; index++)
2492 uint selectedIndex = indices.GetElementUnsafe(index);
2493 uint selectedValue = 0;
2495 if (selectedIndex < Vector512<uint>.Count)
2497 selectedValue = vector.GetElementUnsafe((int)selectedIndex);
2499 result.SetElementUnsafe(index, selectedValue);
2505 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2506 /// <param name="vector">The input vector from which values are selected.</param>
2507 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2508 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2510 public static Vector512<float> Shuffle(Vector512<float> vector, Vector512<int> indices)
2512 Unsafe.SkipInit(out Vector512<float> result);
2514 for (int index = 0; index < Vector512<float>.Count; index++)
2516 uint selectedIndex = (uint)indices.GetElementUnsafe(index);
2517 float selectedValue = 0;
2519 if (selectedIndex < Vector512<float>.Count)
2521 selectedValue = vector.GetElementUnsafe((int)selectedIndex);
2523 result.SetElementUnsafe(index, selectedValue);
2529 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2530 /// <param name="vector">The input vector from which values are selected.</param>
2531 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2532 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2534 public static Vector512<long> Shuffle(Vector512<long> vector, Vector512<long> indices)
2536 Unsafe.SkipInit(out Vector512<long> result);
2538 for (int index = 0; index < Vector512<long>.Count; index++)
2540 ulong selectedIndex = (ulong)indices.GetElementUnsafe(index);
2541 long selectedValue = 0;
2543 if (selectedIndex < (uint)Vector512<long>.Count)
2545 selectedValue = vector.GetElementUnsafe((int)selectedIndex);
2547 result.SetElementUnsafe(index, selectedValue);
2553 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2554 /// <param name="vector">The input vector from which values are selected.</param>
2555 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2556 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2558 [CLSCompliant(false)]
2559 public static Vector512<ulong> Shuffle(Vector512<ulong> vector, Vector512<ulong> indices)
2561 Unsafe.SkipInit(out Vector512<ulong> result);
2563 for (int index = 0; index < Vector512<ulong>.Count; index++)
2565 ulong selectedIndex = indices.GetElementUnsafe(index);
2566 ulong selectedValue = 0;
2568 if (selectedIndex < (uint)Vector512<ulong>.Count)
2570 selectedValue = vector.GetElementUnsafe((int)selectedIndex);
2572 result.SetElementUnsafe(index, selectedValue);
2578 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2579 /// <param name="vector">The input vector from which values are selected.</param>
2580 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2581 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2583 public static Vector512<double> Shuffle(Vector512<double> vector, Vector512<long> indices)
2585 Unsafe.SkipInit(out Vector512<double> result);
2587 for (int index = 0; index < Vector512<double>.Count; index++)
2589 ulong selectedIndex = (ulong)indices.GetElementUnsafe(index);
2590 double selectedValue = 0;
2592 if (selectedIndex < (uint)Vector512<double>.Count)
2594 selectedValue = vector.GetElementUnsafe((int)selectedIndex);
2596 result.SetElementUnsafe(index, selectedValue);
2602 /// <summary>Computes the square root of a vector on a per-element basis.</summary>
2603 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2604 /// <param name="vector">The vector whose square root is to be computed.</param>
2605 /// <returns>A vector whose elements are the square root of the corresponding elements in <paramref name="vector" />.</returns>
2606 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
2608 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2609 public static Vector512<T> Sqrt<T>(Vector512<T> vector)
2612 Vector256.Sqrt(vector._lower),
2613 Vector256.Sqrt(vector._upper)
2617 #pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T')
2618 /// <summary>Stores a vector at the given destination.</summary>
2619 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2620 /// <param name="source">The vector that will be stored.</param>
2621 /// <param name="destination">The destination at which <paramref name="source" /> will be stored.</param>
2622 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
2624 [CLSCompliant(false)]
2625 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2626 public static void Store<T>(this Vector512<T> source, T* destination) => source.StoreUnsafe(ref *destination);
2628 /// <summary>Stores a vector at the given aligned destination.</summary>
2629 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2630 /// <param name="source">The vector that will be stored.</param>
2631 /// <param name="destination">The aligned destination at which <paramref name="source" /> will be stored.</param>
2632 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
2634 [CLSCompliant(false)]
2635 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2636 public static void StoreAligned<T>(this Vector512<T> source, T* destination)
2638 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
2640 if (((nuint)(destination) % Alignment) != 0)
2642 ThrowHelper.ThrowAccessViolationException();
2645 *(Vector512<T>*)(destination) = source;
2648 /// <summary>Stores a vector at the given aligned destination.</summary>
2649 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2650 /// <param name="source">The vector that will be stored.</param>
2651 /// <param name="destination">The aligned destination at which <paramref name="source" /> will be stored.</param>
2652 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
2653 /// <remarks>This method may bypass the cache on certain platforms.</remarks>
2655 [CLSCompliant(false)]
2656 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2657 public static void StoreAlignedNonTemporal<T>(this Vector512<T> source, T* destination) => source.StoreAligned(destination);
2658 #pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T')
2660 /// <summary>Stores a vector at the given destination.</summary>
2661 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2662 /// <param name="source">The vector that will be stored.</param>
2663 /// <param name="destination">The destination at which <paramref name="source" /> will be stored.</param>
2664 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
2666 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2667 public static void StoreUnsafe<T>(this Vector512<T> source, ref T destination)
2669 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
2670 ref byte address = ref Unsafe.As<T, byte>(ref destination);
2671 Unsafe.WriteUnaligned(ref address, source);
2674 /// <summary>Stores a vector at the given destination.</summary>
2675 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2676 /// <param name="source">The vector that will be stored.</param>
2677 /// <param name="destination">The destination to which <paramref name="elementOffset" /> will be added before the vector will be stored.</param>
2678 /// <param name="elementOffset">The element offset from <paramref name="destination" /> from which the vector will be stored.</param>
2679 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
2681 [CLSCompliant(false)]
2682 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2683 public static void StoreUnsafe<T>(this Vector512<T> source, ref T destination, nuint elementOffset)
2685 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
2686 destination = ref Unsafe.Add(ref destination, (nint)elementOffset);
2687 Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination), source);
2690 /// <summary>Subtracts two vectors to compute their difference.</summary>
2691 /// <param name="left">The vector from which <paramref name="right" /> will be subtracted.</param>
2692 /// <param name="right">The vector to subtract from <paramref name="left" />.</param>
2693 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2694 /// <returns>The difference of <paramref name="left" /> and <paramref name="right" />.</returns>
2695 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
2697 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2698 public static Vector512<T> Subtract<T>(Vector512<T> left, Vector512<T> right) => left - right;
2700 /// <summary>Computes the sum of all elements in a vector.</summary>
2701 /// <param name="vector">The vector whose elements will be summed.</param>
2702 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2703 /// <returns>The sum of all elements in <paramref name="vector" />.</returns>
2704 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
2706 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2707 public static T Sum<T>(Vector512<T> vector)
2709 // Doing this as Sum(lower) + Sum(upper) is important for floating-point determinism
2710 // This is because the underlying dpps instruction on x86/x64 will do this equivalently
2711 // and otherwise the software vs accelerated implementations may differ in returned result.
2713 T result = Vector256.Sum(vector._lower);
2714 result = Scalar<T>.Add(result, Vector256.Sum(vector._upper));
2718 /// <summary>Converts the given vector to a scalar containing the value of the first element.</summary>
2719 /// <typeparam name="T">The type of the input vector.</typeparam>
2720 /// <param name="vector">The vector to get the first element from.</param>
2721 /// <returns>A scalar <typeparamref name="T" /> containing the value of the first element.</returns>
2722 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
2724 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2725 public static T ToScalar<T>(this Vector512<T> vector)
2727 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
2728 return vector.GetElementUnsafe(0);
2731 /// <summary>Tries to copy a <see cref="Vector{T}" /> to a given span.</summary>
2732 /// <typeparam name="T">The type of the input vector.</typeparam>
2733 /// <param name="vector">The vector to copy.</param>
2734 /// <param name="destination">The span to which <paramref name="destination" /> is copied.</param>
2735 /// <returns><c>true</c> if <paramref name="vector" /> was successfully copied to <paramref name="destination" />; otherwise, <c>false</c> if the length of <paramref name="destination" /> is less than <see cref="Vector512{T}.Count" />.</returns>
2736 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
2737 public static bool TryCopyTo<T>(this Vector512<T> vector, Span<T> destination)
2739 if ((uint)destination.Length < (uint)Vector512<T>.Count)
2744 ref byte address = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination));
2745 Unsafe.WriteUnaligned(ref address, vector);
2749 /// <summary>Widens a <see cref="Vector512{Byte}" /> into two <see cref="Vector512{UInt16} " />.</summary>
2750 /// <param name="source">The vector whose elements are to be widened.</param>
2751 /// <returns>A pair of vectors that contain the widened lower and upper halves of <paramref name="source" />.</returns>
2752 [CLSCompliant(false)]
2753 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2754 public static (Vector512<ushort> Lower, Vector512<ushort> Upper) Widen(Vector512<byte> source) => (WidenLower(source), WidenUpper(source));
2756 /// <summary>Widens a <see cref="Vector512{Int16}" /> into two <see cref="Vector512{Int32} " />.</summary>
2757 /// <param name="source">The vector whose elements are to be widened.</param>
2758 /// <returns>A pair of vectors that contain the widened lower and upper halves of <paramref name="source" />.</returns>
2759 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2760 public static (Vector512<int> Lower, Vector512<int> Upper) Widen(Vector512<short> source) => (WidenLower(source), WidenUpper(source));
2762 /// <summary>Widens a <see cref="Vector512{Int32}" /> into two <see cref="Vector512{Int64} " />.</summary>
2763 /// <param name="source">The vector whose elements are to be widened.</param>
2764 /// <returns>A pair of vectors that contain the widened lower and upper halves of <paramref name="source" />.</returns>
2765 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2766 public static (Vector512<long> Lower, Vector512<long> Upper) Widen(Vector512<int> source) => (WidenLower(source), WidenUpper(source));
2768 /// <summary>Widens a <see cref="Vector512{SByte}" /> into two <see cref="Vector512{Int16} " />.</summary>
2769 /// <param name="source">The vector whose elements are to be widened.</param>
2770 /// <returns>A pair of vectors that contain the widened lower and upper halves of <paramref name="source" />.</returns>
2771 [CLSCompliant(false)]
2772 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2773 public static (Vector512<short> Lower, Vector512<short> Upper) Widen(Vector512<sbyte> source) => (WidenLower(source), WidenUpper(source));
2775 /// <summary>Widens a <see cref="Vector512{Single}" /> into two <see cref="Vector512{Double} " />.</summary>
2776 /// <param name="source">The vector whose elements are to be widened.</param>
2777 /// <returns>A pair of vectors that contain the widened lower and upper halves of <paramref name="source" />.</returns>
2778 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2779 public static (Vector512<double> Lower, Vector512<double> Upper) Widen(Vector512<float> source) => (WidenLower(source), WidenUpper(source));
2781 /// <summary>Widens a <see cref="Vector512{UInt16}" /> into two <see cref="Vector512{UInt32} " />.</summary>
2782 /// <param name="source">The vector whose elements are to be widened.</param>
2783 /// <returns>A pair of vectors that contain the widened lower and upper halves of <paramref name="source" />.</returns>
2784 [CLSCompliant(false)]
2785 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2786 public static (Vector512<uint> Lower, Vector512<uint> Upper) Widen(Vector512<ushort> source) => (WidenLower(source), WidenUpper(source));
2788 /// <summary>Widens a <see cref="Vector512{UInt32}" /> into two <see cref="Vector512{UInt64} " />.</summary>
2789 /// <param name="source">The vector whose elements are to be widened.</param>
2790 /// <returns>A pair of vectors that contain the widened lower and upper halves of <paramref name="source" />.</returns>
2791 [CLSCompliant(false)]
2792 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2793 public static (Vector512<ulong> Lower, Vector512<ulong> Upper) Widen(Vector512<uint> source) => (WidenLower(source), WidenUpper(source));
2795 /// <summary>Widens the lower half of a <see cref="Vector512{Byte}" /> into a <see cref="Vector512{UInt16} " />.</summary>
2796 /// <param name="source">The vector whose elements are to be widened.</param>
2797 /// <returns>A vector that contain the widened lower half of <paramref name="source" />.</returns>
2799 [CLSCompliant(false)]
2800 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2801 public static Vector512<ushort> WidenLower(Vector512<byte> source)
2803 Vector256<byte> lower = source._lower;
2806 Vector256.WidenLower(lower),
2807 Vector256.WidenUpper(lower)
2811 /// <summary>Widens the lower half of a <see cref="Vector512{Int16}" /> into a <see cref="Vector512{Int32} " />.</summary>
2812 /// <param name="source">The vector whose elements are to be widened.</param>
2813 /// <returns>A vector that contain the widened lower half of <paramref name="source" />.</returns>
2815 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2816 public static Vector512<int> WidenLower(Vector512<short> source)
2818 Vector256<short> lower = source._lower;
2821 Vector256.WidenLower(lower),
2822 Vector256.WidenUpper(lower)
2826 /// <summary>Widens the lower half of a <see cref="Vector512{Int32}" /> into a <see cref="Vector512{Int64} " />.</summary>
2827 /// <param name="source">The vector whose elements are to be widened.</param>
2828 /// <returns>A vector that contain the widened lower half of <paramref name="source" />.</returns>
2830 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2831 public static Vector512<long> WidenLower(Vector512<int> source)
2833 Vector256<int> lower = source._lower;
2836 Vector256.WidenLower(lower),
2837 Vector256.WidenUpper(lower)
2841 /// <summary>Widens the lower half of a <see cref="Vector512{SByte}" /> into a <see cref="Vector512{Int16} " />.</summary>
2842 /// <param name="source">The vector whose elements are to be widened.</param>
2843 /// <returns>A vector that contain the widened lower half of <paramref name="source" />.</returns>
2845 [CLSCompliant(false)]
2846 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2847 public static Vector512<short> WidenLower(Vector512<sbyte> source)
2849 Vector256<sbyte> lower = source._lower;
2852 Vector256.WidenLower(lower),
2853 Vector256.WidenUpper(lower)
2856 /// <summary>Widens the lower half of a <see cref="Vector512{Single}" /> into a <see cref="Vector512{Double} " />.</summary>
2857 /// <param name="source">The vector whose elements are to be widened.</param>
2858 /// <returns>A vector that contain the widened lower half of <paramref name="source" />.</returns>
2860 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2861 public static Vector512<double> WidenLower(Vector512<float> source)
2863 Vector256<float> lower = source._lower;
2866 Vector256.WidenLower(lower),
2867 Vector256.WidenUpper(lower)
2871 /// <summary>Widens the lower half of a <see cref="Vector512{UInt16}" /> into a <see cref="Vector512{UInt32} " />.</summary>
2872 /// <param name="source">The vector whose elements are to be widened.</param>
2873 /// <returns>A vector that contain the widened lower half of <paramref name="source" />.</returns>
2875 [CLSCompliant(false)]
2876 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2877 public static Vector512<uint> WidenLower(Vector512<ushort> source)
2879 Vector256<ushort> lower = source._lower;
2882 Vector256.WidenLower(lower),
2883 Vector256.WidenUpper(lower)
2887 /// <summary>Widens the lower half of a <see cref="Vector512{UInt32}" /> into a <see cref="Vector512{UInt64} " />.</summary>
2888 /// <param name="source">The vector whose elements are to be widened.</param>
2889 /// <returns>A vector that contain the widened lower half of <paramref name="source" />.</returns>
2891 [CLSCompliant(false)]
2892 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2893 public static Vector512<ulong> WidenLower(Vector512<uint> source)
2895 Vector256<uint> lower = source._lower;
2898 Vector256.WidenLower(lower),
2899 Vector256.WidenUpper(lower)
2903 /// <summary>Widens the upper half of a <see cref="Vector512{Byte}" /> into a <see cref="Vector512{UInt16} " />.</summary>
2904 /// <param name="source">The vector whose elements are to be widened.</param>
2905 /// <returns>A vector that contain the widened upper half of <paramref name="source" />.</returns>
2907 [CLSCompliant(false)]
2908 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2909 public static Vector512<ushort> WidenUpper(Vector512<byte> source)
2911 Vector256<byte> upper = source._upper;
2914 Vector256.WidenLower(upper),
2915 Vector256.WidenUpper(upper)
2919 /// <summary>Widens the upper half of a <see cref="Vector512{Int16}" /> into a <see cref="Vector512{Int32} " />.</summary>
2920 /// <param name="source">The vector whose elements are to be widened.</param>
2921 /// <returns>A vector that contain the widened upper half of <paramref name="source" />.</returns>
2923 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2924 public static Vector512<int> WidenUpper(Vector512<short> source)
2926 Vector256<short> upper = source._upper;
2929 Vector256.WidenLower(upper),
2930 Vector256.WidenUpper(upper)
2934 /// <summary>Widens the upper half of a <see cref="Vector512{Int32}" /> into a <see cref="Vector512{Int64} " />.</summary>
2935 /// <param name="source">The vector whose elements are to be widened.</param>
2936 /// <returns>A vector that contain the widened upper half of <paramref name="source" />.</returns>
2938 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2939 public static Vector512<long> WidenUpper(Vector512<int> source)
2941 Vector256<int> upper = source._upper;
2944 Vector256.WidenLower(upper),
2945 Vector256.WidenUpper(upper)
2949 /// <summary>Widens the upper half of a <see cref="Vector512{SByte}" /> into a <see cref="Vector512{Int16} " />.</summary>
2950 /// <param name="source">The vector whose elements are to be widened.</param>
2951 /// <returns>A vector that contain the widened upper half of <paramref name="source" />.</returns>
2953 [CLSCompliant(false)]
2954 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2955 public static Vector512<short> WidenUpper(Vector512<sbyte> source)
2957 Vector256<sbyte> upper = source._upper;
2960 Vector256.WidenLower(upper),
2961 Vector256.WidenUpper(upper)
2965 /// <summary>Widens the upper half of a <see cref="Vector512{Single}" /> into a <see cref="Vector512{Double} " />.</summary>
2966 /// <param name="source">The vector whose elements are to be widened.</param>
2967 /// <returns>A vector that contain the widened upper half of <paramref name="source" />.</returns>
2969 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2970 public static Vector512<double> WidenUpper(Vector512<float> source)
2972 Vector256<float> upper = source._upper;
2975 Vector256.WidenLower(upper),
2976 Vector256.WidenUpper(upper)
2980 /// <summary>Widens the upper half of a <see cref="Vector512{UInt16}" /> into a <see cref="Vector512{UInt32} " />.</summary>
2981 /// <param name="source">The vector whose elements are to be widened.</param>
2982 /// <returns>A vector that contain the widened upper half of <paramref name="source" />.</returns>
2984 [CLSCompliant(false)]
2985 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2986 public static Vector512<uint> WidenUpper(Vector512<ushort> source)
2988 Vector256<ushort> upper = source._upper;
2991 Vector256.WidenLower(upper),
2992 Vector256.WidenUpper(upper)
2996 /// <summary>Widens the upper half of a <see cref="Vector512{UInt32}" /> into a <see cref="Vector512{UInt64} " />.</summary>
2997 /// <param name="source">The vector whose elements are to be widened.</param>
2998 /// <returns>A vector that contain the widened upper half of <paramref name="source" />.</returns>
3000 [CLSCompliant(false)]
3001 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3002 public static Vector512<ulong> WidenUpper(Vector512<uint> source)
3004 Vector256<uint> upper = source._upper;
3007 Vector256.WidenLower(upper),
3008 Vector256.WidenUpper(upper)
3012 /// <summary>Creates a new <see cref="Vector512{T}" /> with the element at the specified index set to the specified value and the remaining elements set to the same value as that in the given vector.</summary>
3013 /// <typeparam name="T">The type of the input vector.</typeparam>
3014 /// <param name="vector">The vector to get the remaining elements from.</param>
3015 /// <param name="index">The index of the element to set.</param>
3016 /// <param name="value">The value to set the element to.</param>
3017 /// <returns>A <see cref="Vector512{T}" /> with the value of the element at <paramref name="index" /> set to <paramref name="value" /> and the remaining elements set to the same value as that in <paramref name="vector" />.</returns>
3018 /// <exception cref="ArgumentOutOfRangeException"><paramref name="index" /> was less than zero or greater than the number of elements.</exception>
3019 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
3021 public static Vector512<T> WithElement<T>(this Vector512<T> vector, int index, T value)
3023 if ((uint)(index) >= (uint)(Vector512<T>.Count))
3025 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index);
3028 Vector512<T> result = vector;
3029 result.SetElementUnsafe(index, value);
3033 /// <summary>Creates a new <see cref="Vector512{T}" /> with the lower 256-bits set to the specified value and the upper 256-bits set to the same value as that in the given vector.</summary>
3034 /// <typeparam name="T">The type of the input vector.</typeparam>
3035 /// <param name="vector">The vector to get the upper 256-bits from.</param>
3036 /// <param name="value">The value of the lower 256-bits as a <see cref="Vector256{T}" />.</param>
3037 /// <returns>A new <see cref="Vector512{T}" /> with the lower 256-bits set to <paramref name="value" /> and the upper 256-bits set to the same value as that in <paramref name="vector" />.</returns>
3038 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
3040 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3041 public static Vector512<T> WithLower<T>(this Vector512<T> vector, Vector256<T> value)
3043 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
3045 Vector512<T> result = vector;
3046 result.SetLowerUnsafe(value);
3050 /// <summary>Creates a new <see cref="Vector512{T}" /> with the upper 256-bits set to the specified value and the lower 256-bits set to the same value as that in the given vector.</summary>
3051 /// <typeparam name="T">The type of the input vector.</typeparam>
3052 /// <param name="vector">The vector to get the lower 256-bits from.</param>
3053 /// <param name="value">The value of the upper 256-bits as a <see cref="Vector256{T}" />.</param>
3054 /// <returns>A new <see cref="Vector512{T}" /> with the upper 256-bits set to <paramref name="value" /> and the lower 256-bits set to the same value as that in <paramref name="vector" />.</returns>
3055 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
3057 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3058 public static Vector512<T> WithUpper<T>(this Vector512<T> vector, Vector256<T> value)
3060 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
3062 Vector512<T> result = vector;
3063 result.SetUpperUnsafe(value);
3067 /// <summary>Computes the exclusive-or of two vectors.</summary>
3068 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
3069 /// <param name="left">The vector to exclusive-or with <paramref name="right" />.</param>
3070 /// <param name="right">The vector to exclusive-or with <paramref name="left" />.</param>
3071 /// <returns>The exclusive-or of <paramref name="left" /> and <paramref name="right" />.</returns>
3072 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
3074 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3075 public static Vector512<T> Xor<T>(Vector512<T> left, Vector512<T> right) => left ^ right;
3077 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3078 internal static T GetElementUnsafe<T>(in this Vector512<T> vector, int index)
3080 Debug.Assert((index >= 0) && (index < Vector512<T>.Count));
3081 ref T address = ref Unsafe.As<Vector512<T>, T>(ref Unsafe.AsRef(in vector));
3082 return Unsafe.Add(ref address, index);
3085 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3086 internal static void SetElementUnsafe<T>(in this Vector512<T> vector, int index, T value)
3088 Debug.Assert((index >= 0) && (index < Vector512<T>.Count));
3089 ref T address = ref Unsafe.As<Vector512<T>, T>(ref Unsafe.AsRef(in vector));
3090 Unsafe.Add(ref address, index) = value;
3093 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3094 internal static void SetLowerUnsafe<T>(in this Vector512<T> vector, Vector256<T> value)
3096 Unsafe.AsRef(in vector._lower) = value;
3099 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3100 internal static void SetUpperUnsafe<T>(in this Vector512<T> vector, Vector256<T> value)
3102 Unsafe.AsRef(in vector._upper) = value;