End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Complex#abs2
cmp.abs2 → real
complex.c
View on GitHub ↗
static VALUE
nucomp_abs2(VALUE self)
{
get_dat1(self);
return f_add(f_mul(dat->real, dat->real),
f_mul(dat->imag, dat->imag));
}
Returns square of the absolute value.
Example
Complex(-1).abs2 #=> 1 Complex(3.0, -4.0).abs2 #=> 25.0