Partajați prin


TensorPrimitives.SumOfSquares Method

Definition

Overloads

SumOfSquares(ReadOnlySpan<Single>)

Computes the sum of the square of every element in the specified tensor of single-precision floating-point numbers.

SumOfSquares<T>(ReadOnlySpan<T>)

Computes the sum of the square of every element in the specified tensor of numbers.

SumOfSquares(ReadOnlySpan<Single>)

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

Computes the sum of the square of every element in the specified tensor of single-precision floating-point numbers.

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

Parameters

x
ReadOnlySpan<Single>

The tensor, represented as a span.

Returns

The result of adding the square of every element in x, or zero if x is empty.

Remarks

This method effectively computes: Span<float> squaredValues = ...; TensorPrimitives.Multiply(x, x, squaredValues); float result = TensorPrimitives.Sum(squaredValues); but without requiring intermediate storage for the squared values.

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

SumOfSquares<T>(ReadOnlySpan<T>)

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

Computes the sum of the square of every element in the specified tensor of numbers.

public:
generic <typename T>
 where T : System::Numerics::IAdditionOperators<T, T, T>, System::Numerics::IAdditiveIdentity<T, T>, System::Numerics::IMultiplyOperators<T, T, T> static T SumOfSquares(ReadOnlySpan<T> x);
public static T SumOfSquares<T> (ReadOnlySpan<T> x) where T : System.Numerics.IAdditionOperators<T,T,T>, System.Numerics.IAdditiveIdentity<T,T>, System.Numerics.IMultiplyOperators<T,T,T>;
static member SumOfSquares : ReadOnlySpan<'T (requires 'T :> System.Numerics.IAdditionOperators<'T, 'T, 'T> and 'T :> System.Numerics.IAdditiveIdentity<'T, 'T> and 'T :> System.Numerics.IMultiplyOperators<'T, 'T, 'T>)> -> 'T (requires 'T :> System.Numerics.IAdditionOperators<'T, 'T, 'T> and 'T :> System.Numerics.IAdditiveIdentity<'T, 'T> and 'T :> System.Numerics.IMultiplyOperators<'T, 'T, 'T>)
Public Shared Function SumOfSquares(Of T As {IAdditionOperators(Of T, T, T), IAdditiveIdentity(Of T, T), IMultiplyOperators(Of T, 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 the square of every element in x, or zero if x is empty.

Remarks

This method effectively computes: Span<T> squaredValues = ...; TensorPrimitives.Multiply(x, x, squaredValues); T result = TensorPrimitives.Sum(squaredValues); but without requiring intermediate storage for the squared values.

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