complex.c: rb_complex_new_polar
* complex.c (rb_complex_new_polar): renamed with _new to clarify that it creates a new instance, but is not an instance method. * complex.c (rb_complex_polar): deprecated. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
dd046c59de
commit
dc8afd385d
2
bignum.c
2
bignum.c
@ -6237,7 +6237,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_pi(pow(-rb_big2dbl(x), d), d);
|
return rb_dbl_complex_new_polar_pi(pow(-rb_big2dbl(x), d), d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (RB_BIGNUM_TYPE_P(y)) {
|
else if (RB_BIGNUM_TYPE_P(y)) {
|
||||||
|
12
complex.c
12
complex.c
@ -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_pi(double abs, double ang)
|
rb_dbl_complex_new_polar_pi(double abs, double ang)
|
||||||
{
|
{
|
||||||
double fi;
|
double fi;
|
||||||
const double fr = modf(ang, &fi);
|
const double fr = modf(ang, &fi);
|
||||||
@ -1382,11 +1382,17 @@ rb_complex_new(VALUE x, VALUE y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_complex_polar(VALUE x, VALUE y)
|
rb_complex_new_polar(VALUE x, VALUE y)
|
||||||
{
|
{
|
||||||
return f_complex_polar(rb_cComplex, x, y);
|
return f_complex_polar(rb_cComplex, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
rb_complex_polar(VALUE x, VALUE y)
|
||||||
|
{
|
||||||
|
return rb_complex_new_polar(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_Complex(VALUE x, VALUE y)
|
rb_Complex(VALUE x, VALUE y)
|
||||||
{
|
{
|
||||||
@ -1737,7 +1743,7 @@ read_comp(const char **s, int strict,
|
|||||||
return 0; /* e.g. "1@-" */
|
return 0; /* e.g. "1@-" */
|
||||||
}
|
}
|
||||||
num2 = str2num(bb);
|
num2 = str2num(bb);
|
||||||
*ret = rb_complex_polar(num, num2);
|
*ret = rb_complex_new_polar(num, num2);
|
||||||
if (!st)
|
if (!st)
|
||||||
return 0; /* e.g. "1@2." */
|
return 0; /* e.g. "1@2." */
|
||||||
else
|
else
|
||||||
|
@ -188,7 +188,8 @@ VALUE rb_complex_raw(VALUE, VALUE);
|
|||||||
VALUE rb_complex_new(VALUE, VALUE);
|
VALUE rb_complex_new(VALUE, VALUE);
|
||||||
#define rb_complex_new1(x) rb_complex_new((x), INT2FIX(0))
|
#define rb_complex_new1(x) rb_complex_new((x), INT2FIX(0))
|
||||||
#define rb_complex_new2(x,y) rb_complex_new((x), (y))
|
#define rb_complex_new2(x,y) rb_complex_new((x), (y))
|
||||||
VALUE rb_complex_polar(VALUE, VALUE);
|
VALUE rb_complex_new_polar(VALUE abs, VALUE arg);
|
||||||
|
DEPRECATED_BY(rb_complex_new_polar, VALUE rb_complex_polar(VALUE abs, VALUE arg));
|
||||||
VALUE rb_Complex(VALUE, VALUE);
|
VALUE rb_Complex(VALUE, VALUE);
|
||||||
#define rb_Complex1(x) rb_Complex((x), INT2FIX(0))
|
#define rb_Complex1(x) rb_Complex((x), INT2FIX(0))
|
||||||
#define rb_Complex2(x,y) rb_Complex((x), (y))
|
#define rb_Complex2(x,y) rb_Complex((x), (y))
|
||||||
|
@ -1384,7 +1384,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_pi(double abs, double ang);
|
VALUE rb_dbl_complex_new_polar_pi(double abs, double ang);
|
||||||
VALUE rb_complex_pow(VALUE self, VALUE other);
|
VALUE rb_complex_pow(VALUE self, VALUE other);
|
||||||
|
|
||||||
struct rb_thread_struct;
|
struct rb_thread_struct;
|
||||||
|
@ -1308,7 +1308,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_pi(pow(-dx, dy), dy);
|
return rb_dbl_complex_new_polar_pi(pow(-dx, dy), dy);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return rb_num_coerce_bin(x, y, idPow);
|
return rb_num_coerce_bin(x, y, idPow);
|
||||||
@ -4083,7 +4083,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_pi(pow(-(double)a, dy), dy);
|
return rb_dbl_complex_new_polar_pi(pow(-(double)a, dy), dy);
|
||||||
return DBL2NUM(pow((double)a, dy));
|
return DBL2NUM(pow((double)a, dy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user