Jaa


TensorPrimitives.SumOfMagnitudes Method

Definition

Overloads

SumOfMagnitudes(ReadOnlySpan<Single>)

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

SumOfMagnitudes<T>(ReadOnlySpan<T>)

Computes the sum of the absolute values of every element in the specified tensor of numbers.

SumOfMagnitudes(ReadOnlySpan<Single>)

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

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

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

Parameters

x
ReadOnlySpan<Single>

The tensor, represented as a span.

Returns

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

Remarks

This method effectively computes: Span<float> absoluteValues = ...; TensorPrimitives.Abs(x, absoluteValues); float result = TensorPrimitives.Sum(absoluteValues); but without requiring intermediate storage for the absolute values. It corresponds to the asum method defined by BLAS1.

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

SumOfMagnitudes<T>(ReadOnlySpan<T>)

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

Computes the sum of the absolute values of every element in the specified tensor of numbers.

public:
generic <typename T>
 where T : System::Numerics::INumberBase<T> static T SumOfMagnitudes(ReadOnlySpan<T> x);
public static T SumOfMagnitudes<T> (ReadOnlySpan<T> x) where T : System.Numerics.INumberBase<T>;
static member SumOfMagnitudes : ReadOnlySpan<'T (requires 'T :> System.Numerics.INumberBase<'T>)> -> 'T (requires 'T :> System.Numerics.INumberBase<'T>)
Public Shared Function SumOfMagnitudes(Of T As INumberBase(Of 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 absolute value of every element in x, or zero if x is empty.

Exceptions

T is a signed integer type and x contained a value equal to T's minimum value.

Remarks

This method effectively computes: Span<T> absoluteValues = ...; TensorPrimitives.Abs(x, absoluteValues); T result = TensorPrimitives.Sum(absoluteValues); but without requiring intermediate storage for the absolute values. It corresponds to the asum method defined by BLAS1.

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