Summary
Add a magnitude operation for the first-class numeric Vector type introduced by #684.
magnitude returns the Euclidean (L2) magnitude of the input vector.
Syntax
returns:
Semantics
For V(x1, ..., xn), the result is:
- Input:
Vector
- Output: numeric
- An all-zero vector has magnitude
0.
- Numeric behavior follows existing Expressif promotion/coercion rules.
- Generic arrays and tuples are not implicitly treated as vectors.
Naming
Use magnitude rather than the former norm wording from #553. This keeps the user-facing vocabulary explicit and avoids overloading norm with different possible norm definitions.
Acceptance criteria
V(3,4) | magnitude returns 5.
- Zero, positive, and negative components are supported.
- The all-zero vector returns
0.
- Result precision follows Expressif numeric semantics.
- Generic arrays and tuples are rejected as vector input.
- Tests and function metadata/documentation are added.
Dependency
Depends on #684.
Summary
Add a
magnitudeoperation for the first-class numericVectortype introduced by #684.magnitudereturns the Euclidean (L2) magnitude of the input vector.Syntax
returns:
Semantics
For
V(x1, ..., xn), the result is:Vector0.Naming
Use
magnituderather than the formernormwording from #553. This keeps the user-facing vocabulary explicit and avoids overloadingnormwith different possible norm definitions.Acceptance criteria
V(3,4) | magnitudereturns5.0.Dependency
Depends on #684.