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 // TODO-RISCV64: Update alignment to proper value when we implement RISC-V intrinsic.
41 internal const int Alignment = 16;
43 internal const int Alignment = 64;
46 /// <summary>Gets a value that indicates whether 512-bit vector operations are subject to hardware acceleration through JIT intrinsic support.</summary>
47 /// <value><see langword="true" /> if 512-bit vector operations are subject to hardware acceleration; otherwise, <see langword="false" />.</value>
48 /// <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>
49 public static bool IsHardwareAccelerated
52 get => IsHardwareAccelerated;
55 /// <summary>Computes the absolute value of each element in a vector.</summary>
56 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
57 /// <param name="vector">The vector that will have its absolute value computed.</param>
58 /// <returns>A vector whose elements are the absolute value of the elements in <paramref name="vector" />.</returns>
59 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
61 [MethodImpl(MethodImplOptions.AggressiveInlining)]
62 public static Vector512<T> Abs<T>(Vector512<T> vector)
65 Vector256.Abs(vector._lower),
66 Vector256.Abs(vector._upper)
70 /// <summary>Adds two vectors to compute their sum.</summary>
71 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
72 /// <param name="left">The vector to add with <paramref name="right" />.</param>
73 /// <param name="right">The vector to add with <paramref name="left" />.</param>
74 /// <returns>The sum of <paramref name="left" /> and <paramref name="right" />.</returns>
75 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
77 [MethodImpl(MethodImplOptions.AggressiveInlining)]
78 public static Vector512<T> Add<T>(Vector512<T> left, Vector512<T> right) => left + right;
80 /// <summary>Computes the bitwise-and of a given vector and the ones complement of another vector.</summary>
81 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
82 /// <param name="left">The vector to bitwise-and with <paramref name="right" />.</param>
83 /// <param name="right">The vector to that is ones-complemented before being bitwise-and with <paramref name="left" />.</param>
84 /// <returns>The bitwise-and of <paramref name="left" /> and the ones-complement of <paramref name="right" />.</returns>
85 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
87 [MethodImpl(MethodImplOptions.AggressiveInlining)]
88 public static Vector512<T> AndNot<T>(Vector512<T> left, Vector512<T> right)
91 Vector256.AndNot(left._lower, right._lower),
92 Vector256.AndNot(left._upper, right._upper)
96 /// <summary>Reinterprets a <see cref="Vector512{TFrom}" /> as a new <see cref="Vector512{TTo}" />.</summary>
97 /// <typeparam name="TFrom">The type of the elements in the input vector.</typeparam>
98 /// <typeparam name="TTo">The type of the elements in the output vector.</typeparam>
99 /// <param name="vector">The vector to reinterpret.</param>
100 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{TTo}" />.</returns>
101 /// <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>
103 [MethodImpl(MethodImplOptions.AggressiveInlining)]
104 public static Vector512<TTo> As<TFrom, TTo>(this Vector512<TFrom> vector)
106 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<TFrom>();
107 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<TTo>();
109 return Unsafe.As<Vector512<TFrom>, Vector512<TTo>>(ref vector);
112 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{Byte}" />.</summary>
113 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
114 /// <param name="vector">The vector to reinterpret.</param>
115 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{Byte}" />.</returns>
116 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
118 [MethodImpl(MethodImplOptions.AggressiveInlining)]
119 public static Vector512<byte> AsByte<T>(this Vector512<T> vector) => vector.As<T, byte>();
121 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{Double}" />.</summary>
122 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
123 /// <param name="vector">The vector to reinterpret.</param>
124 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{Double}" />.</returns>
125 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
127 [MethodImpl(MethodImplOptions.AggressiveInlining)]
128 public static Vector512<double> AsDouble<T>(this Vector512<T> vector) => vector.As<T, double>();
130 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{Int16}" />.</summary>
131 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
132 /// <param name="vector">The vector to reinterpret.</param>
133 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{Int16}" />.</returns>
134 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
136 [MethodImpl(MethodImplOptions.AggressiveInlining)]
137 public static Vector512<short> AsInt16<T>(this Vector512<T> vector) => vector.As<T, short>();
139 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{Int32}" />.</summary>
140 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
141 /// <param name="vector">The vector to reinterpret.</param>
142 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{Int32}" />.</returns>
143 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
145 [MethodImpl(MethodImplOptions.AggressiveInlining)]
146 public static Vector512<int> AsInt32<T>(this Vector512<T> vector) => vector.As<T, int>();
148 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{Int64}" />.</summary>
149 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
150 /// <param name="vector">The vector to reinterpret.</param>
151 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{Int64}" />.</returns>
152 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
154 [MethodImpl(MethodImplOptions.AggressiveInlining)]
155 public static Vector512<long> AsInt64<T>(this Vector512<T> vector) => vector.As<T, long>();
157 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{IntPtr}" />.</summary>
158 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
159 /// <param name="vector">The vector to reinterpret.</param>
160 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{IntPtr}" />.</returns>
161 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
163 [MethodImpl(MethodImplOptions.AggressiveInlining)]
164 public static Vector512<nint> AsNInt<T>(this Vector512<T> vector) => vector.As<T, nint>();
166 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{UIntPtr}" />.</summary>
167 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
168 /// <param name="vector">The vector to reinterpret.</param>
169 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{UIntPtr}" />.</returns>
170 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
172 [CLSCompliant(false)]
173 [MethodImpl(MethodImplOptions.AggressiveInlining)]
174 public static Vector512<nuint> AsNUInt<T>(this Vector512<T> vector) => vector.As<T, nuint>();
176 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{SByte}" />.</summary>
177 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
178 /// <param name="vector">The vector to reinterpret.</param>
179 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{SByte}" />.</returns>
180 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
182 [CLSCompliant(false)]
183 [MethodImpl(MethodImplOptions.AggressiveInlining)]
184 public static Vector512<sbyte> AsSByte<T>(this Vector512<T> vector) => vector.As<T, sbyte>();
186 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{Single}" />.</summary>
187 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
188 /// <param name="vector">The vector to reinterpret.</param>
189 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{Single}" />.</returns>
190 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
192 [MethodImpl(MethodImplOptions.AggressiveInlining)]
193 public static Vector512<float> AsSingle<T>(this Vector512<T> vector) => vector.As<T, float>();
195 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{UInt16}" />.</summary>
196 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
197 /// <param name="vector">The vector to reinterpret.</param>
198 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{UInt16}" />.</returns>
199 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
201 [CLSCompliant(false)]
202 [MethodImpl(MethodImplOptions.AggressiveInlining)]
203 public static Vector512<ushort> AsUInt16<T>(this Vector512<T> vector) => vector.As<T, ushort>();
205 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{UInt32}" />.</summary>
206 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
207 /// <param name="vector">The vector to reinterpret.</param>
208 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{UInt32}" />.</returns>
209 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
211 [CLSCompliant(false)]
212 [MethodImpl(MethodImplOptions.AggressiveInlining)]
213 public static Vector512<uint> AsUInt32<T>(this Vector512<T> vector) => vector.As<T, uint>();
215 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector512{UInt64}" />.</summary>
216 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
217 /// <param name="vector">The vector to reinterpret.</param>
218 /// <returns><paramref name="vector" /> reinterpreted as a new <see cref="Vector512{UInt64}" />.</returns>
219 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
221 [CLSCompliant(false)]
222 [MethodImpl(MethodImplOptions.AggressiveInlining)]
223 public static Vector512<ulong> AsUInt64<T>(this Vector512<T> vector) => vector.As<T, ulong>();
225 /// <summary>Reinterprets a <see cref="Vector{T}" /> as a new <see cref="Vector512{T}" />.</summary>
226 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
227 /// <param name="value">The vector to reinterpret.</param>
228 /// <returns><paramref name="value" /> reinterpreted as a new <see cref="Vector512{T}" />.</returns>
229 /// <exception cref="NotSupportedException">The type of <paramref name="value" /> (<typeparamref name="T" />) is not supported.</exception>
231 [MethodImpl(MethodImplOptions.AggressiveInlining)]
232 public static Vector512<T> AsVector512<T>(this Vector<T> value)
234 Debug.Assert(Vector512<T>.Count >= Vector<T>.Count);
235 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
237 Vector512<T> result = default;
238 Unsafe.WriteUnaligned(ref Unsafe.As<Vector512<T>, byte>(ref result), value);
242 /// <summary>Reinterprets a <see cref="Vector512{T}" /> as a new <see cref="Vector{T}" />.</summary>
243 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
244 /// <param name="value">The vector to reinterpret.</param>
245 /// <returns><paramref name="value" /> reinterpreted as a new <see cref="Vector{T}" />.</returns>
246 /// <exception cref="NotSupportedException">The type of <paramref name="value" /> (<typeparamref name="T" />) is not supported.</exception>
248 [MethodImpl(MethodImplOptions.AggressiveInlining)]
249 public static Vector<T> AsVector<T>(this Vector512<T> value)
251 Debug.Assert(Vector512<T>.Count >= Vector<T>.Count);
252 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
254 ref byte address = ref Unsafe.As<Vector512<T>, byte>(ref value);
255 return Unsafe.ReadUnaligned<Vector<T>>(ref address);
258 /// <summary>Computes the bitwise-and of two vectors.</summary>
259 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
260 /// <param name="left">The vector to bitwise-and with <paramref name="right" />.</param>
261 /// <param name="right">The vector to bitwise-and with <paramref name="left" />.</param>
262 /// <returns>The bitwise-and of <paramref name="left" /> and <paramref name="right"/>.</returns>
263 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
265 [MethodImpl(MethodImplOptions.AggressiveInlining)]
266 public static Vector512<T> BitwiseAnd<T>(Vector512<T> left, Vector512<T> right) => left & right;
268 /// <summary>Computes the bitwise-or of two vectors.</summary>
269 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
270 /// <param name="left">The vector to bitwise-or with <paramref name="right" />.</param>
271 /// <param name="right">The vector to bitwise-or with <paramref name="left" />.</param>
272 /// <returns>The bitwise-or of <paramref name="left" /> and <paramref name="right"/>.</returns>
273 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
275 [MethodImpl(MethodImplOptions.AggressiveInlining)]
276 public static Vector512<T> BitwiseOr<T>(Vector512<T> left, Vector512<T> right) => left | right;
278 /// <summary>Computes the ceiling of each element in a vector.</summary>
279 /// <param name="vector">The vector that will have its ceiling computed.</param>
280 /// <returns>A vector whose elements are the ceiling of the elements in <paramref name="vector" />.</returns>
281 /// <seealso cref="MathF.Ceiling(float)" />
283 [MethodImpl(MethodImplOptions.AggressiveInlining)]
284 public static Vector512<float> Ceiling(Vector512<float> vector)
287 Vector256.Ceiling(vector._lower),
288 Vector256.Ceiling(vector._upper)
292 /// <summary>Computes the ceiling of each element in a vector.</summary>
293 /// <param name="vector">The vector that will have its ceiling computed.</param>
294 /// <returns>A vector whose elements are the ceiling of the elements in <paramref name="vector" />.</returns>
295 /// <seealso cref="Math.Ceiling(double)" />
297 [MethodImpl(MethodImplOptions.AggressiveInlining)]
298 public static Vector512<double> Ceiling(Vector512<double> vector)
301 Vector256.Ceiling(vector._lower),
302 Vector256.Ceiling(vector._upper)
306 /// <summary>Conditionally selects a value from two vectors on a bitwise basis.</summary>
307 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
308 /// <param name="condition">The mask that is used to select a value from <paramref name="left" /> or <paramref name="right" />.</param>
309 /// <param name="left">The vector that is selected when the corresponding bit in <paramref name="condition" /> is one.</param>
310 /// <param name="right">The vector that is selected when the corresponding bit in <paramref name="condition" /> is zero.</param>
311 /// <returns>A vector whose bits come from <paramref name="left" /> or <paramref name="right" /> based on the value of <paramref name="condition" />.</returns>
312 /// <exception cref="NotSupportedException">The type of <paramref name="condition" />, <paramref name="left" />, and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
314 [MethodImpl(MethodImplOptions.AggressiveInlining)]
315 public static Vector512<T> ConditionalSelect<T>(Vector512<T> condition, Vector512<T> left, Vector512<T> right)
318 Vector256.ConditionalSelect(condition._lower, left._lower, right._lower),
319 Vector256.ConditionalSelect(condition._upper, left._upper, right._upper)
323 /// <summary>Converts a <see cref="Vector512{Int64}" /> to a <see cref="Vector512{Double}" />.</summary>
324 /// <param name="vector">The vector to convert.</param>
325 /// <returns>The converted vector.</returns>
327 [MethodImpl(MethodImplOptions.AggressiveInlining)]
328 public static Vector512<double> ConvertToDouble(Vector512<long> vector)
331 Vector256.ConvertToDouble(vector._lower),
332 Vector256.ConvertToDouble(vector._upper)
336 /// <summary>Converts a <see cref="Vector512{UInt64}" /> to a <see cref="Vector512{Double}" />.</summary>
337 /// <param name="vector">The vector to convert.</param>
338 /// <returns>The converted vector.</returns>
340 [CLSCompliant(false)]
341 [MethodImpl(MethodImplOptions.AggressiveInlining)]
342 public static Vector512<double> ConvertToDouble(Vector512<ulong> vector)
345 Vector256.ConvertToDouble(vector._lower),
346 Vector256.ConvertToDouble(vector._upper)
350 /// <summary>Converts a <see cref="Vector512{Single}" /> to a <see cref="Vector512{Int32}" />.</summary>
351 /// <param name="vector">The vector to convert.</param>
352 /// <returns>The converted vector.</returns>
354 [MethodImpl(MethodImplOptions.AggressiveInlining)]
355 public static Vector512<int> ConvertToInt32(Vector512<float> vector)
358 Vector256.ConvertToInt32(vector._lower),
359 Vector256.ConvertToInt32(vector._upper)
363 /// <summary>Converts a <see cref="Vector512{Double}" /> to a <see cref="Vector512{Int64}" />.</summary>
364 /// <param name="vector">The vector to convert.</param>
365 /// <returns>The converted vector.</returns>
367 [MethodImpl(MethodImplOptions.AggressiveInlining)]
368 public static Vector512<long> ConvertToInt64(Vector512<double> vector)
371 Vector256.ConvertToInt64(vector._lower),
372 Vector256.ConvertToInt64(vector._upper)
376 /// <summary>Converts a <see cref="Vector512{Int32}" /> to a <see cref="Vector512{Single}" />.</summary>
377 /// <param name="vector">The vector to convert.</param>
378 /// <returns>The converted vector.</returns>
380 [MethodImpl(MethodImplOptions.AggressiveInlining)]
381 public static Vector512<float> ConvertToSingle(Vector512<int> vector)
384 Vector256.ConvertToSingle(vector._lower),
385 Vector256.ConvertToSingle(vector._upper)
389 /// <summary>Converts a <see cref="Vector512{UInt32}" /> to a <see cref="Vector512{Single}" />.</summary>
390 /// <param name="vector">The vector to convert.</param>
391 /// <returns>The converted vector.</returns>
393 [CLSCompliant(false)]
394 [MethodImpl(MethodImplOptions.AggressiveInlining)]
395 public static Vector512<float> ConvertToSingle(Vector512<uint> vector)
398 Vector256.ConvertToSingle(vector._lower),
399 Vector256.ConvertToSingle(vector._upper)
403 /// <summary>Converts a <see cref="Vector512{Single}" /> to a <see cref="Vector512{UInt32}" />.</summary>
404 /// <param name="vector">The vector to convert.</param>
405 /// <returns>The converted vector.</returns>
407 [CLSCompliant(false)]
408 [MethodImpl(MethodImplOptions.AggressiveInlining)]
409 public static Vector512<uint> ConvertToUInt32(Vector512<float> vector)
412 Vector256.ConvertToUInt32(vector._lower),
413 Vector256.ConvertToUInt32(vector._upper)
417 /// <summary>Converts a <see cref="Vector512{Double}" /> to a <see cref="Vector512{UInt64}" />.</summary>
418 /// <param name="vector">The vector to convert.</param>
419 /// <returns>The converted vector.</returns>
421 [CLSCompliant(false)]
422 [MethodImpl(MethodImplOptions.AggressiveInlining)]
423 public static Vector512<ulong> ConvertToUInt64(Vector512<double> vector)
426 Vector256.ConvertToUInt64(vector._lower),
427 Vector256.ConvertToUInt64(vector._upper)
431 /// <summary>Copies a <see cref="Vector512{T}" /> to a given array.</summary>
432 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
433 /// <param name="vector">The vector to be copied.</param>
434 /// <param name="destination">The array to which <paramref name="vector" /> is copied.</param>
435 /// <exception cref="ArgumentException">The length of <paramref name="destination" /> is less than <see cref="Vector512{T}.Count" />.</exception>
436 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
437 /// <exception cref="NullReferenceException"><paramref name="destination" /> is <c>null</c>.</exception>
438 public static void CopyTo<T>(this Vector512<T> vector, T[] destination)
440 // We explicitly don't check for `null` because historically this has thrown `NullReferenceException` for perf reasons
442 if (destination.Length < Vector512<T>.Count)
444 ThrowHelper.ThrowArgumentException_DestinationTooShort();
447 ref byte address = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetArrayDataReference(destination));
448 Unsafe.WriteUnaligned(ref address, vector);
451 /// <summary>Copies a <see cref="Vector512{T}" /> to a given array starting at the specified index.</summary>
452 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
453 /// <param name="vector">The vector to be copied.</param>
454 /// <param name="destination">The array to which <paramref name="vector" /> is copied.</param>
455 /// <param name="startIndex">The starting index of <paramref name="destination" /> which <paramref name="vector" /> will be copied to.</param>
456 /// <exception cref="ArgumentException">The length of <paramref name="destination" /> is less than <see cref="Vector512{T}.Count" />.</exception>
457 /// <exception cref="ArgumentOutOfRangeException"><paramref name="startIndex" /> is negative or greater than the length of <paramref name="destination" />.</exception>
458 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
459 /// <exception cref="NullReferenceException"><paramref name="destination" /> is <c>null</c>.</exception>
460 public static void CopyTo<T>(this Vector512<T> vector, T[] destination, int startIndex)
462 // We explicitly don't check for `null` because historically this has thrown `NullReferenceException` for perf reasons
464 if ((uint)startIndex >= (uint)destination.Length)
466 ThrowHelper.ThrowStartIndexArgumentOutOfRange_ArgumentOutOfRange_IndexMustBeLess();
469 if ((destination.Length - startIndex) < Vector512<T>.Count)
471 ThrowHelper.ThrowArgumentException_DestinationTooShort();
474 ref byte address = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetArrayDataReference(destination));
475 Unsafe.WriteUnaligned(ref Unsafe.Add(ref address, startIndex), vector);
478 /// <summary>Copies a <see cref="Vector512{T}" /> to a given span.</summary>
479 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
480 /// <param name="vector">The vector to be copied.</param>
481 /// <param name="destination">The span to which the <paramref name="vector" /> is copied.</param>
482 /// <exception cref="ArgumentException">The length of <paramref name="destination" /> is less than <see cref="Vector512{T}.Count" />.</exception>
483 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
484 public static void CopyTo<T>(this Vector512<T> vector, Span<T> destination)
486 if ((uint)destination.Length < (uint)Vector512<T>.Count)
488 ThrowHelper.ThrowArgumentException_DestinationTooShort();
491 ref byte address = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination));
492 Unsafe.WriteUnaligned(ref address, vector);
495 /// <summary>Creates a new <see cref="Vector512{T}" /> instance with all elements initialized to the specified value.</summary>
496 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
497 /// <param name="value">The value that all elements will be initialized to.</param>
498 /// <returns>A new <see cref="Vector512{T}" /> with all elements initialized to <paramref name="value" />.</returns>
499 /// <exception cref="NotSupportedException">The type of <paramref name="value" /> (<typeparamref name="T" />) is not supported.</exception>
501 [MethodImpl(MethodImplOptions.AggressiveInlining)]
502 public static Vector512<T> Create<T>(T value)
504 Vector256<T> vector = Vector256.Create(value);
505 return Create(vector, vector);
508 /// <summary>Creates a new <see cref="Vector512{Byte}" /> instance with all elements initialized to the specified value.</summary>
509 /// <param name="value">The value that all elements will be initialized to.</param>
510 /// <returns>A new <see cref="Vector512{Byte}" /> with all elements initialized to <paramref name="value" />.</returns>
511 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi8</remarks>
513 [MethodImpl(MethodImplOptions.AggressiveInlining)]
514 public static Vector512<byte> Create(byte value) => Create<byte>(value);
516 /// <summary>Creates a new <see cref="Vector512{Double}" /> instance with all elements initialized to the specified value.</summary>
517 /// <param name="value">The value that all elements will be initialized to.</param>
518 /// <returns>A new <see cref="Vector512{Double}" /> with all elements initialized to <paramref name="value" />.</returns>
519 /// <remarks>On x86, this method corresponds to __m512d _mm512_set1_pd</remarks>
521 [MethodImpl(MethodImplOptions.AggressiveInlining)]
522 public static Vector512<double> Create(double value) => Create<double>(value);
524 /// <summary>Creates a new <see cref="Vector512{Int16}" /> instance with all elements initialized to the specified value.</summary>
525 /// <param name="value">The value that all elements will be initialized to.</param>
526 /// <returns>A new <see cref="Vector512{Int16}" /> with all elements initialized to <paramref name="value" />.</returns>
527 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi16</remarks>
529 [MethodImpl(MethodImplOptions.AggressiveInlining)]
530 public static Vector512<short> Create(short value) => Create<short>(value);
532 /// <summary>Creates a new <see cref="Vector512{Int32}" /> instance with all elements initialized to the specified value.</summary>
533 /// <param name="value">The value that all elements will be initialized to.</param>
534 /// <returns>A new <see cref="Vector512{Int32}" /> with all elements initialized to <paramref name="value" />.</returns>
535 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi32</remarks>
537 [MethodImpl(MethodImplOptions.AggressiveInlining)]
538 public static Vector512<int> Create(int value) => Create<int>(value);
540 /// <summary>Creates a new <see cref="Vector512{Int64}" /> instance with all elements initialized to the specified value.</summary>
541 /// <param name="value">The value that all elements will be initialized to.</param>
542 /// <returns>A new <see cref="Vector512{Int64}" /> with all elements initialized to <paramref name="value" />.</returns>
543 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi64x</remarks>
545 [MethodImpl(MethodImplOptions.AggressiveInlining)]
546 public static Vector512<long> Create(long value) => Create<long>(value);
548 /// <summary>Creates a new <see cref="Vector512{IntPtr}" /> instance with all elements initialized to the specified value.</summary>
549 /// <param name="value">The value that all elements will be initialized to.</param>
550 /// <returns>A new <see cref="Vector512{IntPtr}" /> with all elements initialized to <paramref name="value" />.</returns>
552 [MethodImpl(MethodImplOptions.AggressiveInlining)]
553 public static Vector512<nint> Create(nint value) => Create<nint>(value);
555 /// <summary>Creates a new <see cref="Vector512{UIntPtr}" /> instance with all elements initialized to the specified value.</summary>
556 /// <param name="value">The value that all elements will be initialized to.</param>
557 /// <returns>A new <see cref="Vector512{UIntPtr}" /> with all elements initialized to <paramref name="value" />.</returns>
559 [CLSCompliant(false)]
560 [MethodImpl(MethodImplOptions.AggressiveInlining)]
561 public static Vector512<nuint> Create(nuint value) => Create<nuint>(value);
563 /// <summary>Creates a new <see cref="Vector512{SByte}" /> instance with all elements initialized to the specified value.</summary>
564 /// <param name="value">The value that all elements will be initialized to.</param>
565 /// <returns>A new <see cref="Vector512{SByte}" /> with all elements initialized to <paramref name="value" />.</returns>
566 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi8</remarks>
568 [CLSCompliant(false)]
569 [MethodImpl(MethodImplOptions.AggressiveInlining)]
570 public static Vector512<sbyte> Create(sbyte value) => Create<sbyte>(value);
572 /// <summary>Creates a new <see cref="Vector512{Single}" /> instance with all elements initialized to the specified value.</summary>
573 /// <param name="value">The value that all elements will be initialized to.</param>
574 /// <returns>A new <see cref="Vector512{Single}" /> with all elements initialized to <paramref name="value" />.</returns>
575 /// <remarks>On x86, this method corresponds to __m512 _mm512_set1_ps</remarks>
577 [MethodImpl(MethodImplOptions.AggressiveInlining)]
578 public static Vector512<float> Create(float value) => Create<float>(value);
580 /// <summary>Creates a new <see cref="Vector512{UInt16}" /> instance with all elements initialized to the specified value.</summary>
581 /// <param name="value">The value that all elements will be initialized to.</param>
582 /// <returns>A new <see cref="Vector512{UInt16}" /> with all elements initialized to <paramref name="value" />.</returns>
583 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi16</remarks>
585 [CLSCompliant(false)]
586 [MethodImpl(MethodImplOptions.AggressiveInlining)]
587 public static Vector512<ushort> Create(ushort value) => Create<ushort>(value);
589 /// <summary>Creates a new <see cref="Vector512{UInt32}" /> instance with all elements initialized to the specified value.</summary>
590 /// <param name="value">The value that all elements will be initialized to.</param>
591 /// <returns>A new <see cref="Vector512{UInt32}" /> with all elements initialized to <paramref name="value" />.</returns>
592 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi32</remarks>
594 [CLSCompliant(false)]
595 [MethodImpl(MethodImplOptions.AggressiveInlining)]
596 public static Vector512<uint> Create(uint value) => Create<uint>(value);
598 /// <summary>Creates a new <see cref="Vector512{UInt64}" /> instance with all elements initialized to the specified value.</summary>
599 /// <param name="value">The value that all elements will be initialized to.</param>
600 /// <returns>A new <see cref="Vector512{UInt64}" /> with all elements initialized to <paramref name="value" />.</returns>
601 /// <remarks>On x86, this method corresponds to __m512i _mm512_set1_epi64x</remarks>
603 [CLSCompliant(false)]
604 [MethodImpl(MethodImplOptions.AggressiveInlining)]
605 public static Vector512<ulong> Create(ulong value) => Create<ulong>(value);
607 /// <summary>Creates a new <see cref="Vector512{T}" /> from a given array.</summary>
608 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
609 /// <param name="values">The array from which the vector is created.</param>
610 /// <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>
611 /// <exception cref="ArgumentOutOfRangeException">The length of <paramref name="values" /> is less than <see cref="Vector512{T}.Count" />.</exception>
612 /// <exception cref="NotSupportedException">The type of <paramref name="values" /> (<typeparamref name="T" />) is not supported.</exception>
613 /// <exception cref="NullReferenceException"><paramref name="values" /> is <c>null</c>.</exception>
614 public static Vector512<T> Create<T>(T[] values)
616 // We explicitly don't check for `null` because historically this has thrown `NullReferenceException` for perf reasons
618 if (values.Length < Vector512<T>.Count)
620 ThrowHelper.ThrowArgumentOutOfRange_IndexMustBeLessOrEqualException();
623 ref byte address = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetArrayDataReference(values));
624 return Unsafe.ReadUnaligned<Vector512<T>>(ref address);
627 /// <summary>Creates a new <see cref="Vector512{T}" /> from a given array.</summary>
628 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
629 /// <param name="values">The array from which the vector is created.</param>
630 /// <param name="index">The index in <paramref name="values" /> at which to being reading elements.</param>
631 /// <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>
632 /// <exception cref="ArgumentOutOfRangeException">The length of <paramref name="values" />, starting from <paramref name="index" />, is less than <see cref="Vector512{T}.Count" />.</exception>
633 /// <exception cref="NotSupportedException">The type of <paramref name="values" /> (<typeparamref name="T" />) is not supported.</exception>
634 /// <exception cref="NullReferenceException"><paramref name="values" /> is <c>null</c>.</exception>
635 public static Vector512<T> Create<T>(T[] values, int index)
637 // We explicitly don't check for `null` because historically this has thrown `NullReferenceException` for perf reasons
639 if ((index < 0) || ((values.Length - index) < Vector512<T>.Count))
641 ThrowHelper.ThrowArgumentOutOfRange_IndexMustBeLessOrEqualException();
644 ref byte address = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetArrayDataReference(values));
645 return Unsafe.ReadUnaligned<Vector512<T>>(ref Unsafe.Add(ref address, index));
648 /// <summary>Creates a new <see cref="Vector512{T}" /> from a given readonly span.</summary>
649 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
650 /// <param name="values">The readonly span from which the vector is created.</param>
651 /// <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>
652 /// <exception cref="ArgumentOutOfRangeException">The length of <paramref name="values" /> is less than <see cref="Vector512{T}.Count" />.</exception>
653 /// <exception cref="NotSupportedException">The type of <paramref name="values" /> (<typeparamref name="T" />) is not supported.</exception>
654 [MethodImpl(MethodImplOptions.AggressiveInlining)]
655 public static Vector512<T> Create<T>(ReadOnlySpan<T> values)
657 if (values.Length < Vector512<T>.Count)
659 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.values);
662 ref byte address = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(values));
663 return Unsafe.ReadUnaligned<Vector512<T>>(ref address);
666 /// <summary>Creates a new <see cref="Vector512{Byte}" /> instance with each element initialized to the corresponding specified value.</summary>
667 /// <param name="e0">The value that element 0 will be initialized to.</param>
668 /// <param name="e1">The value that element 1 will be initialized to.</param>
669 /// <param name="e2">The value that element 2 will be initialized to.</param>
670 /// <param name="e3">The value that element 3 will be initialized to.</param>
671 /// <param name="e4">The value that element 4 will be initialized to.</param>
672 /// <param name="e5">The value that element 5 will be initialized to.</param>
673 /// <param name="e6">The value that element 6 will be initialized to.</param>
674 /// <param name="e7">The value that element 7 will be initialized to.</param>
675 /// <param name="e8">The value that element 8 will be initialized to.</param>
676 /// <param name="e9">The value that element 9 will be initialized to.</param>
677 /// <param name="e10">The value that element 10 will be initialized to.</param>
678 /// <param name="e11">The value that element 11 will be initialized to.</param>
679 /// <param name="e12">The value that element 12 will be initialized to.</param>
680 /// <param name="e13">The value that element 13 will be initialized to.</param>
681 /// <param name="e14">The value that element 14 will be initialized to.</param>
682 /// <param name="e15">The value that element 15 will be initialized to.</param>
683 /// <param name="e16">The value that element 16 will be initialized to.</param>
684 /// <param name="e17">The value that element 17 will be initialized to.</param>
685 /// <param name="e18">The value that element 18 will be initialized to.</param>
686 /// <param name="e19">The value that element 19 will be initialized to.</param>
687 /// <param name="e20">The value that element 20 will be initialized to.</param>
688 /// <param name="e21">The value that element 21 will be initialized to.</param>
689 /// <param name="e22">The value that element 22 will be initialized to.</param>
690 /// <param name="e23">The value that element 23 will be initialized to.</param>
691 /// <param name="e24">The value that element 24 will be initialized to.</param>
692 /// <param name="e25">The value that element 25 will be initialized to.</param>
693 /// <param name="e26">The value that element 26 will be initialized to.</param>
694 /// <param name="e27">The value that element 27 will be initialized to.</param>
695 /// <param name="e28">The value that element 28 will be initialized to.</param>
696 /// <param name="e29">The value that element 29 will be initialized to.</param>
697 /// <param name="e30">The value that element 30 will be initialized to.</param>
698 /// <param name="e31">The value that element 31 will be initialized to.</param>
699 /// <param name="e32">The value that element 32 will be initialized to.</param>
700 /// <param name="e33">The value that element 33 will be initialized to.</param>
701 /// <param name="e34">The value that element 34 will be initialized to.</param>
702 /// <param name="e35">The value that element 35 will be initialized to.</param>
703 /// <param name="e36">The value that element 36 will be initialized to.</param>
704 /// <param name="e37">The value that element 37 will be initialized to.</param>
705 /// <param name="e38">The value that element 38 will be initialized to.</param>
706 /// <param name="e39">The value that element 39 will be initialized to.</param>
707 /// <param name="e40">The value that element 40 will be initialized to.</param>
708 /// <param name="e41">The value that element 41 will be initialized to.</param>
709 /// <param name="e42">The value that element 42 will be initialized to.</param>
710 /// <param name="e43">The value that element 43 will be initialized to.</param>
711 /// <param name="e44">The value that element 44 will be initialized to.</param>
712 /// <param name="e45">The value that element 45 will be initialized to.</param>
713 /// <param name="e46">The value that element 46 will be initialized to.</param>
714 /// <param name="e47">The value that element 47 will be initialized to.</param>
715 /// <param name="e48">The value that element 48 will be initialized to.</param>
716 /// <param name="e49">The value that element 49 will be initialized to.</param>
717 /// <param name="e50">The value that element 50 will be initialized to.</param>
718 /// <param name="e51">The value that element 51 will be initialized to.</param>
719 /// <param name="e52">The value that element 52 will be initialized to.</param>
720 /// <param name="e53">The value that element 53 will be initialized to.</param>
721 /// <param name="e54">The value that element 54 will be initialized to.</param>
722 /// <param name="e55">The value that element 55 will be initialized to.</param>
723 /// <param name="e56">The value that element 56 will be initialized to.</param>
724 /// <param name="e57">The value that element 57 will be initialized to.</param>
725 /// <param name="e58">The value that element 58 will be initialized to.</param>
726 /// <param name="e59">The value that element 59 will be initialized to.</param>
727 /// <param name="e60">The value that element 60 will be initialized to.</param>
728 /// <param name="e61">The value that element 61 will be initialized to.</param>
729 /// <param name="e62">The value that element 62 will be initialized to.</param>
730 /// <param name="e63">The value that element 63 will be initialized to.</param>
731 /// <returns>A new <see cref="Vector512{Byte}" /> with each element initialized to corresponding specified value.</returns>
732 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi8</remarks>
734 [MethodImpl(MethodImplOptions.AggressiveInlining)]
735 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,
736 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,
737 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,
738 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)
741 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),
742 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)
746 /// <summary>Creates a new <see cref="Vector512{Double}" /> instance with each element initialized to the corresponding specified value.</summary>
747 /// <param name="e0">The value that element 0 will be initialized to.</param>
748 /// <param name="e1">The value that element 1 will be initialized to.</param>
749 /// <param name="e2">The value that element 2 will be initialized to.</param>
750 /// <param name="e3">The value that element 3 will be initialized to.</param>
751 /// <param name="e4">The value that element 4 will be initialized to.</param>
752 /// <param name="e5">The value that element 5 will be initialized to.</param>
753 /// <param name="e6">The value that element 6 will be initialized to.</param>
754 /// <param name="e7">The value that element 7 will be initialized to.</param>
755 /// <returns>A new <see cref="Vector512{Double}" /> with each element initialized to corresponding specified value.</returns>
756 /// <remarks>On x86, this method corresponds to __m512d _mm512_setr_pd</remarks>
758 [MethodImpl(MethodImplOptions.AggressiveInlining)]
759 public static Vector512<double> Create(double e0, double e1, double e2, double e3, double e4, double e5, double e6, double e7)
762 Vector256.Create(e0, e1, e2, e3),
763 Vector256.Create(e4, e5, e6, e7)
767 /// <summary>Creates a new <see cref="Vector512{Int16}" /> instance with each element initialized to the corresponding specified value.</summary>
768 /// <param name="e0">The value that element 0 will be initialized to.</param>
769 /// <param name="e1">The value that element 1 will be initialized to.</param>
770 /// <param name="e2">The value that element 2 will be initialized to.</param>
771 /// <param name="e3">The value that element 3 will be initialized to.</param>
772 /// <param name="e4">The value that element 4 will be initialized to.</param>
773 /// <param name="e5">The value that element 5 will be initialized to.</param>
774 /// <param name="e6">The value that element 6 will be initialized to.</param>
775 /// <param name="e7">The value that element 7 will be initialized to.</param>
776 /// <param name="e8">The value that element 8 will be initialized to.</param>
777 /// <param name="e9">The value that element 9 will be initialized to.</param>
778 /// <param name="e10">The value that element 10 will be initialized to.</param>
779 /// <param name="e11">The value that element 11 will be initialized to.</param>
780 /// <param name="e12">The value that element 12 will be initialized to.</param>
781 /// <param name="e13">The value that element 13 will be initialized to.</param>
782 /// <param name="e14">The value that element 14 will be initialized to.</param>
783 /// <param name="e15">The value that element 15 will be initialized to.</param>
784 /// <param name="e16">The value that element 16 will be initialized to.</param>
785 /// <param name="e17">The value that element 17 will be initialized to.</param>
786 /// <param name="e18">The value that element 18 will be initialized to.</param>
787 /// <param name="e19">The value that element 19 will be initialized to.</param>
788 /// <param name="e20">The value that element 20 will be initialized to.</param>
789 /// <param name="e21">The value that element 21 will be initialized to.</param>
790 /// <param name="e22">The value that element 22 will be initialized to.</param>
791 /// <param name="e23">The value that element 23 will be initialized to.</param>
792 /// <param name="e24">The value that element 24 will be initialized to.</param>
793 /// <param name="e25">The value that element 25 will be initialized to.</param>
794 /// <param name="e26">The value that element 26 will be initialized to.</param>
795 /// <param name="e27">The value that element 27 will be initialized to.</param>
796 /// <param name="e28">The value that element 28 will be initialized to.</param>
797 /// <param name="e29">The value that element 29 will be initialized to.</param>
798 /// <param name="e30">The value that element 30 will be initialized to.</param>
799 /// <param name="e31">The value that element 31 will be initialized to.</param>
800 /// <returns>A new <see cref="Vector512{Int16}" /> with each element initialized to corresponding specified value.</returns>
801 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi16</remarks>
803 [MethodImpl(MethodImplOptions.AggressiveInlining)]
804 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,
805 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)
808 Vector256.Create(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15),
809 Vector256.Create(e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31)
813 /// <summary>Creates a new <see cref="Vector512{Int32}" /> instance with each element initialized to the corresponding specified value.</summary>
814 /// <param name="e0">The value that element 0 will be initialized to.</param>
815 /// <param name="e1">The value that element 1 will be initialized to.</param>
816 /// <param name="e2">The value that element 2 will be initialized to.</param>
817 /// <param name="e3">The value that element 3 will be initialized to.</param>
818 /// <param name="e4">The value that element 4 will be initialized to.</param>
819 /// <param name="e5">The value that element 5 will be initialized to.</param>
820 /// <param name="e6">The value that element 6 will be initialized to.</param>
821 /// <param name="e7">The value that element 7 will be initialized to.</param>
822 /// <param name="e8">The value that element 8 will be initialized to.</param>
823 /// <param name="e9">The value that element 9 will be initialized to.</param>
824 /// <param name="e10">The value that element 10 will be initialized to.</param>
825 /// <param name="e11">The value that element 11 will be initialized to.</param>
826 /// <param name="e12">The value that element 12 will be initialized to.</param>
827 /// <param name="e13">The value that element 13 will be initialized to.</param>
828 /// <param name="e14">The value that element 14 will be initialized to.</param>
829 /// <param name="e15">The value that element 15 will be initialized to.</param>
830 /// <returns>A new <see cref="Vector512{Int32}" /> with each element initialized to corresponding specified value.</returns>
831 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi32</remarks>
833 [MethodImpl(MethodImplOptions.AggressiveInlining)]
834 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)
837 Vector256.Create(e0, e1, e2, e3, e4, e5, e6, e7),
838 Vector256.Create(e8, e9, e10, e11, e12, e13, e14, e15)
842 /// <summary>Creates a new <see cref="Vector512{Int64}" /> instance with each element initialized to the corresponding specified value.</summary>
843 /// <param name="e0">The value that element 0 will be initialized to.</param>
844 /// <param name="e1">The value that element 1 will be initialized to.</param>
845 /// <param name="e2">The value that element 2 will be initialized to.</param>
846 /// <param name="e3">The value that element 3 will be initialized to.</param>
847 /// <param name="e4">The value that element 4 will be initialized to.</param>
848 /// <param name="e5">The value that element 5 will be initialized to.</param>
849 /// <param name="e6">The value that element 6 will be initialized to.</param>
850 /// <param name="e7">The value that element 7 will be initialized to.</param>
851 /// <returns>A new <see cref="Vector512{Int64}" /> with each element initialized to corresponding specified value.</returns>
852 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi64x</remarks>
854 [MethodImpl(MethodImplOptions.AggressiveInlining)]
855 public static Vector512<long> Create(long e0, long e1, long e2, long e3, long e4, long e5, long e6, long e7)
858 Vector256.Create(e0, e1, e2, e3),
859 Vector256.Create(e4, e5, e6, e7)
863 /// <summary>Creates a new <see cref="Vector512{SByte}" /> instance with each element initialized to the corresponding specified value.</summary>
864 /// <param name="e0">The value that element 0 will be initialized to.</param>
865 /// <param name="e1">The value that element 1 will be initialized to.</param>
866 /// <param name="e2">The value that element 2 will be initialized to.</param>
867 /// <param name="e3">The value that element 3 will be initialized to.</param>
868 /// <param name="e4">The value that element 4 will be initialized to.</param>
869 /// <param name="e5">The value that element 5 will be initialized to.</param>
870 /// <param name="e6">The value that element 6 will be initialized to.</param>
871 /// <param name="e7">The value that element 7 will be initialized to.</param>
872 /// <param name="e8">The value that element 8 will be initialized to.</param>
873 /// <param name="e9">The value that element 9 will be initialized to.</param>
874 /// <param name="e10">The value that element 10 will be initialized to.</param>
875 /// <param name="e11">The value that element 11 will be initialized to.</param>
876 /// <param name="e12">The value that element 12 will be initialized to.</param>
877 /// <param name="e13">The value that element 13 will be initialized to.</param>
878 /// <param name="e14">The value that element 14 will be initialized to.</param>
879 /// <param name="e15">The value that element 15 will be initialized to.</param>
880 /// <param name="e16">The value that element 16 will be initialized to.</param>
881 /// <param name="e17">The value that element 17 will be initialized to.</param>
882 /// <param name="e18">The value that element 18 will be initialized to.</param>
883 /// <param name="e19">The value that element 19 will be initialized to.</param>
884 /// <param name="e20">The value that element 20 will be initialized to.</param>
885 /// <param name="e21">The value that element 21 will be initialized to.</param>
886 /// <param name="e22">The value that element 22 will be initialized to.</param>
887 /// <param name="e23">The value that element 23 will be initialized to.</param>
888 /// <param name="e24">The value that element 24 will be initialized to.</param>
889 /// <param name="e25">The value that element 25 will be initialized to.</param>
890 /// <param name="e26">The value that element 26 will be initialized to.</param>
891 /// <param name="e27">The value that element 27 will be initialized to.</param>
892 /// <param name="e28">The value that element 28 will be initialized to.</param>
893 /// <param name="e29">The value that element 29 will be initialized to.</param>
894 /// <param name="e30">The value that element 30 will be initialized to.</param>
895 /// <param name="e31">The value that element 31 will be initialized to.</param>
896 /// <param name="e32">The value that element 32 will be initialized to.</param>
897 /// <param name="e33">The value that element 33 will be initialized to.</param>
898 /// <param name="e34">The value that element 34 will be initialized to.</param>
899 /// <param name="e35">The value that element 35 will be initialized to.</param>
900 /// <param name="e36">The value that element 36 will be initialized to.</param>
901 /// <param name="e37">The value that element 37 will be initialized to.</param>
902 /// <param name="e38">The value that element 38 will be initialized to.</param>
903 /// <param name="e39">The value that element 39 will be initialized to.</param>
904 /// <param name="e40">The value that element 40 will be initialized to.</param>
905 /// <param name="e41">The value that element 41 will be initialized to.</param>
906 /// <param name="e42">The value that element 42 will be initialized to.</param>
907 /// <param name="e43">The value that element 43 will be initialized to.</param>
908 /// <param name="e44">The value that element 44 will be initialized to.</param>
909 /// <param name="e45">The value that element 45 will be initialized to.</param>
910 /// <param name="e46">The value that element 46 will be initialized to.</param>
911 /// <param name="e47">The value that element 47 will be initialized to.</param>
912 /// <param name="e48">The value that element 48 will be initialized to.</param>
913 /// <param name="e49">The value that element 49 will be initialized to.</param>
914 /// <param name="e50">The value that element 50 will be initialized to.</param>
915 /// <param name="e51">The value that element 51 will be initialized to.</param>
916 /// <param name="e52">The value that element 52 will be initialized to.</param>
917 /// <param name="e53">The value that element 53 will be initialized to.</param>
918 /// <param name="e54">The value that element 54 will be initialized to.</param>
919 /// <param name="e55">The value that element 55 will be initialized to.</param>
920 /// <param name="e56">The value that element 56 will be initialized to.</param>
921 /// <param name="e57">The value that element 57 will be initialized to.</param>
922 /// <param name="e58">The value that element 58 will be initialized to.</param>
923 /// <param name="e59">The value that element 59 will be initialized to.</param>
924 /// <param name="e60">The value that element 60 will be initialized to.</param>
925 /// <param name="e61">The value that element 61 will be initialized to.</param>
926 /// <param name="e62">The value that element 62 will be initialized to.</param>
927 /// <param name="e63">The value that element 63 will be initialized to.</param>
928 /// <returns>A new <see cref="Vector512{SByte}" /> with each element initialized to corresponding specified value.</returns>
929 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi8</remarks>
931 [CLSCompliant(false)]
932 [MethodImpl(MethodImplOptions.AggressiveInlining)]
933 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,
934 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,
935 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,
936 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)
939 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),
940 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)
944 /// <summary>Creates a new <see cref="Vector512{Single}" /> instance with each element initialized to the corresponding specified value.</summary>
945 /// <param name="e0">The value that element 0 will be initialized to.</param>
946 /// <param name="e1">The value that element 1 will be initialized to.</param>
947 /// <param name="e2">The value that element 2 will be initialized to.</param>
948 /// <param name="e3">The value that element 3 will be initialized to.</param>
949 /// <param name="e4">The value that element 4 will be initialized to.</param>
950 /// <param name="e5">The value that element 5 will be initialized to.</param>
951 /// <param name="e6">The value that element 6 will be initialized to.</param>
952 /// <param name="e7">The value that element 7 will be initialized to.</param>
953 /// <param name="e8">The value that element 8 will be initialized to.</param>
954 /// <param name="e9">The value that element 9 will be initialized to.</param>
955 /// <param name="e10">The value that element 10 will be initialized to.</param>
956 /// <param name="e11">The value that element 11 will be initialized to.</param>
957 /// <param name="e12">The value that element 12 will be initialized to.</param>
958 /// <param name="e13">The value that element 13 will be initialized to.</param>
959 /// <param name="e14">The value that element 14 will be initialized to.</param>
960 /// <param name="e15">The value that element 15 will be initialized to.</param>
961 /// <returns>A new <see cref="Vector512{Single}" /> with each element initialized to corresponding specified value.</returns>
962 /// <remarks>On x86, this method corresponds to __m512 _mm512_setr_ps</remarks>
964 [MethodImpl(MethodImplOptions.AggressiveInlining)]
965 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)
968 Vector256.Create(e0, e1, e2, e3, e4, e5, e6, e7),
969 Vector256.Create(e8, e9, e10, e11, e12, e13, e14, e15)
973 /// <summary>Creates a new <see cref="Vector512{UInt16}" /> instance with each element initialized to the corresponding specified value.</summary>
974 /// <param name="e0">The value that element 0 will be initialized to.</param>
975 /// <param name="e1">The value that element 1 will be initialized to.</param>
976 /// <param name="e2">The value that element 2 will be initialized to.</param>
977 /// <param name="e3">The value that element 3 will be initialized to.</param>
978 /// <param name="e4">The value that element 4 will be initialized to.</param>
979 /// <param name="e5">The value that element 5 will be initialized to.</param>
980 /// <param name="e6">The value that element 6 will be initialized to.</param>
981 /// <param name="e7">The value that element 7 will be initialized to.</param>
982 /// <param name="e8">The value that element 8 will be initialized to.</param>
983 /// <param name="e9">The value that element 9 will be initialized to.</param>
984 /// <param name="e10">The value that element 10 will be initialized to.</param>
985 /// <param name="e11">The value that element 11 will be initialized to.</param>
986 /// <param name="e12">The value that element 12 will be initialized to.</param>
987 /// <param name="e13">The value that element 13 will be initialized to.</param>
988 /// <param name="e14">The value that element 14 will be initialized to.</param>
989 /// <param name="e15">The value that element 15 will be initialized to.</param>
990 /// <param name="e16">The value that element 16 will be initialized to.</param>
991 /// <param name="e17">The value that element 17 will be initialized to.</param>
992 /// <param name="e18">The value that element 18 will be initialized to.</param>
993 /// <param name="e19">The value that element 19 will be initialized to.</param>
994 /// <param name="e20">The value that element 20 will be initialized to.</param>
995 /// <param name="e21">The value that element 21 will be initialized to.</param>
996 /// <param name="e22">The value that element 22 will be initialized to.</param>
997 /// <param name="e23">The value that element 23 will be initialized to.</param>
998 /// <param name="e24">The value that element 24 will be initialized to.</param>
999 /// <param name="e25">The value that element 25 will be initialized to.</param>
1000 /// <param name="e26">The value that element 26 will be initialized to.</param>
1001 /// <param name="e27">The value that element 27 will be initialized to.</param>
1002 /// <param name="e28">The value that element 28 will be initialized to.</param>
1003 /// <param name="e29">The value that element 29 will be initialized to.</param>
1004 /// <param name="e30">The value that element 30 will be initialized to.</param>
1005 /// <param name="e31">The value that element 31 will be initialized to.</param>
1006 /// <returns>A new <see cref="Vector512{UInt16}" /> with each element initialized to corresponding specified value.</returns>
1007 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi16</remarks>
1009 [CLSCompliant(false)]
1010 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1011 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,
1012 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)
1015 Vector256.Create(e0, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15),
1016 Vector256.Create(e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31)
1020 /// <summary>Creates a new <see cref="Vector512{UInt32}" /> instance with each element initialized to the corresponding specified value.</summary>
1021 /// <param name="e0">The value that element 0 will be initialized to.</param>
1022 /// <param name="e1">The value that element 1 will be initialized to.</param>
1023 /// <param name="e2">The value that element 2 will be initialized to.</param>
1024 /// <param name="e3">The value that element 3 will be initialized to.</param>
1025 /// <param name="e4">The value that element 4 will be initialized to.</param>
1026 /// <param name="e5">The value that element 5 will be initialized to.</param>
1027 /// <param name="e6">The value that element 6 will be initialized to.</param>
1028 /// <param name="e7">The value that element 7 will be initialized to.</param>
1029 /// <param name="e8">The value that element 8 will be initialized to.</param>
1030 /// <param name="e9">The value that element 9 will be initialized to.</param>
1031 /// <param name="e10">The value that element 10 will be initialized to.</param>
1032 /// <param name="e11">The value that element 11 will be initialized to.</param>
1033 /// <param name="e12">The value that element 12 will be initialized to.</param>
1034 /// <param name="e13">The value that element 13 will be initialized to.</param>
1035 /// <param name="e14">The value that element 14 will be initialized to.</param>
1036 /// <param name="e15">The value that element 15 will be initialized to.</param>
1037 /// <returns>A new <see cref="Vector512{UInt32}" /> with each element initialized to corresponding specified value.</returns>
1038 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi32</remarks>
1040 [CLSCompliant(false)]
1041 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1042 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)
1045 Vector256.Create(e0, e1, e2, e3, e4, e5, e6, e7),
1046 Vector256.Create(e8, e9, e10, e11, e12, e13, e14, e15)
1050 /// <summary>Creates a new <see cref="Vector512{UInt64}" /> instance with each element initialized to the corresponding specified value.</summary>
1051 /// <param name="e0">The value that element 0 will be initialized to.</param>
1052 /// <param name="e1">The value that element 1 will be initialized to.</param>
1053 /// <param name="e2">The value that element 2 will be initialized to.</param>
1054 /// <param name="e3">The value that element 3 will be initialized to.</param>
1055 /// <param name="e4">The value that element 4 will be initialized to.</param>
1056 /// <param name="e5">The value that element 5 will be initialized to.</param>
1057 /// <param name="e6">The value that element 6 will be initialized to.</param>
1058 /// <param name="e7">The value that element 7 will be initialized to.</param>
1059 /// <returns>A new <see cref="Vector512{UInt64}" /> with each element initialized to corresponding specified value.</returns>
1060 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_epi64x</remarks>
1062 [CLSCompliant(false)]
1063 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1064 public static Vector512<ulong> Create(ulong e0, ulong e1, ulong e2, ulong e3, ulong e4, ulong e5, ulong e6, ulong e7)
1067 Vector256.Create(e0, e1, e2, e3),
1068 Vector256.Create(e4, e5, e6, e7)
1072 /// <summary>Creates a new <see cref="Vector512{T}" /> instance from two <see cref="Vector256{T}" /> instances.</summary>
1073 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1074 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1075 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1076 /// <returns>A new <see cref="Vector512{T}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1077 /// <exception cref="NotSupportedException">The type of <paramref name="lower" /> and <paramref name="upper" /> (<typeparamref name="T" />) is not supported.</exception>
1078 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1079 public static Vector512<T> Create<T>(Vector256<T> lower, Vector256<T> upper)
1081 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
1082 Unsafe.SkipInit(out Vector512<T> result);
1084 result.SetLowerUnsafe(lower);
1085 result.SetUpperUnsafe(upper);
1090 /// <summary>Creates a new <see cref="Vector512{Byte}" /> instance from two <see cref="Vector256{Byte}" /> instances.</summary>
1091 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1092 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1093 /// <returns>A new <see cref="Vector512{Byte}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1094 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1095 public static Vector512<byte> Create(Vector256<byte> lower, Vector256<byte> upper) => Create<byte>(lower, upper);
1097 /// <summary>Creates a new <see cref="Vector512{Double}" /> instance from two <see cref="Vector256{Double}" /> instances.</summary>
1098 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1099 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1100 /// <returns>A new <see cref="Vector512{Double}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1101 /// <remarks>On x86, this method corresponds to __m512d _mm512_setr_m256d (__m256d lo, __m256d hi)</remarks>
1102 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1103 public static Vector512<double> Create(Vector256<double> lower, Vector256<double> upper) => Create<double>(lower, upper);
1105 /// <summary>Creates a new <see cref="Vector512{Int16}" /> instance from two <see cref="Vector256{Int16}" /> instances.</summary>
1106 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1107 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1108 /// <returns>A new <see cref="Vector512{Int16}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1109 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1110 public static Vector512<short> Create(Vector256<short> lower, Vector256<short> upper) => Create<short>(lower, upper);
1112 /// <summary>Creates a new <see cref="Vector512{Int32}" /> instance from two <see cref="Vector256{Int32}" /> instances.</summary>
1113 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1114 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1115 /// <returns>A new <see cref="Vector512{Int32}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1116 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_m256i (__m256i lo, __m256i hi)</remarks>
1117 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1118 public static Vector512<int> Create(Vector256<int> lower, Vector256<int> upper) => Create<int>(lower, upper);
1120 /// <summary>Creates a new <see cref="Vector512{Int64}" /> instance from two <see cref="Vector256{Int64}" /> instances.</summary>
1121 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1122 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1123 /// <returns>A new <see cref="Vector512{Int64}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1124 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1125 public static Vector512<long> Create(Vector256<long> lower, Vector256<long> upper) => Create<long>(lower, upper);
1127 /// <summary>Creates a new <see cref="Vector512{IntPtr}" /> instance from two <see cref="Vector256{IntPtr}" /> instances.</summary>
1128 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1129 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1130 /// <returns>A new <see cref="Vector512{IntPtr}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1131 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1132 public static Vector512<nint> Create(Vector256<nint> lower, Vector256<nint> upper) => Create<nint>(lower, upper);
1134 /// <summary>Creates a new <see cref="Vector512{UIntPtr}" /> instance from two <see cref="Vector256{UIntPtr}" /> instances.</summary>
1135 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1136 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1137 /// <returns>A new <see cref="Vector512{UIntPtr}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1138 [CLSCompliant(false)]
1139 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1140 public static Vector512<nuint> Create(Vector256<nuint> lower, Vector256<nuint> upper) => Create<nuint>(lower, upper);
1142 /// <summary>Creates a new <see cref="Vector512{SByte}" /> instance from two <see cref="Vector256{SByte}" /> instances.</summary>
1143 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1144 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1145 /// <returns>A new <see cref="Vector512{SByte}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1146 [CLSCompliant(false)]
1147 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1148 public static Vector512<sbyte> Create(Vector256<sbyte> lower, Vector256<sbyte> upper) => Create<sbyte>(lower, upper);
1150 /// <summary>Creates a new <see cref="Vector512{Single}" /> instance from two <see cref="Vector256{Single}" /> instances.</summary>
1151 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1152 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1153 /// <returns>A new <see cref="Vector512{Single}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1154 /// <remarks>On x86, this method corresponds to __m512 _mm512_setr_m256 (__m256 lo, __m256 hi)</remarks>
1155 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1156 public static Vector512<float> Create(Vector256<float> lower, Vector256<float> upper) => Create<float>(lower, upper);
1158 /// <summary>Creates a new <see cref="Vector512{UInt16}" /> instance from two <see cref="Vector256{UInt16}" /> instances.</summary>
1159 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1160 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1161 /// <returns>A new <see cref="Vector512{UInt16}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1162 [CLSCompliant(false)]
1163 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1164 public static Vector512<ushort> Create(Vector256<ushort> lower, Vector256<ushort> upper) => Create<ushort>(lower, upper);
1166 /// <summary>Creates a new <see cref="Vector512{UInt32}" /> instance from two <see cref="Vector256{UInt32}" /> instances.</summary>
1167 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1168 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1169 /// <returns>A new <see cref="Vector512{UInt32}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1170 /// <remarks>On x86, this method corresponds to __m512i _mm512_setr_m256i (__m256i lo, __m256i hi)</remarks>
1171 [CLSCompliant(false)]
1172 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1173 public static Vector512<uint> Create(Vector256<uint> lower, Vector256<uint> upper) => Create<uint>(lower, upper);
1175 /// <summary>Creates a new <see cref="Vector512{UInt64}" /> instance from two <see cref="Vector256{UInt64}" /> instances.</summary>
1176 /// <param name="lower">The value that the lower 256-bits will be initialized to.</param>
1177 /// <param name="upper">The value that the upper 256-bits will be initialized to.</param>
1178 /// <returns>A new <see cref="Vector512{UInt64}" /> initialized from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1179 [CLSCompliant(false)]
1180 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1181 public static Vector512<ulong> Create(Vector256<ulong> lower, Vector256<ulong> upper) => Create<ulong>(lower, upper);
1183 /// <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>
1184 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1185 /// <param name="value">The value that element 0 will be initialized to.</param>
1186 /// <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>
1187 /// <exception cref="NotSupportedException">The type of <paramref name="value" /> (<typeparamref name="T" />) is not supported.</exception>
1188 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1189 public static Vector512<T> CreateScalar<T>(T value) => Vector256.CreateScalar(value).ToVector512();
1191 /// <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>
1192 /// <param name="value">The value that element 0 will be initialized to.</param>
1193 /// <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>
1194 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1195 public static Vector512<byte> CreateScalar(byte value) => CreateScalar<byte>(value);
1197 /// <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>
1198 /// <param name="value">The value that element 0 will be initialized to.</param>
1199 /// <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>
1200 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1201 public static Vector512<double> CreateScalar(double value) => CreateScalar<double>(value);
1203 /// <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>
1204 /// <param name="value">The value that element 0 will be initialized to.</param>
1205 /// <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>
1206 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1207 public static Vector512<short> CreateScalar(short value) => CreateScalar<short>(value);
1209 /// <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>
1210 /// <param name="value">The value that element 0 will be initialized to.</param>
1211 /// <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>
1212 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1213 public static Vector512<int> CreateScalar(int value) => CreateScalar<int>(value);
1215 /// <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>
1216 /// <param name="value">The value that element 0 will be initialized to.</param>
1217 /// <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>
1218 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1219 public static Vector512<long> CreateScalar(long value) => CreateScalar<long>(value);
1221 /// <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>
1222 /// <param name="value">The value that element 0 will be initialized to.</param>
1223 /// <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>
1224 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1225 public static Vector512<nint> CreateScalar(nint value) => CreateScalar<nint>(value);
1227 /// <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>
1228 /// <param name="value">The value that element 0 will be initialized to.</param>
1229 /// <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>
1230 [CLSCompliant(false)]
1231 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1232 public static Vector512<nuint> CreateScalar(nuint value) => CreateScalar<nuint>(value);
1234 /// <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>
1235 /// <param name="value">The value that element 0 will be initialized to.</param>
1236 /// <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>
1237 [CLSCompliant(false)]
1238 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1239 public static Vector512<sbyte> CreateScalar(sbyte value) => CreateScalar<sbyte>(value);
1241 /// <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>
1242 /// <param name="value">The value that element 0 will be initialized to.</param>
1243 /// <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>
1244 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1245 public static Vector512<float> CreateScalar(float value) => CreateScalar<float>(value);
1247 /// <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>
1248 /// <param name="value">The value that element 0 will be initialized to.</param>
1249 /// <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>
1250 [CLSCompliant(false)]
1251 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1252 public static Vector512<ushort> CreateScalar(ushort value) => CreateScalar<ushort>(value);
1254 /// <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>
1255 /// <param name="value">The value that element 0 will be initialized to.</param>
1256 /// <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>
1257 [CLSCompliant(false)]
1258 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1259 public static Vector512<uint> CreateScalar(uint value) => CreateScalar<uint>(value);
1261 /// <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>
1262 /// <param name="value">The value that element 0 will be initialized to.</param>
1263 /// <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>
1264 [CLSCompliant(false)]
1265 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1266 public static Vector512<ulong> CreateScalar(ulong value) => CreateScalar<ulong>(value);
1268 /// <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>
1269 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1270 /// <param name="value">The value that element 0 will be initialized to.</param>
1271 /// <returns>A new <see cref="Vector512{T}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1272 /// <exception cref="NotSupportedException">The type of <paramref name="value" /> (<typeparamref name="T" />) is not supported.</exception>
1274 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1275 public static Vector512<T> CreateScalarUnsafe<T>(T value)
1277 // This relies on us stripping the "init" flag from the ".locals"
1278 // declaration to let the upper bits be uninitialized.
1280 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
1281 Unsafe.SkipInit(out Vector512<T> result);
1283 result.SetElementUnsafe(0, value);
1287 /// <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>
1288 /// <param name="value">The value that element 0 will be initialized to.</param>
1289 /// <returns>A new <see cref="Vector512{Byte}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1291 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1292 public static Vector512<byte> CreateScalarUnsafe(byte value) => CreateScalarUnsafe<byte>(value);
1294 /// <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>
1295 /// <param name="value">The value that element 0 will be initialized to.</param>
1296 /// <returns>A new <see cref="Vector512{Double}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1298 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1299 public static Vector512<double> CreateScalarUnsafe(double value) => CreateScalarUnsafe<double>(value);
1301 /// <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>
1302 /// <param name="value">The value that element 0 will be initialized to.</param>
1303 /// <returns>A new <see cref="Vector512{Int16}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1305 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1306 public static Vector512<short> CreateScalarUnsafe(short value) => CreateScalarUnsafe<short>(value);
1308 /// <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>
1309 /// <param name="value">The value that element 0 will be initialized to.</param>
1310 /// <returns>A new <see cref="Vector512{Int32}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1312 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1313 public static Vector512<int> CreateScalarUnsafe(int value) => CreateScalarUnsafe<int>(value);
1315 /// <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>
1316 /// <param name="value">The value that element 0 will be initialized to.</param>
1317 /// <returns>A new <see cref="Vector512{Int64}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1319 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1320 public static Vector512<long> CreateScalarUnsafe(long value) => CreateScalarUnsafe<long>(value);
1322 /// <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>
1323 /// <param name="value">The value that element 0 will be initialized to.</param>
1324 /// <returns>A new <see cref="Vector512{IntPtr}" /> instance with the first element initialized to <paramref name="value"/> and the remaining elements left uninitialized.</returns>
1326 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1327 public static Vector512<nint> CreateScalarUnsafe(nint value) => CreateScalarUnsafe<nint>(value);
1329 /// <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>
1330 /// <param name="value">The value that element 0 will be initialized to.</param>
1331 /// <returns>A new <see cref="Vector512{UIntPtr}" /> instance with the first element initialized to <paramref name="value"/> and the remaining elements left uninitialized.</returns>
1333 [CLSCompliant(false)]
1334 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1335 public static Vector512<nuint> CreateScalarUnsafe(nuint value) => CreateScalarUnsafe<nuint>(value);
1337 /// <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>
1338 /// <param name="value">The value that element 0 will be initialized to.</param>
1339 /// <returns>A new <see cref="Vector512{SByte}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1341 [CLSCompliant(false)]
1342 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1343 public static Vector512<sbyte> CreateScalarUnsafe(sbyte value) => CreateScalarUnsafe<sbyte>(value);
1345 /// <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>
1346 /// <param name="value">The value that element 0 will be initialized to.</param>
1347 /// <returns>A new <see cref="Vector512{Single}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1349 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1350 public static Vector512<float> CreateScalarUnsafe(float value) => CreateScalarUnsafe<float>(value);
1352 /// <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>
1353 /// <param name="value">The value that element 0 will be initialized to.</param>
1354 /// <returns>A new <see cref="Vector512{UInt16}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1356 [CLSCompliant(false)]
1357 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1358 public static Vector512<ushort> CreateScalarUnsafe(ushort value) => CreateScalarUnsafe<ushort>(value);
1360 /// <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>
1361 /// <param name="value">The value that element 0 will be initialized to.</param>
1362 /// <returns>A new <see cref="Vector512{UInt32}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1364 [CLSCompliant(false)]
1365 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1366 public static Vector512<uint> CreateScalarUnsafe(uint value) => CreateScalarUnsafe<uint>(value);
1368 /// <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>
1369 /// <param name="value">The value that element 0 will be initialized to.</param>
1370 /// <returns>A new <see cref="Vector512{UInt64}" /> instance with the first element initialized to <paramref name="value" /> and the remaining elements left uninitialized.</returns>
1372 [CLSCompliant(false)]
1373 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1374 public static Vector512<ulong> CreateScalarUnsafe(ulong value) => CreateScalarUnsafe<ulong>(value);
1376 /// <summary>Divides two vectors to compute their quotient.</summary>
1377 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1378 /// <param name="left">The vector that will be divided by <paramref name="right" />.</param>
1379 /// <param name="right">The vector that will divide <paramref name="left" />.</param>
1380 /// <returns>The quotient of <paramref name="left" /> divided by <paramref name="right" />.</returns>
1381 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1383 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1384 public static Vector512<T> Divide<T>(Vector512<T> left, Vector512<T> right)
1387 Vector256.Divide(left._lower, right._lower),
1388 Vector256.Divide(left._upper, right._upper)
1392 /// <summary>Divides a vector by a scalar to compute the per-element quotient.</summary>
1393 /// <param name="left">The vector that will be divided by <paramref name="right" />.</param>
1394 /// <param name="right">The scalar that will divide <paramref name="left" />.</param>
1395 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1396 /// <returns>The quotient of <paramref name="left" /> divided by <paramref name="right" />.</returns>
1398 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1399 public static Vector512<T> Divide<T>(Vector512<T> left, T right) => left / right;
1401 /// <summary>Computes the dot product of two vectors.</summary>
1402 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1403 /// <param name="left">The vector that will be dotted with <paramref name="right" />.</param>
1404 /// <param name="right">The vector that will be dotted with <paramref name="left" />.</param>
1405 /// <returns>The dot product of <paramref name="left" /> and <paramref name="right" />.</returns>
1406 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1408 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1409 public static T Dot<T>(Vector512<T> left, Vector512<T> right)
1411 // Doing this as Dot(lower) + Dot(upper) is important for floating-point determinism
1412 // This is because the underlying dpps instruction on x86/x64 will do this equivalently
1413 // and otherwise the software vs accelerated implementations may differ in returned result.
1415 T result = Vector256.Dot(left._lower, right._lower);
1416 result = Scalar<T>.Add(result, Vector256.Dot(left._upper, right._upper));
1420 /// <summary>Compares two vectors to determine if they are equal on a per-element basis.</summary>
1421 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1422 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1423 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1424 /// <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>
1425 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1427 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1428 public static Vector512<T> Equals<T>(Vector512<T> left, Vector512<T> right)
1431 Vector256.Equals(left._lower, right._lower),
1432 Vector256.Equals(left._upper, right._upper)
1436 /// <summary>Compares two vectors to determine if all elements are equal.</summary>
1437 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1438 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1439 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1440 /// <returns><c>true</c> if all elements in <paramref name="left" /> were equal to the corresponding element in <paramref name="right" />.</returns>
1441 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1443 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1444 public static bool EqualsAll<T>(Vector512<T> left, Vector512<T> right) => left == right;
1446 /// <summary>Compares two vectors to determine if any elements are equal.</summary>
1447 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1448 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1449 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1450 /// <returns><c>true</c> if any elements in <paramref name="left" /> was equal to the corresponding element in <paramref name="right" />.</returns>
1451 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1453 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1454 public static bool EqualsAny<T>(Vector512<T> left, Vector512<T> right)
1456 return Vector256.EqualsAny(left._lower, right._lower)
1457 || Vector256.EqualsAny(left._upper, right._upper);
1460 /// <summary>Extracts the most significant bit from each element in a vector.</summary>
1461 /// <param name="vector">The vector whose elements should have their most significant bit extracted.</param>
1462 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1463 /// <returns>The packed most significant bits extracted from the elements in <paramref name="vector" />.</returns>
1464 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
1466 [CLSCompliant(false)]
1467 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1468 public static ulong ExtractMostSignificantBits<T>(this Vector512<T> vector)
1470 ulong result = vector._lower.ExtractMostSignificantBits();
1471 result |= (ulong)(vector._upper.ExtractMostSignificantBits()) << Vector256<T>.Count;
1475 /// <summary>Computes the floor of each element in a vector.</summary>
1476 /// <param name="vector">The vector that will have its floor computed.</param>
1477 /// <returns>A vector whose elements are the floor of the elements in <paramref name="vector" />.</returns>
1478 /// <seealso cref="MathF.Floor(float)" />
1480 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1481 public static Vector512<float> Floor(Vector512<float> vector)
1484 Vector256.Floor(vector._lower),
1485 Vector256.Floor(vector._upper)
1489 /// <summary>Computes the floor of each element in a vector.</summary>
1490 /// <param name="vector">The vector that will have its floor computed.</param>
1491 /// <returns>A vector whose elements are the floor of the elements in <paramref name="vector" />.</returns>
1492 /// <seealso cref="Math.Floor(double)" />
1494 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1495 public static Vector512<double> Floor(Vector512<double> vector)
1498 Vector256.Floor(vector._lower),
1499 Vector256.Floor(vector._upper)
1503 /// <summary>Gets the element at the specified index.</summary>
1504 /// <typeparam name="T">The type of the input vector.</typeparam>
1505 /// <param name="vector">The vector to get the element from.</param>
1506 /// <param name="index">The index of the element to get.</param>
1507 /// <returns>The value of the element at <paramref name="index" />.</returns>
1508 /// <exception cref="ArgumentOutOfRangeException"><paramref name="index" /> was less than zero or greater than the number of elements.</exception>
1509 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
1511 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1512 public static T GetElement<T>(this Vector512<T> vector, int index)
1514 if ((uint)(index) >= (uint)(Vector512<T>.Count))
1516 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index);
1519 return vector.GetElementUnsafe(index);
1522 /// <summary>Gets the value of the lower 256-bits as a new <see cref="Vector256{T}" />.</summary>
1523 /// <typeparam name="T">The type of the input vector.</typeparam>
1524 /// <param name="vector">The vector to get the lower 256-bits from.</param>
1525 /// <returns>The value of the lower 256-bits as a new <see cref="Vector256{T}" />.</returns>
1526 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
1528 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1529 public static Vector256<T> GetLower<T>(this Vector512<T> vector)
1531 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
1532 return vector._lower;
1535 /// <summary>Gets the value of the upper 256-bits as a new <see cref="Vector256{T}" />.</summary>
1536 /// <typeparam name="T">The type of the input vector.</typeparam>
1537 /// <param name="vector">The vector to get the upper 256-bits from.</param>
1538 /// <returns>The value of the upper 256-bits as a new <see cref="Vector256{T}" />.</returns>
1539 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
1541 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1542 public static Vector256<T> GetUpper<T>(this Vector512<T> vector)
1544 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
1545 return vector._upper;
1548 /// <summary>Compares two vectors to determine which is greater on a per-element basis.</summary>
1549 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1550 /// <param name="left">The vector to compare with <paramref name="left" />.</param>
1551 /// <param name="right">The vector to compare with <paramref name="right" />.</param>
1552 /// <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>
1553 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1555 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1556 public static Vector512<T> GreaterThan<T>(Vector512<T> left, Vector512<T> right)
1559 Vector256.GreaterThan(left._lower, right._lower),
1560 Vector256.GreaterThan(left._upper, right._upper)
1564 /// <summary>Compares two vectors to determine if all elements are greater.</summary>
1565 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1566 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1567 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1568 /// <returns><c>true</c> if all elements in <paramref name="left" /> were greater than the corresponding element in <paramref name="right" />.</returns>
1569 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1571 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1572 public static bool GreaterThanAll<T>(Vector512<T> left, Vector512<T> right)
1574 return Vector256.GreaterThanAll(left._lower, right._lower)
1575 && Vector256.GreaterThanAll(left._upper, right._upper);
1578 /// <summary>Compares two vectors to determine if any elements are greater.</summary>
1579 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1580 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1581 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1582 /// <returns><c>true</c> if any elements in <paramref name="left" /> was greater than the corresponding element in <paramref name="right" />.</returns>
1583 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1585 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1586 public static bool GreaterThanAny<T>(Vector512<T> left, Vector512<T> right)
1588 return Vector256.GreaterThanAny(left._lower, right._lower)
1589 || Vector256.GreaterThanAny(left._upper, right._upper);
1592 /// <summary>Compares two vectors to determine which is greater or equal on a per-element basis.</summary>
1593 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1594 /// <param name="left">The vector to compare with <paramref name="left" />.</param>
1595 /// <param name="right">The vector to compare with <paramref name="right" />.</param>
1596 /// <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>
1597 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1599 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1600 public static Vector512<T> GreaterThanOrEqual<T>(Vector512<T> left, Vector512<T> right)
1603 Vector256.GreaterThanOrEqual(left._lower, right._lower),
1604 Vector256.GreaterThanOrEqual(left._upper, right._upper)
1608 /// <summary>Compares two vectors to determine if all elements are greater or equal.</summary>
1609 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1610 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1611 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1612 /// <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>
1613 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1615 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1616 public static bool GreaterThanOrEqualAll<T>(Vector512<T> left, Vector512<T> right)
1618 return Vector256.GreaterThanOrEqualAll(left._lower, right._lower)
1619 && Vector256.GreaterThanOrEqualAll(left._upper, right._upper);
1622 /// <summary>Compares two vectors to determine if any elements are greater or equal.</summary>
1623 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1624 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1625 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1626 /// <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>
1627 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1629 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1630 public static bool GreaterThanOrEqualAny<T>(Vector512<T> left, Vector512<T> right)
1632 return Vector256.GreaterThanOrEqualAny(left._lower, right._lower)
1633 || Vector256.GreaterThanOrEqualAny(left._upper, right._upper);
1636 /// <summary>Compares two vectors to determine which is less on a per-element basis.</summary>
1637 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1638 /// <param name="left">The vector to compare with <paramref name="left" />.</param>
1639 /// <param name="right">The vector to compare with <paramref name="right" />.</param>
1640 /// <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>
1641 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1643 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1644 public static Vector512<T> LessThan<T>(Vector512<T> left, Vector512<T> right)
1647 Vector256.LessThan(left._lower, right._lower),
1648 Vector256.LessThan(left._upper, right._upper)
1652 /// <summary>Compares two vectors to determine if all elements are less.</summary>
1653 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1654 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1655 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1656 /// <returns><c>true</c> if all elements in <paramref name="left" /> were less than the corresponding element in <paramref name="right" />.</returns>
1657 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1659 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1660 public static bool LessThanAll<T>(Vector512<T> left, Vector512<T> right)
1662 return Vector256.LessThanAll(left._lower, right._lower)
1663 && Vector256.LessThanAll(left._upper, right._upper);
1666 /// <summary>Compares two vectors to determine if any elements are less.</summary>
1667 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1668 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1669 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1670 /// <returns><c>true</c> if any elements in <paramref name="left" /> was less than the corresponding element in <paramref name="right" />.</returns>
1671 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1673 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1674 public static bool LessThanAny<T>(Vector512<T> left, Vector512<T> right)
1676 return Vector256.LessThanAny(left._lower, right._lower)
1677 || Vector256.LessThanAny(left._upper, right._upper);
1680 /// <summary>Compares two vectors to determine which is less or equal on a per-element basis.</summary>
1681 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1682 /// <param name="left">The vector to compare with <paramref name="left" />.</param>
1683 /// <param name="right">The vector to compare with <paramref name="right" />.</param>
1684 /// <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>
1685 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1687 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1688 public static Vector512<T> LessThanOrEqual<T>(Vector512<T> left, Vector512<T> right)
1691 Vector256.LessThanOrEqual(left._lower, right._lower),
1692 Vector256.LessThanOrEqual(left._upper, right._upper)
1696 /// <summary>Compares two vectors to determine if all elements are less or equal.</summary>
1697 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1698 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1699 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1700 /// <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>
1701 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1703 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1704 public static bool LessThanOrEqualAll<T>(Vector512<T> left, Vector512<T> right)
1706 return Vector256.LessThanOrEqualAll(left._lower, right._lower)
1707 && Vector256.LessThanOrEqualAll(left._upper, right._upper);
1710 /// <summary>Compares two vectors to determine if any elements are less or equal.</summary>
1711 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1712 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1713 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1714 /// <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>
1715 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1717 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1718 public static bool LessThanOrEqualAny<T>(Vector512<T> left, Vector512<T> right)
1720 return Vector256.LessThanOrEqualAny(left._lower, right._lower)
1721 || Vector256.LessThanOrEqualAny(left._upper, right._upper);
1724 #pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T')
1725 /// <summary>Loads a vector from the given source.</summary>
1726 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1727 /// <param name="source">The source from which the vector will be loaded.</param>
1728 /// <returns>The vector loaded from <paramref name="source" />.</returns>
1729 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> (<typeparamref name="T" />) is not supported.</exception>
1731 [CLSCompliant(false)]
1732 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1733 public static Vector512<T> Load<T>(T* source) => LoadUnsafe(ref *source);
1735 /// <summary>Loads a vector from the given aligned source.</summary>
1736 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1737 /// <param name="source">The aligned source from which the vector will be loaded.</param>
1738 /// <returns>The vector loaded from <paramref name="source" />.</returns>
1739 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> (<typeparamref name="T" />) is not supported.</exception>
1741 [CLSCompliant(false)]
1742 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1743 public static Vector512<T> LoadAligned<T>(T* source)
1745 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
1747 if (((nuint)(source) % Alignment) != 0)
1749 ThrowHelper.ThrowAccessViolationException();
1752 return *(Vector512<T>*)(source);
1755 /// <summary>Loads a vector from the given aligned source.</summary>
1756 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1757 /// <param name="source">The aligned source from which the vector will be loaded.</param>
1758 /// <returns>The vector loaded from <paramref name="source" />.</returns>
1759 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> (<typeparamref name="T" />) is not supported.</exception>
1760 /// <remarks>This method may bypass the cache on certain platforms.</remarks>
1762 [CLSCompliant(false)]
1763 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1764 public static Vector512<T> LoadAlignedNonTemporal<T>(T* source) => LoadAligned(source);
1765 #pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T')
1767 /// <summary>Loads a vector from the given source.</summary>
1768 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1769 /// <param name="source">The source from which the vector will be loaded.</param>
1770 /// <returns>The vector loaded from <paramref name="source" />.</returns>
1771 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> (<typeparamref name="T" />) is not supported.</exception>
1773 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1774 public static Vector512<T> LoadUnsafe<T>(ref readonly T source)
1776 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
1777 ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.AsRef(in source));
1778 return Unsafe.ReadUnaligned<Vector512<T>>(in address);
1781 /// <summary>Loads a vector from the given source and element offset.</summary>
1782 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1783 /// <param name="source">The source to which <paramref name="elementOffset" /> will be added before loading the vector.</param>
1784 /// <param name="elementOffset">The element offset from <paramref name="source" /> from which the vector will be loaded.</param>
1785 /// <returns>The vector loaded from <paramref name="source" /> plus <paramref name="elementOffset" />.</returns>
1786 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> (<typeparamref name="T" />) is not supported.</exception>
1788 [CLSCompliant(false)]
1789 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1790 public static Vector512<T> LoadUnsafe<T>(ref readonly T source, nuint elementOffset)
1792 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
1793 ref readonly byte address = ref Unsafe.As<T, byte>(ref Unsafe.Add(ref Unsafe.AsRef(in source), (nint)elementOffset));
1794 return Unsafe.ReadUnaligned<Vector512<T>>(in address);
1797 /// <summary>Loads a vector from the given source and reinterprets it as <see cref="ushort"/>.</summary>
1798 /// <param name="source">The source from which the vector will be loaded.</param>
1799 /// <returns>The vector loaded from <paramref name="source" />.</returns>
1800 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1801 internal static Vector512<ushort> LoadUnsafe(ref char source) =>
1802 LoadUnsafe(ref Unsafe.As<char, ushort>(ref source));
1804 /// <summary>Loads a vector from the given source and element offset and reinterprets it as <see cref="ushort"/>.</summary>
1805 /// <param name="source">The source to which <paramref name="elementOffset" /> will be added before loading the vector.</param>
1806 /// <param name="elementOffset">The element offset from <paramref name="source" /> from which the vector will be loaded.</param>
1807 /// <returns>The vector loaded from <paramref name="source" /> plus <paramref name="elementOffset" />.</returns>
1808 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1809 internal static Vector512<ushort> LoadUnsafe(ref char source, nuint elementOffset) =>
1810 LoadUnsafe(ref Unsafe.As<char, ushort>(ref source), elementOffset);
1812 /// <summary>Computes the maximum of two vectors on a per-element basis.</summary>
1813 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1814 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1815 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1816 /// <returns>A vector whose elements are the maximum of the corresponding elements in <paramref name="left" /> and <paramref name="right" />.</returns>
1817 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1819 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1820 public static Vector512<T> Max<T>(Vector512<T> left, Vector512<T> right)
1823 Vector256.Max(left._lower, right._lower),
1824 Vector256.Max(left._upper, right._upper)
1828 /// <summary>Computes the minimum of two vectors on a per-element basis.</summary>
1829 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1830 /// <param name="left">The vector to compare with <paramref name="right" />.</param>
1831 /// <param name="right">The vector to compare with <paramref name="left" />.</param>
1832 /// <returns>A vector whose elements are the minimum of the corresponding elements in <paramref name="left" /> and <paramref name="right" />.</returns>
1833 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1835 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1836 public static Vector512<T> Min<T>(Vector512<T> left, Vector512<T> right)
1839 Vector256.Min(left._lower, right._lower),
1840 Vector256.Min(left._upper, right._upper)
1844 /// <summary>Multiplies two vectors to compute their element-wise product.</summary>
1845 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1846 /// <param name="left">The vector to multiply with <paramref name="right" />.</param>
1847 /// <param name="right">The vector to multiply with <paramref name="left" />.</param>
1848 /// <returns>The element-wise product of <paramref name="left" /> and <paramref name="right" />.</returns>
1849 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1851 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1852 public static Vector512<T> Multiply<T>(Vector512<T> left, Vector512<T> right) => left * right;
1854 /// <summary>Multiplies a vector by a scalar to compute their product.</summary>
1855 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1856 /// <param name="left">The vector to multiply with <paramref name="right" />.</param>
1857 /// <param name="right">The scalar to multiply with <paramref name="left" />.</param>
1858 /// <returns>The product of <paramref name="left" /> and <paramref name="right" />.</returns>
1859 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1861 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1862 public static Vector512<T> Multiply<T>(Vector512<T> left, T right) => left * right;
1864 /// <summary>Multiplies a vector by a scalar to compute their product.</summary>
1865 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1866 /// <param name="left">The scalar to multiply with <paramref name="right" />.</param>
1867 /// <param name="right">The vector to multiply with <paramref name="left" />.</param>
1868 /// <returns>The product of <paramref name="left" /> and <paramref name="right" />.</returns>
1869 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
1871 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1872 public static Vector512<T> Multiply<T>(T left, Vector512<T> right) => left * right;
1874 /// <summary>Narrows two <see cref="Vector512{Double}"/> instances into one <see cref="Vector512{Single}" />.</summary>
1875 /// <param name="lower">The vector that will be narrowed to the lower half of the result vector.</param>
1876 /// <param name="upper">The vector that will be narrowed to the upper half of the result vector.</param>
1877 /// <returns>A <see cref="Vector512{Single}"/> containing elements narrowed from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1879 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1880 public static Vector512<float> Narrow(Vector512<double> lower, Vector512<double> upper)
1883 Vector256.Narrow(lower._lower, lower._upper),
1884 Vector256.Narrow(upper._lower, upper._upper)
1888 /// <summary>Narrows two <see cref="Vector512{Int16}"/> instances into one <see cref="Vector512{SByte}" />.</summary>
1889 /// <param name="lower">The vector that will be narrowed to the lower half of the result vector.</param>
1890 /// <param name="upper">The vector that will be narrowed to the upper half of the result vector.</param>
1891 /// <returns>A <see cref="Vector512{SByte}"/> containing elements narrowed from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1893 [CLSCompliant(false)]
1894 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1895 public static Vector512<sbyte> Narrow(Vector512<short> lower, Vector512<short> upper)
1898 Vector256.Narrow(lower._lower, lower._upper),
1899 Vector256.Narrow(upper._lower, upper._upper)
1903 /// <summary>Narrows two <see cref="Vector512{Int32}"/> instances into one <see cref="Vector512{Int16}" />.</summary>
1904 /// <param name="lower">The vector that will be narrowed to the lower half of the result vector.</param>
1905 /// <param name="upper">The vector that will be narrowed to the upper half of the result vector.</param>
1906 /// <returns>A <see cref="Vector512{Int16}"/> containing elements narrowed from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1908 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1909 public static Vector512<short> Narrow(Vector512<int> lower, Vector512<int> upper)
1912 Vector256.Narrow(lower._lower, lower._upper),
1913 Vector256.Narrow(upper._lower, upper._upper)
1917 /// <summary>Narrows two <see cref="Vector512{Int64}"/> instances into one <see cref="Vector512{Int32}" />.</summary>
1918 /// <param name="lower">The vector that will be narrowed to the lower half of the result vector.</param>
1919 /// <param name="upper">The vector that will be narrowed to the upper half of the result vector.</param>
1920 /// <returns>A <see cref="Vector512{Int32}"/> containing elements narrowed from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1922 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1923 public static Vector512<int> Narrow(Vector512<long> lower, Vector512<long> upper)
1926 Vector256.Narrow(lower._lower, lower._upper),
1927 Vector256.Narrow(upper._lower, upper._upper)
1931 /// <summary>Narrows two <see cref="Vector512{UInt16}"/> instances into one <see cref="Vector512{Byte}" />.</summary>
1932 /// <param name="lower">The vector that will be narrowed to the lower half of the result vector.</param>
1933 /// <param name="upper">The vector that will be narrowed to the upper half of the result vector.</param>
1934 /// <returns>A <see cref="Vector512{Byte}"/> containing elements narrowed from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1936 [CLSCompliant(false)]
1937 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1938 public static Vector512<byte> Narrow(Vector512<ushort> lower, Vector512<ushort> upper)
1941 Vector256.Narrow(lower._lower, lower._upper),
1942 Vector256.Narrow(upper._lower, upper._upper)
1946 /// <summary>Narrows two <see cref="Vector512{UInt32}"/> instances into one <see cref="Vector512{UInt16}" />.</summary>
1947 /// <param name="lower">The vector that will be narrowed to the lower half of the result vector.</param>
1948 /// <param name="upper">The vector that will be narrowed to the upper half of the result vector.</param>
1949 /// <returns>A <see cref="Vector512{UInt16}"/> containing elements narrowed from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1951 [CLSCompliant(false)]
1952 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1953 public static Vector512<ushort> Narrow(Vector512<uint> lower, Vector512<uint> upper)
1956 Vector256.Narrow(lower._lower, lower._upper),
1957 Vector256.Narrow(upper._lower, upper._upper)
1961 /// <summary>Narrows two <see cref="Vector512{UInt64}"/> instances into one <see cref="Vector512{UInt32}" />.</summary>
1962 /// <param name="lower">The vector that will be narrowed to the lower half of the result vector.</param>
1963 /// <param name="upper">The vector that will be narrowed to the upper half of the result vector.</param>
1964 /// <returns>A <see cref="Vector512{UInt32}"/> containing elements narrowed from <paramref name="lower" /> and <paramref name="upper" />.</returns>
1966 [CLSCompliant(false)]
1967 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1968 public static Vector512<uint> Narrow(Vector512<ulong> lower, Vector512<ulong> upper)
1971 Vector256.Narrow(lower._lower, lower._upper),
1972 Vector256.Narrow(upper._lower, upper._upper)
1976 /// <summary>Negates a vector.</summary>
1977 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1978 /// <param name="vector">The vector to negate.</param>
1979 /// <returns>A vector whose elements are the negation of the corresponding elements in <paramref name="vector" />.</returns>
1980 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
1982 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1983 public static Vector512<T> Negate<T>(Vector512<T> vector) => -vector;
1985 /// <summary>Computes the ones-complement of a vector.</summary>
1986 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
1987 /// <param name="vector">The vector whose ones-complement is to be computed.</param>
1988 /// <returns>A vector whose elements are the ones-complement of the corresponding elements in <paramref name="vector" />.</returns>
1989 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
1991 [MethodImpl(MethodImplOptions.AggressiveInlining)]
1992 public static Vector512<T> OnesComplement<T>(Vector512<T> vector)
1995 Vector256.OnesComplement(vector._lower),
1996 Vector256.OnesComplement(vector._upper)
2000 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2001 /// <param name="vector">The vector whose elements are to be shifted.</param>
2002 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2003 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2005 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2006 public static Vector512<byte> ShiftLeft(Vector512<byte> vector, int shiftCount)
2009 Vector256.ShiftLeft(vector._lower, shiftCount),
2010 Vector256.ShiftLeft(vector._upper, shiftCount)
2014 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2015 /// <param name="vector">The vector whose elements are to be shifted.</param>
2016 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2017 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2019 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2020 public static Vector512<short> ShiftLeft(Vector512<short> vector, int shiftCount)
2023 Vector256.ShiftLeft(vector._lower, shiftCount),
2024 Vector256.ShiftLeft(vector._upper, shiftCount)
2028 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2029 /// <param name="vector">The vector whose elements are to be shifted.</param>
2030 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2031 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2033 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2034 public static Vector512<int> ShiftLeft(Vector512<int> vector, int shiftCount)
2037 Vector256.ShiftLeft(vector._lower, shiftCount),
2038 Vector256.ShiftLeft(vector._upper, shiftCount)
2042 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2043 /// <param name="vector">The vector whose elements are to be shifted.</param>
2044 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2045 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2047 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2048 public static Vector512<long> ShiftLeft(Vector512<long> vector, int shiftCount)
2051 Vector256.ShiftLeft(vector._lower, shiftCount),
2052 Vector256.ShiftLeft(vector._upper, shiftCount)
2056 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2057 /// <param name="vector">The vector whose elements are to be shifted.</param>
2058 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2059 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2061 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2062 public static Vector512<nint> ShiftLeft(Vector512<nint> vector, int shiftCount)
2065 Vector256.ShiftLeft(vector._lower, shiftCount),
2066 Vector256.ShiftLeft(vector._upper, shiftCount)
2070 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2071 /// <param name="vector">The vector whose elements are to be shifted.</param>
2072 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2073 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2075 [CLSCompliant(false)]
2076 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2077 public static Vector512<nuint> ShiftLeft(Vector512<nuint> vector, int shiftCount)
2080 Vector256.ShiftLeft(vector._lower, shiftCount),
2081 Vector256.ShiftLeft(vector._upper, shiftCount)
2085 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2086 /// <param name="vector">The vector whose elements are to be shifted.</param>
2087 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2088 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2090 [CLSCompliant(false)]
2091 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2092 public static Vector512<sbyte> ShiftLeft(Vector512<sbyte> vector, int shiftCount)
2095 Vector256.ShiftLeft(vector._lower, shiftCount),
2096 Vector256.ShiftLeft(vector._upper, shiftCount)
2100 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2101 /// <param name="vector">The vector whose elements are to be shifted.</param>
2102 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2103 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2105 [CLSCompliant(false)]
2106 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2107 public static Vector512<ushort> ShiftLeft(Vector512<ushort> vector, int shiftCount)
2110 Vector256.ShiftLeft(vector._lower, shiftCount),
2111 Vector256.ShiftLeft(vector._upper, shiftCount)
2115 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2116 /// <param name="vector">The vector whose elements are to be shifted.</param>
2117 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2118 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2120 [CLSCompliant(false)]
2121 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2122 public static Vector512<uint> ShiftLeft(Vector512<uint> vector, int shiftCount)
2125 Vector256.ShiftLeft(vector._lower, shiftCount),
2126 Vector256.ShiftLeft(vector._upper, shiftCount)
2130 /// <summary>Shifts each element of a vector left by the specified amount.</summary>
2131 /// <param name="vector">The vector whose elements are to be shifted.</param>
2132 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2133 /// <returns>A vector whose elements where shifted left by <paramref name="shiftCount" />.</returns>
2135 [CLSCompliant(false)]
2136 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2137 public static Vector512<ulong> ShiftLeft(Vector512<ulong> vector, int shiftCount)
2140 Vector256.ShiftLeft(vector._lower, shiftCount),
2141 Vector256.ShiftLeft(vector._upper, shiftCount)
2145 /// <summary>Shifts (signed) each element of a vector right by the specified amount.</summary>
2146 /// <param name="vector">The vector whose elements are to be shifted.</param>
2147 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2148 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2150 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2151 public static Vector512<short> ShiftRightArithmetic(Vector512<short> vector, int shiftCount)
2154 Vector256.ShiftRightArithmetic(vector._lower, shiftCount),
2155 Vector256.ShiftRightArithmetic(vector._upper, shiftCount)
2159 /// <summary>Shifts (signed) each element of a vector right by the specified amount.</summary>
2160 /// <param name="vector">The vector whose elements are to be shifted.</param>
2161 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2162 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2164 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2165 public static Vector512<int> ShiftRightArithmetic(Vector512<int> vector, int shiftCount)
2168 Vector256.ShiftRightArithmetic(vector._lower, shiftCount),
2169 Vector256.ShiftRightArithmetic(vector._upper, shiftCount)
2173 /// <summary>Shifts (signed) each element of a vector right by the specified amount.</summary>
2174 /// <param name="vector">The vector whose elements are to be shifted.</param>
2175 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2176 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2178 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2179 public static Vector512<long> ShiftRightArithmetic(Vector512<long> vector, int shiftCount)
2182 Vector256.ShiftRightArithmetic(vector._lower, shiftCount),
2183 Vector256.ShiftRightArithmetic(vector._upper, shiftCount)
2187 /// <summary>Shifts (signed) each element of a vector right by the specified amount.</summary>
2188 /// <param name="vector">The vector whose elements are to be shifted.</param>
2189 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2190 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2192 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2193 public static Vector512<nint> ShiftRightArithmetic(Vector512<nint> vector, int shiftCount)
2196 Vector256.ShiftRightArithmetic(vector._lower, shiftCount),
2197 Vector256.ShiftRightArithmetic(vector._upper, shiftCount)
2201 /// <summary>Shifts (signed) each element of a vector right by the specified amount.</summary>
2202 /// <param name="vector">The vector whose elements are to be shifted.</param>
2203 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2204 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2206 [CLSCompliant(false)]
2207 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2208 public static Vector512<sbyte> ShiftRightArithmetic(Vector512<sbyte> vector, int shiftCount)
2211 Vector256.ShiftRightArithmetic(vector._lower, shiftCount),
2212 Vector256.ShiftRightArithmetic(vector._upper, shiftCount)
2216 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2217 /// <param name="vector">The vector whose elements are to be shifted.</param>
2218 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2219 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2221 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2222 public static Vector512<byte> ShiftRightLogical(Vector512<byte> vector, int shiftCount)
2225 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2226 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2230 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2231 /// <param name="vector">The vector whose elements are to be shifted.</param>
2232 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2233 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2235 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2236 public static Vector512<short> ShiftRightLogical(Vector512<short> vector, int shiftCount)
2239 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2240 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2244 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2245 /// <param name="vector">The vector whose elements are to be shifted.</param>
2246 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2247 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2249 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2250 public static Vector512<int> ShiftRightLogical(Vector512<int> vector, int shiftCount)
2253 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2254 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2258 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2259 /// <param name="vector">The vector whose elements are to be shifted.</param>
2260 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2261 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2263 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2264 public static Vector512<long> ShiftRightLogical(Vector512<long> vector, int shiftCount)
2267 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2268 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2272 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2273 /// <param name="vector">The vector whose elements are to be shifted.</param>
2274 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2275 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2277 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2278 public static Vector512<nint> ShiftRightLogical(Vector512<nint> vector, int shiftCount)
2281 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2282 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2286 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2287 /// <param name="vector">The vector whose elements are to be shifted.</param>
2288 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2289 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2291 [CLSCompliant(false)]
2292 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2293 public static Vector512<nuint> ShiftRightLogical(Vector512<nuint> vector, int shiftCount)
2296 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2297 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2301 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2302 /// <param name="vector">The vector whose elements are to be shifted.</param>
2303 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2304 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2306 [CLSCompliant(false)]
2307 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2308 public static Vector512<sbyte> ShiftRightLogical(Vector512<sbyte> vector, int shiftCount)
2311 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2312 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2316 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2317 /// <param name="vector">The vector whose elements are to be shifted.</param>
2318 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2319 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2321 [CLSCompliant(false)]
2322 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2323 public static Vector512<ushort> ShiftRightLogical(Vector512<ushort> vector, int shiftCount)
2326 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2327 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2331 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2332 /// <param name="vector">The vector whose elements are to be shifted.</param>
2333 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2334 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2336 [CLSCompliant(false)]
2337 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2338 public static Vector512<uint> ShiftRightLogical(Vector512<uint> vector, int shiftCount)
2341 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2342 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2346 /// <summary>Shifts (unsigned) each element of a vector right by the specified amount.</summary>
2347 /// <param name="vector">The vector whose elements are to be shifted.</param>
2348 /// <param name="shiftCount">The number of bits by which to shift each element.</param>
2349 /// <returns>A vector whose elements where shifted right by <paramref name="shiftCount" />.</returns>
2351 [CLSCompliant(false)]
2352 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2353 public static Vector512<ulong> ShiftRightLogical(Vector512<ulong> vector, int shiftCount)
2356 Vector256.ShiftRightLogical(vector._lower, shiftCount),
2357 Vector256.ShiftRightLogical(vector._upper, shiftCount)
2361 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2362 /// <param name="vector">The input vector from which values are selected.</param>
2363 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2364 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2366 public static Vector512<byte> Shuffle(Vector512<byte> vector, Vector512<byte> indices)
2368 Unsafe.SkipInit(out Vector512<byte> result);
2370 for (int index = 0; index < Vector512<byte>.Count; index++)
2372 byte selectedIndex = indices.GetElementUnsafe(index);
2373 byte selectedValue = 0;
2375 if (selectedIndex < Vector512<byte>.Count)
2377 selectedValue = vector.GetElementUnsafe(selectedIndex);
2379 result.SetElementUnsafe(index, selectedValue);
2385 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2386 /// <param name="vector">The input vector from which values are selected.</param>
2387 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2388 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2390 [CLSCompliant(false)]
2391 public static Vector512<sbyte> Shuffle(Vector512<sbyte> vector, Vector512<sbyte> indices)
2393 Unsafe.SkipInit(out Vector512<sbyte> result);
2395 for (int index = 0; index < Vector512<sbyte>.Count; index++)
2397 byte selectedIndex = (byte)indices.GetElementUnsafe(index);
2398 sbyte selectedValue = 0;
2400 if (selectedIndex < Vector512<sbyte>.Count)
2402 selectedValue = vector.GetElementUnsafe(selectedIndex);
2404 result.SetElementUnsafe(index, selectedValue);
2410 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2411 /// <param name="vector">The input vector from which values are selected.</param>
2412 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2413 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2415 public static Vector512<short> Shuffle(Vector512<short> vector, Vector512<short> indices)
2417 Unsafe.SkipInit(out Vector512<short> result);
2419 for (int index = 0; index < Vector512<short>.Count; index++)
2421 ushort selectedIndex = (ushort)indices.GetElementUnsafe(index);
2422 short selectedValue = 0;
2424 if (selectedIndex < Vector512<short>.Count)
2426 selectedValue = vector.GetElementUnsafe(selectedIndex);
2428 result.SetElementUnsafe(index, selectedValue);
2434 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2435 /// <param name="vector">The input vector from which values are selected.</param>
2436 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2437 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2439 [CLSCompliant(false)]
2440 public static Vector512<ushort> Shuffle(Vector512<ushort> vector, Vector512<ushort> indices)
2442 Unsafe.SkipInit(out Vector512<ushort> result);
2444 for (int index = 0; index < Vector512<ushort>.Count; index++)
2446 ushort selectedIndex = indices.GetElementUnsafe(index);
2447 ushort selectedValue = 0;
2449 if (selectedIndex < Vector512<ushort>.Count)
2451 selectedValue = vector.GetElementUnsafe(selectedIndex);
2453 result.SetElementUnsafe(index, selectedValue);
2459 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2460 /// <param name="vector">The input vector from which values are selected.</param>
2461 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2462 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2464 public static Vector512<int> Shuffle(Vector512<int> vector, Vector512<int> indices)
2466 Unsafe.SkipInit(out Vector512<int> result);
2468 for (int index = 0; index < Vector512<int>.Count; index++)
2470 uint selectedIndex = (uint)indices.GetElementUnsafe(index);
2471 int selectedValue = 0;
2473 if (selectedIndex < Vector512<int>.Count)
2475 selectedValue = vector.GetElementUnsafe((int)selectedIndex);
2477 result.SetElementUnsafe(index, selectedValue);
2483 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2484 /// <param name="vector">The input vector from which values are selected.</param>
2485 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2486 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2488 [CLSCompliant(false)]
2489 public static Vector512<uint> Shuffle(Vector512<uint> vector, Vector512<uint> indices)
2491 Unsafe.SkipInit(out Vector512<uint> result);
2493 for (int index = 0; index < Vector512<uint>.Count; index++)
2495 uint selectedIndex = indices.GetElementUnsafe(index);
2496 uint selectedValue = 0;
2498 if (selectedIndex < Vector512<uint>.Count)
2500 selectedValue = vector.GetElementUnsafe((int)selectedIndex);
2502 result.SetElementUnsafe(index, selectedValue);
2508 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2509 /// <param name="vector">The input vector from which values are selected.</param>
2510 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2511 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2513 public static Vector512<float> Shuffle(Vector512<float> vector, Vector512<int> indices)
2515 Unsafe.SkipInit(out Vector512<float> result);
2517 for (int index = 0; index < Vector512<float>.Count; index++)
2519 uint selectedIndex = (uint)indices.GetElementUnsafe(index);
2520 float selectedValue = 0;
2522 if (selectedIndex < Vector512<float>.Count)
2524 selectedValue = vector.GetElementUnsafe((int)selectedIndex);
2526 result.SetElementUnsafe(index, selectedValue);
2532 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2533 /// <param name="vector">The input vector from which values are selected.</param>
2534 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2535 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2537 public static Vector512<long> Shuffle(Vector512<long> vector, Vector512<long> indices)
2539 Unsafe.SkipInit(out Vector512<long> result);
2541 for (int index = 0; index < Vector512<long>.Count; index++)
2543 ulong selectedIndex = (ulong)indices.GetElementUnsafe(index);
2544 long selectedValue = 0;
2546 if (selectedIndex < (uint)Vector512<long>.Count)
2548 selectedValue = vector.GetElementUnsafe((int)selectedIndex);
2550 result.SetElementUnsafe(index, selectedValue);
2556 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2557 /// <param name="vector">The input vector from which values are selected.</param>
2558 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2559 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2561 [CLSCompliant(false)]
2562 public static Vector512<ulong> Shuffle(Vector512<ulong> vector, Vector512<ulong> indices)
2564 Unsafe.SkipInit(out Vector512<ulong> result);
2566 for (int index = 0; index < Vector512<ulong>.Count; index++)
2568 ulong selectedIndex = indices.GetElementUnsafe(index);
2569 ulong selectedValue = 0;
2571 if (selectedIndex < (uint)Vector512<ulong>.Count)
2573 selectedValue = vector.GetElementUnsafe((int)selectedIndex);
2575 result.SetElementUnsafe(index, selectedValue);
2581 /// <summary>Creates a new vector by selecting values from an input vector using a set of indices.</summary>
2582 /// <param name="vector">The input vector from which values are selected.</param>
2583 /// <param name="indices">The per-element indices used to select a value from <paramref name="vector" />.</param>
2584 /// <returns>A new vector containing the values from <paramref name="vector" /> selected by the given <paramref name="indices" />.</returns>
2586 public static Vector512<double> Shuffle(Vector512<double> vector, Vector512<long> indices)
2588 Unsafe.SkipInit(out Vector512<double> result);
2590 for (int index = 0; index < Vector512<double>.Count; index++)
2592 ulong selectedIndex = (ulong)indices.GetElementUnsafe(index);
2593 double selectedValue = 0;
2595 if (selectedIndex < (uint)Vector512<double>.Count)
2597 selectedValue = vector.GetElementUnsafe((int)selectedIndex);
2599 result.SetElementUnsafe(index, selectedValue);
2605 /// <summary>Computes the square root of a vector on a per-element basis.</summary>
2606 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2607 /// <param name="vector">The vector whose square root is to be computed.</param>
2608 /// <returns>A vector whose elements are the square root of the corresponding elements in <paramref name="vector" />.</returns>
2609 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
2611 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2612 public static Vector512<T> Sqrt<T>(Vector512<T> vector)
2615 Vector256.Sqrt(vector._lower),
2616 Vector256.Sqrt(vector._upper)
2620 #pragma warning disable CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T')
2621 /// <summary>Stores a vector at the given destination.</summary>
2622 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2623 /// <param name="source">The vector that will be stored.</param>
2624 /// <param name="destination">The destination at which <paramref name="source" /> will be stored.</param>
2625 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
2627 [CLSCompliant(false)]
2628 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2629 public static void Store<T>(this Vector512<T> source, T* destination) => source.StoreUnsafe(ref *destination);
2631 /// <summary>Stores a vector at the given aligned destination.</summary>
2632 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2633 /// <param name="source">The vector that will be stored.</param>
2634 /// <param name="destination">The aligned destination at which <paramref name="source" /> will be stored.</param>
2635 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
2637 [CLSCompliant(false)]
2638 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2639 public static void StoreAligned<T>(this Vector512<T> source, T* destination)
2641 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
2643 if (((nuint)(destination) % Alignment) != 0)
2645 ThrowHelper.ThrowAccessViolationException();
2648 *(Vector512<T>*)(destination) = source;
2651 /// <summary>Stores a vector at the given aligned destination.</summary>
2652 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2653 /// <param name="source">The vector that will be stored.</param>
2654 /// <param name="destination">The aligned destination at which <paramref name="source" /> will be stored.</param>
2655 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
2656 /// <remarks>This method may bypass the cache on certain platforms.</remarks>
2658 [CLSCompliant(false)]
2659 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2660 public static void StoreAlignedNonTemporal<T>(this Vector512<T> source, T* destination) => source.StoreAligned(destination);
2661 #pragma warning restore CS8500 // This takes the address of, gets the size of, or declares a pointer to a managed type ('T')
2663 /// <summary>Stores a vector at the given destination.</summary>
2664 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2665 /// <param name="source">The vector that will be stored.</param>
2666 /// <param name="destination">The destination at which <paramref name="source" /> will be stored.</param>
2667 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
2669 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2670 public static void StoreUnsafe<T>(this Vector512<T> source, ref T destination)
2672 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
2673 ref byte address = ref Unsafe.As<T, byte>(ref destination);
2674 Unsafe.WriteUnaligned(ref address, source);
2677 /// <summary>Stores a vector at the given destination.</summary>
2678 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2679 /// <param name="source">The vector that will be stored.</param>
2680 /// <param name="destination">The destination to which <paramref name="elementOffset" /> will be added before the vector will be stored.</param>
2681 /// <param name="elementOffset">The element offset from <paramref name="destination" /> from which the vector will be stored.</param>
2682 /// <exception cref="NotSupportedException">The type of <paramref name="source" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
2684 [CLSCompliant(false)]
2685 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2686 public static void StoreUnsafe<T>(this Vector512<T> source, ref T destination, nuint elementOffset)
2688 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
2689 destination = ref Unsafe.Add(ref destination, (nint)elementOffset);
2690 Unsafe.WriteUnaligned(ref Unsafe.As<T, byte>(ref destination), source);
2693 /// <summary>Subtracts two vectors to compute their difference.</summary>
2694 /// <param name="left">The vector from which <paramref name="right" /> will be subtracted.</param>
2695 /// <param name="right">The vector to subtract from <paramref name="left" />.</param>
2696 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2697 /// <returns>The difference of <paramref name="left" /> and <paramref name="right" />.</returns>
2698 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
2700 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2701 public static Vector512<T> Subtract<T>(Vector512<T> left, Vector512<T> right) => left - right;
2703 /// <summary>Computes the sum of all elements in a vector.</summary>
2704 /// <param name="vector">The vector whose elements will be summed.</param>
2705 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
2706 /// <returns>The sum of all elements in <paramref name="vector" />.</returns>
2707 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
2709 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2710 public static T Sum<T>(Vector512<T> vector)
2712 // Doing this as Sum(lower) + Sum(upper) is important for floating-point determinism
2713 // This is because the underlying dpps instruction on x86/x64 will do this equivalently
2714 // and otherwise the software vs accelerated implementations may differ in returned result.
2716 T result = Vector256.Sum(vector._lower);
2717 result = Scalar<T>.Add(result, Vector256.Sum(vector._upper));
2721 /// <summary>Converts the given vector to a scalar containing the value of the first element.</summary>
2722 /// <typeparam name="T">The type of the input vector.</typeparam>
2723 /// <param name="vector">The vector to get the first element from.</param>
2724 /// <returns>A scalar <typeparamref name="T" /> containing the value of the first element.</returns>
2725 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
2727 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2728 public static T ToScalar<T>(this Vector512<T> vector)
2730 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
2731 return vector.GetElementUnsafe(0);
2734 /// <summary>Tries to copy a <see cref="Vector{T}" /> to a given span.</summary>
2735 /// <typeparam name="T">The type of the input vector.</typeparam>
2736 /// <param name="vector">The vector to copy.</param>
2737 /// <param name="destination">The span to which <paramref name="destination" /> is copied.</param>
2738 /// <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>
2739 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> and <paramref name="destination" /> (<typeparamref name="T" />) is not supported.</exception>
2740 public static bool TryCopyTo<T>(this Vector512<T> vector, Span<T> destination)
2742 if ((uint)destination.Length < (uint)Vector512<T>.Count)
2747 ref byte address = ref Unsafe.As<T, byte>(ref MemoryMarshal.GetReference(destination));
2748 Unsafe.WriteUnaligned(ref address, vector);
2752 /// <summary>Widens a <see cref="Vector512{Byte}" /> into two <see cref="Vector512{UInt16} " />.</summary>
2753 /// <param name="source">The vector whose elements are to be widened.</param>
2754 /// <returns>A pair of vectors that contain the widened lower and upper halves of <paramref name="source" />.</returns>
2755 [CLSCompliant(false)]
2756 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2757 public static (Vector512<ushort> Lower, Vector512<ushort> Upper) Widen(Vector512<byte> source) => (WidenLower(source), WidenUpper(source));
2759 /// <summary>Widens a <see cref="Vector512{Int16}" /> into two <see cref="Vector512{Int32} " />.</summary>
2760 /// <param name="source">The vector whose elements are to be widened.</param>
2761 /// <returns>A pair of vectors that contain the widened lower and upper halves of <paramref name="source" />.</returns>
2762 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2763 public static (Vector512<int> Lower, Vector512<int> Upper) Widen(Vector512<short> source) => (WidenLower(source), WidenUpper(source));
2765 /// <summary>Widens a <see cref="Vector512{Int32}" /> into two <see cref="Vector512{Int64} " />.</summary>
2766 /// <param name="source">The vector whose elements are to be widened.</param>
2767 /// <returns>A pair of vectors that contain the widened lower and upper halves of <paramref name="source" />.</returns>
2768 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2769 public static (Vector512<long> Lower, Vector512<long> Upper) Widen(Vector512<int> source) => (WidenLower(source), WidenUpper(source));
2771 /// <summary>Widens a <see cref="Vector512{SByte}" /> into two <see cref="Vector512{Int16} " />.</summary>
2772 /// <param name="source">The vector whose elements are to be widened.</param>
2773 /// <returns>A pair of vectors that contain the widened lower and upper halves of <paramref name="source" />.</returns>
2774 [CLSCompliant(false)]
2775 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2776 public static (Vector512<short> Lower, Vector512<short> Upper) Widen(Vector512<sbyte> source) => (WidenLower(source), WidenUpper(source));
2778 /// <summary>Widens a <see cref="Vector512{Single}" /> into two <see cref="Vector512{Double} " />.</summary>
2779 /// <param name="source">The vector whose elements are to be widened.</param>
2780 /// <returns>A pair of vectors that contain the widened lower and upper halves of <paramref name="source" />.</returns>
2781 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2782 public static (Vector512<double> Lower, Vector512<double> Upper) Widen(Vector512<float> source) => (WidenLower(source), WidenUpper(source));
2784 /// <summary>Widens a <see cref="Vector512{UInt16}" /> into two <see cref="Vector512{UInt32} " />.</summary>
2785 /// <param name="source">The vector whose elements are to be widened.</param>
2786 /// <returns>A pair of vectors that contain the widened lower and upper halves of <paramref name="source" />.</returns>
2787 [CLSCompliant(false)]
2788 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2789 public static (Vector512<uint> Lower, Vector512<uint> Upper) Widen(Vector512<ushort> source) => (WidenLower(source), WidenUpper(source));
2791 /// <summary>Widens a <see cref="Vector512{UInt32}" /> into two <see cref="Vector512{UInt64} " />.</summary>
2792 /// <param name="source">The vector whose elements are to be widened.</param>
2793 /// <returns>A pair of vectors that contain the widened lower and upper halves of <paramref name="source" />.</returns>
2794 [CLSCompliant(false)]
2795 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2796 public static (Vector512<ulong> Lower, Vector512<ulong> Upper) Widen(Vector512<uint> source) => (WidenLower(source), WidenUpper(source));
2798 /// <summary>Widens the lower half of a <see cref="Vector512{Byte}" /> into a <see cref="Vector512{UInt16} " />.</summary>
2799 /// <param name="source">The vector whose elements are to be widened.</param>
2800 /// <returns>A vector that contain the widened lower half of <paramref name="source" />.</returns>
2802 [CLSCompliant(false)]
2803 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2804 public static Vector512<ushort> WidenLower(Vector512<byte> source)
2806 Vector256<byte> lower = source._lower;
2809 Vector256.WidenLower(lower),
2810 Vector256.WidenUpper(lower)
2814 /// <summary>Widens the lower half of a <see cref="Vector512{Int16}" /> into a <see cref="Vector512{Int32} " />.</summary>
2815 /// <param name="source">The vector whose elements are to be widened.</param>
2816 /// <returns>A vector that contain the widened lower half of <paramref name="source" />.</returns>
2818 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2819 public static Vector512<int> WidenLower(Vector512<short> source)
2821 Vector256<short> lower = source._lower;
2824 Vector256.WidenLower(lower),
2825 Vector256.WidenUpper(lower)
2829 /// <summary>Widens the lower half of a <see cref="Vector512{Int32}" /> into a <see cref="Vector512{Int64} " />.</summary>
2830 /// <param name="source">The vector whose elements are to be widened.</param>
2831 /// <returns>A vector that contain the widened lower half of <paramref name="source" />.</returns>
2833 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2834 public static Vector512<long> WidenLower(Vector512<int> source)
2836 Vector256<int> lower = source._lower;
2839 Vector256.WidenLower(lower),
2840 Vector256.WidenUpper(lower)
2844 /// <summary>Widens the lower half of a <see cref="Vector512{SByte}" /> into a <see cref="Vector512{Int16} " />.</summary>
2845 /// <param name="source">The vector whose elements are to be widened.</param>
2846 /// <returns>A vector that contain the widened lower half of <paramref name="source" />.</returns>
2848 [CLSCompliant(false)]
2849 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2850 public static Vector512<short> WidenLower(Vector512<sbyte> source)
2852 Vector256<sbyte> lower = source._lower;
2855 Vector256.WidenLower(lower),
2856 Vector256.WidenUpper(lower)
2859 /// <summary>Widens the lower half of a <see cref="Vector512{Single}" /> into a <see cref="Vector512{Double} " />.</summary>
2860 /// <param name="source">The vector whose elements are to be widened.</param>
2861 /// <returns>A vector that contain the widened lower half of <paramref name="source" />.</returns>
2863 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2864 public static Vector512<double> WidenLower(Vector512<float> source)
2866 Vector256<float> lower = source._lower;
2869 Vector256.WidenLower(lower),
2870 Vector256.WidenUpper(lower)
2874 /// <summary>Widens the lower half of a <see cref="Vector512{UInt16}" /> into a <see cref="Vector512{UInt32} " />.</summary>
2875 /// <param name="source">The vector whose elements are to be widened.</param>
2876 /// <returns>A vector that contain the widened lower half of <paramref name="source" />.</returns>
2878 [CLSCompliant(false)]
2879 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2880 public static Vector512<uint> WidenLower(Vector512<ushort> source)
2882 Vector256<ushort> lower = source._lower;
2885 Vector256.WidenLower(lower),
2886 Vector256.WidenUpper(lower)
2890 /// <summary>Widens the lower half of a <see cref="Vector512{UInt32}" /> into a <see cref="Vector512{UInt64} " />.</summary>
2891 /// <param name="source">The vector whose elements are to be widened.</param>
2892 /// <returns>A vector that contain the widened lower half of <paramref name="source" />.</returns>
2894 [CLSCompliant(false)]
2895 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2896 public static Vector512<ulong> WidenLower(Vector512<uint> source)
2898 Vector256<uint> lower = source._lower;
2901 Vector256.WidenLower(lower),
2902 Vector256.WidenUpper(lower)
2906 /// <summary>Widens the upper half of a <see cref="Vector512{Byte}" /> into a <see cref="Vector512{UInt16} " />.</summary>
2907 /// <param name="source">The vector whose elements are to be widened.</param>
2908 /// <returns>A vector that contain the widened upper half of <paramref name="source" />.</returns>
2910 [CLSCompliant(false)]
2911 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2912 public static Vector512<ushort> WidenUpper(Vector512<byte> source)
2914 Vector256<byte> upper = source._upper;
2917 Vector256.WidenLower(upper),
2918 Vector256.WidenUpper(upper)
2922 /// <summary>Widens the upper half of a <see cref="Vector512{Int16}" /> into a <see cref="Vector512{Int32} " />.</summary>
2923 /// <param name="source">The vector whose elements are to be widened.</param>
2924 /// <returns>A vector that contain the widened upper half of <paramref name="source" />.</returns>
2926 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2927 public static Vector512<int> WidenUpper(Vector512<short> source)
2929 Vector256<short> upper = source._upper;
2932 Vector256.WidenLower(upper),
2933 Vector256.WidenUpper(upper)
2937 /// <summary>Widens the upper half of a <see cref="Vector512{Int32}" /> into a <see cref="Vector512{Int64} " />.</summary>
2938 /// <param name="source">The vector whose elements are to be widened.</param>
2939 /// <returns>A vector that contain the widened upper half of <paramref name="source" />.</returns>
2941 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2942 public static Vector512<long> WidenUpper(Vector512<int> source)
2944 Vector256<int> upper = source._upper;
2947 Vector256.WidenLower(upper),
2948 Vector256.WidenUpper(upper)
2952 /// <summary>Widens the upper half of a <see cref="Vector512{SByte}" /> into a <see cref="Vector512{Int16} " />.</summary>
2953 /// <param name="source">The vector whose elements are to be widened.</param>
2954 /// <returns>A vector that contain the widened upper half of <paramref name="source" />.</returns>
2956 [CLSCompliant(false)]
2957 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2958 public static Vector512<short> WidenUpper(Vector512<sbyte> source)
2960 Vector256<sbyte> upper = source._upper;
2963 Vector256.WidenLower(upper),
2964 Vector256.WidenUpper(upper)
2968 /// <summary>Widens the upper half of a <see cref="Vector512{Single}" /> into a <see cref="Vector512{Double} " />.</summary>
2969 /// <param name="source">The vector whose elements are to be widened.</param>
2970 /// <returns>A vector that contain the widened upper half of <paramref name="source" />.</returns>
2972 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2973 public static Vector512<double> WidenUpper(Vector512<float> source)
2975 Vector256<float> upper = source._upper;
2978 Vector256.WidenLower(upper),
2979 Vector256.WidenUpper(upper)
2983 /// <summary>Widens the upper half of a <see cref="Vector512{UInt16}" /> into a <see cref="Vector512{UInt32} " />.</summary>
2984 /// <param name="source">The vector whose elements are to be widened.</param>
2985 /// <returns>A vector that contain the widened upper half of <paramref name="source" />.</returns>
2987 [CLSCompliant(false)]
2988 [MethodImpl(MethodImplOptions.AggressiveInlining)]
2989 public static Vector512<uint> WidenUpper(Vector512<ushort> source)
2991 Vector256<ushort> upper = source._upper;
2994 Vector256.WidenLower(upper),
2995 Vector256.WidenUpper(upper)
2999 /// <summary>Widens the upper half of a <see cref="Vector512{UInt32}" /> into a <see cref="Vector512{UInt64} " />.</summary>
3000 /// <param name="source">The vector whose elements are to be widened.</param>
3001 /// <returns>A vector that contain the widened upper half of <paramref name="source" />.</returns>
3003 [CLSCompliant(false)]
3004 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3005 public static Vector512<ulong> WidenUpper(Vector512<uint> source)
3007 Vector256<uint> upper = source._upper;
3010 Vector256.WidenLower(upper),
3011 Vector256.WidenUpper(upper)
3015 /// <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>
3016 /// <typeparam name="T">The type of the input vector.</typeparam>
3017 /// <param name="vector">The vector to get the remaining elements from.</param>
3018 /// <param name="index">The index of the element to set.</param>
3019 /// <param name="value">The value to set the element to.</param>
3020 /// <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>
3021 /// <exception cref="ArgumentOutOfRangeException"><paramref name="index" /> was less than zero or greater than the number of elements.</exception>
3022 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
3024 public static Vector512<T> WithElement<T>(this Vector512<T> vector, int index, T value)
3026 if ((uint)(index) >= (uint)(Vector512<T>.Count))
3028 ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index);
3031 Vector512<T> result = vector;
3032 result.SetElementUnsafe(index, value);
3036 /// <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>
3037 /// <typeparam name="T">The type of the input vector.</typeparam>
3038 /// <param name="vector">The vector to get the upper 256-bits from.</param>
3039 /// <param name="value">The value of the lower 256-bits as a <see cref="Vector256{T}" />.</param>
3040 /// <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>
3041 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
3043 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3044 public static Vector512<T> WithLower<T>(this Vector512<T> vector, Vector256<T> value)
3046 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
3048 Vector512<T> result = vector;
3049 result.SetLowerUnsafe(value);
3053 /// <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>
3054 /// <typeparam name="T">The type of the input vector.</typeparam>
3055 /// <param name="vector">The vector to get the lower 256-bits from.</param>
3056 /// <param name="value">The value of the upper 256-bits as a <see cref="Vector256{T}" />.</param>
3057 /// <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>
3058 /// <exception cref="NotSupportedException">The type of <paramref name="vector" /> (<typeparamref name="T" />) is not supported.</exception>
3060 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3061 public static Vector512<T> WithUpper<T>(this Vector512<T> vector, Vector256<T> value)
3063 ThrowHelper.ThrowForUnsupportedIntrinsicsVector512BaseType<T>();
3065 Vector512<T> result = vector;
3066 result.SetUpperUnsafe(value);
3070 /// <summary>Computes the exclusive-or of two vectors.</summary>
3071 /// <typeparam name="T">The type of the elements in the vector.</typeparam>
3072 /// <param name="left">The vector to exclusive-or with <paramref name="right" />.</param>
3073 /// <param name="right">The vector to exclusive-or with <paramref name="left" />.</param>
3074 /// <returns>The exclusive-or of <paramref name="left" /> and <paramref name="right" />.</returns>
3075 /// <exception cref="NotSupportedException">The type of <paramref name="left" /> and <paramref name="right" /> (<typeparamref name="T" />) is not supported.</exception>
3077 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3078 public static Vector512<T> Xor<T>(Vector512<T> left, Vector512<T> right) => left ^ right;
3080 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3081 internal static T GetElementUnsafe<T>(in this Vector512<T> vector, int index)
3083 Debug.Assert((index >= 0) && (index < Vector512<T>.Count));
3084 ref T address = ref Unsafe.As<Vector512<T>, T>(ref Unsafe.AsRef(in vector));
3085 return Unsafe.Add(ref address, index);
3088 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3089 internal static void SetElementUnsafe<T>(in this Vector512<T> vector, int index, T value)
3091 Debug.Assert((index >= 0) && (index < Vector512<T>.Count));
3092 ref T address = ref Unsafe.As<Vector512<T>, T>(ref Unsafe.AsRef(in vector));
3093 Unsafe.Add(ref address, index) = value;
3096 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3097 internal static void SetLowerUnsafe<T>(in this Vector512<T> vector, Vector256<T> value)
3099 Unsafe.AsRef(in vector._lower) = value;
3102 [MethodImpl(MethodImplOptions.AggressiveInlining)]
3103 internal static void SetUpperUnsafe<T>(in this Vector512<T> vector, Vector256<T> value)
3105 Unsafe.AsRef(in vector._upper) = value;