Vector<T> 结构

定义

表示指定数值类型(适用于并行算法的低级别优化)的单个向量。

generic <typename T>
 where T : value classpublic value class Vector : IEquatable<System::Numerics::Vector<T>>, IFormattable
generic <typename T>
public value class Vector : IEquatable<System::Numerics::Vector<T>>, IFormattable
public struct Vector<T> : IEquatable<System.Numerics.Vector<T>>, IFormattable where T : struct
public readonly struct Vector<T> : IEquatable<System.Numerics.Vector<T>>, IFormattable where T : struct
public readonly struct Vector<T> : IEquatable<System.Numerics.Vector<T>>, IFormattable
type Vector<'T (requires 'T : struct)> = struct
    interface IFormattable
type Vector<'T> = struct
    interface IFormattable
Public Structure Vector(Of T)
Implements IEquatable(Of Vector(Of T)), IFormattable

类型参数

T

向量中元素的类型。 T 可以是任何基元数值类型。

继承
Vector<T>
实现

注解

Vector<T> 是一个不可变结构,表示指定数值类型的单个向量。 实例计数是固定的 Vector<T> ,但其上限依赖于 CPU 寄存器。 它旨在用作向量化大型算法的构建基块,因此不能直接用作任意长度向量或张量。

结构 Vector<T> 支持硬件加速。

本文中的术语 基元数值数据类型 是指 CPU 直接支持的数值数据类型,并且具有可操作这些数据类型的指令。

构造函数

Vector<T>(ReadOnlySpan<Byte>)

根据给定的只读字节跨度构造一个矢量。

Vector<T>(ReadOnlySpan<T>)

根据给定的 ReadOnlySpan<T> 构造一个向量。

Vector<T>(Span<T>)

根据给定的 Span<T> 构造一个向量。

Vector<T>(T)

创建其组件为指定类型的向量。

Vector<T>(T[])

从指定数组创建一个向量。

Vector<T>(T[], Int32)

于指定索引位置开始,从指定数组创建一个向量。

属性

AllBitsSet

获取一个新的 Vector<T>,并将所有位设置为 1。

Count

返回存储在向量中的元素数量。

Indices

表示指定数值类型(适用于并行算法的低级别优化)的单个向量。

IsSupported

获取一个值,该值指示是否 T 受支持。

Item[Int32]

获取指定索引处的元素。

One

返回一个包含所有 1 的向量。

Zero

返回一个包含所有 0 的向量。

方法

CopyTo(Span<Byte>)

将向量复制到给定的 Span<T>

CopyTo(Span<T>)

请将向量复制到给定跨度。 .

CopyTo(T[])

将向量实例复制到指定的目标数组。

CopyTo(T[], Int32)

从指定索引位置开始,将向量实例复制到指定的目标数组中。

Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。

Equals(Vector<T>)

返回一个值,该值指示此实例是否与指定的向量相等。

GetHashCode()

返回此实例的哈希代码。

ToString()

通过使用默认格式设置,返回此向量的字符串表示形式。

ToString(String)

通过使用指定格式字符串设置各个元素的格式,来返回此向量的字符串表示形式。

ToString(String, IFormatProvider)

通过使用指定格式字符串设置各个元素的格式并使用指定格式提供程序定义特定于区域性的格式设置,来返回此向量的字符串表示形式。

TryCopyTo(Span<Byte>)

请尝试将向量复制到给定字节跨度。

TryCopyTo(Span<T>)

请尝试将向量复制到给定的 Span<T>

运算符

Addition(Vector<T>, Vector<T>)

将两个向量相加。

BitwiseAnd(Vector<T>, Vector<T>)

通过在两个向量中的每个元素上执行按位 And 运算,返回一个新向量。

BitwiseOr(Vector<T>, Vector<T>)

通过在两个向量中的每个元素上执行按位 Or 运算,返回一个新向量。

Division(Vector<T>, T)

将向量除以标量以计算每个元素的商。

Division(Vector<T>, Vector<T>)

将第一个向量除以第二个向量。

Equality(Vector<T>, Vector<T>)

返回一个值,该值指示两个指定向量中的每对元素是否相等。

ExclusiveOr(Vector<T>, Vector<T>)

通过在两个向量中的每个元素上执行按位 XOr 运算,返回一个新向量。

Explicit(Vector<T> to Vector<Byte>)

将指定向量的位重新解释为 Byte 类型的向量。

Explicit(Vector<T> to Vector<Double>)

将指定向量的位重新解释为 Double 类型的向量。

Explicit(Vector<T> to Vector<Int16>)

将指定向量的位重新解释为 Int16 类型的向量。

Explicit(Vector<T> to Vector<Int32>)

将指定向量的位重新解释为 Int32 类型的向量。

Explicit(Vector<T> to Vector<Int64>)

将指定向量的位重新解释为 Int64 类型的向量。

Explicit(Vector<T> to Vector<IntPtr>)

将源向量的位重新解释为本机大小整数的向量。

Explicit(Vector<T> to Vector<SByte>)

将指定向量的位重新解释为 SByte 类型的向量。

Explicit(Vector<T> to Vector<Single>)

将指定向量的位重新解释为 Single 类型的向量。

Explicit(Vector<T> to Vector<UInt16>)

将指定向量的位重新解释为 UInt16 类型的向量。

Explicit(Vector<T> to Vector<UInt32>)

将指定向量的位重新解释为 UInt32 类型的向量。

Explicit(Vector<T> to Vector<UInt64>)

将指定向量的位重新解释为 UInt64 类型的向量。

Explicit(Vector<T> to Vector<UIntPtr>)

将源向量的位重新解释为本机大小无符号整数的向量。

Inequality(Vector<T>, Vector<T>)

返回一个值,该值指示指定向量中的任意元素对是否相等。

LeftShift(Vector<T>, Int32)

将向量的每个元素左移指定量。

Multiply(T, Vector<T>)

将向量乘以指定标量值。

Multiply(Vector<T>, T)

将向量乘以指定标量值。

Multiply(Vector<T>, Vector<T>)

返回一个新向量,其值是两个指定向量中的每对元素的乘积。

OnesComplement(Vector<T>)

返回一个新向量,其元素是通过取用指定向量的元素的二进制反码来获取的。

RightShift(Vector<T>, Int32)

(向量右侧的每个元素) 有符号的偏移量。

Subtraction(Vector<T>, Vector<T>)

从第一个向量中减去第二个向量。

UnaryNegation(Vector<T>)

对给定向量求反。

UnaryPlus(Vector<T>)

返回未更改的给定向量。

UnsignedRightShift(Vector<T>, Int32)

将 (无符号) 向量右侧的每个元素按指定量移位。

扩展方法

As<TFrom,TTo>(Vector<TFrom>)

Vector<T> 重新解释为新的 Vector<T>

GetElement<T>(Vector<T>, Int32)

获取指定索引处的元素。

Store<T>(Vector<T>, T*)

将向量存储在给定目标处。

StoreAligned<T>(Vector<T>, T*)

将矢量存储在给定的对齐目标处。

StoreAlignedNonTemporal<T>(Vector<T>, T*)

将矢量存储在给定的对齐目标处。

StoreUnsafe<T>(Vector<T>, T)

将向量存储在给定目标处。

StoreUnsafe<T>(Vector<T>, T, UIntPtr)

将向量存储在给定目标处。

ToScalar<T>(Vector<T>)

将给定向量转换为包含第一个元素的值的标量。

WithElement<T>(Vector<T>, Int32, T)

创建一个新的 Vector<T>,将指定索引处的元素设置为指定值,并将其余元素设置为与给定向量中的值相同的值。

AsVector128<T>(Vector<T>)

Vector<T> 重新解释为新的 Vector128<T>

AsVector256<T>(Vector<T>)

Vector<T> 重新解释为新的 Vector256<T>

AsVector512<T>(Vector<T>)

Vector<T> 重新解释为新的 Vector512<T>

适用于