Tensor.If<T> Method

Selects the elements of one of two tensors based on a condition.

Definition

Namespace: Numerics.NET.Tensors
Assembly: Numerics.NET.Tensors (in Numerics.NET.Tensors.dll) Version: 9.0.3
C#
public static Tensor<T> If<T>(
	Tensor<bool> condition,
	Tensor<T> trueValues,
	Tensor<T> falseValues,
	Tensor<T>? result = null,
	Tensor<bool>? mask = null,
	TensorElementOrder order = TensorElementOrder.Automatic
)

Parameters

condition  Tensor<Boolean>
A boolean tensor that specifies whether the corresponding element from trueValues or falseValues should be returned.
trueValues  Tensor<T>
A tensor that contains the values that should be returned if the corresponding element in mask is true.
falseValues  Tensor<T>
A tensor that contains the values that should be returned if the corresponding element in mask is false.
result  Tensor<T>  (Optional)
Optional. The tensor that is to hold the result. May be null.
mask  Tensor<Boolean>  (Optional)
Optional. A boolean tensor that specifies for which elements the operation should be performed. If null (the default), the operation is applied everywhere.
order  TensorElementOrder  (Optional)
Optional. If result is null, the desired ordering in memory of the result.

Type Parameters

T
The type of the elements of the tensors and the result.

Return Value

Tensor<T>
A tensor whose elements are taken from either trueValues or falseValues, depending on the corresponding element in mask.

Exceptions

ArgumentNullException

condition is null.

-or-

trueValues is null.

-or-

falseValues is null.

See Also