complex op• Data kinds: cpoints → measurement
• Call: import mathops; mathops.cplx_winding_number(z, w=0.0) (or opsmath.get("cplx_winding_number"))
Winding number of a closed contour around a point (turning number).
How many times the polygon `z` (closing segment implicit) travels
counter-clockwise around *w*: `+1` for a simple positively-oriented loop
containing it, `-1 clockwise, 0 outside, ±k for a k`-fold
loop. Computed as the sum of the principal-value argument increments of
`z_k - w divided by 2*pi` and rounded — for a *polygon* that sum is an
exact multiple of `2*pi`, so the result is an exact integer, not an
estimate (the rounding merely removes ~1e-14 of accumulated float error).
Honest limitation — **the count can alias low, and no local check can stop
it**: this is the winding number of the polygon *through the samples*,
which equals that of the underlying curve only if the sampling resolves it.
A segment that turns the ray to *w* by `>= pi` is ambiguous (which side
did it pass?) and raises. Below that there is no contradiction to detect:
`z**5 sampled on a 4-point circle turns exactly pi/2` per step and
counts 1 instead of 5 (measured). From `pi/2` up, a
`RuntimeWarning says so (WIND_ALIAS_WARN`); the only real remedy is
the classical one — refine until the count stops changing.
Raises `ValueError`: *w* coincides with a vertex or lies on a segment
(the winding number is undefined on the contour), a segment subtends
`>= pi` as seen from *w* (undersampled — refine the contour), fewer than
3 points, degenerate contour, non-finite/masked input.
HALCON: no operator (`test_region_point` answers the related but weaker
inside/outside question for regions).
Every mathops op validates its input before computing (nothing slips through silently):
• **complex input raises ValueError** — coercing to float64 silently discards the imaginary part (numpy only emits a ComplexWarning and returns a plausible-looking wrong real number). State .real/.imag/abs() explicitly, or use complexops, which handles complex data.
• **masked arrays with masked elements raise ValueError** — the implicit conversion that peels off the mask and uses the raw values underneath is refused. Say explicitly whether to fill or to drop.
• **NaN/Inf raises ValueError on every input** (refused with the count stated — it propagates through the whole result).
• Shapes are strict: 1-D and 2-D are never implicitly promoted or broadcast (a matrix in a vector slot, or a vector in a matrix slot, raises ValueError; reshape explicitly).
• Size cap: ops that take a matrix, and the stat_histogram bins, raise ValueError beyond mathops.MAX_ELEMENTS (2^26 ≈ 67 million elements).
• Sample-data catalog (download URLs / licences) — 2-D uses skimage.data (BSD/public domain) plus synthetic images; 3-D lists download URLs for real data sources (Stanford, PDS, …).
• Operator provenance and references — the sources of the research/methods this op family came from.
• The canonical algorithm (author, year) and its uses are named in the family usage guide above.
• math_complex — py -3.11 examples/math_complex.py
measurement as input)—
complex)cplx_contour_circle · cplx_poly_eval · cplx_contour_integral · cplx_cauchy_value · cplx_argument_principle · cplx_laurent_coeffs · cplx_joukowski · cplx_mobius
*Provenance: mathops.py — MATH operator registry. This per-op note is generated by tools/opdocs.py md (do not hand-edit).*
© 2026 Kazufumi Furuse — Fullseye operator documentation. Licensed under Apache-2.0.