abs2#
Squared absolute value. For complex numbers, this is the squared complex magnitude, or real(t)2 + imag(t)2. For real numbers, this is equivalent to the squared value, or t2.
-
Op matx::abs2(Op t)#
Compute squared absolute value of every element in the tensor. For complex numbers this returns the squared magnitude, or real(t)^2 + imag(t)^2. For real numbers this returns the squared value, or t*t.
- Parameters:
t – Tensor or operator input
Examples#
auto x = make_tensor<cuda::std::complex<float>>({});
auto y = make_tensor<float>({});
x() = { 1.5f, 2.5f };
(y = abs2(x)).run(exec);
exec.sync();
ASSERT_NEAR(y(), 1.5f*1.5f+2.5f*2.5f, 1.0e-6);