Vector<T> Vector<T> Vector<T> Vector<T> Struct

定义

表示指定数值类型(适用于并行算法的低级别优化)的单个向量。Represents a single vector of a specified numeric type that is suitable for low-level optimization of parallel algorithms.

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

类型参数

T

向量类型。The vector type. T可以是任何基元数值类型。T can be any primitive numeric type.

继承
实现

注解

Vector<T> 是一个不可变的结构,它表示指定数值类型的单个向量。Vector<T> is an immutable structure that represents a single vector of a specified numeric type. @No__t-0 实例的计数是固定的,但其上限是 CPU 寄存器相关的。The count of a Vector<T> instance is fixed, but its upper limit is CPU-register dependent. 它旨在用作向量化大型算法的构建基块。It is intended to be used as a building block for vectorizing large algorithms.

@No__t-0 结构为硬件加速提供支持。The Vector<T> structure provides support for hardware acceleration.

下表显示了哪些基元数值数据类型和操作组合使用内部指令来实现更快的执行:The following table shows which primitive numeric data type and operation combination uses intrinsic instructions for faster executions:

基元类型Primitive type + - * /
sbyte Yes Yes NoNo NoNo
byte Yes Yes NoNo NoNo
short Yes Yes Yes NoNo
ushort Yes Yes NoNo NoNo
int Yes Yes Yes NoNo
uint Yes Yes NoNo NoNo
long Yes Yes NoNo NoNo
ulong Yes Yes NoNo NoNo
float Yes Yes Yes Yes
double Yes Yes Yes Yes

构造函数

Vector<T>(ReadOnlySpan<Byte>) Vector<T>(ReadOnlySpan<Byte>) Vector<T>(ReadOnlySpan<Byte>) Vector<T>(ReadOnlySpan<Byte>)

根据给定的只读字节跨度构造一个矢量。Constructs a vector from the given read-only span of bytes.

Vector<T>(ReadOnlySpan<T>) Vector<T>(ReadOnlySpan<T>) Vector<T>(ReadOnlySpan<T>) Vector<T>(ReadOnlySpan<T>)

根据给定的 ReadOnlySpan<T> 构造一个向量。Constructs a vector from the given ReadOnlySpan<T>.

Vector<T>(Span<T>) Vector<T>(Span<T>) Vector<T>(Span<T>) Vector<T>(Span<T>)

根据给定的 Span<T> 构造一个向量。Constructs a vector from the given Span<T>.

Vector<T>(T) Vector<T>(T) Vector<T>(T) Vector<T>(T)

创建其组件为指定类型的向量。Creates a vector whose components are of a specified type.

Vector<T>(T[]) Vector<T>(T[]) Vector<T>(T[]) Vector<T>(T[])

从指定数组创建一个向量。Creates a vector from a specified array.

Vector<T>(T[], Int32) Vector<T>(T[], Int32) Vector<T>(T[], Int32) Vector<T>(T[], Int32)

于指定索引位置开始,从指定数组创建一个向量。Creates a vector from a specified array starting at a specified index position.

属性

Count Count Count Count

返回存储在向量中的元素数量。Returns the number of elements stored in the vector.

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

获取指定索引处的元素。Gets the element at a specified index.

One One One One

返回一个包含所有 1 的向量。Returns a vector containing all ones.

Zero Zero Zero Zero

返回一个包含所有 0 的向量。Returns a vector containing all zeroes.

方法

CopyTo(Span<Byte>) CopyTo(Span<Byte>) CopyTo(Span<Byte>) CopyTo(Span<Byte>)

将向量复制到给定的 Span<T>Copies the vector to the given Span<T>.

CopyTo(Span<T>) CopyTo(Span<T>) CopyTo(Span<T>) CopyTo(Span<T>)

请将向量复制到给定跨度。Copies the vector to the given span. .

CopyTo(T[]) CopyTo(T[]) CopyTo(T[]) CopyTo(T[])

将向量实例复制到指定的目标数组。Copies the vector instance to a specified destination array.

CopyTo(T[], Int32) CopyTo(T[], Int32) CopyTo(T[], Int32) CopyTo(T[], Int32)

从指定索引位置开始,将向量实例复制到指定的目标数组中。Copies the vector instance to a specified destination array starting at a specified index position.

Equals(Vector<T>) Equals(Vector<T>) Equals(Vector<T>) Equals(Vector<T>)

返回一个值,该值指示此实例是否与指定的向量相等。Returns a value that indicates whether this instance is equal to a specified vector.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

ToString() ToString() ToString() ToString()

通过使用默认格式设置,返回此向量的字符串表示形式。Returns the string representation of this vector using default formatting.

ToString(String) ToString(String) ToString(String) ToString(String)

通过使用指定格式字符串设置各个元素的格式,来返回此向量的字符串表示形式。Returns the string representation of this vector using the specified format string to format individual elements.

ToString(String, IFormatProvider) ToString(String, IFormatProvider) ToString(String, IFormatProvider) ToString(String, IFormatProvider)

通过使用指定格式字符串设置各个元素的格式并使用指定格式提供程序定义特定于区域性的格式设置,来返回此向量的字符串表示形式。Returns the string representation of this vector using the specified format string to format individual elements and the specified format provider to define culture-specific formatting.

TryCopyTo(Span<Byte>) TryCopyTo(Span<Byte>) TryCopyTo(Span<Byte>) TryCopyTo(Span<Byte>)

请尝试将向量复制到给定字节跨度。Attempts to copy the vector to the given byte span.

TryCopyTo(Span<T>) TryCopyTo(Span<T>) TryCopyTo(Span<T>) TryCopyTo(Span<T>)

请尝试将向量复制到给定的 Span<T>Attempts to copy the vector to the given Span<T>.

操作员

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

将两个向量相加。Adds two vectors together.

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

通过在两个向量中的每个元素上执行按位 And 运算,返回一个新向量。Returns a new vector by performing a bitwise And operation on each of the elements in two vectors.

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

通过在两个向量中的每个元素上执行按位 Or 运算,返回一个新向量。Returns a new vector by performing a bitwise Or operation on each of the elements in two vectors.

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

将第一个向量除以第二个向量。Divides the first vector by the second.

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

返回一个值,该值指示两个指定向量中的每对元素是否相等。Returns a value that indicates whether each pair of elements in two specified vectors are equal.

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

通过在两个向量中的每个元素上执行按位 XOr 运算,返回一个新向量。Returns a new vector by performing a bitwise XOr operation on each of the elements in two vectors.

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

将指定向量的位重新解释为 UInt64 类型的向量。Reinterprets the bits of the specified vector into a vector of type UInt64.

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

将指定向量的位重新解释为 UInt32 类型的向量。Reinterprets the bits of the specified vector into a vector of type UInt32.

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

将指定向量的位重新解释为 UInt16 类型的向量。Reinterprets the bits of the specified vector into a vector of type UInt16.

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

将指定向量的位重新解释为 Single 类型的向量。Reinterprets the bits of the specified vector into a vector of type Single.

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

将指定向量的位重新解释为 SByte 类型的向量。Reinterprets the bits of the specified vector into a vector of type SByte.

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

将指定向量的位重新解释为 Byte 类型的向量。Reinterprets the bits of the specified vector into a vector of type Byte.

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

将指定向量的位重新解释为 Int32 类型的向量。Reinterprets the bits of the specified vector into a vector of type Int32.

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

将指定向量的位重新解释为 Int16 类型的向量。Reinterprets the bits of the specified vector into a vector of type Int16.

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

将指定向量的位重新解释为 Double 类型的向量。Reinterprets the bits of the specified vector into a vector of type Double.

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

将指定向量的位重新解释为 Int64 类型的向量。Reinterprets the bits of the specified vector into a vector of type Int64.

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

返回一个值,该值指示指定向量中的任意元素对是否相等。Returns a value that indicates whether any single pair of elements in the specified vectors is equal.

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

返回一个新向量,其值是两个指定向量中的每对元素的乘积。Returns a new vector whose values are the product of each pair of elements in two specified vectors.

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

将向量乘以指定标量值。Multiplies a vector by a specified scalar value.

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

将向量乘以指定标量值。Multiplies a vector by a specified scalar value.

OnesComplement(Vector<T>) OnesComplement(Vector<T>) OnesComplement(Vector<T>) OnesComplement(Vector<T>)

返回一个新向量,其元素是通过取用指定向量的元素的二进制反码来获取的。Returns a new vector whose elements are obtained by taking the one's complement of a specified vector's elements.

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

从第一个向量中减去第二个向量。Subtracts the second vector from the first.

UnaryNegation(Vector<T>) UnaryNegation(Vector<T>) UnaryNegation(Vector<T>) UnaryNegation(Vector<T>)

对给定向量求反。Negates a given vector.

适用于