1 #ifndef STAN_MATH_PRIM_FUN_NORM_HPP 2 #define STAN_MATH_PRIM_FUN_NORM_HPP 3 4 #include <stan/math/prim/fun/isinf.hpp> 5 #include <cmath> 6 #include <complex> 7 8 namespace stan { 9 namespace math { 10 namespace internal { 11 /** 12 * Return the squared magnitude of the complex argument. 13 * 14 * @tparam V value type of argument 15 * @param[in] z argument 16 * @return squared magnitude of the argument 17 */ 18 template <typename V> complex_norm(const std::complex<V> & z)19inline V complex_norm(const std::complex<V>& z) { 20 return square(z.real()) + square(z.imag()); 21 } 22 } // namespace internal 23 } // namespace math 24 } // namespace stan 25 26 #endif 27