D-Programming-Language/phobos — pull request #2297 by Element-126 (2014-07-02 20:10:46+00:00)
Title: Enhancement request 13022: add `std.complex.abs2`

Add `std.complex.abs2`, which returns the squared modulus of a
`Complex` or real number.

Rationale:
* It is common to need the squared modulus of a complex number,
and using `abs(z)*abs(z)` would be inefficient due to the
computation of the square root.
* The name `abs2` has been chosen for consistency with `abs`, and
for being mathematically more correct than `norm`, used by C++ STL
for the equivalent function.
* For genericity, the function `abs2` is also declared for real
floating point numbers, in which case it simply returns its
square.

https://issues.dlang.org/show_bug.cgi?id=13022