Function norm
Computes the Euclidean norm of a vector.
Returns
The norm in MetricScalar!T.
Components are converted to the metric computation type and evaluated
with the shared Core hypot-compatible metric helper. The operation
deliberately does not compute sqrt(squaredNorm(vector)), avoiding
unnecessary intermediate square overflow and underflow.
Floating-point NaN and infinity follow the corresponding hypot
semantics.
No allocation is performed.
Complexity
O(1) time and O(1) auxiliary space.
Example
Example computing a vector norm through the public package API.
import geo;
auto vector = Vector2!int(3, 4);
static assert(
is(typeof(norm(vector)) == double)
);
assert(norm(vector) == 5.0);