[前][次][番号順一覧][スレッド一覧]

ruby-changes:52512

From: hsbt <ko1@a...>
Date: Thu, 13 Sep 2018 16:21:01 +0900 (JST)
Subject: [ruby-changes:52512] hsbt:r64723: Move rexml_adds_tests branch to tags.

hsbt	2018-09-13 16:02:43 +0900 (Thu, 13 Sep 2018)

  New Revision: 64723

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64723

  Log:
    Move rexml_adds_tests branch to tags.

  Added directories:
    tags/rexml_adds_tests/
  Removed directories:
    branches/rexml_adds_tests/
Index: rexml_adds_tests/vm_evalbody.c
===================================================================
--- rexml_adds_tests/vm_evalbody.c	(revision 64722)
+++ rexml_adds_tests/vm_evalbody.c	(nonexistent)
@@ -1,148 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/rexml_adds_tests/vm_evalbody.c#L0
-/* -*-c-*- */
-/**********************************************************************
-
-  vm_evalbody.c -
-
-  $Author$
-
-  Copyright (C) 2004-2007 Koichi Sasada
-
-**********************************************************************/
-
-#include <math.h>
-
-#if VMDEBUG > 0
-#define DECL_SC_REG(type, r, reg) register type reg_##r
-
-#elif __GNUC__ && __x86_64__
-#define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("r" reg)
-
-#elif __GNUC__ && __i386__
-#define DECL_SC_REG(type, r, reg) register type reg_##r __asm__("e" reg)
-
-#else
-#define DECL_SC_REG(type, r, reg) register type reg_##r
-#endif
-/* #define DECL_SC_REG(r, reg) VALUE reg_##r */
-
-#if !OPT_CALL_THREADED_CODE
-static VALUE
-vm_eval(rb_thread_t *th, VALUE initial)
-{
-
-#if OPT_STACK_CACHING
-#if 0
-#elif __GNUC__ && __x86_64
-    DECL_SC_REG(VALUE, a, "12");
-    DECL_SC_REG(VALUE, b, "13");
-#else
-    register VALUE reg_a;
-    register VALUE reg_b;
-#endif
-#endif
-
-#if __GNUC__ && __i386__
-    DECL_SC_REG(VALUE *, pc, "di");
-    DECL_SC_REG(rb_control_frame_t *, cfp, "si");
-#define USE_MACHINE_REGS 1
-
-#elif __GNUC__ && __x86_64__
-    DECL_SC_REG(VALUE *, pc, "14");
-    DECL_SC_REG(rb_control_frame_t *, cfp, "15");
-#define USE_MACHINE_REGS 1
-
-#else
-    register rb_control_frame_t *reg_cfp;
-    VALUE *reg_pc;
-#endif
-
-#if USE_MACHINE_REGS
-
-#undef  RESTORE_REGS
-#define RESTORE_REGS() \
-{ \
-  REG_CFP = th->cfp; \
-  reg_pc  = reg_cfp->pc; \
-}
-
-#undef  REG_PC
-#define REG_PC reg_pc
-#undef  GET_PC
-#define GET_PC() (reg_pc)
-#undef  SET_PC
-#define SET_PC(x) (reg_cfp->pc = REG_PC = (x))
-#endif
-
-#if OPT_TOKEN_THREADED_CODE || OPT_DIRECT_THREADED_CODE
-#include "vmtc.inc"
-    if (th == 0) {
-#if OPT_STACK_CACHING
-	finish_insn_seq[0] = (VALUE)&&LABEL (finish_SC_ax_ax);
-#else
-	finish_insn_seq[0] = (VALUE)&&LABEL (finish);
-#endif
-	return (VALUE)insns_address_table;
-    }
-#endif
-    reg_cfp = th->cfp;
-    reg_pc = reg_cfp->pc;
-
-#if OPT_STACK_CACHING
-    reg_a = initial;
-    reg_b = 0;
-#endif
-
-  first:
-    INSN_DISPATCH();
-/*****************/
- #include "vm.inc"
-/*****************/
-    END_INSNS_DISPATCH();
-
-    /* unreachable */
-    rb_bug("vm_eval: unreachable");
-    goto first;
-}
-
-#else
-
-#include "vm.inc"
-#include "vmtc.inc"
-
-const void *const *
-get_insns_address_table()
-{
-    return insns_address_table;
-}
-
-VALUE
-vm_eval(rb_thread_t *th, VALUE initial)
-{
-    register rb_control_frame_t *reg_cfp = th->cfp;
-    VALUE ret;
-
-    while (*GET_PC()) {
-	reg_cfp = ((rb_insn_func_t) (*GET_PC()))(th, reg_cfp);
-
-	if (reg_cfp == 0) {
-	    VALUE err = th->errinfo;
-	    th->errinfo = Qnil;
-	    return err;
-	}
-    }
-
-    if (VM_FRAME_TYPE(th->cfp) != VM_FRAME_MAGIC_FINISH) {
-	rb_bug("cfp consistency error");
-    }
-
-    ret = *(th->cfp->sp-1); /* pop */
-    th->cfp++; /* pop cf */
-    return ret;
-}
-#endif
-
-const void **
-vm_get_insns_address_table(void)
-{
-    return (const void **)vm_eval(0, 0);
-}

Property changes on: rexml_adds_tests/vm_evalbody.c
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-LF
\ No newline at end of property
Deleted: svn:keywords
## -1 +0,0 ##
-Author Date Id Revision
\ No newline at end of property
Index: rexml_adds_tests/complex.c
===================================================================
--- rexml_adds_tests/complex.c	(revision 64722)
+++ rexml_adds_tests/complex.c	(nonexistent)
@@ -1,1516 +0,0 @@ https://github.com/ruby/ruby/blob/trunk/rexml_adds_tests/complex.c#L0
-/*
-  complex.c: Coded by Tadayoshi Funaba 2008
-
-  This implementation is based on Keiju Ishitsuka's Complex library
-  which is written in ruby.
-*/
-
-#include "ruby.h"
-#include <math.h>
-
-#define NDEBUG
-#include <assert.h>
-
-#ifndef COMPLEX_NAME
-#define COMPLEX_NAME "Complex"
-#endif
-
-#define ZERO INT2FIX(0)
-#define ONE INT2FIX(1)
-#define TWO INT2FIX(2)
-
-VALUE rb_cComplex;
-
-static ID id_Unify, id_abs, id_abs2, id_arg, id_cmp, id_conj, id_convert,
-    id_denominator, id_divmod, id_equal_p, id_expt, id_floor, id_hash,
-    id_idiv, id_inspect, id_negate, id_numerator, id_polar, id_quo,
-    id_real_p, id_to_f, id_to_i, id_to_r, id_to_s;
-
-#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
-
-#define binop(n,op) \
-inline static VALUE \
-f_##n(VALUE x, VALUE y)\
-{\
-    return rb_funcall(x, op, 1, y);\
-}
-
-#define fun1(n) \
-inline static VALUE \
-f_##n(VALUE x)\
-{\
-    return rb_funcall(x, id_##n, 0);\
-}
-
-#define fun2(n) \
-inline static VALUE \
-f_##n(VALUE x, VALUE y)\
-{\
-    return rb_funcall(x, id_##n, 1, y);\
-}
-
-#define math1(n) \
-inline static VALUE \
-m_##n(VALUE x)\
-{\
-    return rb_funcall(rb_mMath, id_##n, 1, x);\
-}
-
-#define math2(n) \
-inline static VALUE \
-m_##n(VALUE x, VALUE y)\
-{\
-    return rb_funcall(rb_mMath, id_##n, 2, x, y);\
-}
-
-#define PRESERVE_SIGNEDZERO
-
-inline static VALUE
-f_add(VALUE x, VALUE y)
-{
-#ifndef PRESERVE_SIGNEDZERO
-    if (FIXNUM_P(y) && FIX2LONG(y) == 0)
-	return x;
-    else if (FIXNUM_P(x) && FIX2LONG(x) == 0)
-	return y;
-#endif
-    return rb_funcall(x, '+', 1, y);
-}
-
-inline static VALUE
-f_cmp(VALUE x, VALUE y)
-{
-    if (FIXNUM_P(x) && FIXNUM_P(y)) {
-	long c = FIX2LONG(x) - FIX2LONG(y);
-	if (c > 0)
-	    c = 1;
-	else if (c < 0)
-	    c = -1;
-	return INT2FIX(c);
-    }
-    return rb_funcall(x, id_cmp, 1, y);
-}
-
-inline static VALUE
-f_div(VALUE x, VALUE y)
-{
-    if (FIXNUM_P(y) && FIX2LONG(y) == 1)
-	return x;
-    return rb_funcall(x, '/', 1, y);
-}
-
-inline static VALUE
-f_gt_p(VALUE x, VALUE y)
-{
-    if (FIXNUM_P(x) && FIXNUM_P(y))
-	return f_boolcast(FIX2LONG(x) > FIX2LONG(y));
-    return rb_funcall(x, '>', 1, y);
-}
-
-inline static VALUE
-f_lt_p(VALUE x, VALUE y)
-{
-    if (FIXNUM_P(x) && FIXNUM_P(y))
-	return f_boolcast(FIX2LONG(x) < FIX2LONG(y));
-    return rb_funcall(x, '<', 1, y);
-}
-
-binop(mod, '%')
-
-inline static VALUE
-f_mul(VALUE x, VALUE y)
-{
-#ifndef PRESERVE_SIGNEDZERO
-    if (FIXNUM_P(y)) {
-	long iy = FIX2LONG(y);
-	if (iy == 0) {
-	    if (FIXNUM_P(x) || TYPE(x) == T_BIGNUM)
-		return ZERO;
-	}
-	else if (iy == 1)
-	    return x;
-    }
-    else if (FIXNUM_P(x)) {
-	long ix = FIX2LONG(x);
-	if (ix == 0) {
-	    if (FIXNUM_P(y) || TYPE(y) == T_BIGNUM)
-		return ZERO;
-	}
-	else if (ix == 1)
-	    return y;
-    }
-#endif
-    return rb_funcall(x, '*', 1, y);
-}
-
-inline static VALUE
-f_sub(VALUE x, VALUE y)
-{
-#ifndef PRESERVE_SIGNEDZERO
-    if (FIXNUM_P(y) && FIX2LONG(y) == 0)
-	return x;
-#endif
-    return rb_funcall(x, '-', 1, y);
-}
-
-binop(xor, '^')
-
-fun1(abs)
-fun1(abs2)
-fun1(arg)
-fun1(conj)
-fun1(denominator)
-fun1(floor)
-fun1(hash)
-fun1(inspect)
-fun1(negate)
-fun1(numerator)
-fun1(polar)
-fun1(real_p)
-
-fun1(to_f)
-fun1(to_i)
-fun1(to_r)
-fun1(to_s)
-
-fun2(divmod)
-
-inline static VALUE
-f_equal_p(VALUE x, VALUE y)
-{
-    if (FIXNUM_P(x) && FIXNUM_P(y))
-	return f_boolcast(FIX2LONG(x) == FIX2LONG(y));
-    return rb_funcall(x, id_equal_p, 1, y);
-}
-
-fun2(expt)
-fun2(idiv)
-fun2(quo)
-
-inline static VALUE
-f_negative_p(VALUE x)
-{
-    if (FIXNUM_P(x))
-	return f_boolcast(FIX2LONG(x) < 0);
-    return rb_funcall(x, '<', 1, ZERO);
-}
-
-#define f_positive_p(x) (!f_negative_p(x))
-
-inline static VALUE
-f_zero_p(VALUE x)
-{
-    if (FIXNUM_P(x))
-	return f_boolcast(FIX2LONG(x) == 0);
-    return rb_funcall(x, id_equal_p, 1, ZERO);
-}
-
-#define f_nonzero_p(x) (!f_zero_p(x))
-
-inline static VALUE
-f_one_p(VALUE x)
-{
-    if (FIXNUM_P(x))
-	return f_boolcast(FIX2LONG(x) == 1);
-    return rb_funcall(x, id_equal_p, 1, ONE);
-}
-
-inline static VALUE
-f_kind_of_p(VALUE x, VALUE c)
-{
-    return rb_obj_is_kind_of(x, c);
-}
-
-inline static VALUE
-k_numeric_p(VALUE x)
-{
-    return f_kind_of_p(x, rb_cNumeric);
-}
-
-inline static VALUE
-k_integer_p(VALUE x)
-{
-    return f_kind_of_p(x, rb_cInteger);
-}
-
-inline static VALUE
-k_float_p(VALUE x)
-{
-    return f_kind_of_p(x, rb_cFloat);
-}
-
-inline static VALUE
-k_rational_p(VALUE x)
-{
-    return f_kind_of_p(x, rb_cRational);
-}
-
-inline static VALUE
-k_complex_p(VALUE x)
-{
-    return f_kind_of_p(x, rb_cComplex);
-}
-
-#define k_exact_p(x) (!k_float_p(x))
-#define k_inexact_p(x) k_float_p(x)
-
-#define get_dat1(x) \
-    struct RComplex *dat;\
-    dat = ((struct RComplex *)(x))
-
-#define get_dat2(x,y) \
-    struct RComplex *adat, *bdat;\
-    adat = ((struct RComplex *)(x));\
-    bdat = ((struct RComplex *)(y))
-
-inline static VALUE
-nucomp_s_new_internal(VALUE klass, VALUE real, VALUE imag)
-{
-    NEWOBJ(obj, struct RComplex);
-    OBJSETUP(obj, klass, T_COMPLEX);
-
-    obj->real = real;
-    obj->imag = imag;
-
-    return (VALUE)obj;
-}
-
-static VALUE
-nucomp_s_alloc(VALUE klass)
-{
-    return nucomp_s_new_internal(klass, ZERO, ZERO);
-}
-
-static VALUE
-nucomp_s_new_bang(int argc, VALUE *argv, VALUE klass)
-{
-    VALUE real, imag;
-
-    switch (rb_scan_args(argc, argv, "11", &real, &imag)) {
-      case 1:
-	if (!k_numeric_p(real))
-	    real = f_to_i(real);
-	imag = ZERO;
-	break;
-      default:
-	if (!k_numeric_p(real))
-	    real = f_to_i(real);
-	if (!k_numeric_p(imag))
-	    imag = f_to_i(imag);
-	break;
-    }
-
-    return nucomp_s_new_internal(klass, real, imag);
-}
-
-inline static VALUE
-f_complex_new_bang1(VALUE klass, VALUE x)
-{
-    assert(!k_complex_p(x));
-    return nucomp_s_new_internal(klass, x, ZERO);
-}
-
-inline static VALUE
-f_complex_new_bang2(VALUE klass, VALUE x, VALUE y)
-{
-    assert(!k_complex_p(x));
-    assert(!k_complex_p(y));
-    return nucomp_s_new_internal(klass, x, y);
-}
-
-#define f_unify_p(klass) rb_const_defined(klass, id_Unify)
-
-inline static void
-nucomp_real_check(VALUE num)
-{
-    switch (TYPE(num)) {
-      case T_FIXNUM:
-      case T_BIGNUM:
-      case T_FLOAT:
-      case T_RATIONAL:
-	break;
-      default:
-	if (!k_numeric_p(num) || !f_real_p(num))
-	    rb_raise(rb_eArgError, "not a real");
-    }
-}
-
-inline static VALUE
-nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE imag)
-{
-#define CL_CANON
-#ifdef CL_CANON
-    if (f_zero_p(imag) && k_exact_p(imag) && f_unify_p(klass))
-	return real;
-#else
-    if (f_zero_p(imag) && f_unify_p(klass))
-	return real;
-#endif
-    else if (f_real_p(real) && f_real_p(imag))
-	return nucomp_s_new_internal(klass, real, imag);
-    else if (f_real_p(real)) {
-	get_dat1(imag);
-
-	return nucomp_s_new_internal(klass,
-				     f_sub(real, dat->imag),
-				     f_add(ZERO, dat->real));
-    }
-    else if (f_real_p(imag)) {
-	get_dat1(real);
-
-	return nucomp_s_new_internal(klass,
-				     dat->real,
-				     f_add(dat->imag, imag));
-    }
-    else {
-	get_dat2(real, imag);
-
-	return nucomp_s_new_internal(klass,
-				     f_sub(adat->real, bdat->imag),
-				     f_add(adat->imag, bdat->real));
-    }
-}
-
-#if 0
-static VALUE
-nucomp_s_canonicalize(int argc, VALUE *argv, VALUE klass)
-{
-    VALUE real, imag;
-
-    switch (rb_scan_args(argc, argv, "11", &real, &imag)) {
-      case 1:
-	nucomp_real_check(real);
-	imag = ZERO;
-	break;
-      default:
-	nucomp_real_check(real);
-	nucomp_real_check(imag);
-	break;
-    }
-
-    return nucomp_s_canonicalize_internal(klass, real, imag);
-}
-#endif
-
-static VALUE
-nucomp_s_new(int argc, VALUE *argv, VALUE klass)
-{
-    VALUE real, imag;
-
-    switch (rb_scan_args(argc, argv, "11", &real, &imag)) {
-      case 1:
-	nucomp_real_check(real);
-	imag = ZERO;
-	break;
-      default:
-	nucomp_real_check(real);
-	nucomp_real_check(imag);
-	break;
-    }
-
-    return nucomp_s_canonicalize_internal(klass, real, imag);
-}
-
-inline static VALUE
-f_complex_new1(VALUE klass, VALUE x)
-{
-    assert(!k_complex_p(x));
-    return nucomp_s_canonicalize_internal(klass, x, ZERO);
-}
-
-inline static VALUE
-f_complex_new2(VALUE klass, VALUE x, VALUE y)
-{
-    assert(!k_complex_p(x));
-    return nucomp_s_canonicalize_internal(klass, x, y);
-}
-
-static VALUE
-nucomp_f_complex(int argc, VALUE *argv, VALUE klass)
-{
-    return rb_funcall2(rb_cComplex, id_convert, argc, argv);
-}
-
-extern VALUE math_atan2(VALUE obj, VALUE x, VALUE y);
-extern VALUE math_cos(VALUE obj, VALUE x);
-extern VALUE math_cosh(VALUE obj, VALUE x);
-extern VALUE math_exp(VALUE obj, VALUE x);
-extern VALUE math_hypot(VALUE obj, VALUE x, VALUE y);
-extern VALUE math_log(int argc, VALUE *argv);
-extern VALUE math_sin(VALUE obj, VALUE x);
-extern VALUE math_sinh(VALUE obj, VALUE x);
-extern VALUE math_sqrt(VALUE obj, VALUE x);
-
-#define m_atan2_bang(x,y) math_atan2(Qnil,x,y)
-#define m_cos_bang(x) math_cos(Qnil,x)
-#define m_cosh_bang(x) math_cosh(Qnil,x)
-#define m_exp_bang(x) math_exp(Qnil,x)
-#define m_hypot(x,y) math_hypot(Qnil,x,y)
-
-static VALUE
-m_log_bang(VALUE x)
-{
-    return math_log(1, &x);
-}
-
-#define m_sin_bang(x) math_sin(Qnil,x)
-#define m_sinh_bang(x) math_sinh(Qnil,x)
-#define m_sqrt_bang(x) math_sqrt(Qnil,x)
-
-static VALUE
-m_cos(VALUE x)
-{
-    if (f_real_p(x))
-	return m_cos_bang(x);
-    {
-	get_dat1(x);
-	return f_complex_new2(rb_cComplex,
-			      f_mul(m_cos_bang(dat->real),
-				    m_cosh_bang(dat->imag)),
-			      f_mul(f_negate(m_sin_bang(dat->real)),
-				    m_sinh_bang(dat->imag)));
-    }
-}
-
-static VALUE
-m_sin(VALUE x)
-{
-    if (f_real_p(x))
-	return m_sin_bang(x);
-    {
-	get_dat1(x);
-	return f_complex_new2(rb_cComplex,
-			      f_mul(m_sin_bang(dat->real),
-				    m_cosh_bang(dat->imag)),
-			      f_mul(m_cos_bang(dat->real),
-				    m_sinh_bang(dat->imag)));
-    }
-}
-
-static VALUE
-m_sqrt(VALUE x)
-{
-    if (f_real_p(x)) {
-	if (f_positive_p(x))
-	    return m_sqrt_bang(x);
-	return f_complex_new2(rb_cComplex, ZERO, m_sqrt_bang(f_negate(x)));
-    }
-    else {
-	get_dat1(x);
-
-	if (f_negative_p(dat->imag))
-	    return f_conj(m_sqrt(f_conj(x)));
-	else {
-	    VALUE a = f_abs(x);
-	    return f_complex_new2(rb_cComplex,
-				  m_sqrt_bang(f_div(f_add(a, dat->real), TWO)),
-				  m_sqrt_bang(f_div(f_sub(a, dat->real), TWO)));
-	}
-    }
-}
-
-inline static VALUE
-f_complex_polar(VALUE klass, VALUE x, VALUE y)
-{
-    assert(!k_complex_p(x));
-    assert(!k_complex_p(y));
-    return nucomp_s_canonicalize_internal(klass,
-					  f_mul(x, m_cos(y)),
-					  f_mul(x, m_sin(y)));
-}
-
-static VALUE
-nucomp_s_polar(VALUE klass, VALUE abs, VALUE arg)
-{
-    return f_complex_polar(klass, abs, arg);
-}
-
-static VALUE
-nucomp_real(VALUE self)
-{
-    get_dat1(self);
-    return dat->real;
-}
-
-static VALUE
-nucomp_imag(VALUE self)
-{
-    get_dat1(self);
-    return dat->imag;
-}
-
-static VALUE
-nucomp_negate(VALUE self)
-{
-  get_dat1(self);
-  return f_complex_new2(CLASS_OF(self),
-			f_negate(dat->real), f_negate(dat->imag));
-}
-
-static VALUE
-nucomp_add(VALUE self, VALUE other)
-{
-    if (k_complex_p(other)) {
-	VALUE real, imag;
-
-	get_dat2(self, other);
-
-	real = f_add(adat->real, bdat->real);
-	imag = f_add(adat->imag, bdat->imag);
-
-	return f_complex_new2(CLASS_OF(self), real, imag);
-    }
-    if (k_numeric_p(other) && f_real_p(other)) {
-	get_dat1(self);
-
-	return f_complex_new2(CLASS_OF(self),
-			      f_add(dat->real, other), dat->imag);
-    }
-    return rb_num_coerce_bin(self, other, '+');
-}
-
-static VALUE
-nucomp_sub(VALUE self, VALUE other)
-{
-    if (k_complex_p(other)) {
-	VALUE real, imag;
-
-	get_dat2(self, other);
-
-	real = f_sub(adat->real, bdat->real);
-	imag = f_sub(adat->imag, bdat->imag);
-
-	return f_complex_new2(CLASS_OF(self), real, imag);
-    }
-    if (k_numeric_p(other) && f_real_p(other)) {
-	get_dat1(self);
-
-	return f_complex_new2(CLASS_OF(self),
-			      f_sub(dat->real, other), dat->imag);
-    }
-    return rb_num_coerce_bin(self, other, '-');
-}
-
-static VALUE
-nucomp_mul(VALUE self, VALUE other)
-{
-    if (k_complex_p(other)) {
-	VALUE real, imag;
-
-	get_dat2(self, other);
-
-	real = f_sub(f_mul(adat->real, bdat->real),
-		     f_mul(adat->imag, bdat->imag));
-	imag = f_add(f_mul(adat->real, bdat->imag),
-		      f_mul(adat->imag, bdat->real));
-
-	return f_complex_new2(CLASS_OF(self), real, imag);
-    }
-    if (k_numeric_p(other) && f_real_p(other)) {
-	get_dat1(self);
-
-	return f_complex_new2(CLASS_OF(self),
-			      f_mul(dat->real, other),
-			      f_mul(dat->imag, other));
-    }
-    return rb_num_coerce_bin(self, other, '*');
-}
-
-#define f_div f_quo
-
-static VALUE
-nucomp_div(VALUE self, VALUE other)
-{
-    if (k_complex_p(other)) {
-	get_dat2(self, other);
-
-	if (TYPE(adat->real)  == T_FLOAT ||
-	    TYPE(adat->imag) == T_FLOAT ||
-	    TYPE(bdat->real)  == T_FLOAT ||
-	    TYPE(bdat->imag) == T_FLOAT) {
-	    VALUE magn = m_hypot(bdat->real, bdat->imag);
-	    VALUE tmp = f_complex_new_bang2(CLASS_OF(self),
-					    f_div(bdat->real, magn),
-					    f_div(bdat->imag, magn));
-	    return f_div(f_mul(self, f_conj(tmp)), magn);
-	}
-	return f_div(f_mul(self, f_conj(other)), f_abs2(other));
-    }
-    if (k_numeric_p(other) && f_real_p(other)) {
-	get_dat1(self);
-
-	return f_complex_new2(CLASS_OF(self),
-			      f_div(dat->real, other),
-			      f_div(dat->imag, other));
-    }
-    return rb_num_coerce_bin(self, other, '/');
-}
-
-#undef f_div
-#define nucomp_quo nucomp_div
-
-static VALUE
-nucomp_fdiv(VALUE self, VALUE other)
-{
-    get_dat1(self);
-
-    return f_div(f_complex_new2(CLASS_OF(self),
-				f_to_f(dat->real),
-				f_to_f(dat->imag)), other);
-}
-
-static VALUE
-nucomp_expt(VALUE self, VALUE other)
-{
-    if (k_exact_p(other) && f_zero_p(other))
-	return f_complex_new_bang1(CLASS_OF(self), ONE);
-
-    if (k_rational_p(other) && f_one_p(f_denominator(other)))
-	other = f_numerator(other); /* good? */
-
-    if (k_complex_p(other)) {
-	VALUE a, r, theta, ore, oim, nr, ntheta;
-
-	get_dat1(other);
-
-	a = f_polar(self);
-	r = RARRAY_PTR(a)[0];
-	theta = RARRAY_PTR(a)[1];
-
-	ore = dat->real;
-	oim = dat->imag;
-	nr = m_exp_bang(f_sub(f_mul(ore, m_log_bang(r)),
-			      f_mul(oim, theta)));
-	ntheta = f_add(f_mul(theta, ore), f_mul(oim, m_log_bang(r)));
-	return f_complex_polar(CLASS_OF(self), nr, ntheta);
-    }
-    if (k_integer_p(other)) {
-	if (f_gt_p(other, ZERO)) {
-	    VALUE x, z, n;
-
-	    x = self;
-	    z = x;
-	    n = f_sub(other, ONE);
-
-	    while (f_nonzero_p(n)) {
-		VALUE a;
-
-		while (a = f_divmod(n, TWO),
-		       f_zero_p(RARRAY_PTR(a)[1])) {
-		    get_dat1(x);
-
-		    x = f_complex_new2(CLASS_OF(self),
-				       f_sub(f_mul(dat->real, dat->real),
-					     f_mul(dat->imag, dat->imag)),
-				       f_mul(f_mul(TWO, dat->real), dat->imag));
-		    n = RARRAY_PTR(a)[0];
-		}
-		z = f_mul(z, x);
-		n = f_sub(n, ONE);
-	    }
-	    return z;
-	}
-	return f_expt(f_div(f_to_r(ONE), self), f_negate(other));
-    }
-    if (k_numeric_p(other) && f_real_p(other)) {
-	VALUE a, r, theta;
-
-	a = f_polar(self);
-	r = RARRAY_PTR(a)[0];
-	theta = RARRAY_PTR(a)[1];
-	return f_complex_polar(CLASS_OF(self), f_expt(r, other),
-			      f_mul(theta, other));
-    }
-    return rb_num_coerce_bin(self, other, id_expt);
-}
-
-static VALUE
-nucomp_equal_p(VALUE self, VALUE other)
-{
-    if (k_complex_p(other)) {
-	get_dat2(self, other);
-
-	return f_boolcast(f_equal_p(adat->real, bdat->real) &&
-			  f_equal_p(adat->imag, bdat->imag));
-    }
-    if (k_numeric_p(other) && f_real_p(other)) {
-	get_dat1(self);
-
-	return f_boolcast(f_equal_p(dat->real, other) && f_zero_p(dat->imag));
-    }
-    return f_equal_p(other, self);
-}
-
-static VALUE
-nucomp_coerce(VALUE self, VALUE other)
-{
-    if (k_numeric_p(other) && f_real_p(other))
-	return rb_assoc_new(f_complex_new_bang1(CLASS_OF(self), other), self);
-
-    rb_raise(rb_eTypeError, "%s can't be coerced into %s",
-	     rb_obj_classname(other), rb_obj_classname(self));
-    (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]