Class: Numeric
Defined Under Namespace
Modules: FloatFunction
Instance Method Summary collapse
- #deg_180 ⇒ Object
- #deg_360 ⇒ Object
- #eq(other) ⇒ Object
- #ne(other) ⇒ Object
- #rad_2pi ⇒ Object
- #rad_pi ⇒ Object
- #to_cc ⇒ Object
Instance Method Details
#deg_180 ⇒ Object
91 92 93 94 95 96 97 |
# File 'ext/carray_mathfunc.c', line 91 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 ⇒ Object
49 50 51 52 53 54 55 |
# File 'ext/carray_mathfunc.c', line 49 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) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/carray/basic.rb', line 45 def eq (other) case other when CArray return other.eq(self) else return send(:eq, *other.coerce(self)) end end |
#ne(other) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/carray/basic.rb', line 54 def ne (other) case other when CArray return other.ne(self) else return send(:ne, *other.coerce(self)) end end |
#rad_2pi ⇒ Object
129 130 131 132 133 134 135 |
# File 'ext/carray_mathfunc.c', line 129 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 ⇒ Object
171 172 173 174 175 176 177 |
# File 'ext/carray_mathfunc.c', line 171 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 ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'ext/ruby_ccomplex.c', line 98 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"); } |