Removed canonicalization for mathn
This commit is contained in:
parent
8b3653b484
commit
b958e2add8
Notes:
git
2020-11-10 11:14:40 +09:00
1
.github/workflows/compilers.yml
vendored
1
.github/workflows/compilers.yml
vendored
@ -92,7 +92,6 @@ jobs:
|
|||||||
- { key: append_configure, name: valgrind, value: '--with-valgrind' }
|
- { key: append_configure, name: valgrind, value: '--with-valgrind' }
|
||||||
- { key: append_configure, name: 'coroutine=ucontext', value: '--with-coroutine=ucontext' }
|
- { key: append_configure, name: 'coroutine=ucontext', value: '--with-coroutine=ucontext' }
|
||||||
- { key: append_configure, name: 'coroutine=copy', value: '--with-coroutine=copy' }
|
- { key: append_configure, name: 'coroutine=copy', value: '--with-coroutine=copy' }
|
||||||
- { key: append_configure, name: disable-mathn, value: '--disable-mathn' }
|
|
||||||
- { key: append_configure, name: disable-jit-support, value: '--disable-jit-support' }
|
- { key: append_configure, name: disable-jit-support, value: '--disable-jit-support' }
|
||||||
- { key: append_configure, name: disable-dln, value: '--disable-dln' }
|
- { key: append_configure, name: disable-dln, value: '--disable-dln' }
|
||||||
- { key: append_configure, name: disable-rubygems, value: '--disable-rubygems' }
|
- { key: append_configure, name: disable-rubygems, value: '--disable-rubygems' }
|
||||||
|
6
array.c
6
array.c
@ -7593,12 +7593,6 @@ finish_exact_sum(long n, VALUE r, VALUE v, int z)
|
|||||||
if (n != 0)
|
if (n != 0)
|
||||||
v = rb_fix_plus(LONG2FIX(n), v);
|
v = rb_fix_plus(LONG2FIX(n), v);
|
||||||
if (r != Qundef) {
|
if (r != Qundef) {
|
||||||
/* r can be an Integer when mathn is loaded */
|
|
||||||
if (FIXNUM_P(r))
|
|
||||||
v = rb_fix_plus(r, v);
|
|
||||||
else if (RB_TYPE_P(r, T_BIGNUM))
|
|
||||||
v = rb_big_plus(r, v);
|
|
||||||
else
|
|
||||||
v = rb_rational_plus(r, v);
|
v = rb_rational_plus(r, v);
|
||||||
}
|
}
|
||||||
else if (!n && z) {
|
else if (!n && z) {
|
||||||
|
21
complex.c
21
complex.c
@ -429,18 +429,6 @@ f_complex_new_bang2(VALUE klass, VALUE x, VALUE y)
|
|||||||
return nucomp_s_new_internal(klass, x, y);
|
return nucomp_s_new_internal(klass, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CANONICALIZATION_FOR_MATHN
|
|
||||||
static int canonicalization = 0;
|
|
||||||
|
|
||||||
RUBY_FUNC_EXPORTED void
|
|
||||||
nucomp_canonicalization(int f)
|
|
||||||
{
|
|
||||||
canonicalization = f;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define canonicalization 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline static void
|
inline static void
|
||||||
nucomp_real_check(VALUE num)
|
nucomp_real_check(VALUE num)
|
||||||
{
|
{
|
||||||
@ -456,10 +444,6 @@ inline static VALUE
|
|||||||
nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE imag)
|
nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE imag)
|
||||||
{
|
{
|
||||||
int complex_r, complex_i;
|
int complex_r, complex_i;
|
||||||
#ifdef CANONICALIZATION_FOR_MATHN
|
|
||||||
if (k_exact_zero_p(imag) && canonicalization)
|
|
||||||
return real;
|
|
||||||
#endif
|
|
||||||
complex_r = RB_TYPE_P(real, T_COMPLEX);
|
complex_r = RB_TYPE_P(real, T_COMPLEX);
|
||||||
complex_i = RB_TYPE_P(imag, T_COMPLEX);
|
complex_i = RB_TYPE_P(imag, T_COMPLEX);
|
||||||
if (!complex_r && !complex_i) {
|
if (!complex_r && !complex_i) {
|
||||||
@ -636,14 +620,12 @@ f_complex_polar(VALUE klass, VALUE x, VALUE y)
|
|||||||
assert(!RB_TYPE_P(x, T_COMPLEX));
|
assert(!RB_TYPE_P(x, T_COMPLEX));
|
||||||
assert(!RB_TYPE_P(y, T_COMPLEX));
|
assert(!RB_TYPE_P(y, T_COMPLEX));
|
||||||
if (f_zero_p(x) || f_zero_p(y)) {
|
if (f_zero_p(x) || f_zero_p(y)) {
|
||||||
if (canonicalization) return x;
|
|
||||||
return nucomp_s_new_internal(klass, x, RFLOAT_0);
|
return nucomp_s_new_internal(klass, x, RFLOAT_0);
|
||||||
}
|
}
|
||||||
if (RB_FLOAT_TYPE_P(y)) {
|
if (RB_FLOAT_TYPE_P(y)) {
|
||||||
const double arg = RFLOAT_VALUE(y);
|
const double arg = RFLOAT_VALUE(y);
|
||||||
if (arg == M_PI) {
|
if (arg == M_PI) {
|
||||||
x = f_negate(x);
|
x = f_negate(x);
|
||||||
if (canonicalization) return x;
|
|
||||||
y = RFLOAT_0;
|
y = RFLOAT_0;
|
||||||
}
|
}
|
||||||
else if (arg == M_PI_2) {
|
else if (arg == M_PI_2) {
|
||||||
@ -658,14 +640,12 @@ f_complex_polar(VALUE klass, VALUE x, VALUE y)
|
|||||||
const double abs = RFLOAT_VALUE(x);
|
const double abs = RFLOAT_VALUE(x);
|
||||||
const double real = abs * cos(arg), imag = abs * sin(arg);
|
const double real = abs * cos(arg), imag = abs * sin(arg);
|
||||||
x = DBL2NUM(real);
|
x = DBL2NUM(real);
|
||||||
if (canonicalization && imag == 0.0) return x;
|
|
||||||
y = DBL2NUM(imag);
|
y = DBL2NUM(imag);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const double ax = sin(arg), ay = cos(arg);
|
const double ax = sin(arg), ay = cos(arg);
|
||||||
y = f_mul(x, DBL2NUM(ax));
|
y = f_mul(x, DBL2NUM(ax));
|
||||||
x = f_mul(x, DBL2NUM(ay));
|
x = f_mul(x, DBL2NUM(ay));
|
||||||
if (canonicalization && f_zero_p(y)) return x;
|
|
||||||
}
|
}
|
||||||
return nucomp_s_new_internal(klass, x, y);
|
return nucomp_s_new_internal(klass, x, y);
|
||||||
}
|
}
|
||||||
@ -725,7 +705,6 @@ nucomp_s_polar(int argc, VALUE *argv, VALUE klass)
|
|||||||
switch (rb_scan_args(argc, argv, "11", &abs, &arg)) {
|
switch (rb_scan_args(argc, argv, "11", &abs, &arg)) {
|
||||||
case 1:
|
case 1:
|
||||||
nucomp_real_check(abs);
|
nucomp_real_check(abs);
|
||||||
if (canonicalization) return abs;
|
|
||||||
return nucomp_s_new_internal(klass, abs, ZERO);
|
return nucomp_s_new_internal(klass, abs, ZERO);
|
||||||
default:
|
default:
|
||||||
nucomp_real_check(abs);
|
nucomp_real_check(abs);
|
||||||
|
@ -1626,10 +1626,8 @@ RUBY_DECL_ATTRIBUTE([__nonnull__(n)], [RUBY_FUNC_NONNULL(n,x)], [rb_cv_func_nonn
|
|||||||
RUBY_APPEND_OPTION(XCFLAGS, -DRUBY_EXPORT)
|
RUBY_APPEND_OPTION(XCFLAGS, -DRUBY_EXPORT)
|
||||||
|
|
||||||
AC_ARG_ENABLE(mathn,
|
AC_ARG_ENABLE(mathn,
|
||||||
AS_HELP_STRING([--disable-mathn], [disable canonicalization for mathn]),
|
AS_HELP_STRING([--enable-mathn], [enable canonicalization for mathn]),
|
||||||
[mathn=$enableval], [mathn=yes])
|
[AC_MSG_ERROR([mathn support has been dropped])])
|
||||||
test "x$mathn" = xyes || mathn=
|
|
||||||
AC_SUBST(MATHN, $mathn)
|
|
||||||
|
|
||||||
AC_CACHE_CHECK(for function name string predefined identifier,
|
AC_CACHE_CHECK(for function name string predefined identifier,
|
||||||
rb_cv_function_name_string,
|
rb_cv_function_name_string,
|
||||||
|
9
enum.c
9
enum.c
@ -3854,10 +3854,7 @@ sum_iter_normalize_memo(struct enum_sum_memo *memo)
|
|||||||
memo->v = rb_fix_plus(LONG2FIX(memo->n), memo->v);
|
memo->v = rb_fix_plus(LONG2FIX(memo->n), memo->v);
|
||||||
memo->n = 0;
|
memo->n = 0;
|
||||||
|
|
||||||
/* r can be an Integer when mathn is loaded */
|
|
||||||
switch (TYPE(memo->r)) {
|
switch (TYPE(memo->r)) {
|
||||||
case T_FIXNUM: memo->v = rb_fix_plus(memo->r, memo->v); break;
|
|
||||||
case T_BIGNUM: memo->v = rb_big_plus(memo->r, memo->v); break;
|
|
||||||
case T_RATIONAL: memo->v = rb_rational_plus(memo->r, memo->v); break;
|
case T_RATIONAL: memo->v = rb_rational_plus(memo->r, memo->v); break;
|
||||||
case T_UNDEF: break;
|
case T_UNDEF: break;
|
||||||
default: UNREACHABLE; /* or ...? */
|
default: UNREACHABLE; /* or ...? */
|
||||||
@ -4107,12 +4104,6 @@ enum_sum(int argc, VALUE* argv, VALUE obj)
|
|||||||
if (memo.n != 0)
|
if (memo.n != 0)
|
||||||
memo.v = rb_fix_plus(LONG2FIX(memo.n), memo.v);
|
memo.v = rb_fix_plus(LONG2FIX(memo.n), memo.v);
|
||||||
if (memo.r != Qundef) {
|
if (memo.r != Qundef) {
|
||||||
/* r can be an Integer when mathn is loaded */
|
|
||||||
if (FIXNUM_P(memo.r))
|
|
||||||
memo.v = rb_fix_plus(memo.r, memo.v);
|
|
||||||
else if (RB_TYPE_P(memo.r, T_BIGNUM))
|
|
||||||
memo.v = rb_big_plus(memo.r, memo.v);
|
|
||||||
else
|
|
||||||
memo.v = rb_rational_plus(memo.r, memo.v);
|
memo.v = rb_rational_plus(memo.r, memo.v);
|
||||||
}
|
}
|
||||||
return memo.v;
|
return memo.v;
|
||||||
|
33
rational.c
33
rational.c
@ -430,18 +430,6 @@ f_rational_new_bang1(VALUE klass, VALUE x)
|
|||||||
return nurat_s_new_internal(klass, x, ONE);
|
return nurat_s_new_internal(klass, x, ONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CANONICALIZATION_FOR_MATHN
|
|
||||||
static int canonicalization = 0;
|
|
||||||
|
|
||||||
RUBY_FUNC_EXPORTED void
|
|
||||||
nurat_canonicalization(int f)
|
|
||||||
{
|
|
||||||
canonicalization = f;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
# define canonicalization 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline static void
|
inline static void
|
||||||
nurat_int_check(VALUE num)
|
nurat_int_check(VALUE num)
|
||||||
{
|
{
|
||||||
@ -490,8 +478,6 @@ nurat_s_canonicalize_internal(VALUE klass, VALUE num, VALUE den)
|
|||||||
nurat_canonicalize(&num, &den);
|
nurat_canonicalize(&num, &den);
|
||||||
nurat_reduce(&num, &den);
|
nurat_reduce(&num, &den);
|
||||||
|
|
||||||
if (canonicalization && f_one_p(den))
|
|
||||||
return num;
|
|
||||||
return nurat_s_new_internal(klass, num, den);
|
return nurat_s_new_internal(klass, num, den);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,8 +486,6 @@ nurat_s_canonicalize_internal_no_reduce(VALUE klass, VALUE num, VALUE den)
|
|||||||
{
|
{
|
||||||
nurat_canonicalize(&num, &den);
|
nurat_canonicalize(&num, &den);
|
||||||
|
|
||||||
if (canonicalization && f_one_p(den))
|
|
||||||
return num;
|
|
||||||
return nurat_s_new_internal(klass, num, den);
|
return nurat_s_new_internal(klass, num, den);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2028,12 +2012,7 @@ rb_numeric_quo(VALUE x, VALUE y)
|
|||||||
return rb_funcallv(x, idFdiv, 1, &y);
|
return rb_funcallv(x, idFdiv, 1, &y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canonicalization) {
|
|
||||||
x = rb_rational_raw1(x);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
x = rb_convert_type(x, T_RATIONAL, "Rational", "to_r");
|
x = rb_convert_type(x, T_RATIONAL, "Rational", "to_r");
|
||||||
}
|
|
||||||
return nurat_div(x, y);
|
return nurat_div(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2092,9 +2071,6 @@ rb_float_numerator(VALUE self)
|
|||||||
if (isinf(d) || isnan(d))
|
if (isinf(d) || isnan(d))
|
||||||
return self;
|
return self;
|
||||||
r = float_to_r(self);
|
r = float_to_r(self);
|
||||||
if (canonicalization && k_integer_p(r)) {
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
return nurat_numerator(r);
|
return nurat_numerator(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2115,9 +2091,6 @@ rb_float_denominator(VALUE self)
|
|||||||
if (isinf(d) || isnan(d))
|
if (isinf(d) || isnan(d))
|
||||||
return INT2FIX(1);
|
return INT2FIX(1);
|
||||||
r = float_to_r(self);
|
r = float_to_r(self);
|
||||||
if (canonicalization && k_integer_p(r)) {
|
|
||||||
return ONE;
|
|
||||||
}
|
|
||||||
return nurat_denominator(r);
|
return nurat_denominator(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2425,7 +2398,7 @@ parse_rat(const char *s, const char *const e, int strict, int raise)
|
|||||||
|
|
||||||
if (!read_num(&s, e, &num, &nexp)) {
|
if (!read_num(&s, e, &num, &nexp)) {
|
||||||
if (strict) return Qnil;
|
if (strict) return Qnil;
|
||||||
return canonicalization ? ZERO : nurat_s_alloc(rb_cRational);
|
return nurat_s_alloc(rb_cRational);
|
||||||
}
|
}
|
||||||
den = ONE;
|
den = ONE;
|
||||||
if (s < e && *s == '/') {
|
if (s < e && *s == '/') {
|
||||||
@ -2481,9 +2454,7 @@ parse_rat(const char *s, const char *const e, int strict, int raise)
|
|||||||
num = negate_num(num);
|
num = negate_num(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!canonicalization || den != ONE)
|
return rb_rational_raw(num, den);
|
||||||
num = rb_rational_raw(num, den);
|
|
||||||
return num;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
|
@ -84,8 +84,7 @@ optflags = @optflags@
|
|||||||
debugflags = @debugflags@
|
debugflags = @debugflags@
|
||||||
warnflags = @warnflags@ @strict_warnflags@
|
warnflags = @warnflags@ @strict_warnflags@
|
||||||
cppflags = @cppflags@
|
cppflags = @cppflags@
|
||||||
MATHN = @MATHN@
|
XCFLAGS = @XCFLAGS@ $(INCFLAGS)
|
||||||
XCFLAGS = @XCFLAGS@ $(MATHN:yes=-DCANONICALIZATION_FOR_MATHN) $(INCFLAGS)
|
|
||||||
USE_RUBYGEMS = @USE_RUBYGEMS@
|
USE_RUBYGEMS = @USE_RUBYGEMS@
|
||||||
USE_RUBYGEMS_ = $(USE_RUBYGEMS:yes=)
|
USE_RUBYGEMS_ = $(USE_RUBYGEMS:yes=)
|
||||||
CPPFLAGS = @CPPFLAGS@ $(USE_RUBYGEMS_:no=-DDISABLE_RUBYGEMS=1)
|
CPPFLAGS = @CPPFLAGS@ $(USE_RUBYGEMS_:no=-DDISABLE_RUBYGEMS=1)
|
||||||
|
@ -67,9 +67,6 @@ icondirs=$(ICONDIRS)
|
|||||||
icondirs=$(icondirs:\=/)
|
icondirs=$(icondirs:\=/)
|
||||||
iconinc=-I$(icondirs: = -I)
|
iconinc=-I$(icondirs: = -I)
|
||||||
!endif
|
!endif
|
||||||
!if !defined(MATHN)
|
|
||||||
MATHN = yes
|
|
||||||
!endif
|
|
||||||
###############
|
###############
|
||||||
|
|
||||||
.SUFFIXES: .def .lib
|
.SUFFIXES: .def .lib
|
||||||
@ -308,9 +305,6 @@ ARFLAGS = -machine:$(MACHINE) -out:
|
|||||||
LD = $(CC)
|
LD = $(CC)
|
||||||
LDSHARED = $(LD) -LD
|
LDSHARED = $(LD) -LD
|
||||||
XCFLAGS = -DRUBY_EXPORT $(INCFLAGS) $(XCFLAGS)
|
XCFLAGS = -DRUBY_EXPORT $(INCFLAGS) $(XCFLAGS)
|
||||||
!if "$(MATHN)" == "yes"
|
|
||||||
XCFLAGS = $(XCFLAGS) -DCANONICALIZATION_FOR_MATHN
|
|
||||||
!endif
|
|
||||||
!if $(MSC_VER) >= 1400
|
!if $(MSC_VER) >= 1400
|
||||||
# Prevents VC++ 2005 (cl ver 14) warnings
|
# Prevents VC++ 2005 (cl ver 14) warnings
|
||||||
MANIFESTTOOL = mt -nologo
|
MANIFESTTOOL = mt -nologo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user