Share via


TensorPrimitives.Sign<T> Method

Definition

Computes the element-wise sign of numbers in the specified tensor.

public:
generic <typename T>
 where T : System::Numerics::INumber<T> static void Sign(ReadOnlySpan<T> x, Span<int> destination);
public static void Sign<T>(ReadOnlySpan<T> x, Span<int> destination) where T : System.Numerics.INumber<T>;
static member Sign : ReadOnlySpan<'T (requires 'T :> System.Numerics.INumber<'T>)> * Span<int> -> unit (requires 'T :> System.Numerics.INumber<'T>)
Public Shared Sub Sign(Of T As INumber(Of T)) (x As ReadOnlySpan(Of T), destination As Span(Of Integer))

Type Parameters

T

Parameters

x
ReadOnlySpan<T>

The tensor, represented as a span.

destination
Span<Int32>

The destination tensor, represented as a span.

Exceptions

x and destination reference overlapping memory locations and do not begin at the same location.

Remarks

This method effectively computes destination[i] = T.Sign(x[i]). If the value is less than 0, the result is -1; if the value is 0, the result is 0; if the value is greater than 0, the result is 1.

Applies to