class Numeric

Public Instance Methods

deg_180() click to toggle source
static VALUE
rb_num_deg_180 (VALUE self)
{
  double v0, v1 = NUM2DBL(self);
  mathfunc_deg_180(&v0, &v1);
  return rb_float_new(v0);
}
deg_360() click to toggle source
static VALUE
rb_num_deg_360 (VALUE self)
{
  double v0, v1 = NUM2DBL(self);
  mathfunc_deg_360(&v0, &v1);
  return rb_float_new(v0);
}
eq(other) click to toggle source
# File lib/carray/basic.rb, line 43
def eq (other)
  case other
  when CArray
    return other.eq(self)
  else
    return send(:eq, *other.coerce(self))
  end
end
ne(other) click to toggle source
# File lib/carray/basic.rb, line 52
def ne (other)
  case other
  when CArray
    return other.ne(self)
  else
    return send(:ne, *other.coerce(self))
  end
end
rad_2pi() click to toggle source
static VALUE
rb_num_rad_2pi (VALUE self)
{
  double v0, v1 = NUM2DBL(self);
  mathfunc_rad_2pi(&v0, &v1);
  return rb_float_new(v0);
}
rad_pi() click to toggle source
static VALUE
rb_num_rad_pi (VALUE self)
{
  double v0, v1 = NUM2DBL(self);
  mathfunc_rad_pi(&v0, &v1);
  return rb_float_new(v0);
}
to_cc() click to toggle source
static VALUE
rb_num_to_cc (VALUE num)
{
  if ( rb_obj_is_kind_of(num, rb_cCComplex) ) {
    double complex cc = 0.0, *cp;
    cp = &cc;
    Data_Get_Struct(num, double complex, cp);
    return rb_ccomplex_new(cc);
  }
  switch ( TYPE(num) ) {
  case T_FIXNUM:
    return rb_ccomplex_new((double complex) NUM2LONG(num));
  case T_BIGNUM:
    return rb_ccomplex_new((double complex) rb_big2dbl(num));
  case T_FLOAT:
    return rb_ccomplex_new((double complex) NUM2DBL(num));
  }
  if ( rb_obj_is_kind_of(num, rb_cComplex) ) {
    return rb_ccomplex_new(rb_complex_to_cval(num));
  }
  if ( rb_respond_to(num, rb_intern("to_c")) ) {
    return rb_ccomplex_new(rb_complex_to_cval(rb_funcall(num, rb_intern("to_c"), 0)));
  }
  if ( rb_respond_to(num, rb_intern("to_f")) ) {
    return rb_ccomplex_new(NUM2DBL(rb_funcall(num, rb_intern("to_f"), 0)));
  }
  rb_raise(rb_eRuntimeError, "can not convert to CComplex");
}