Feature #10386 ยป from_complex.c.patch
complex.c | ||
---|---|---|
523 | 523 |
} |
524 | 524 |
} |
525 |
#if 0 |
|
526 |
imp1(sqrt) |
|
527 | ||
528 |
static VALUE |
|
529 |
m_sqrt(VALUE x) |
|
530 |
{ |
|
531 |
if (f_real_p(x)) { |
|
532 |
if (f_positive_p(x)) |
|
533 |
return m_sqrt_bang(x); |
|
534 |
return f_complex_new2(rb_cComplex, ZERO, m_sqrt_bang(f_negate(x))); |
|
535 |
} |
|
536 |
else { |
|
537 |
get_dat1(x); |
|
538 | ||
539 |
if (f_negative_p(dat->imag)) |
|
540 |
return f_conj(m_sqrt(f_conj(x))); |
|
541 |
else { |
|
542 |
VALUE a = f_abs(x); |
|
543 |
return f_complex_new2(rb_cComplex, |
|
544 |
m_sqrt_bang(f_div(f_add(a, dat->real), TWO)), |
|
545 |
m_sqrt_bang(f_div(f_sub(a, dat->real), TWO))); |
|
546 |
} |
|
547 |
} |
|
548 |
} |
|
549 |
#endif |
|
550 | ||
551 | 525 |
inline static VALUE |
552 | 526 |
f_complex_polar(VALUE klass, VALUE x, VALUE y) |
553 | 527 |
{ |
554 |
- |