TensorPrimitives.Sum Method

Definition

Overloads

Sum(ReadOnlySpan<Single>)

Computes the sum of all elements in the specified tensor of single-precision floating-point numbers.

Sum<T>(ReadOnlySpan<T>)

Computes the sum of all elements in the specified tensor of numbers.

Sum(ReadOnlySpan<Single>)

Source:
TensorPrimitives.cs
Source:
TensorPrimitives.Single.cs
Source:
TensorPrimitives.Single.cs

Computes the sum of all elements in the specified tensor of single-precision floating-point numbers.

public:
 static float Sum(ReadOnlySpan<float> x);
public static float Sum (ReadOnlySpan<float> x);
static member Sum : ReadOnlySpan<single> -> single
Public Shared Function Sum (x As ReadOnlySpan(Of Single)) As Single

Parameters

x
ReadOnlySpan<Single>

The tensor, represented as a span.

Returns

The result of adding all elements in x, or zero if x is empty.

Remarks

If any of the values in the input is equal to NaN, the result is also NaN.

This method may call into the underlying C runtime or employ instructions specific to the current architecture. Exact results may differ between different operating systems or architectures.

Applies to

Sum<T>(ReadOnlySpan<T>)

Source:
TensorPrimitives.Sum.cs
Source:
TensorPrimitives.Sum.cs

Computes the sum of all elements in the specified tensor of numbers.

public:
generic <typename T>
 where T : System::Numerics::IAdditionOperators<T, T, T>, System::Numerics::IAdditiveIdentity<T, T> static T Sum(ReadOnlySpan<T> x);
public static T Sum<T> (ReadOnlySpan<T> x) where T : System.Numerics.IAdditionOperators<T,T,T>, System.Numerics.IAdditiveIdentity<T,T>;
static member Sum : ReadOnlySpan<'T (requires 'T :> System.Numerics.IAdditionOperators<'T, 'T, 'T> and 'T :> System.Numerics.IAdditiveIdentity<'T, 'T>)> -> 'T (requires 'T :> System.Numerics.IAdditionOperators<'T, 'T, 'T> and 'T :> System.Numerics.IAdditiveIdentity<'T, 'T>)
Public Shared Function Sum(Of T As {IAdditionOperators(Of T, T, T), IAdditiveIdentity(Of T, T)}) (x As ReadOnlySpan(Of T)) As T

Type Parameters

T

Parameters

x
ReadOnlySpan<T>

The tensor, represented as a span.

Returns

T

The result of adding all elements in x, or zero if x is empty.

Remarks

If any of the values in the input is equal to NaN, the result is also NaN.

This method may call into the underlying C runtime or employ instructions specific to the current architecture. Exact results may differ between different operating systems or architectures.

Applies to