instance method
Complex#abs2
() -> ::Numeric
abs2 → float
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 (magnitude) for self; see polar coordinates:
Example
Complex.polar(2, 2).abs2 # => 4.0
If self was created with rectangular coordinates, the returned value is computed, and may be inexact:
Example
Complex.rectangular(1.0/3, 1.0/3).abs2 # => 0.2222222222222222