mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* complex.c: continues to support canonicalization *unofficially*
for an odd library mathn for the time being (only 1.9.x). since grand mathn is must be very very special library for us. * rational.c: ditto. * ext/mathn/*/*: follow the above changes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d563f1680c
commit
2b72e549a7
7 changed files with 44 additions and 3136 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Tue Oct 28 23:05:35 2008 Tadayoshi Funaba <tadf@dotrb.org>
|
||||
|
||||
* complex.c: continues to support canonicalization *unofficially*
|
||||
for an odd library mathn for the time being (only 1.9.x).
|
||||
since grand mathn is must be very very special library for us.
|
||||
|
||||
* rational.c: ditto.
|
||||
|
||||
* ext/mathn/*/*: follow the above changes.
|
||||
|
||||
Tue Oct 28 21:31:55 2008 Yusuke Endoh <mame@tsg.ne.jp>
|
||||
|
||||
* parse.y (parser_yylex): check EOF explicitly.
|
||||
|
|
18
complex.c
18
complex.c
|
@ -320,7 +320,19 @@ f_complex_new_bang2(VALUE klass, VALUE x, VALUE y)
|
|||
return nucomp_s_new_internal(klass, x, y);
|
||||
}
|
||||
|
||||
#define f_unify_p(klass) rb_const_defined(klass, id_Unify)
|
||||
#if RUBY_VERSION_CODE < 200
|
||||
#define CANON
|
||||
#endif
|
||||
|
||||
#ifdef CANON
|
||||
static int canonicalization = 0;
|
||||
|
||||
void
|
||||
nucomp_canonicalize(int f)
|
||||
{
|
||||
canonicalization = f;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline static void
|
||||
nucomp_real_check(VALUE num)
|
||||
|
@ -343,10 +355,10 @@ nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE imag)
|
|||
#ifdef CANON
|
||||
#define CL_CANON
|
||||
#ifdef CL_CANON
|
||||
if (f_zero_p(imag) && k_exact_p(imag) && f_unify_p(klass))
|
||||
if (f_zero_p(imag) && k_exact_p(imag) && canonicalization)
|
||||
return real;
|
||||
#else
|
||||
if (f_zero_p(imag) && f_unify_p(klass))
|
||||
if (f_zero_p(imag) && canonicalization)
|
||||
return real;
|
||||
#endif
|
||||
#endif
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,3 @@
|
|||
require "mkmf"
|
||||
|
||||
$CPPFLAGS = "-DEXT_MATHN -DCANON -DCLCANON "
|
||||
|
||||
create_makefile "mathn/complex"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
require "mkmf"
|
||||
|
||||
$CPPFLAGS = "-DEXT_MATHN -DCANON -DCLCANON"
|
||||
|
||||
create_makefile "mathn/rational"
|
||||
|
|
File diff suppressed because it is too large
Load diff
18
rational.c
18
rational.c
|
@ -377,7 +377,19 @@ f_rational_new_bang2(VALUE klass, VALUE x, VALUE y)
|
|||
return nurat_s_new_internal(klass, x, y);
|
||||
}
|
||||
|
||||
#define f_unify_p(klass) rb_const_defined(klass, id_Unify)
|
||||
#if RUBY_VERSION_CODE < 200
|
||||
#define CANON
|
||||
#endif
|
||||
|
||||
#ifdef CANON
|
||||
static int canonicalization = 0;
|
||||
|
||||
void
|
||||
nurat_canonicalize(int f)
|
||||
{
|
||||
canonicalization = f;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline static void
|
||||
nurat_int_check(VALUE num)
|
||||
|
@ -421,7 +433,7 @@ nurat_s_canonicalize_internal(VALUE klass, VALUE num, VALUE den)
|
|||
den = f_idiv(den, gcd);
|
||||
|
||||
#ifdef CANON
|
||||
if (f_one_p(den) && f_unify_p(klass))
|
||||
if (f_one_p(den) && canonicalization)
|
||||
return num;
|
||||
#endif
|
||||
return nurat_s_new_internal(klass, num, den);
|
||||
|
@ -441,7 +453,7 @@ nurat_s_canonicalize_internal_no_reduce(VALUE klass, VALUE num, VALUE den)
|
|||
}
|
||||
|
||||
#ifdef CANON
|
||||
if (f_one_p(den) && f_unify_p(klass))
|
||||
if (f_one_p(den) && canonicalization)
|
||||
return num;
|
||||
#endif
|
||||
return nurat_s_new_internal(klass, num, den);
|
||||
|
|
Loading…
Reference in a new issue