Method: Complex#abs2
- Defined in:
- complex.c
#abs2 ⇒ Float
Returns square of the absolute value (magnitude) for self; see polar coordinates:
Complex.polar(2, 2).abs2 # => 4.0
If self was created with rectangular coordinates, the returned value is computed, and may be inexact:
Complex.rectangular(1.0/3, 1.0/3).abs2 # => 0.2222222222222222
1366 1367 1368 1369 1370 1371 1372 |
# File 'complex.c', line 1366 static VALUE nucomp_abs2(VALUE self) { get_dat1(self); return f_add(f_mul(dat->real, dat->real), f_mul(dat->imag, dat->imag)); } |