# Vector<T> 结构

## 定义

``````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

Vector<T>

## 注解

Vector<T> 是一个不可变的结构，它表示指定数值类型的单个向量。Vector<T> is an immutable structure that represents a single vector of a specified numeric type. Vector<T> 实例的计数是固定的，但其上限是 CPU 寄存器相关的。The count of Vector<T> instances is fixed, but its upper limit is CPU-register dependent. 它旨在用作向量化大型算法的构建基块，因此不能直接用作任意长度向量或 tensor。It is intended to be used as a building block for vectorizing large algorithms, and therefore cannot be used directly as an arbitrary length vector or tensor.

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

`sbyte` Yes Yes No No
`byte` Yes Yes No No
`short` Yes Yes Yes NoNo
`ushort` Yes Yes No No
`int` Yes Yes Yes NoNo
`uint` Yes Yes No No
`long` Yes Yes No No
`ulong` Yes Yes No No
`float` Yes Yes Yes Yes
`double` Yes Yes Yes Yes

## 构造函数

 根据给定的只读字节跨度构造一个矢量。Constructs a vector from the given read-only span of bytes. 根据给定的 ReadOnlySpan 构造一个向量。Constructs a vector from the given ReadOnlySpan. 根据给定的 Span 构造一个向量。Constructs a vector from the given Span. 创建其组件为指定类型的向量。Creates a vector whose components are of a specified type. 从指定数组创建一个向量。Creates a vector from a specified array. 于指定索引位置开始，从指定数组创建一个向量。Creates a vector from a specified array starting at a specified index position.

## 属性

 返回存储在向量中的元素数量。Returns the number of elements stored in the vector. 获取指定索引处的元素。Gets the element at a specified index. 返回一个包含所有 1 的向量。Returns a vector containing all ones. 返回一个包含所有 0 的向量。Returns a vector containing all zeroes.

## 方法

 将向量复制到给定的 Span。Copies the vector to the given Span. 请将向量复制到给定跨度。Copies the vector to the given span. 。. 将向量实例复制到指定的目标数组。Copies the vector instance to a specified destination array. 从指定索引位置开始，将向量实例复制到指定的目标数组中。Copies the vector instance to a specified destination array starting at a specified index position. 返回一个值，该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object. 返回一个值，该值指示此实例是否与指定的向量相等。Returns a value that indicates whether this instance is equal to a specified vector. 返回此实例的哈希代码。Returns the hash code for this instance. 通过使用默认格式设置，返回此向量的字符串表示形式。Returns the string representation of this vector using default formatting. 通过使用指定格式字符串设置各个元素的格式，来返回此向量的字符串表示形式。Returns the string representation of this vector using the specified format string to format individual elements. 通过使用指定格式字符串设置各个元素的格式并使用指定格式提供程序定义特定于区域性的格式设置，来返回此向量的字符串表示形式。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. 请尝试将向量复制到给定字节跨度。Attempts to copy the vector to the given byte span. 请尝试将向量复制到给定的 Span。Attempts to copy the vector to the given Span.

## 运算符

 将两个向量相加。Adds two vectors together. 通过在两个向量中的每个元素上执行按位 `And` 运算，返回一个新向量。Returns a new vector by performing a bitwise `And` operation on each of the elements in two vectors. 通过在两个向量中的每个元素上执行按位 `Or` 运算，返回一个新向量。Returns a new vector by performing a bitwise `Or` operation on each of the elements in two vectors. 将第一个向量除以第二个向量。Divides the first vector by the second. 返回一个值，该值指示两个指定向量中的每对元素是否相等。Returns a value that indicates whether each pair of elements in two specified vectors are equal. 通过在两个向量中的每个元素上执行按位 `XOr` 运算，返回一个新向量。Returns a new vector by performing a bitwise `XOr` operation on each of the elements in two vectors. 将指定向量的位重新解释为 Byte 类型的向量。Reinterprets the bits of the specified vector into a vector of type Byte. 将指定向量的位重新解释为 Double 类型的向量。Reinterprets the bits of the specified vector into a vector of type Double. 将指定向量的位重新解释为 Int16 类型的向量。Reinterprets the bits of the specified vector into a vector of type Int16. 将指定向量的位重新解释为 Int32 类型的向量。Reinterprets the bits of the specified vector into a vector of type Int32. 将指定向量的位重新解释为 Int64 类型的向量。Reinterprets the bits of the specified vector into a vector of type Int64. 将指定向量的位重新解释为 SByte 类型的向量。Reinterprets the bits of the specified vector into a vector of type SByte. 将指定向量的位重新解释为 Single 类型的向量。Reinterprets the bits of the specified vector into a vector of type Single. 将指定向量的位重新解释为 UInt16 类型的向量。Reinterprets the bits of the specified vector into a vector of type UInt16. 将指定向量的位重新解释为 UInt32 类型的向量。Reinterprets the bits of the specified vector into a vector of type UInt32. 将指定向量的位重新解释为 UInt64 类型的向量。Reinterprets the bits of the specified vector into a vector of type UInt64. 返回一个值，该值指示指定向量中的任意元素对是否相等。Returns a value that indicates whether any single pair of elements in the specified vectors is equal. 将向量乘以指定标量值。Multiplies a vector by a specified scalar value. 将向量乘以指定标量值。Multiplies a vector by a specified scalar value. 返回一个新向量，其值是两个指定向量中的每对元素的乘积。Returns a new vector whose values are the product of each pair of elements in two specified vectors. 返回一个新向量，其元素是通过取用指定向量的元素的二进制反码来获取的。Returns a new vector whose elements are obtained by taking the one's complement of a specified vector's elements. 从第一个向量中减去第二个向量。Subtracts the second vector from the first. 对给定向量求反。Negates a given vector.