carray 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +4 -4
  2. data/{LICENSES → LICENSE} +0 -0
  3. data/NEWS.md +42 -0
  4. data/README.md +5 -5
  5. data/TODO.md +16 -0
  6. data/carray.gemspec +9 -5
  7. data/ext/ca_iter_block.c +3 -5
  8. data/ext/ca_iter_dimension.c +4 -5
  9. data/ext/ca_iter_window.c +2 -4
  10. data/ext/ca_obj_array.c +394 -124
  11. data/ext/ca_obj_bitarray.c +3 -5
  12. data/ext/ca_obj_bitfield.c +3 -5
  13. data/ext/ca_obj_block.c +6 -8
  14. data/ext/ca_obj_fake.c +3 -5
  15. data/ext/ca_obj_farray.c +3 -5
  16. data/ext/ca_obj_field.c +15 -17
  17. data/ext/ca_obj_grid.c +5 -6
  18. data/ext/ca_obj_mapping.c +2 -4
  19. data/ext/ca_obj_object.c +3 -5
  20. data/ext/ca_obj_reduce.c +2 -4
  21. data/ext/ca_obj_refer.c +5 -7
  22. data/ext/ca_obj_repeat.c +2 -4
  23. data/ext/ca_obj_select.c +2 -4
  24. data/ext/ca_obj_shift.c +3 -5
  25. data/ext/ca_obj_transpose.c +3 -5
  26. data/ext/ca_obj_unbound_repeat.c +58 -81
  27. data/ext/ca_obj_window.c +7 -9
  28. data/ext/carray.h +13 -8
  29. data/ext/carray_access.c +111 -18
  30. data/ext/carray_attribute.c +136 -197
  31. data/ext/carray_call_cfunc.c +1 -3
  32. data/ext/carray_cast.c +344 -143
  33. data/ext/carray_cast_func.rb +1 -2
  34. data/ext/carray_class.c +28 -36
  35. data/ext/carray_conversion.c +49 -59
  36. data/ext/carray_copy.c +16 -32
  37. data/ext/carray_core.c +51 -44
  38. data/ext/carray_element.c +25 -44
  39. data/ext/carray_generate.c +71 -50
  40. data/ext/carray_iterator.c +13 -15
  41. data/ext/carray_loop.c +53 -82
  42. data/ext/carray_mask.c +87 -117
  43. data/ext/carray_math.rb +8 -10
  44. data/ext/carray_mathfunc.c +1 -3
  45. data/ext/carray_numeric.c +19 -3
  46. data/ext/carray_operator.c +45 -32
  47. data/ext/carray_order.c +72 -65
  48. data/ext/carray_sort_addr.c +14 -21
  49. data/ext/carray_stat.c +1 -3
  50. data/ext/carray_stat_proc.rb +2 -4
  51. data/ext/carray_test.c +28 -30
  52. data/ext/carray_undef.c +1 -3
  53. data/ext/carray_utils.c +12 -4
  54. data/ext/extconf.rb +1 -1
  55. data/ext/mkmath.rb +1 -1
  56. data/ext/ruby_carray.c +11 -6
  57. data/ext/ruby_ccomplex.c +1 -3
  58. data/ext/ruby_float_func.c +1 -3
  59. data/ext/version.h +5 -7
  60. data/lib/carray.rb +2 -0
  61. data/lib/carray/autoload/autoload_gem_numo_narray.rb +6 -6
  62. data/lib/carray/broadcast.rb +45 -0
  63. data/lib/carray/construct.rb +21 -4
  64. data/lib/carray/iterator.rb +1 -0
  65. data/lib/carray/ordering.rb +28 -2
  66. data/spec/Classes/CABitfield_spec.rb +58 -0
  67. data/spec/Classes/CABlockIterator_spec.rb +114 -0
  68. data/spec/Classes/CABlock_spec.rb +205 -0
  69. data/spec/Classes/CAField_spec.rb +39 -0
  70. data/spec/Classes/CAGrid_spec.rb +75 -0
  71. data/spec/Classes/CAMap_spec.rb +0 -0
  72. data/{test/test_CAMapping.rb → spec/Classes/CAMapping_spec.rb} +35 -36
  73. data/spec/Classes/CAObject_attribute_spec.rb +33 -0
  74. data/spec/Classes/CAObject_spec.rb +33 -0
  75. data/spec/Classes/CARefer_spec.rb +93 -0
  76. data/spec/Classes/CARepeat_spec.rb +65 -0
  77. data/spec/Classes/CASelect_spec.rb +22 -0
  78. data/spec/Classes/CAShift_spec.rb +16 -0
  79. data/spec/Classes/CAStruct_spec.rb +71 -0
  80. data/{test/test_CATranspose.rb → spec/Classes/CATranspose_spec.rb} +20 -21
  81. data/spec/Classes/CAUnboudRepeat_spec.rb +78 -0
  82. data/spec/Classes/CAWindow_spec.rb +54 -0
  83. data/spec/Classes/CAWrap_spec.rb +8 -0
  84. data/{test/test_CArray.rb → spec/Classes/CArray_spec.rb} +48 -92
  85. data/spec/Classes/CScalar_spec.rb +55 -0
  86. data/spec/Features/feature_130_spec.rb +19 -0
  87. data/spec/Features/feature_attributes_spec.rb +280 -0
  88. data/spec/Features/feature_boolean_spec.rb +97 -0
  89. data/spec/Features/feature_broadcast.rb +100 -0
  90. data/spec/Features/feature_cast_function.rb +19 -0
  91. data/spec/Features/feature_cast_spec.rb +33 -0
  92. data/spec/Features/feature_class_spec.rb +84 -0
  93. data/spec/Features/feature_complex_spec.rb +42 -0
  94. data/{test/test_composite.rb → spec/Features/feature_composite_spec.rb} +17 -18
  95. data/spec/Features/feature_convert_spec.rb +46 -0
  96. data/spec/Features/feature_copy_spec.rb +123 -0
  97. data/spec/Features/feature_creation_spec.rb +84 -0
  98. data/spec/Features/feature_element_spec.rb +144 -0
  99. data/spec/Features/feature_extream_spec.rb +54 -0
  100. data/spec/Features/feature_generate_spec.rb +74 -0
  101. data/spec/Features/feature_index_spec.rb +69 -0
  102. data/spec/Features/feature_mask_spec.rb +574 -0
  103. data/spec/Features/feature_math_spec.rb +97 -0
  104. data/spec/Features/feature_order_spec.rb +146 -0
  105. data/spec/Features/feature_ref_store_spec.rb +209 -0
  106. data/spec/Features/feature_serialization_spec.rb +125 -0
  107. data/spec/Features/feature_stat_spec.rb +397 -0
  108. data/spec/Features/feature_virtual_spec.rb +48 -0
  109. data/spec/Features/method_eq_spec.rb +81 -0
  110. data/spec/Features/method_is_nan_spec.rb +12 -0
  111. data/spec/Features/method_map_spec.rb +54 -0
  112. data/spec/Features/method_max_with.rb +20 -0
  113. data/spec/Features/method_min_with.rb +19 -0
  114. data/spec/Features/method_ne_spec.rb +18 -0
  115. data/spec/Features/method_project_spec.rb +188 -0
  116. data/spec/Features/method_ref_spec.rb +27 -0
  117. data/spec/Features/method_round_spec.rb +11 -0
  118. data/spec/Features/method_s_linspace_spec.rb +48 -0
  119. data/spec/Features/method_s_span_spec.rb +14 -0
  120. data/spec/Features/method_seq_spec.rb +47 -0
  121. data/spec/Features/method_sort_with.rb +43 -0
  122. data/spec/Features/method_sorted_with.rb +29 -0
  123. data/spec/Features/method_span_spec.rb +42 -0
  124. data/spec/Features/method_wrap_readonly_spec.rb +43 -0
  125. data/{test → spec/UnitTest}/test_CAVirtual.rb +0 -0
  126. data/spec/spec_all.rb +0 -1
  127. data/utils/convert_test.rb +73 -0
  128. data/utils/{extract_rdoc.rb → extract_yard.rb} +7 -12
  129. metadata +77 -60
  130. data/spec/CABlockIterator/CABlockIterator_spec.rb +0 -113
  131. data/spec/CArray/bug/store_spec.rb +0 -27
  132. data/spec/CArray/index/repeat_spec.rb +0 -10
  133. data/spec/CArray/method/eq_spec.rb +0 -80
  134. data/spec/CArray/method/is_nan_spec.rb +0 -12
  135. data/spec/CArray/method/ne_spec.rb +0 -18
  136. data/spec/CArray/method/round_spec.rb +0 -11
  137. data/spec/CArray/object/_attribute_spec.rb +0 -32
  138. data/spec/CArray/object/s_new_spec.rb +0 -31
  139. data/spec/CArray/serialize/Serialization_spec.rb +0 -89
  140. data/test/test_130.rb +0 -23
  141. data/test/test_ALL.rb +0 -49
  142. data/test/test_CABitfield.rb +0 -59
  143. data/test/test_CABlock.rb +0 -208
  144. data/test/test_CAField.rb +0 -40
  145. data/test/test_CAGrid.rb +0 -76
  146. data/test/test_CAMmap.rb +0 -11
  147. data/test/test_CARefer.rb +0 -94
  148. data/test/test_CARepeat.rb +0 -66
  149. data/test/test_CASelect.rb +0 -23
  150. data/test/test_CAShift.rb +0 -17
  151. data/test/test_CAWindow.rb +0 -55
  152. data/test/test_CAWrap.rb +0 -9
  153. data/test/test_CComplex.rb +0 -83
  154. data/test/test_CScalar.rb +0 -91
  155. data/test/test_attribute.rb +0 -281
  156. data/test/test_block_iterator.rb +0 -17
  157. data/test/test_boolean.rb +0 -99
  158. data/test/test_cast.rb +0 -33
  159. data/test/test_class.rb +0 -85
  160. data/test/test_complex.rb +0 -43
  161. data/test/test_convert.rb +0 -79
  162. data/test/test_copy.rb +0 -141
  163. data/test/test_creation.rb +0 -85
  164. data/test/test_element.rb +0 -146
  165. data/test/test_extream.rb +0 -55
  166. data/test/test_generate.rb +0 -75
  167. data/test/test_index.rb +0 -71
  168. data/test/test_mask.rb +0 -578
  169. data/test/test_math.rb +0 -98
  170. data/test/test_order.rb +0 -147
  171. data/test/test_ref_store.rb +0 -211
  172. data/test/test_stat.rb +0 -406
  173. data/test/test_struct.rb +0 -72
  174. data/test/test_virtual.rb +0 -49
@@ -3,10 +3,8 @@
3
3
  carray_operator.c
4
4
 
5
5
  This file is part of Ruby/CArray extension library.
6
- You can redistribute it and/or modify it under the terms of
7
- the Ruby Licence.
8
6
 
9
- Copyright (C) 2005 Hiroki Motoyoshi
7
+ Copyright (C) 2005-2020 Hiroki Motoyoshi
10
8
 
11
9
  ---------------------------------------------------------------------------- */
12
10
 
@@ -28,7 +26,6 @@ ca_zerodiv ()
28
26
  rb_raise(rb_eZeroDivError, "divided by 0");
29
27
  }
30
28
 
31
-
32
29
  VALUE
33
30
  rb_ca_call_monop (VALUE self, ca_monop_func_t func[])
34
31
  {
@@ -50,7 +47,7 @@ rb_ca_call_monop (VALUE self, ca_monop_func_t func[])
50
47
  ca_attach(ca1);
51
48
  ca_copy_mask_overlay(ca2, ca2->elements, 1, ca1);
52
49
  func[ca1->data_type](ca1->elements,
53
- ( ca2->mask ) ? ca2->mask->ptr : NULL,
50
+ ( ca2->mask ) ? (boolean8_t *)ca2->mask->ptr : NULL,
54
51
  ca1->ptr, 1,
55
52
  ca2->ptr, 1);
56
53
  ca_detach(ca1);
@@ -58,7 +55,7 @@ rb_ca_call_monop (VALUE self, ca_monop_func_t func[])
58
55
  /* unresolved unbound repeat array generates unbound repeat array again */
59
56
  if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
60
57
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
61
- out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
58
+ out = rb_ca_ubrep_new(rb_ca_ubrep_shave(self, out), cx->rep_ndim, cx->rep_dim);
62
59
  }
63
60
 
64
61
  return out;
@@ -75,7 +72,7 @@ rb_ca_call_monop_bang (VALUE self, ca_monop_func_t func[])
75
72
 
76
73
  ca_attach(ca1);
77
74
  func[ca1->data_type](ca1->elements,
78
- ( ca1->mask ) ? ca1->mask->ptr : NULL,
75
+ ( ca1->mask ) ? (boolean8_t *)ca1->mask->ptr : NULL,
79
76
  ca1->ptr, 1,
80
77
  ca1->ptr, 1);
81
78
  ca_sync(ca1);
@@ -134,7 +131,8 @@ rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
134
131
  out = ca_wrap_struct(ca3);
135
132
 
136
133
  ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
137
- func[ca1->data_type](ca1->elements, ( ca3->mask ) ? ca3->mask->ptr : NULL,
134
+ func[ca1->data_type](ca1->elements,
135
+ ( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
138
136
  ca1->ptr, 0,
139
137
  ca2->ptr, 0,
140
138
  ca3->ptr, 0);
@@ -149,7 +147,8 @@ rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
149
147
  out = ca_wrap_struct(ca3);
150
148
 
151
149
  ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
152
- func[ca1->data_type](ca2->elements, ( ca3->mask ) ? ca3->mask->ptr : NULL,
150
+ func[ca1->data_type](ca2->elements,
151
+ ( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
153
152
  ca1->ptr, 0,
154
153
  ca2->ptr, 1,
155
154
  ca3->ptr, 1);
@@ -166,7 +165,8 @@ rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
166
165
  out = ca_wrap_struct(ca3);
167
166
 
168
167
  ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
169
- func[ca1->data_type](ca1->elements, ( ca3->mask ) ? ca3->mask->ptr : NULL,
168
+ func[ca1->data_type](ca1->elements,
169
+ ( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
170
170
  ca1->ptr, 1,
171
171
  ca2->ptr, 0,
172
172
  ca3->ptr, 1);
@@ -185,7 +185,8 @@ rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
185
185
  out = ca_wrap_struct(ca3);
186
186
 
187
187
  ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
188
- func[ca1->data_type](ca1->elements, ( ca3->mask ) ? ca3->mask->ptr : NULL,
188
+ func[ca1->data_type](ca1->elements,
189
+ ( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
189
190
  ca1->ptr, 1,
190
191
  ca2->ptr, 1,
191
192
  ca3->ptr, 1);
@@ -197,13 +198,13 @@ rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
197
198
  /* unresolved unbound repeat array generates unbound repeat array again */
198
199
  if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
199
200
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
200
- out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
201
+ out = rb_ca_ubrep_new(rb_ca_ubrep_shave(self, out), cx->rep_ndim, cx->rep_dim);
201
202
  }
202
203
 
203
204
  /* unresolved unbound repeat array generates unbound repeat array again */
204
205
  if ( ca2->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
205
206
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca2;
206
- out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
207
+ out = rb_ca_ubrep_new(rb_ca_ubrep_shave(other, out), cx->rep_ndim, cx->rep_dim);
207
208
  }
208
209
 
209
210
  return out;
@@ -228,7 +229,8 @@ rb_ca_call_binop_bang (VALUE self, VALUE other, ca_binop_func_t func[])
228
229
  if ( rb_obj_is_cscalar(self) ) {
229
230
  if ( rb_obj_is_cscalar(other) ) { /* scalar vs scalar */
230
231
  ca_copy_mask_overlay(ca1, ca1->elements, 2, ca1, ca2);
231
- func[ca1->data_type](ca1->elements, ( ca1->mask ) ? ca1->mask->ptr : NULL,
232
+ func[ca1->data_type](ca1->elements,
233
+ ( ca1->mask ) ? (boolean8_t *) ca1->mask->ptr : NULL,
232
234
  ca1->ptr, 0,
233
235
  ca2->ptr, 0,
234
236
  ca1->ptr, 0);
@@ -240,7 +242,8 @@ rb_ca_call_binop_bang (VALUE self, VALUE other, ca_binop_func_t func[])
240
242
  }
241
243
 
242
244
  ca_copy_mask_overlay(ca1, ca1->elements, 2, ca1, ca2);
243
- func[ca1->data_type](ca1->elements, ( ca1->mask ) ? ca1->mask->ptr : NULL,
245
+ func[ca1->data_type](ca1->elements,
246
+ ( ca1->mask ) ? (boolean8_t *) ca1->mask->ptr : NULL,
244
247
  ca1->ptr, 0,
245
248
  ca2->ptr, 0,
246
249
  ca1->ptr, 0);
@@ -249,7 +252,8 @@ rb_ca_call_binop_bang (VALUE self, VALUE other, ca_binop_func_t func[])
249
252
  else {
250
253
  if ( rb_obj_is_cscalar(other) ) { /* array vs scalar */
251
254
  ca_copy_mask_overlay(ca1, ca1->elements, 2, ca1, ca2);
252
- func[ca1->data_type](ca1->elements, ( ca1->mask ) ? ca1->mask->ptr : NULL,
255
+ func[ca1->data_type](ca1->elements,
256
+ ( ca1->mask ) ? (boolean8_t *) ca1->mask->ptr : NULL,
253
257
  ca1->ptr, 1,
254
258
  ca2->ptr, 0,
255
259
  ca1->ptr, 1);
@@ -261,7 +265,8 @@ rb_ca_call_binop_bang (VALUE self, VALUE other, ca_binop_func_t func[])
261
265
  }
262
266
 
263
267
  ca_copy_mask_overlay(ca1, ca1->elements, 2, ca1, ca2);
264
- func[ca1->data_type](ca1->elements, ( ca1->mask ) ? ca1->mask->ptr : NULL,
268
+ func[ca1->data_type](ca1->elements,
269
+ ( ca1->mask ) ? (boolean8_t *) ca1->mask->ptr : NULL,
265
270
  ca1->ptr, 1,
266
271
  ca2->ptr, 1,
267
272
  ca1->ptr, 1);
@@ -294,15 +299,16 @@ rb_ca_call_moncmp (VALUE self, ca_moncmp_func_t func[])
294
299
 
295
300
  ca_attach(ca1);
296
301
  ca_copy_mask_overlay(ca2, ca2->elements, 1, ca1);
297
- func[ca1->data_type](ca1->elements, ( ca2->mask ) ? ca2->mask->ptr : NULL,
302
+ func[ca1->data_type](ca1->elements,
303
+ ( ca2->mask ) ? (boolean8_t *) ca2->mask->ptr : NULL,
298
304
  ca1->ptr, 1,
299
- ca2->ptr, 1);
305
+ (boolean8_t *) ca2->ptr, 1);
300
306
  ca_detach(ca1);
301
307
 
302
308
  /* unresolved unbound repeat array generates unbound repeat array again */
303
309
  if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
304
310
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
305
- out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
311
+ out = rb_ca_ubrep_new(rb_ca_ubrep_shave(self, out), cx->rep_ndim, cx->rep_dim);
306
312
  }
307
313
 
308
314
  return out;
@@ -321,10 +327,10 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
321
327
 
322
328
  /* check for comparison with CA_UNDEF */
323
329
  if ( other == CA_UNDEF ) {
324
- if ( func == ca_bincmp_eq ) { /* a.eq(UNDEF) -> a.is_masked */
330
+ if ( (ca_bincmp_func_t) func == (ca_bincmp_func_t) ca_bincmp_eq ) { /* a.eq(UNDEF) -> a.is_masked */
325
331
  return rb_ca_is_masked(self);
326
332
  }
327
- else if ( func == ca_bincmp_ne ) { /* a.ne(UNDEF) -> a.is_not_masked */
333
+ else if ( (ca_bincmp_func_t) func == (ca_bincmp_func_t) ca_bincmp_ne ) { /* a.ne(UNDEF) -> a.is_not_masked */
328
334
  return rb_ca_is_not_masked(self);
329
335
  }
330
336
  else {
@@ -347,7 +353,8 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
347
353
  Data_Get_Struct(out, CArray, ca3);
348
354
 
349
355
  ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
350
- func[ca1->data_type](ca1->elements, ( ca3->mask ) ? ca3->mask->ptr : NULL,
356
+ func[ca1->data_type](ca1->elements,
357
+ ( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
351
358
  ca1->ptr, ca1->bytes, 0,
352
359
  ca2->ptr, ca2->bytes, 0,
353
360
  ca3->ptr, ca3->bytes, 0);
@@ -357,7 +364,8 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
357
364
  Data_Get_Struct(out, CArray, ca3);
358
365
 
359
366
  ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
360
- func[ca1->data_type](ca2->elements, ( ca3->mask ) ? ca3->mask->ptr : NULL,
367
+ func[ca1->data_type](ca2->elements,
368
+ ( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
361
369
  ca1->ptr, ca1->bytes, 0,
362
370
  ca2->ptr, ca2->bytes, 1,
363
371
  ca3->ptr, ca3->bytes, 1);
@@ -369,7 +377,8 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
369
377
  Data_Get_Struct(out, CArray, ca3);
370
378
 
371
379
  ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
372
- func[ca1->data_type](ca1->elements, ( ca3->mask ) ? ca3->mask->ptr : NULL,
380
+ func[ca1->data_type](ca1->elements,
381
+ ( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
373
382
  ca1->ptr, ca1->bytes, 1,
374
383
  ca2->ptr, ca2->bytes, 0,
375
384
  ca3->ptr, ca3->bytes, 1);
@@ -383,7 +392,8 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
383
392
  Data_Get_Struct(out, CArray, ca3);
384
393
 
385
394
  ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
386
- func[ca1->data_type](ca1->elements, ( ca3->mask ) ? ca3->mask->ptr : NULL,
395
+ func[ca1->data_type](ca1->elements,
396
+ ( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
387
397
  ca1->ptr, ca1->bytes, 1,
388
398
  ca2->ptr, ca2->bytes, 1,
389
399
  ca3->ptr, ca3->bytes, 1);
@@ -395,7 +405,7 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
395
405
  /* unresolved unbound repeat array generates unbound repeat array again */
396
406
  if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
397
407
  CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
398
- out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
408
+ out = rb_ca_ubrep_new(rb_ca_ubrep_shave(self, out), cx->rep_ndim, cx->rep_dim);
399
409
  }
400
410
 
401
411
  return out;
@@ -458,11 +468,9 @@ ca_math_call (VALUE mod, VALUE arg, ID id)
458
468
  }
459
469
  }
460
470
 
461
- /* rdoc:
462
- class CArray
463
- def coerce (other)
464
- end
465
- end
471
+ /* @overload coerece (other)
472
+
473
+ [TBD]
466
474
  */
467
475
 
468
476
  static VALUE
@@ -524,6 +532,11 @@ rb_ca_coerce (VALUE self, VALUE other)
524
532
  } \
525
533
  }
526
534
 
535
+ /* @overload mul_add (weight, min_count=nil, fill_value=nil)
536
+
537
+ [TBD]
538
+ */
539
+
527
540
  static VALUE
528
541
  rb_ca_mul_add (int argc, VALUE *argv, volatile VALUE self)
529
542
  {
@@ -3,10 +3,8 @@
3
3
  carray_order.c
4
4
 
5
5
  This file is part of Ruby/CArray extension library.
6
- You can redistribute it and/or modify it under the terms of
7
- the Ruby Licence.
8
6
 
9
- Copyright (C) 2005 Hiroki Motoyoshi
7
+ Copyright (C) 2005-2020 Hiroki Motoyoshi
10
8
 
11
9
  ---------------------------------------------------------------------------- */
12
10
 
@@ -140,26 +138,24 @@ ca_project (CArray *ca, CArray *ci, char *lfill, char *ufill)
140
138
  return co;
141
139
  }
142
140
 
143
- /* rdoc:
144
- class CArray
145
- def project (idx,lval=nil,uval=nil)
146
- end
147
- end
141
+ /* @overload project (idx, lval=nil, uval=nil)
142
+
143
+ [TBD]. Creates new array the element of the object as address.
148
144
  */
149
145
 
150
146
  VALUE
151
147
  rb_ca_project (int argc, VALUE *argv, VALUE self)
152
148
  {
153
- volatile VALUE obj, rindex, vlfval, vufval;
149
+ volatile VALUE obj, ridx, vlfval, vufval;
154
150
  CArray *ca, *ci, *co;
155
151
  char *lfval, *ufval;
156
152
 
157
- rb_scan_args(argc, argv, "12", (VALUE *) &rindex, (VALUE *) &vlfval, (VALUE *) &vufval);
153
+ rb_scan_args(argc, argv, "12", (VALUE *)&ridx, (VALUE *) &vlfval, (VALUE *) &vufval);
158
154
 
159
155
  Data_Get_Struct(self, CArray, ca);
160
156
 
161
- rb_check_carray_object(rindex);
162
- ci = ca_wrap_readonly(rindex, CA_SIZE);
157
+ rb_check_carray_object(ridx);
158
+ ci = ca_wrap_readonly(ridx, CA_SIZE);
163
159
 
164
160
  lfval = malloc_with_check(ca->bytes);
165
161
  ufval = malloc_with_check(ca->bytes);
@@ -227,12 +223,9 @@ rb_ca_project (int argc, VALUE *argv, VALUE self)
227
223
  free(v); \
228
224
  }
229
225
 
230
- /* rdoc:
231
- class CArray
232
- # Reverses the elements of +ca+ in place.
233
- def reverse!
234
- end
235
- end
226
+ /* @overload reverse!
227
+
228
+ Reverses the elements of +ca+ in place.
236
229
  */
237
230
 
238
231
  static VALUE
@@ -279,13 +272,10 @@ rb_ca_reverse_bang (VALUE self)
279
272
  return self;
280
273
  }
281
274
 
282
- /* rdoc:
283
- class CArray
284
- # Returns a new CArray object containing <i>ca</i>'s elements in
285
- # reverse order.
286
- def reverse
287
- end
288
- end
275
+ /* @overload reverse
276
+
277
+ Returns a new CArray object containing <i>ca</i>'s elements in
278
+ reverse order.
289
279
  */
290
280
 
291
281
  static VALUE
@@ -384,12 +374,9 @@ ca_qsort_cmp[CA_NTYPE] = {
384
374
  qcmp_VALUE,
385
375
  };
386
376
 
387
- /* rdoc:
388
- class CArray
389
- # Sorts <i>ca</i>'s elements in place.
390
- def sort!
391
- end
392
- end
377
+ /* @overload sort!
378
+
379
+ Sorts <i>ca</i>'s elements in place.
393
380
  */
394
381
 
395
382
  static VALUE
@@ -433,12 +420,9 @@ rb_ca_sort_bang (VALUE self)
433
420
  return self;
434
421
  }
435
422
 
436
- /* rdoc:
437
- class CArray
438
- # Returns a new CArray object containing <i>ca</i>'s elements sorted.
439
- def sort
440
- end
441
- end
423
+ /* @overload sort
424
+
425
+ Returns a new CArray object containing <i>ca</i>'s elements sorted.
442
426
  */
443
427
 
444
428
  static VALUE
@@ -452,11 +436,9 @@ rb_ca_sorted_copy (VALUE self)
452
436
 
453
437
  /* --------------------------------------------------------------- */
454
438
 
455
- /* rdoc:
456
- class CArray
457
- def bsearch
458
- end
459
- end
439
+ /* @overload bsearch
440
+
441
+ Returns a new CArray object containing <i>ca</i>'s elements sorted.
460
442
  */
461
443
 
462
444
  static VALUE
@@ -561,11 +543,9 @@ rb_ca_binary_search (VALUE self, volatile VALUE rval)
561
543
  return out;
562
544
  }
563
545
 
564
- /* rdoc:
565
- class CArray
566
- def bsearch_index
567
- end
568
- end
546
+ /* @overload bsearch_index
547
+
548
+ [TBD].
569
549
  */
570
550
 
571
551
  static VALUE
@@ -630,6 +610,33 @@ rb_ca_binary_search_index (VALUE self, volatile VALUE rval)
630
610
  } \
631
611
  }
632
612
 
613
+ #define proc_find_value_float128(type, defeps) \
614
+ { \
615
+ type *ptr = (type *) ca->ptr; \
616
+ boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
617
+ type val = (type) NUM2DBL(value); \
618
+ float128_t eps = (NIL_P(veps)) ? defeps*fabsl(val) : NUM2DBL(veps); \
619
+ ca_size_t i; \
620
+ if ( m ) { \
621
+ for (i=0; i<ca->elements; i++, ptr++) { \
622
+ if ( ! *m++ ) { \
623
+ if ( fabsl(*ptr - val) <= eps ) { \
624
+ addr = i; \
625
+ break; \
626
+ } \
627
+ } \
628
+ } \
629
+ } \
630
+ else { \
631
+ for (i=0; i<ca->elements; i++, ptr++) { \
632
+ if ( fabsl(*ptr - val) <= eps ) { \
633
+ addr = i; \
634
+ break; \
635
+ } \
636
+ } \
637
+ } \
638
+ }
639
+
633
640
  #define proc_find_value_cmplx(type, defeps) \
634
641
  { \
635
642
  type *ptr = (type *) ca->ptr; \
@@ -683,11 +690,9 @@ rb_ca_binary_search_index (VALUE self, volatile VALUE rval)
683
690
  }
684
691
 
685
692
 
686
- /* rdoc:
687
- class CArray
688
- def search
689
- end
690
- end
693
+ /* @overload search
694
+
695
+ [TBD].
691
696
  */
692
697
 
693
698
  static VALUE
@@ -717,7 +722,7 @@ rb_ca_linear_search (int argc, VALUE *argv, VALUE self)
717
722
  case CA_UINT64: proc_find_value(uint64_t); break;
718
723
  case CA_FLOAT32: proc_find_value_float(float32_t, FLT_EPSILON); break;
719
724
  case CA_FLOAT64: proc_find_value_float(float64_t, DBL_EPSILON); break;
720
- case CA_FLOAT128: proc_find_value_float(float128_t, DBL_EPSILON); break;
725
+ case CA_FLOAT128: proc_find_value_float128(float128_t, DBL_EPSILON); break;
721
726
  #ifdef HAVE_COMPLEX_H
722
727
  case CA_CMPLX64: proc_find_value_cmplx(cmplx64_t, FLT_EPSILON); break;
723
728
  case CA_CMPLX128: proc_find_value_cmplx(cmplx128_t, DBL_EPSILON); break;
@@ -733,11 +738,9 @@ rb_ca_linear_search (int argc, VALUE *argv, VALUE self)
733
738
  return ( addr == -1 ) ? Qnil : SIZE2NUM(addr);
734
739
  }
735
740
 
736
- /* rdoc:
737
- class CArray
738
- def search_index
739
- end
740
- end
741
+ /* @overload search_index
742
+
743
+ [TBD].
741
744
  */
742
745
 
743
746
  static VALUE
@@ -811,11 +814,9 @@ rb_ca_linear_search_index (int argc, VALUE *argv, VALUE self)
811
814
  } \
812
815
  }
813
816
 
814
- /* rdoc:
815
- class CArray
816
- def search_nearest
817
- end
818
- end
817
+ /* @overload search_nearest
818
+
819
+ [TBD].
819
820
  */
820
821
 
821
822
  static VALUE
@@ -856,6 +857,11 @@ rb_ca_linear_search_nearest (VALUE self, VALUE value)
856
857
  return ( addr == -1 ) ? Qnil : SIZE2NUM(addr);
857
858
  }
858
859
 
860
+ /* @overload search_nearest_index
861
+
862
+ [TBD].
863
+ */
864
+
859
865
  static VALUE
860
866
  rb_ca_linear_search_nearest_index (VALUE self, VALUE value)
861
867
  {
@@ -876,6 +882,9 @@ Init_carray_order ()
876
882
  rb_define_method(rb_cCArray, "sort!", rb_ca_sort_bang, 0);
877
883
  rb_define_method(rb_cCArray, "sort", rb_ca_sorted_copy, 0);
878
884
 
885
+ rb_define_method(rb_cCArray, "bsearch", rb_ca_binary_search, 1);
886
+ rb_define_method(rb_cCArray, "bsearch_index", rb_ca_binary_search_index, 1);
887
+
879
888
  rb_define_method(rb_cCArray, "search", rb_ca_linear_search, -1);
880
889
  rb_define_method(rb_cCArray, "search_index", rb_ca_linear_search_index, -1);
881
890
 
@@ -884,6 +893,4 @@ Init_carray_order ()
884
893
  rb_define_method(rb_cCArray, "search_nearest_index",
885
894
  rb_ca_linear_search_nearest_index, 1);
886
895
 
887
- rb_define_method(rb_cCArray, "bsearch", rb_ca_binary_search, 1);
888
- rb_define_method(rb_cCArray, "bsearch_index", rb_ca_binary_search_index, 1);
889
896
  }