ccmath 0.2.71 → 0.2.718

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2fda0ca3c87789fe9fbba2ab15250a2e4cf7c6d
4
- data.tar.gz: 73c23f5a3218c774c21035689ca9ded2d6d30b14
3
+ metadata.gz: 979543fe759c6e85612bd3a9d89558b259e3de58
4
+ data.tar.gz: 98123a1a0f6ab2947285814d8ebcc1a7a92e8472
5
5
  SHA512:
6
- metadata.gz: eae6b0686f5e9bcc96a12d557ae39830badc4c3863c9ac80baf8d1a4385bd3ea8cb2819ccca506d60ada66b5520cbaac87ab9a2eadb7ddcbf583627070fd5576
7
- data.tar.gz: 2792755a0be3d4849243eca410c013eb33b302d99ce0022191abc10f235b8bd002f1fb7ff49264e4b5f497a755dcc03637e98923b6616f74a4c1ee8f21a29914
6
+ metadata.gz: 96f050ff40340b62ebf98609fde8ffd315f0907a302e36c9852807ce746c5efc4f77534f91b5eb32bd15d529a06ddfad49b47505d1b58633a224935a6e916e1c
7
+ data.tar.gz: edb0f7ec2e5d43e968ad51f707bfad35e97b70afa9d255857d5bad9b03072dd8c6e64ff4c21004d21a743627fb142952958d5c7494d34691a7c7b0101af46908
@@ -3,6 +3,7 @@
3
3
  ### v2.71
4
4
 
5
5
  * `CCMath.gamma` can receive `Complex` object.
6
+ * Now `CCMath.set` is deprecated.
6
7
 
7
8
  ### v2.7
8
9
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Hopefully, CCMath is better than CMath... (・ω・;)
1
+ ## Hopefully, CCMath is better than CMath...! (・ω・;)
2
2
 
3
3
  [![Build Status](https://travis-ci.org/gogotanaka/ccmath.svg?branch=master)](https://travis-ci.org/gogotanaka/ccmath)
4
4
 
@@ -17,18 +17,25 @@ CCMath.cos(1)
17
17
 
18
18
  ```
19
19
  Calculating -------------------------------------
20
- CMath 31.262k i/100ms
21
- CCMath 53.484k i/100ms
20
+ CMath 28.423k i/100ms
21
+ CCMath 61.123k i/100ms
22
22
  -------------------------------------------------
23
- CMath 437.150k7.1%) i/s - 2.188M
24
- CCMath 1.044M28.3%) i/s - 4.600M
23
+ CMath 379.852k4.2%) i/s - 1.904M
24
+ CCMath 1.163M 4.0%) i/s - 5.807M
25
25
 
26
26
  Comparison:
27
- CCMath: 1044410.2 i/s
28
- CMath: 437150.3 i/s - 2.39x slower
27
+ CCMath: 1163020.7 i/s
28
+ CMath: 379852.3 i/s - 3.06x slower
29
29
 
30
30
  ```
31
31
 
32
+ ## What's the difference between CCMath and CMath..?(・ω・;)
33
+ 1. CCMath return Complex object even if image part is equivalent 0.
34
+ 2. Faster(about 3 times)
35
+ 3. Better error handling
36
+
37
+ Other behaviours suppose to be same.
38
+
32
39
  ## Installation
33
40
 
34
41
 
@@ -3,7 +3,7 @@
3
3
  VALUE rb_mCCMath;
4
4
  VALUE rb_eMathDomainError;
5
5
 
6
- static ID id_real_p, id_set, id_power;
6
+ static ID id_power;
7
7
 
8
8
  #define RB_BIGNUM_TYPE_P(x) RB_TYPE_P((x), T_BIGNUM)
9
9
  #define BIGNUM_POSITIVE_P(b) (FIX2LONG(rb_big_cmp((b), INT2FIX(0))) >= 0)
@@ -38,10 +38,23 @@ num2dbl_without_to_f(VALUE num)
38
38
 
39
39
  #define NUM2DBL_F(x) num2dbl_without_to_f(x)
40
40
 
41
- inline static VALUE
42
- f_real_p(VALUE x)
41
+ inline static int
42
+ real_p(VALUE x)
43
43
  {
44
- return rb_funcall(x, id_real_p, 0);
44
+ if (SPECIAL_CONST_P(x)){
45
+ if (FIXNUM_P(x) || FLONUM_P(x)) {
46
+ return 1;
47
+ }
48
+ }
49
+ else {
50
+ switch (BUILTIN_TYPE(x)) {
51
+ case T_FLOAT: return 1;
52
+ case T_BIGNUM: return 1;
53
+ case T_RATIONAL: return 1;
54
+ case T_COMPLEX: return 0;
55
+ }
56
+ }
57
+ rb_raise(rb_eTypeError, "Numeric Number required");
45
58
  }
46
59
 
47
60
  #define binop(n,op) \
@@ -60,8 +73,7 @@ binop(pow, id_power)
60
73
  inline static VALUE
61
74
  DBLS2COMP(double real, double imag)
62
75
  {
63
- NEWOBJ_OF(obj, struct RComplex, rb_cComplex,
64
- T_COMPLEX | (RGENGC_WB_PROTECTED_COMPLEX ? FL_WB_PROTECTED : 0));
76
+ NEWOBJ_OF(obj, struct RComplex, rb_cComplex, T_COMPLEX | FL_WB_PROTECTED);
65
77
 
66
78
  RCOMPLEX_SET_REAL(obj, DBL2NUM(real));
67
79
  RCOMPLEX_SET_IMAG(obj, DBL2NUM(imag));
@@ -82,7 +94,7 @@ DBLS2COMP(double real, double imag)
82
94
  #define EXTRACT_DBLS(z); \
83
95
  double z##_real, z##_imag; \
84
96
  do { \
85
- if (f_real_p(z)) { \
97
+ if (real_p(z)) { \
86
98
  EXTRACT_DBLS_FROM_REAL(z) \
87
99
  } else { \
88
100
  EXTRACT_DBLS_FROM_COMP(z) \
@@ -156,7 +168,7 @@ ccmath_log(int argc, const VALUE* argv, VALUE obj)
156
168
  EXTRACT_DBLS(z);
157
169
  float r = hypot(z_real, z_imag);
158
170
  if (argc == 2) {
159
- if (!rb_respond_to(base, id_real_p)) rb_raise(rb_eTypeError, "Numeric Number required");
171
+ real_p(base);
160
172
  EXTRACT_DBLS(base);
161
173
  if (base_imag != 0.0) domain_error("log");
162
174
  if (base_real > 0.0) {
@@ -364,18 +376,9 @@ ccmath_gamma(VALUE obj, VALUE z)
364
376
  }
365
377
  }
366
378
 
367
- // static VALUE
368
- // ccmath_define_set(VALUE obj, VALUE str)
369
- // {
370
- // rb_ivar_set(obj, id_set, str);
371
- // return obj;
372
- // }
373
-
374
379
  void Init_ccmath(void)
375
380
  {
376
- id_real_p = rb_intern("real?");
377
381
  id_power = rb_intern("**");
378
- id_set = rb_intern("set");
379
382
  rb_mCCMath = rb_define_module("CCMath");
380
383
 
381
384
  rb_eMathDomainError = rb_define_class_under(rb_mCCMath, "DomainError", rb_eStandardError);
@@ -409,7 +412,4 @@ void Init_ccmath(void)
409
412
  rb_define_module_function(rb_mCCMath, "atanh", ccmath_atanh, 1);
410
413
  rb_define_module_function(rb_mCCMath, "atan", ccmath_atan, 1);
411
414
  rb_define_module_function(rb_mCCMath, "gamma", ccmath_gamma, 1);
412
- // rb_define_module_function(rb_mCCMath, "set=", ccmath_define_set, 1);
413
-
414
- // rb_ivar_set(rb_mCCMath, id_set, rb_str_new2("R"));
415
415
  }
@@ -1,3 +1,3 @@
1
1
  module Ccmath
2
- VERSION = "0.2.71"
2
+ VERSION = "0.2.718"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ccmath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.71
4
+ version: 0.2.718
5
5
  platform: ruby
6
6
  authors:
7
7
  - gogotanaka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-07 00:00:00.000000000 Z
11
+ date: 2015-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  requirements: []
110
110
  rubyforge_project:
111
- rubygems_version: 2.4.5
111
+ rubygems_version: 2.4.5.1
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Implement CMath with C.