e$B$J$+$@$G$9!#e(B
At Sat, 15 Mar 2008 12:52:19 +0900,
Tadayoshi F. wrote in [ruby-dev:34060]:
e$B$*$=$i$/!"L@F|:n6H$7$^$9!#@PDM$5$s$,e(B rational.rbe$B!"e(Bcomplex.rb mathn.rb
e$B$r8x3+$5$l$F0JMh!"e(B4121 e$BF|$V$j$NBg2~D{$K$J$k$N$G$O$J$$$+$H;W$$$^$9!#e(B
e$B$*$+$7$J$H$3$m!"<u$1F~$l$kB&$+$i8+$F5$;}$N0-$$$H$3$m$J$I$O!"$I$s$I$sD>e(B
e$B$7$F$b$i$$$?$$$H;W$$$^$9!#:G0-!"2?;~$G$be(B revert e$B$G$-$k$N$G$d$C$F$7$^$$e(B
e$B$^$9!#e(B
e$B?tCM%j%F%i%k$G$OO"B3$9$k%"%s%@!<%9%3%"$O5v$5$l$J$/$J$C$F$$$^$9$+e(B
e$B$i!"e(BComplexe$B$de(BRationale$B$G$bB7$($?$[$&$,$$$$$s$8$c$J$$$G$7$g$&$+!#e(B
e$B%$%s%G%s%H$,B>$H0c$&$N$,$A$g$C$H5$$K$J$k$H$$$&$N$b$"$k$1$I!#e(B
Index: complex.c
— complex.c (revision 15792)
+++ complex.c (working copy)
@@ -203,4 +203,5 @@ nucomp_s_canonicalize_internal(VALUE kla
}
+#if 0
static VALUE
nucomp_s_canonicalize(int argc, VALUE *argv, VALUE klass)
@@ -236,4 +237,5 @@ nucomp_s_canonicalize(int argc, VALUE *a
return nucomp_s_canonicalize_internal(klass, real, image);
}
+#endif
static VALUE
@@ -460,4 +462,5 @@ m_atan2_bang(VALUE y, VALUE x)
}
+#if 0
static VALUE
m_hypot(VALUE x, VALUE y)
@@ -467,4 +470,5 @@ m_hypot(VALUE x, VALUE y)
}
#endif
+#endif
static VALUE
@@ -627,4 +631,5 @@ nucomp_rdiv(VALUE self, VALUE other)
}
+#if 0
static VALUE
nucomp_fdiv(VALUE self, VALUE other)
@@ -636,4 +641,5 @@ nucomp_fdiv(VALUE self, VALUE other)
f_to_f(dat->image)), other);
}
+#endif
static VALUE
@@ -789,4 +795,5 @@ nucomp_conjugate(VALUE self)
}
+#if 0
static VALUE
nucomp_real_p(VALUE self)
@@ -813,4 +820,5 @@ nucomp_inexact_p(VALUE self)
return f_boolcast(!nucomp_exact_p(self));
}
+#endif
inline static long
@@ -979,15 +987,15 @@ nucomp_to_s(VALUE self)
else {
s = f_to_s(dat->real);
- rb_str_concat(s, rb_str_new2(!impos ? “-” : “+”));
- rb_str_cat2(s, (!impos ? “-” : “+”));
}
if (k_rational_p(dat->image) &&
!f_one_p(f_denominator(dat->image))) {
- rb_str_concat(s, rb_str_new2("("));
- rb_str_cat2(s, “(”);
rb_str_concat(s, f_to_s(rezero ? dat->image : f_abs(dat->image)));
- rb_str_concat(s, rb_str_new2(")i"));
- rb_str_cat2(s, “)i”);
} else {
rb_str_concat(s, f_to_s(rezero ? dat->image : f_abs(dat->image)));
- rb_str_concat(s, rb_str_new2(“i”));
@@ -1004,7 +1012,7 @@ nucomp_inspect(VALUE self)
s = rb_str_new2(“Complex(”);
rb_str_concat(s, f_inspect(dat->real));
- rb_str_concat(s, rb_str_new2(", "));
- rb_str_cat2(s, ", ");
rb_str_concat(s, f_inspect(dat->image));
- rb_str_concat(s, rb_str_new2(")"));
static VALUE comp_pat1, comp_pat2, a_slash, a_dot_and_an_e,
- image_garbages_pat, null_string, underscores_pat, an_underscore;
- image_garbages_pat, null_string;
#define DIGITS “(?:\d(?:_\d|\d)*)”
@@ -1123,13 +1131,13 @@ static void
make_patterns(void)
{
- static char *comp_pat1_source = PATTERN1;
- static char *comp_pat2_source = PATTERN2;
- static char *image_garbages_pat_source = “[+\(\)iIjJ]”;
- static char *underscores_pat_source = “_+”;
- static const char comp_pat1_source[] = PATTERN1;
- static const char comp_pat2_source[] = PATTERN2;
- static const char image_garbages_pat_source[] = “[+\(\)iIjJ]”;
+#define REG_NEW(s) rb_reg_new(s, sizeof(s) - 1, 0)
- comp_pat1 = rb_reg_new(comp_pat1_source, strlen(comp_pat1_source),
0);
- comp_pat1 = REG_NEW(comp_pat1_source);
rb_global_variable(&comp_pat1);
- comp_pat2 = rb_reg_new(comp_pat2_source, strlen(comp_pat2_source),
0);
- comp_pat2 = REG_NEW(comp_pat2_source);
rb_global_variable(&comp_pat2);
@@ -1140,6 +1148,5 @@ make_patterns(void)
rb_global_variable(&a_dot_and_an_e);
- image_garbages_pat = REG_NEW(image_garbages_pat_source);
rb_global_variable(&image_garbages_pat);
@@ -1147,10 +1154,5 @@ make_patterns(void)
rb_global_variable(&null_string);
@@ -1247,6 +1249,5 @@ static VALUE
string_to_c(VALUE self)
{
- VALUE s = f_gsub(self, underscores_pat, an_underscore);
- VALUE a = string_to_c_internal(s);
- VALUE a = string_to_c_internal(self);
if (!NIL_P(RARRAY_PTR(a)[0]))
return RARRAY_PTR(a)[0];
Index: rational.c
===================================================================
— rational.c (revision 15792)
+++ rational.c (working copy)
@@ -231,4 +231,5 @@ nurat_s_canonicalize_internal(VALUE klas
}
+#if 0
static VALUE
nurat_s_canonicalize(int argc, VALUE *argv, VALUE klass)
@@ -260,4 +261,5 @@ nurat_s_canonicalize(int argc, VALUE *ar
return nurat_s_canonicalize_internal(klass, num, den);
}
+#endif
static VALUE
@@ -585,4 +587,5 @@ nurat_divmod(VALUE self, VALUE other)
}
+#if 0
static VALUE
nurat_quot(VALUE self, VALUE other)
@@ -590,4 +593,6 @@ nurat_quot(VALUE self, VALUE other)
return f_truncate(f_div(self, other));
}
+#endif
+
static VALUE
nurat_rem(VALUE self, VALUE other)
@@ -597,4 +602,5 @@ nurat_rem(VALUE self, VALUE other)
}
+#if 0
static VALUE
nurat_quotrem(VALUE self, VALUE other)
@@ -603,4 +609,5 @@ nurat_quotrem(VALUE self, VALUE other)
return rb_assoc_new(val, f_sub(self, f_mul(other, val)));
}
+#endif
static VALUE
@@ -613,4 +620,5 @@ nurat_abs(VALUE self)
}
+#if 0
static VALUE
nurat_true(VALUE self)
@@ -618,4 +626,5 @@ nurat_true(VALUE self)
return Qtrue;
}
+#endif
static VALUE
@@ -775,5 +784,5 @@ float_to_r(VALUE self)
}
-static VALUE rat_pat, an_e_pat, a_dot_pat, underscores_pat,
an_underscore;
+static VALUE rat_pat, an_e_pat, a_dot_pat;
#define DIGITS “(?:\d(?:_\d|\d)*)”
@@ -785,24 +794,19 @@ static void
make_patterns(void)
{
- static char *rat_pat_source = PATTERN;
- static char *an_e_pat_source = “[eE]”;
- static char *a_dot_pat_source = “\.”;
- static char *underscores_pat_source = “_+”;
- static const char rat_pat_source[] = PATTERN;
- static const char an_e_pat_source[] = “[eE]”;
- static const char a_dot_pat_source[] = “\.”;
+#define REG_NEW(s) rb_reg_new(s, sizeof(s) - 1, 0)
- rat_pat = rb_reg_new(rat_pat_source, strlen(rat_pat_source), 0);
- rat_pat = REG_NEW(rat_pat_source);
rb_global_variable(&rat_pat);
- an_e_pat = rb_reg_new(an_e_pat_source, strlen(an_e_pat_source), 0);
- an_e_pat = REG_NEW(an_e_pat_source);
rb_global_variable(&an_e_pat);
- a_dot_pat = rb_reg_new(a_dot_pat_source, strlen(a_dot_pat_source),
0);
- a_dot_pat = REG_NEW(a_dot_pat_source);
rb_global_variable(&a_dot_pat);
@@ -909,6 +913,5 @@ static VALUE
string_to_r(VALUE self)
{
- VALUE s = f_gsub(self, underscores_pat, an_underscore);
- VALUE a = string_to_r_internal(s);
- VALUE a = string_to_r_internal(self);
if (!NIL_P(RARRAY_PTR(a)[0]))
return RARRAY_PTR(a)[0];