Enum NDExprReduceKind
Reduction kinds supported by ReduceNode.
public enum NDExprReduceKind : byte
Fields
Sum = 0Prod = 1Min = 2Max = 3Mean = 4Any = 5logical_or.reduceof the nonzero-test of the child (identityFalse; bool result).All = 6logical_and.reduceof the nonzero-test of the child (identityTrue; bool result).Ptp = 7np.ptp— peak-to-peak (max - min) of the child. Result dtype is the child's (integer/unsigned overflow WRAPS exactly as NumPy's, since it is a plain subtract of two same-dtype reductions), a NaN in the child propagates to the result, and there is NO empty identity (a zero-size input raises, like Max/Min). Unlike the fold-driven kinds above it is host-delegated: ptp(NDArray, NDAxis?, NDArray, bool) runs over the materialized child — see the host divert inDefaultEngine.EvaluateReduce.NanMin = 8np.nanmin— minimum ignoring NaN. Result dtype is the child's; a float/complex child has its NaNs skipped (an ALL-NaN input yields NaN, matching NumPy's all-NaN-slice contract), while an integer/bool child carries no NaN and folds as a plain minimum. Host-delegated to np.nanmin(NDArray,int?,NDArray,bool,object,NDArray) over the materialized child, which is why it is TYPE-AWARE for free (the ±inf NaN-replacement sentinel that would promote an int child to float64 lives inside the engine reduction, not in an NDExpr rewrite).NanMax = 9np.nanmax— maximum ignoring NaN (the NanMin twin, all-NaN → NaN). Host-delegated to np.nanmax(NDArray,int?,NDArray,bool,object,NDArray) over the materialized child.ArgMax = 10np.argmax— the index of the maximum. Unlike every value reduction above, the result dtype is int64 (NumPy'sintp), NOT the child dtype. It is host-delegated to np.argmax(NDArray,int,bool) (flat: argmax(NDArray)) over the materialized child. This is bit-exact for the same reason the M4-tail value kinds are — but the property in play is subtler than order-independence: argmax's index DOES depend on visiting order at a tie (the FIRST maximum wins, and a NaN is treated as the largest so the FIRST NaN wins), yet the materialized child is a fresh C-CONTIGUOUS buffer holding exactly NumPy's own C-order intermediate, andnp.argmaxwalks it in that same C-order — so the tie/NaN index is deterministic and identical tonp.argmax(child). There is NO empty identity (a zero-size input raises, like Max). SeeEvaluateDelegatingReduce.ArgMin = 11np.argmin— the index of the minimum (the ArgMax twin: int64 result, first-tie / first-NaN wins over the C-order materialized child). Host-delegated to np.argmin(NDArray,int,bool) / argmin(NDArray).NanMean = 12np.nanmean— the arithmetic mean with NaNs skipped (the Mean twin over the finite elements). Result dtype follows Mean (float16→float16 via a float32 intermediate, float32→float32, float64→float64, complex128→complex128, int/bool→float64), an ALL-NaN input yields NaN and an integer/bool child — carrying no NaN — is exactlyMean. Unlike Sum/Mean it is NOT a fold kind and NOT a factory rewrite (its per-element NaN skip changes the divisor per slab): the host materializes the child once and computesnansum(child) / count_of_non_NaNwith the SAME NumPy-exact pairwise sum the M1/M2 diverts use — seeDefaultEngine.EvaluateStatReduce. Bit-exact vs NumPy 2.4.2, so it carries NO MisalignedRegistry excuse.Var = 13np.var— the varianceΣ(x−mean)² / (N−ddof)(population variance at the defaultddof=0). Result dtype: float16→float16 (computed in float32), float32→float32, float64→float64, int/bool→float64, and — like NumPy — a complex128 child yields a real float64 variance (the deviations are reduced as|x−mean|²). A NaN anywhere PROPAGATES (var uses every element, unlike NanMean);ddof ≥ Ndivides by a clamped zero →+inf(or NaN when the numerator is zero), and an empty input yields NaN. The host materializes the child once, then runs NumPy's own two-pass_varop for op over the exact pairwise sum (mean, thenΣ(x−mean)²) — seeDefaultEngine.EvaluateStatReduce. The degrees-of-freedom offset is carried on the node (NumSharp.Backends.Iteration.ReduceNode.Ddof) and is part of the program identity. Bit-exact vs NumPy 2.4.2, NO excuse.Std = 14np.std— the standard deviationsqrt(var)(the Var twin, same result dtypes / ddof / NaN-propagation / empty→NaN semantics), applied as a final elementwise square root over the variance so it is bit-exact wherever Var is.
Remarks
Any / All are their OWN kinds, not Max / Min
over a boolean child: logical_or / logical_and carry the identities False /
True, so a reduction over an EMPTY input is False / True — where
maximum.reduce / minimum.reduce raise "zero-size array … which has no identity". They
also return bool where a bool Sum would widen to int64. The value fold is a
bitwise OR / AND on a bool accumulator, which is associative AND idempotent — so the 4-accumulator
unroll reorders it freely and stays bit-exact (unlike float Sum / Prod,
whose order matters — the M1/M2 divert).