зеркало из https://github.com/github/ruby.git
complex.c: rb_dbl_complex_polar_pi
* complex.c (rb_dbl_complex_polar_pi): suffixed with _pi to clarify that `ang` is not radian, but multiplied by PI. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
7d9623eb24
Коммит
3e063ca7ae
2
bignum.c
2
bignum.c
|
@ -6211,7 +6211,7 @@ rb_big_pow(VALUE x, VALUE y)
|
||||||
if (RB_FLOAT_TYPE_P(y)) {
|
if (RB_FLOAT_TYPE_P(y)) {
|
||||||
d = RFLOAT_VALUE(y);
|
d = RFLOAT_VALUE(y);
|
||||||
if ((BIGNUM_NEGATIVE_P(x) && !BIGZEROP(x))) {
|
if ((BIGNUM_NEGATIVE_P(x) && !BIGZEROP(x))) {
|
||||||
return rb_dbl_complex_polar(pow(-rb_big2dbl(x), d), d);
|
return rb_dbl_complex_polar_pi(pow(-rb_big2dbl(x), d), d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (RB_BIGNUM_TYPE_P(y)) {
|
else if (RB_BIGNUM_TYPE_P(y)) {
|
||||||
|
|
|
@ -546,7 +546,7 @@ f_complex_polar(VALUE klass, VALUE x, VALUE y)
|
||||||
|
|
||||||
/* returns a Complex or Float of ang*PI-rotated abs */
|
/* returns a Complex or Float of ang*PI-rotated abs */
|
||||||
VALUE
|
VALUE
|
||||||
rb_dbl_complex_polar(double abs, double ang)
|
rb_dbl_complex_polar_pi(double abs, double ang)
|
||||||
{
|
{
|
||||||
double fi;
|
double fi;
|
||||||
const double fr = modf(ang, &fi);
|
const double fr = modf(ang, &fi);
|
||||||
|
|
|
@ -1299,7 +1299,7 @@ VALUE rb_complex_plus(VALUE, VALUE);
|
||||||
VALUE rb_complex_mul(VALUE, VALUE);
|
VALUE rb_complex_mul(VALUE, VALUE);
|
||||||
VALUE rb_complex_abs(VALUE x);
|
VALUE rb_complex_abs(VALUE x);
|
||||||
VALUE rb_complex_sqrt(VALUE x);
|
VALUE rb_complex_sqrt(VALUE x);
|
||||||
VALUE rb_dbl_complex_polar(double abs, double ang);
|
VALUE rb_dbl_complex_polar_pi(double abs, double ang);
|
||||||
VALUE rb_complex_pow(VALUE self, VALUE other);
|
VALUE rb_complex_pow(VALUE self, VALUE other);
|
||||||
|
|
||||||
/* cont.c */
|
/* cont.c */
|
||||||
|
|
|
@ -1276,7 +1276,7 @@ rb_float_pow(VALUE x, VALUE y)
|
||||||
dx = RFLOAT_VALUE(x);
|
dx = RFLOAT_VALUE(x);
|
||||||
dy = RFLOAT_VALUE(y);
|
dy = RFLOAT_VALUE(y);
|
||||||
if (dx < 0 && dy != round(dy))
|
if (dx < 0 && dy != round(dy))
|
||||||
return rb_dbl_complex_polar(pow(-dx, dy), dy);
|
return rb_dbl_complex_polar_pi(pow(-dx, dy), dy);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return rb_num_coerce_bin(x, y, idPow);
|
return rb_num_coerce_bin(x, y, idPow);
|
||||||
|
@ -4056,7 +4056,7 @@ fix_pow(VALUE x, VALUE y)
|
||||||
if (a == 1) return DBL2NUM(1.0);
|
if (a == 1) return DBL2NUM(1.0);
|
||||||
{
|
{
|
||||||
if (a < 0 && dy != round(dy))
|
if (a < 0 && dy != round(dy))
|
||||||
return rb_dbl_complex_polar(pow(-(double)a, dy), dy);
|
return rb_dbl_complex_polar_pi(pow(-(double)a, dy), dy);
|
||||||
return DBL2NUM(pow((double)a, dy));
|
return DBL2NUM(pow((double)a, dy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче