TensorSpan<T> Constructors

Definition

Overloads

TensorSpan<T>(Array)

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

TensorSpan<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).

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

Creates a new TensorSpan<T> over the provided Array using the specified start offsets, lengths, and strides.

TensorSpan<T>(T[], ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Creates a new tensor over the portion of the target array beginning at the specified start index and using the specified lengths and strides.

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

Creates a new tensor span over the target unmanaged buffer using the specified lengths.

TensorSpan<T>(Span<T>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Creates a new TensorSpan<T> over the provided Span<T> using the specified lengths and strides.

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

Creates a new span over the target unmanaged buffer.

TensorSpan<T>(T*, IntPtr)

Creates a new span over the target unmanaged buffer.

TensorSpan<T>(Span<T>, ReadOnlySpan<IntPtr>)

Creates a new tensor span over the target span using the specified lengths.

TensorSpan<T>(T[])

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

TensorSpan<T>(Span<T>)

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

TensorSpan<T>(T[], ReadOnlySpan<IntPtr>)

Creates a new tensor over the portion of the target array using the specified lengths.

TensorSpan<T>(Array)

Source:
TensorSpan.cs
Source:
TensorSpan.cs

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

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

Parameters

array
Array

The target array.

Exceptions

array is covariant and its type is not exactly T[].

Applies to

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

Source:
TensorSpan.cs
Source:
TensorSpan.cs

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

public:
 TensorSpan(cli::array <T> ^ array, int start, ReadOnlySpan<IntPtr> lengths, ReadOnlySpan<IntPtr> strides);
public TensorSpan(T[]? array, int start, scoped ReadOnlySpan<IntPtr> lengths, scoped ReadOnlySpan<IntPtr> strides);
new System.Numerics.Tensors.TensorSpan<'T> : 'T[] * int * ReadOnlySpan<nativeint> * ReadOnlySpan<nativeint> -> System.Numerics.Tensors.TensorSpan<'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, it's assumed to have one 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

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

array is covariant and its type is not exactly T[].

Remarks

Returns default when array is null.

Applies to

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

Source:
TensorSpan.cs
Source:
TensorSpan.cs

Creates a new TensorSpan<T> over the provided Array using the specified start offsets, lengths, and strides.

public:
 TensorSpan(Array ^ array, ReadOnlySpan<int> start, ReadOnlySpan<IntPtr> lengths, ReadOnlySpan<IntPtr> strides);
public TensorSpan(Array? array, scoped ReadOnlySpan<int> start, scoped ReadOnlySpan<IntPtr> lengths, scoped ReadOnlySpan<IntPtr> strides);
new System.Numerics.Tensors.TensorSpan<'T> : Array * ReadOnlySpan<int> * ReadOnlySpan<nativeint> * ReadOnlySpan<nativeint> -> System.Numerics.Tensors.TensorSpan<'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. The strides will be automatically calculated if not provided.

Exceptions

array is covariant and its type is not exactly T[].

Applies to

TensorSpan<T>(T[], ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Source:
TensorSpan.cs

Creates a new tensor over the portion of the target array beginning at the specified start index and using the specified lengths and strides.

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

Parameters

array
T[]

The target array.

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of the dimensions. If an empty span is provided, the created tensor will have a single dimension that is the same length as array.

strides

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The strides of each dimension. If an empty span is provided, then strides will be automatically calculated from lengths.

Exceptions

array is covariant and its type is not exactly T[].

Applies to

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

Source:
TensorSpan.cs

Important

This API is not CLS-compliant.

Creates a new tensor span over the target unmanaged buffer using the specified lengths.

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

Parameters

data
T*

The pointer to the start of the target unmanaged buffer.

dataLength
IntPtr

nativeint

The number of elements the target unmanaged buffer contains.

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of the dimensions. If an empty span is provided, the created tensor span will have a single dimension that is the same length as dataLength.

Attributes

Applies to

TensorSpan<T>(Span<T>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Source:
TensorSpan.cs
Source:
TensorSpan.cs

Creates a new TensorSpan<T> over the provided Span<T> using the specified lengths and strides.

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

Parameters

span
Span<T>

The target span.

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of each dimension.

strides

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

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

Applies to

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

Source:
TensorSpan.cs
Source:
TensorSpan.cs

Important

This API is not CLS-compliant.

Creates a new span over the target unmanaged buffer.

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

Parameters

data
T*

An unmanaged data that points 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, it's assumed to have one 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

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

The specified length is negative.

Remarks

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

Applies to

TensorSpan<T>(T*, IntPtr)

Source:
TensorSpan.cs
Source:
TensorSpan.cs

Important

This API is not CLS-compliant.

Creates a new span over the target unmanaged buffer.

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

Parameters

data
T*

An unmanaged data that points to memory.

dataLength
IntPtr

nativeint

The number of elements the unmanaged memory can hold.

Attributes

Remarks

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

Applies to

TensorSpan<T>(Span<T>, ReadOnlySpan<IntPtr>)

Source:
TensorSpan.cs

Creates a new tensor span over the target span using the specified lengths.

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

Parameters

span
Span<T>

The target span.

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of the dimensions. If an empty span is provided, the created tensor span will have a single dimension that is the same length as span.

Applies to

TensorSpan<T>(T[])

Source:
TensorSpan.cs
Source:
TensorSpan.cs

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

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

Parameters

array
T[]

The target array.

Exceptions

array is covariant and its type is not exactly T[].

Remarks

Returns default when array is null.

Applies to

TensorSpan<T>(Span<T>)

Source:
TensorSpan.cs
Source:
TensorSpan.cs

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

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

Parameters

span
Span<T>

The target span.

Applies to

TensorSpan<T>(T[], ReadOnlySpan<IntPtr>)

Source:
TensorSpan.cs

Creates a new tensor over the portion of the target array using the specified lengths.

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

Parameters

array
T[]

The target array.

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of the dimensions. If an empty span is provided, the created tensor will have a single dimension that is the same length as array.

Exceptions

array is covariant and its type is not exactly T[].

Applies to