Tensor.CreateFromArray Method

Definition

Namespace: Numerics.NET.Tensors
Assembly: Numerics.NET.Tensors (in Numerics.NET.Tensors.dll) Version: 9.0.0
Creates a tensor from a given array with an option to create a view.

Overload List

CreateFromArray<T>(T[]) Constructs a 1-dimensional tensor from a 1-dimensional array.
CreateFromArray<T>(T[,,,]) Constructs a 4-dimensional tensor from a 4-dimensional array.
CreateFromArray<T>(T[,,]) Constructs a 3-dimensional tensor from a 3-dimensional array.
CreateFromArray<T>(T[,]) Constructs a 2-dimensional tensor from a 2-dimensional array.
CreateFromArray<T>(T[], Boolean) Constructs a 1-dimensional tensor from a 1-dimensional array.
CreateFromArray<T>(T[,,,], Boolean) Constructs a 4-dimensional tensor from a 4-dimensional array using the array's memory to store the tensor elements.
CreateFromArray<T>(T[,,], Boolean) Constructs a 3-dimensional tensor from a 3-dimensional array using the array's memory to store the tensor elements.
CreateFromArray<T>(T[,], Boolean) Constructs a 2-dimensional tensor from a 2-dimensional array using the array's memory to store the tensor elements.
CreateFromArray<T>(T[], TensorShape, TensorElementOrder, Boolean) Constructs a new dense tensor of the specifed dimensions, wrapping existing backing memory for the contents.
CreateFromArray<T>(T[], TensorShape, TensorLayout, Boolean) Constructs a new dense tensor of the specifed dimensions, wrapping existing backing memory for the contents.

CreateFromArray<T>(T[])

Constructs a 1-dimensional tensor from a 1-dimensional array.
C#
public static Tensor<T> CreateFromArray<T>(
	T[] values
)

Parameters

values  T[]
An array containing the elements of the new tensor.

Type Parameters

T
The type of the elements of the tensor.

Return Value

Tensor<T>
A 1-dimensional tensor of the same shape and with the same elements as values.

CreateFromArray<T>(T[,])

Constructs a 4-dimensional tensor from a 4-dimensional array.
C#
public static Tensor<T> CreateFromArray<T>(
	T[,,,] values
)

Parameters

values  T[4]
An array containing the elements of the new tensor.

Type Parameters

T
The type of the elements of the tensor.

Return Value

Tensor<T>
A 4-dimensional tensor of the same shape and with the same elements as values.

CreateFromArray<T>(T[,])

Constructs a 3-dimensional tensor from a 3-dimensional array.
C#
public static Tensor<T> CreateFromArray<T>(
	T[,,] values
)

Parameters

values  T[3]
An array containing the elements of the new tensor.

Type Parameters

T
The type of the elements of the tensor.

Return Value

Tensor<T>
A 3-dimensional tensor of the same shape and with the same elements as values.

CreateFromArray<T>(T[,])

Constructs a 2-dimensional tensor from a 2-dimensional array.
C#
public static Tensor<T> CreateFromArray<T>(
	T[,] values
)

Parameters

values  T[2]
An array containing the elements of the new tensor.

Type Parameters

T
The type of the elements of the tensor.

Return Value

Tensor<T>
A 2-dimensional tensor of the same shape and with the same elements as values.

CreateFromArray<T>(T[], Boolean)

Constructs a 1-dimensional tensor from a 1-dimensional array.
C#
public static Tensor<T> CreateFromArray<T>(
	T[] values,
	bool createView
)
where T : struct, new()

Parameters

values  T[]
An array containing the elements of the new tensor.
createView  Boolean
Specifies whether the tensor should be a view of the array or a copy.

Type Parameters

T
The type of the elements of the tensor.

Return Value

Tensor<T>
A 1-dimensional tensor of the same shape and with the same elements as values.

CreateFromArray<T>(T[,], Boolean)

Constructs a 4-dimensional tensor from a 4-dimensional array using the array's memory to store the tensor elements.
C#
public static Tensor<T> CreateFromArray<T>(
	T[,,,] values,
	bool createView
)
where T : struct, new()

Parameters

values  T[4]
An array containing the elements of the new tensor.
createView  Boolean
Specifies whether the tensor should be a view of the array or a copy.

Type Parameters

T
The type of the elements of the tensor. Must be an unmanaged, non-nullable value type.

Return Value

Tensor<T>
A 4-dimensional tensor of the same shape and with the same elements as values.

CreateFromArray<T>(T[,], Boolean)

Constructs a 3-dimensional tensor from a 3-dimensional array using the array's memory to store the tensor elements.
C#
public static Tensor<T> CreateFromArray<T>(
	T[,,] values,
	bool createView
)
where T : struct, new()

Parameters

values  T[3]
An array containing the elements of the new tensor.
createView  Boolean
Specifies whether the tensor should be a view of the array or a copy.

Type Parameters

T
The type of the elements of the tensor. Must be an unmanaged, non-nullable value type.

Return Value

Tensor<T>
A 3-dimensional tensor of the same shape and with the same elements as values.

CreateFromArray<T>(T[,], Boolean)

Constructs a 2-dimensional tensor from a 2-dimensional array using the array's memory to store the tensor elements.
C#
public static Tensor<T> CreateFromArray<T>(
	T[,] values,
	bool createView
)
where T : struct, new()

Parameters

values  T[2]
An array containing the elements of the new tensor.
createView  Boolean
Specifies whether the tensor should be a view of the array or a copy.

Type Parameters

T
The type of the elements of the tensor. Must be an unmanaged, non-nullable value type.

Return Value

Tensor<T>
A 2-dimensional tensor of the same shape and with the same elements as values.

CreateFromArray<T>(T[], TensorShape, TensorElementOrder, Boolean)

Constructs a new dense tensor of the specifed dimensions, wrapping existing backing memory for the contents.
C#
public static Tensor<T> CreateFromArray<T>(
	T[] values,
	TensorShape shape,
	TensorElementOrder order = TensorElementOrder.CStyle,
	bool createView = false
)

Parameters

values  T[]
A 1D array containing the elements of the tensor.
shape  TensorShape
The dimensions of the new tensor.
order  TensorElementOrder  (Optional)
Optional. Specifies the order in which elements are stored in values. The default is C-style (row major).
createView  Boolean  (Optional)
Optional. Specifies whether values should be used to store the tensor's elements. The default is false.

Type Parameters

T

Return Value

Tensor<T>

CreateFromArray<T>(T[], TensorShape, TensorLayout, Boolean)

Constructs a new dense tensor of the specifed dimensions, wrapping existing backing memory for the contents.
C#
public static Tensor<T> CreateFromArray<T>(
	T[] values,
	TensorShape shape,
	TensorLayout layout,
	bool createView = false
)

Parameters

values  T[]
A 1D array containing the elements of the tensor.
shape  TensorShape
The dimensions of the new tensor.
layout  TensorLayout
The layout of the tensor elements.
createView  Boolean  (Optional)
Optional. Specifies whether values should be used as storage for the tensor. The default is false.

Type Parameters

T

Return Value

Tensor<T>

See Also