Condividi tramite


ReadOnlyTensorSpan<T> Constructors

Definition

Overloads

ReadOnlyTensorSpan<T>(Array)

Creates a new ReadOnlyTensorSpan<T> over the provided Array. The new ReadOnlyTensorSpan<T> will have a rank of 1 and a length equal to the length of the provided Array.

ReadOnlyTensorSpan<T>(ReadOnlySpan<T>)

Creates a new ReadOnlyTensorSpan<T> over the provided ReadOnlySpan<T>. The new ReadOnlyTensorSpan<T> will have a rank of 1 and a length equal to the length of the provided ReadOnlySpan<T>.

ReadOnlyTensorSpan<T>(T[])

Creates a new span over the entirety of the target array.

ReadOnlyTensorSpan<T>(T*, IntPtr)

Creates a new span over the target unmanaged buffer. Clearly this is quite dangerous the length is not checked. But if this creation is correct, then all subsequent uses are correct.

ReadOnlyTensorSpan<T>(ReadOnlySpan<T>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Creates a new ReadOnlyTensorSpan<T> over the provided Span<T> using the specified lengths and strides. If the strides are not provided, they will be automatically calculated.

ReadOnlyTensorSpan<T>(Array, ReadOnlySpan<NIndex>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Creates a new ReadOnlyTensorSpan<T> over the provided Array using the specified start offsets, lengths, and strides. If the strides are not provided, they will be automatically calculated.

ReadOnlyTensorSpan<T>(Array, ReadOnlySpan<Int32>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Creates a new ReadOnlyTensorSpan<T> over the provided Array using the specified start offsets, lengths, and strides. If the strides are not provided, they will be automatically calculated.

ReadOnlyTensorSpan<T>(T*, IntPtr, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Creates a new span over the target unmanaged buffer. Clearly this is quite dangerous, because the length is not checked. But if this creation is correct, then all subsequent uses are correct.

ReadOnlyTensorSpan<T>(T[], Index, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Creates a new span over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive).

ReadOnlyTensorSpan<T>(T[], Int32, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Creates a new span over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive).

ReadOnlyTensorSpan<T>(Array)

Source:
ReadOnlyTensorSpan.cs
Source:
ReadOnlyTensorSpan.cs

Creates a new ReadOnlyTensorSpan<T> over the provided Array. The new ReadOnlyTensorSpan<T> will have a rank of 1 and a length equal to the length of the provided Array.

public:
 ReadOnlyTensorSpan(Array ^ array);
public ReadOnlyTensorSpan (Array? array);
new System.Numerics.Tensors.ReadOnlyTensorSpan<'T> : Array -> System.Numerics.Tensors.ReadOnlyTensorSpan<'T>
Public Sub New (array As Array)

Parameters

array
Array

The target array.

Applies to

ReadOnlyTensorSpan<T>(ReadOnlySpan<T>)

Source:
ReadOnlyTensorSpan.cs
Source:
ReadOnlyTensorSpan.cs

Creates a new ReadOnlyTensorSpan<T> over the provided ReadOnlySpan<T>. The new ReadOnlyTensorSpan<T> will have a rank of 1 and a length equal to the length of the provided ReadOnlySpan<T>.

public:
 ReadOnlyTensorSpan(ReadOnlySpan<T> span);
public ReadOnlyTensorSpan (ReadOnlySpan<T> span);
new System.Numerics.Tensors.ReadOnlyTensorSpan<'T> : ReadOnlySpan<'T> -> System.Numerics.Tensors.ReadOnlyTensorSpan<'T>
Public Sub New (span As ReadOnlySpan(Of T))

Parameters

span
ReadOnlySpan<T>

The target span.

Applies to

ReadOnlyTensorSpan<T>(T[])

Source:
ReadOnlyTensorSpan.cs
Source:
ReadOnlyTensorSpan.cs

Creates a new span over the entirety of the target array.

public:
 ReadOnlyTensorSpan(cli::array <T> ^ array);
public ReadOnlyTensorSpan (T[]? array);
new System.Numerics.Tensors.ReadOnlyTensorSpan<'T> : 'T[] -> System.Numerics.Tensors.ReadOnlyTensorSpan<'T>
Public Sub New (array As T())

Parameters

array
T[]

The target array.

Exceptions

Thrown when array is covariant and array's type is not exactly T[].

Remarks

Returns default when array is null.

Applies to

ReadOnlyTensorSpan<T>(T*, IntPtr)

Source:
ReadOnlyTensorSpan.cs
Source:
ReadOnlyTensorSpan.cs

Important

This API is not CLS-compliant.

Creates a new span over the target unmanaged buffer. Clearly this is quite dangerous the length is not checked. But if this creation is correct, then all subsequent uses are correct.

public:
 ReadOnlyTensorSpan(T* data, IntPtr dataLength);
[System.CLSCompliant(false)]
public ReadOnlyTensorSpan (T* data, IntPtr dataLength);
[<System.CLSCompliant(false)>]
new System.Numerics.Tensors.ReadOnlyTensorSpan<'T> : nativeptr<'T> * nativeint -> System.Numerics.Tensors.ReadOnlyTensorSpan<'T>

Parameters

data
T*

An unmanaged data to memory.

dataLength
IntPtr

nativeint

The number of elements the unmanaged memory can hold.

Attributes

Remarks

Clearly this is quite dangerous the length is not checked. But if this creation is correct, then all subsequent uses are correct.

Applies to

ReadOnlyTensorSpan<T>(ReadOnlySpan<T>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Source:
ReadOnlyTensorSpan.cs
Source:
ReadOnlyTensorSpan.cs

Creates a new ReadOnlyTensorSpan<T> over the provided Span<T> using the specified lengths and strides. If the strides are not provided, they will be automatically calculated.

public:
 ReadOnlyTensorSpan(ReadOnlySpan<T> span, ReadOnlySpan<IntPtr> lengths, ReadOnlySpan<IntPtr> strides);
public ReadOnlyTensorSpan (ReadOnlySpan<T> span, scoped ReadOnlySpan<IntPtr> lengths, scoped ReadOnlySpan<IntPtr> strides);
new System.Numerics.Tensors.ReadOnlyTensorSpan<'T> : ReadOnlySpan<'T> * ReadOnlySpan<nativeint> * ReadOnlySpan<nativeint> -> System.Numerics.Tensors.ReadOnlyTensorSpan<'T>
Public Sub New (span As ReadOnlySpan(Of T), lengths As ReadOnlySpan(Of IntPtr), strides As ReadOnlySpan(Of IntPtr))

Parameters

span
ReadOnlySpan<T>

The target span.

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of each dimension.

strides

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The strides for each dimension. Will be automatically calculated if not provided.

Applies to

ReadOnlyTensorSpan<T>(Array, ReadOnlySpan<NIndex>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Source:
ReadOnlyTensorSpan.cs
Source:
ReadOnlyTensorSpan.cs

Creates a new ReadOnlyTensorSpan<T> over the provided Array using the specified start offsets, lengths, and strides. If the strides are not provided, they will be automatically calculated.

public:
 ReadOnlyTensorSpan(Array ^ array, ReadOnlySpan<System::Buffers::NIndex> startIndex, ReadOnlySpan<IntPtr> lengths, ReadOnlySpan<IntPtr> strides);
public ReadOnlyTensorSpan (Array? array, scoped ReadOnlySpan<System.Buffers.NIndex> startIndex, scoped ReadOnlySpan<IntPtr> lengths, scoped ReadOnlySpan<IntPtr> strides);
new System.Numerics.Tensors.ReadOnlyTensorSpan<'T> : Array * ReadOnlySpan<System.Buffers.NIndex> * ReadOnlySpan<nativeint> * ReadOnlySpan<nativeint> -> System.Numerics.Tensors.ReadOnlyTensorSpan<'T>
Public Sub New (array As Array, startIndex As ReadOnlySpan(Of NIndex), lengths As ReadOnlySpan(Of IntPtr), strides As ReadOnlySpan(Of IntPtr))

Parameters

array
Array

The target array.

startIndex
ReadOnlySpan<NIndex>

The starting offset for each dimension.

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of each dimension.

strides

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The strides for each dimension. Will be automatically calculated if not provided.

Applies to

ReadOnlyTensorSpan<T>(Array, ReadOnlySpan<Int32>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Source:
ReadOnlyTensorSpan.cs
Source:
ReadOnlyTensorSpan.cs

Creates a new ReadOnlyTensorSpan<T> over the provided Array using the specified start offsets, lengths, and strides. If the strides are not provided, they will be automatically calculated.

public:
 ReadOnlyTensorSpan(Array ^ array, ReadOnlySpan<int> start, ReadOnlySpan<IntPtr> lengths, ReadOnlySpan<IntPtr> strides);
public ReadOnlyTensorSpan (Array? array, scoped ReadOnlySpan<int> start, scoped ReadOnlySpan<IntPtr> lengths, scoped ReadOnlySpan<IntPtr> strides);
new System.Numerics.Tensors.ReadOnlyTensorSpan<'T> : Array * ReadOnlySpan<int> * ReadOnlySpan<nativeint> * ReadOnlySpan<nativeint> -> System.Numerics.Tensors.ReadOnlyTensorSpan<'T>
Public Sub New (array As Array, start As ReadOnlySpan(Of Integer), lengths As ReadOnlySpan(Of IntPtr), strides As ReadOnlySpan(Of IntPtr))

Parameters

array
Array

The target array.

start
ReadOnlySpan<Int32>

The starting offset for each dimension.

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of each dimension.

strides

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The strides for each dimension. Will be automatically calculated if not provided.

Applies to

ReadOnlyTensorSpan<T>(T*, IntPtr, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Source:
ReadOnlyTensorSpan.cs
Source:
ReadOnlyTensorSpan.cs

Important

This API is not CLS-compliant.

Creates a new span over the target unmanaged buffer. Clearly this is quite dangerous, because the length is not checked. But if this creation is correct, then all subsequent uses are correct.

public:
 ReadOnlyTensorSpan(T* data, IntPtr dataLength, ReadOnlySpan<IntPtr> lengths, ReadOnlySpan<IntPtr> strides);
[System.CLSCompliant(false)]
public ReadOnlyTensorSpan (T* data, IntPtr dataLength, scoped ReadOnlySpan<IntPtr> lengths, scoped ReadOnlySpan<IntPtr> strides);
[<System.CLSCompliant(false)>]
new System.Numerics.Tensors.ReadOnlyTensorSpan<'T> : nativeptr<'T> * nativeint * ReadOnlySpan<nativeint> * ReadOnlySpan<nativeint> -> System.Numerics.Tensors.ReadOnlyTensorSpan<'T>

Parameters

data
T*

An unmanaged data to memory.

dataLength
IntPtr

nativeint

The number of elements the unmanaged memory can hold.

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of the dimensions. If default is provided its assumed to have 1 dimension with a length equal to the length of the data.

strides

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of the strides. If nothing is provided it figures out the default stride configuration.

Attributes

Exceptions

Thrown when T is reference type or contains pointers and hence cannot be stored in unmanaged memory.

Thrown when the specified length is negative.

Applies to

ReadOnlyTensorSpan<T>(T[], Index, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Source:
ReadOnlyTensorSpan.cs
Source:
ReadOnlyTensorSpan.cs

Creates a new span over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive).

public:
 ReadOnlyTensorSpan(cli::array <T> ^ array, Index startIndex, ReadOnlySpan<IntPtr> lengths, ReadOnlySpan<IntPtr> strides);
public ReadOnlyTensorSpan (T[]? array, Index startIndex, scoped ReadOnlySpan<IntPtr> lengths, scoped ReadOnlySpan<IntPtr> strides);
new System.Numerics.Tensors.ReadOnlyTensorSpan<'T> : 'T[] * Index * ReadOnlySpan<nativeint> * ReadOnlySpan<nativeint> -> System.Numerics.Tensors.ReadOnlyTensorSpan<'T>
Public Sub New (array As T(), startIndex As Index, lengths As ReadOnlySpan(Of IntPtr), strides As ReadOnlySpan(Of IntPtr))

Parameters

array
T[]

The target array.

startIndex
Index

The index at which to begin the span.

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of the dimensions. If default is provided its assumed to have 1 dimension with a length equal to the length of the data.

strides

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The strides of each dimension. If default or span of length 0 is provided then strides will be automatically calculated.

Exceptions

Thrown when array is covariant and array's type is not exactly T[].

Thrown when the specified startIndex or end index is not in the range (<0 or >FlattenedLength).

Remarks

Returns default when array is null.

Applies to

ReadOnlyTensorSpan<T>(T[], Int32, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Source:
ReadOnlyTensorSpan.cs
Source:
ReadOnlyTensorSpan.cs

Creates a new span over the portion of the target array beginning at 'start' index and ending at 'end' index (exclusive).

public:
 ReadOnlyTensorSpan(cli::array <T> ^ array, int start, ReadOnlySpan<IntPtr> lengths, ReadOnlySpan<IntPtr> strides);
public ReadOnlyTensorSpan (T[]? array, int start, scoped ReadOnlySpan<IntPtr> lengths, scoped ReadOnlySpan<IntPtr> strides);
new System.Numerics.Tensors.ReadOnlyTensorSpan<'T> : 'T[] * int * ReadOnlySpan<nativeint> * ReadOnlySpan<nativeint> -> System.Numerics.Tensors.ReadOnlyTensorSpan<'T>
Public Sub New (array As T(), start As Integer, lengths As ReadOnlySpan(Of IntPtr), strides As ReadOnlySpan(Of IntPtr))

Parameters

array
T[]

The target array.

start
Int32

The index at which to begin the span.

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of the dimensions. If default is provided its assumed to have 1 dimension with a length equal to the length of the data.

strides

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The strides of each dimension. If default or span of length 0 is provided then strides will be automatically calculated.

Exceptions

Thrown when array is covariant and array's type is not exactly T[].

Thrown when the specified start or end index is not in the range (<0 or >FlattenedLength).

Remarks

Returns default when array is null.

Applies to