Table of Contents

Class WeightedAverageNode

Namespace
NumSharp.Backends.Iteration
Assembly
NumSharp.dll

A root-only fused weighted average Σ(values·weights) / Σ(weights) over two elementwise sub-trees (Average(NDExpr, NDExpr)). Like ReduceNode it is host-driven (no elementwise emit) and must be the root of the expression.

public sealed class WeightedAverageNode : NDExpr
Inheritance
WeightedAverageNode
Inherited Members

Constructors

WeightedAverageNode(NDExpr, NDExpr, int?, bool)

Build a weighted-average node over values and weights.

public WeightedAverageNode(NDExpr values, NDExpr weights, int? axis = null, bool keepdims = false)

Parameters

values NDExpr

The value expression (numerator's left factor).

weights NDExpr

The weight expression (numerator's right factor and the denominator).

axis int?

The reduction axis, or null for a flat (reduce-all) average.

keepdims bool

When true, the reduced axis (or every axis, for a flat average) is kept as size 1.

Exceptions

ArgumentNullException

values or weights is null.

Properties

SupportsSimd

Never SIMD — a reduction has no elementwise vector body; the host drives it.

public override bool SupportsSimd { get; }

Property Value

bool

Methods

AppendSignature(StringBuilder)

Fold the node's identity into a structural signature (axis / keepdims + both children).

public override void AppendSignature(StringBuilder sb)

Parameters

sb StringBuilder

The signature builder.

EmitScalar(ILGenerator, NDExprCompileContext)

A weighted average is host-driven as the tree root; it emits no elementwise scalar value.

public override void EmitScalar(ILGenerator il, NDExprCompileContext ctx)

Parameters

il ILGenerator

Unused.

ctx NDExprCompileContext

Unused.

Exceptions

InvalidOperationException

Always — the node is driven by np.evaluate, never emitted.

EmitVector(ILGenerator, NDExprCompileContext)

A weighted average has no vector path — it is driven by np.evaluate.

public override void EmitVector(ILGenerator il, NDExprCompileContext ctx)

Parameters

il ILGenerator

Unused.

ctx NDExprCompileContext

Unused.

Exceptions

InvalidOperationException

Always.