carray 3.0.0 → 3.0.1

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.
Files changed (180) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/CHANGELOG.md +325 -3
  4. data/{NEWS.md → CHANGELOG.v1.md} +1 -1
  5. data/README.md +32 -32
  6. data/carray.gemspec +12 -8
  7. data/ext/ca_axis_group.c +55 -19
  8. data/ext/ca_binop_dispatch.c +5 -6
  9. data/ext/ca_binop_dispatch.h +0 -7
  10. data/ext/ca_categorical_iterator.c +13 -13
  11. data/ext/ca_for_each_element.h +6 -8
  12. data/ext/ca_group_iter.c +1 -1
  13. data/ext/ca_kernel_iterator.c +69 -23
  14. data/ext/ca_kernel_iterator.h +3 -10
  15. data/ext/ca_obj_bincmp.c +57 -27
  16. data/ext/ca_obj_binop.c +86 -30
  17. data/ext/ca_obj_const_string.c +3 -1
  18. data/ext/ca_obj_face.c +80 -0
  19. data/ext/ca_obj_face.h +33 -1
  20. data/ext/ca_obj_fake.c +11 -0
  21. data/ext/ca_obj_fixlen_string.c +3 -1
  22. data/ext/ca_obj_grid.c +11 -3
  23. data/ext/ca_obj_meld.c +13 -8
  24. data/ext/ca_obj_moncmp.c +33 -14
  25. data/ext/ca_obj_monop.c +19 -7
  26. data/ext/ca_obj_object.c +99 -4
  27. data/ext/ca_obj_record.c +3 -1
  28. data/ext/ca_obj_refer.c +30 -6
  29. data/ext/ca_obj_roll.c +13 -5
  30. data/ext/ca_obj_select_axis.c +16 -6
  31. data/ext/ca_obj_shift.c +3 -3
  32. data/ext/ca_obj_stride.c +106 -23
  33. data/ext/ca_obj_string.c +3 -1
  34. data/ext/ca_obj_tile.c +13 -5
  35. data/ext/ca_obj_time.c +3 -1
  36. data/ext/ca_obj_timedelta.c +3 -1
  37. data/ext/ca_obj_transpose.c +1 -1
  38. data/ext/ca_obj_triop.c +62 -23
  39. data/ext/ca_obj_window.c +86 -17
  40. data/ext/ca_op_cmplx64.h +123 -0
  41. data/ext/ca_op_ipower.c +0 -3
  42. data/ext/ca_sort_kernels.h +5 -5
  43. data/ext/ca_sweep_engine.c +78 -35
  44. data/ext/ca_sweep_engine.h +13 -4
  45. data/ext/ca_transform_common.c +7 -0
  46. data/ext/carray.h +127 -130
  47. data/ext/carray_access.c +56 -34
  48. data/ext/carray_bincount.c +8 -8
  49. data/ext/carray_broadcast.c +99 -6
  50. data/ext/carray_build_flags.h +3 -0
  51. data/ext/carray_call_cfunc.c +1491 -0
  52. data/ext/carray_call_cfunc.h +153 -0
  53. data/ext/carray_cast.c +69 -31
  54. data/ext/carray_conversion.c +22 -22
  55. data/ext/carray_copy.c +12 -2
  56. data/ext/carray_core.c +57 -10
  57. data/ext/carray_count.c +1 -1
  58. data/ext/carray_element.c +7 -7
  59. data/ext/carray_factorize.c +28 -28
  60. data/ext/carray_hold.c +1 -1
  61. data/ext/carray_index_classifier.c +7 -21
  62. data/ext/carray_internal.h +19 -3
  63. data/ext/carray_kernels_bincmp.c +1 -0
  64. data/ext/carray_kernels_binop.c +320 -298
  65. data/ext/carray_kernels_init.c +1095 -0
  66. data/ext/carray_kernels_map.c +1 -0
  67. data/ext/carray_kernels_moncmp.c +1 -0
  68. data/ext/carray_kernels_monop.c +412 -411
  69. data/ext/carray_kernels_reduce_aggregate.c +88 -87
  70. data/ext/carray_kernels_reduce_boolean.c +1 -0
  71. data/ext/carray_kernels_reduce_cumulative.c +54 -53
  72. data/ext/carray_kernels_reduce_extreme.c +51 -50
  73. data/ext/carray_kernels_reduce_variance.c +1 -0
  74. data/ext/carray_kernels_scan.c +1 -0
  75. data/ext/carray_kernels_search.c +93 -92
  76. data/ext/carray_kernels_sort.c +1 -0
  77. data/ext/carray_kernels_triop.c +1 -0
  78. data/ext/carray_lazy.c +175 -5
  79. data/ext/carray_mask.c +6 -5
  80. data/ext/carray_median_percentile.c +1 -1
  81. data/ext/carray_memory_view.c +46 -21
  82. data/ext/carray_operator.c +46 -49
  83. data/ext/carray_partition.c +4 -4
  84. data/ext/carray_random.c +7 -7
  85. data/ext/carray_scatter.c +1 -1
  86. data/ext/carray_sort.c +3 -3
  87. data/ext/carray_sort_kernel.c +10 -10
  88. data/ext/carray_test.c +1 -1
  89. data/ext/extconf.rb +18 -0
  90. data/ext/mk_call_cfunc.rb +243 -52
  91. data/ext/mkkernel.rb +354 -100
  92. data/ext/ruby_carray.c +18 -16
  93. data/ext/version.h +4 -4
  94. data/lib/carray/autoload_carray.rb +19 -0
  95. data/lib/carray/autoload_method_extension.rb +2 -1
  96. data/lib/carray/axis_group.rb +7 -7
  97. data/lib/carray/basics.rb +59 -59
  98. data/lib/carray/bincount_nd.rb +12 -12
  99. data/lib/carray/block_iterator.rb +24 -14
  100. data/lib/carray/categorical.rb +4 -4
  101. data/lib/carray/categorical_iterator.rb +98 -76
  102. data/lib/carray/conditional.rb +14 -14
  103. data/lib/carray/construct.rb +21 -0
  104. data/lib/carray/core_extensions.rb +62 -5
  105. data/lib/carray/data_type_extension.rb +18 -1
  106. data/lib/carray/frame/concat.rb +3 -3
  107. data/lib/carray/frame/convert.rb +1 -1
  108. data/lib/carray/frame/frame.rb +4 -11
  109. data/lib/carray/frame/io.rb +159 -2
  110. data/lib/carray/frame/sort.rb +1 -1
  111. data/lib/carray/frame/verbs.rb +18 -1
  112. data/lib/carray/fuse_source.rb +123 -0
  113. data/lib/carray/fusion.rb +218 -0
  114. data/lib/carray/histogram.rb +16 -16
  115. data/lib/carray/inspect.rb +1 -7
  116. data/lib/carray/iterator.rb +4 -3
  117. data/lib/carray/lazy.rb +125 -73
  118. data/lib/carray/meld_reduce.rb +2 -2
  119. data/lib/carray/methods/align_addr.rb +1 -1
  120. data/lib/carray/methods/composition.rb +1 -1
  121. data/lib/carray/methods/is_in.rb +12 -12
  122. data/lib/carray/methods/locate_addr.rb +6 -1
  123. data/lib/carray/methods/mask_duplicates.rb +1 -1
  124. data/lib/carray/methods/meshgrid.rb +4 -5
  125. data/lib/carray/methods/mode.rb +2 -2
  126. data/lib/carray/methods/nunique.rb +1 -1
  127. data/lib/carray/methods/snap.rb +7 -2
  128. data/lib/carray/methods/unique.rb +3 -3
  129. data/lib/carray/methods/value_counts.rb +2 -2
  130. data/lib/carray/runtime.rb +0 -19
  131. data/lib/carray/slab_iterator.rb +20 -7
  132. data/lib/carray/string_operation_extension.rb +5 -5
  133. data/lib/carray/time.rb +890 -491
  134. data/lib/carray/window_iterator.rb +285 -13
  135. data/lib/carray.rb +5 -5
  136. data/yard-stubs/ca_obj_array.rb +385 -0
  137. data/yard-stubs/ca_obj_bitarray.rb +38 -0
  138. data/yard-stubs/ca_obj_bitfield.rb +43 -0
  139. data/yard-stubs/ca_obj_block.rb +73 -0
  140. data/yard-stubs/ca_obj_byte_swap.rb +56 -0
  141. data/yard-stubs/ca_obj_fake.rb +31 -0
  142. data/yard-stubs/ca_obj_farray.rb +32 -0
  143. data/yard-stubs/ca_obj_field.rb +45 -0
  144. data/yard-stubs/ca_obj_grid.rb +35 -0
  145. data/yard-stubs/ca_obj_refer.rb +72 -0
  146. data/yard-stubs/ca_obj_roll.rb +45 -0
  147. data/yard-stubs/ca_obj_shift.rb +43 -0
  148. data/yard-stubs/ca_obj_stride.rb +181 -0
  149. data/yard-stubs/ca_obj_tile.rb +29 -0
  150. data/yard-stubs/ca_obj_transpose.rb +40 -0
  151. data/yard-stubs/ca_obj_window.rb +49 -0
  152. data/yard-stubs/carray_access.rb +131 -0
  153. data/yard-stubs/carray_attribute.rb +246 -0
  154. data/yard-stubs/carray_broadcast.rb +37 -0
  155. data/yard-stubs/carray_cast.rb +489 -0
  156. data/yard-stubs/carray_class.rb +65 -0
  157. data/yard-stubs/carray_conversion.rb +76 -0
  158. data/yard-stubs/carray_copy.rb +79 -0
  159. data/yard-stubs/carray_core.rb +114 -0
  160. data/yard-stubs/carray_count.rb +79 -0
  161. data/yard-stubs/carray_element.rb +108 -0
  162. data/yard-stubs/carray_generate.rb +66 -0
  163. data/yard-stubs/carray_lazy.rb +23 -0
  164. data/yard-stubs/carray_loop.rb +140 -0
  165. data/yard-stubs/carray_mask.rb +259 -0
  166. data/yard-stubs/carray_math.rb +132 -0
  167. data/yard-stubs/carray_mathfunc.rb +45 -0
  168. data/yard-stubs/carray_median_percentile.rb +89 -0
  169. data/yard-stubs/carray_memory_view.rb +163 -0
  170. data/yard-stubs/carray_order.rb +312 -0
  171. data/yard-stubs/carray_random.rb +89 -0
  172. data/yard-stubs/carray_scatter.rb +106 -0
  173. data/yard-stubs/carray_slab.rb +57 -0
  174. data/yard-stubs/carray_sort.rb +163 -0
  175. data/yard-stubs/carray_test.rb +85 -0
  176. data/yard-stubs/carray_undef.rb +64 -0
  177. data/yard-stubs/carray_utils.rb +97 -0
  178. data/yard-stubs/ruby_carray.rb +193 -0
  179. metadata +59 -10
  180. data/ext/ca_obj_unbound_repeat.c +0 -496
data/ext/carray_element.c CHANGED
@@ -254,10 +254,10 @@ rb_ca_elem_store (VALUE self, VALUE ridx, VALUE obj)
254
254
  from_array = 0;
255
255
  }
256
256
 
257
- /* Super-hot path: entity + no mask + common numeric dtype + Numeric obj.
257
+ /* Super-hot path: entity + no mask + common numeric data type + Numeric obj.
258
258
  Bypasses rb_ca_store_index/addr -> ca_update_mask + rb_ca_obj2ptr ->
259
259
  cast_table dispatch. Falls through to general path for: views,
260
- existing mask, non-numeric dtype, UNDEF, or non-Numeric obj. */
260
+ existing mask, non-numeric data type, UNDEF, or non-Numeric obj. */
261
261
  if ( ca_is_entity(ca) && ! ca->mask && obj != CA_UNDEF ) {
262
262
  int8_t dt = ca->data_type;
263
263
  if ( dt == CA_FLOAT64 || dt == CA_FLOAT32 ||
@@ -269,7 +269,7 @@ rb_ca_elem_store (VALUE self, VALUE ridx, VALUE obj)
269
269
  /* Compute flat addr if T_ARRAY index path. */
270
270
  if ( from_array ) addr = elem_entity_addr(ca, idx);
271
271
  char *p = ca->ptr + ca->bytes * addr;
272
- /* Convert obj to dtype + store. Restrict to Fixnum / Float / true
272
+ /* Convert obj to data type + store. Restrict to Fixnum / Float / true
273
273
  / false to avoid Bignum / Rational / Complex coercion that the
274
274
  cast_table handles in the general path. */
275
275
  switch ( dt ) {
@@ -311,7 +311,7 @@ rb_ca_elem_store (VALUE self, VALUE ridx, VALUE obj)
311
311
  if ( FIXNUM_P(obj) ) { *(uint8_t *)p = (FIX2LONG(obj) != 0); return obj; }
312
312
  break;
313
313
  }
314
- /* Fall through: dtype matches but obj kind needs general coercion. */
314
+ /* Fall through: data type matches but obj kind needs general coercion. */
315
315
  }
316
316
  }
317
317
 
@@ -344,7 +344,7 @@ rb_ca_elem_fetch (VALUE self, VALUE ridx)
344
344
  volatile VALUE out;
345
345
  elem_parse_idx_array(ca, ridx, idx);
346
346
 
347
- /* Super-hot path: entity + common numeric dtype + no mask.
347
+ /* Super-hot path: entity + common numeric data type + no mask.
348
348
  Bypass ca_fetch_index dispatch AND rb_ca_ptr2obj cast-table dispatch.
349
349
  Covers the bench's float64 / int64 / int32 cases. */
350
350
  if ( ca_is_entity(ca) && ! ca->mask ) {
@@ -454,7 +454,7 @@ rb_ca_elem_incr (VALUE self, VALUE ridx1)
454
454
 
455
455
  has_mask = elem_probe_mask(ca);
456
456
 
457
- /* Super-hot path: entity + no mask + integer dtype.
457
+ /* Super-hot path: entity + no mask + integer data type.
458
458
  Reads p directly, modifies in place — no separate fetch/store dispatch. */
459
459
  if ( ca_is_entity(ca) && ! has_mask ) {
460
460
  ca_size_t addr;
@@ -818,7 +818,7 @@ rb_ca_elem_min (VALUE self, VALUE ridx, VALUE rval)
818
818
  "elem_min requires a numeric array");
819
819
  }
820
820
 
821
- /* Super-hot path: entity + numeric dtype + Fixnum/Float rval. */
821
+ /* Super-hot path: entity + numeric data type + Fixnum/Float rval. */
822
822
  ELEM_MINMAX_BODY(<);
823
823
 
824
824
  /* General path: view / Bignum-Rational-Complex rval / fall-through.
@@ -59,7 +59,7 @@
59
59
  codes : narrow unsigned CArray (uint8 / uint16 / uint32), the code
60
60
  storage; masked source cells store the type-max sentinel
61
61
  (from_codes derives the mask from it, matching categorize).
62
- levels : integer CArray (source dtype) of the k distinct values in
62
+ levels : integer CArray (source data type) of the k distinct values in
63
63
  first-appearance order.
64
64
  self.__mask_duplicates__(axis) -> boolean CArray of self.shape, true at
65
65
  each cell that duplicates an earlier-seen one along axis (per-fiber
@@ -487,7 +487,7 @@ fz_levels_free (fz_levels *l)
487
487
  codes = narrow unsigned CArray; masked source cells store the type-max
488
488
  sentinel (0xFF / 0xFFFF / 0xFFFFFFFF), so from_codes reconstructs
489
489
  the mask exactly as the mask_duplicates path does.
490
- levels = CArray (source dtype) of the k distinct values, in first-appearance
490
+ levels = CArray (source data type) of the k distinct values, in first-appearance
491
491
  (row-major flatten) order.
492
492
  */
493
493
  static VALUE
@@ -508,7 +508,7 @@ rb_ca_factorize_appearance (VALUE self)
508
508
  break;
509
509
  default:
510
510
  rb_raise(rb_eCADataTypeError,
511
- "__factorize_appearance__: integer, float, object, or fixlen dtype required (got %d)", dt);
511
+ "__factorize_appearance__: integer, float, object, or fixlen data type required (got %d)", dt);
512
512
  }
513
513
  if ( ca->ndim < 1 ) {
514
514
  rb_raise(rb_eRuntimeError, "__factorize_appearance__: need ndim >= 1");
@@ -535,8 +535,8 @@ rb_ca_factorize_appearance (VALUE self)
535
535
  boolean8_t *m;
536
536
  ca_size_t n;
537
537
 
538
- /* Fiber inner loop, monomorphised per dtype. WIDEN sign- or zero-extends the
539
- element to a 64-bit key; equality within one dtype is preserved. */
538
+ /* Fiber inner loop, monomorphised per data type. WIDEN sign- or zero-extends the
539
+ element to a 64-bit key; equality within one data type is preserved. */
540
540
  #define FZ_LOOP(T, WIDEN) \
541
541
  do { \
542
542
  const T *ip = (const T *) p_in; \
@@ -664,7 +664,7 @@ rb_ca_factorize_appearance (VALUE self)
664
664
  }
665
665
  }
666
666
 
667
- /* Levels: the interned raw values, in source dtype. CA_FIXLEN carries its
667
+ /* Levels: the interned raw values, in source data type. CA_FIXLEN carries its
668
668
  element width; numeric / object use bytes = 0. */
669
669
  ca_size_t ldim[1];
670
670
  ldim[0] = k;
@@ -715,7 +715,7 @@ rb_ca_mask_duplicates (VALUE self, VALUE vaxis)
715
715
  break;
716
716
  default:
717
717
  rb_raise(rb_eCADataTypeError,
718
- "__mask_duplicates__: numeric, object, or fixlen dtype required (got %d)", dt);
718
+ "__mask_duplicates__: numeric, object, or fixlen data type required (got %d)", dt);
719
719
  }
720
720
  if ( ca->ndim < 1 ) {
721
721
  rb_raise(rb_eRuntimeError, "__mask_duplicates__: need ndim >= 1");
@@ -740,8 +740,8 @@ rb_ca_mask_duplicates (VALUE self, VALUE vaxis)
740
740
  boolean8_t *m;
741
741
  ca_size_t n;
742
742
 
743
- /* Fiber inner loop, monomorphised per dtype. WIDEN sign- or zero-extends the
744
- element to a 64-bit key; equality within one dtype is preserved. The hash
743
+ /* Fiber inner loop, monomorphised per data type. WIDEN sign- or zero-extends the
744
+ element to a 64-bit key; equality within one data type is preserved. The hash
745
745
  interns first appearances, so is_new == 0 flags a duplicate. */
746
746
  #define MD_LOOP(T, WIDEN) \
747
747
  do { \
@@ -839,7 +839,7 @@ rb_ca_mask_duplicates (VALUE self, VALUE vaxis)
839
839
 
840
840
  INTERNAL (CArray#unique). Collect the distinct values of self in
841
841
  first-appearance (row-major flatten) order, one linear pass, no sort. Returns
842
- a 1-D CArray of source dtype. Masked cells do not participate.
842
+ a 1-D CArray of source data type. Masked cells do not participate.
843
843
 
844
844
  Numeric (integer / float): distinctness follows `==` except NaN collapses to a
845
845
  single distinct value (all NaN patterns map to one canonical hash key) and
@@ -876,7 +876,7 @@ rb_ca_unique_flat (VALUE self)
876
876
  break;
877
877
  default:
878
878
  rb_raise(rb_eCADataTypeError,
879
- "__unique_flat__: numeric, object, or fixlen dtype required (got %d)", dt);
879
+ "__unique_flat__: numeric, object, or fixlen data type required (got %d)", dt);
880
880
  }
881
881
  if ( ca->ndim < 1 ) {
882
882
  rb_raise(rb_eRuntimeError, "__unique_flat__: need ndim >= 1");
@@ -1098,8 +1098,8 @@ fz_intern_all (fz_hash *h, CArray *cv, fz_levels *lv)
1098
1098
  seen-set). One pass to build the set from `values`, one pass to probe self;
1099
1099
  no sort, peak memory O(distinct values).
1100
1100
 
1101
- `values` must be a CArray of the same dtype as self (the Ruby surface coerces
1102
- Array / Range / other-dtype input first). Masked cells of `values` do not
1101
+ `values` must be a CArray of the same data type as self (the Ruby surface coerces
1102
+ Array / Range / other-type input first). Masked cells of `values` do not
1103
1103
  enter the set. Masked cells of self stay masked in the output (membership is
1104
1104
  unknown), reproducing the mask propagation of the retired `contains`
1105
1105
  (self.eq(v)); their boolean payload is false.
@@ -1127,7 +1127,7 @@ rb_ca_is_in (VALUE self, VALUE rvalues)
1127
1127
  break;
1128
1128
  default:
1129
1129
  rb_raise(rb_eCADataTypeError,
1130
- "__is_in__: numeric, object, or fixlen dtype required (got %d)", dt);
1130
+ "__is_in__: numeric, object, or fixlen data type required (got %d)", dt);
1131
1131
  }
1132
1132
  if ( ca->ndim < 1 ) {
1133
1133
  rb_raise(rb_eRuntimeError, "__is_in__: need ndim >= 1");
@@ -1139,7 +1139,7 @@ rb_ca_is_in (VALUE self, VALUE rvalues)
1139
1139
  GetCArray(rvalues, cv);
1140
1140
  if ( cv->data_type != dt || (dt == CA_FIXLEN && cv->bytes != ca->bytes) ) {
1141
1141
  rb_raise(rb_eCADataTypeError,
1142
- "__is_in__: values dtype must match self (%d)", dt);
1142
+ "__is_in__: values data type must match self (%d)", dt);
1143
1143
  }
1144
1144
  if ( cv->ndim < 1 ) {
1145
1145
  rb_raise(rb_eRuntimeError, "__is_in__: values need ndim >= 1");
@@ -1256,7 +1256,7 @@ rb_ca_is_in (VALUE self, VALUE rvalues)
1256
1256
  through the discovery-family lanes (NaN collapse, rb_hash + rb_eql, byte
1257
1257
  equality).
1258
1258
 
1259
- `ref` must be a CArray of the same dtype as self (the Ruby surface coerces
1259
+ `ref` must be a CArray of the same data type as self (the Ruby surface coerces
1260
1260
  first). Masked cells of `ref` do not enter the map but still occupy their
1261
1261
  flat address (position counts). Masked cells of self, and cells whose value
1262
1262
  is absent from `ref`, are UNDEF in the output. "First" occurrence is
@@ -1286,7 +1286,7 @@ rb_ca_locate_addr (VALUE self, VALUE rref)
1286
1286
  break;
1287
1287
  default:
1288
1288
  rb_raise(rb_eCADataTypeError,
1289
- "__locate_addr__: numeric, object, or fixlen dtype required (got %d)", dt);
1289
+ "__locate_addr__: numeric, object, or fixlen data type required (got %d)", dt);
1290
1290
  }
1291
1291
  if ( ca->ndim < 1 ) {
1292
1292
  rb_raise(rb_eRuntimeError, "__locate_addr__: need ndim >= 1");
@@ -1297,7 +1297,7 @@ rb_ca_locate_addr (VALUE self, VALUE rref)
1297
1297
  GetCArray(rref, cr);
1298
1298
  if ( cr->data_type != dt || (dt == CA_FIXLEN && cr->bytes != ca->bytes) ) {
1299
1299
  rb_raise(rb_eCADataTypeError,
1300
- "__locate_addr__: ref dtype must match self (%d)", dt);
1300
+ "__locate_addr__: ref data type must match self (%d)", dt);
1301
1301
  }
1302
1302
  if ( cr->ndim < 1 ) {
1303
1303
  rb_raise(rb_eRuntimeError, "__locate_addr__: ref need ndim >= 1");
@@ -1521,7 +1521,7 @@ rb_ca_locate_addr (VALUE self, VALUE rref)
1521
1521
  /* Shared body of __intersection__ (keep_when_hit = 1) and __difference__
1522
1522
  (keep_when_hit = 0): the distinct values of self that are (resp. are not)
1523
1523
  present in `other`, in self's first-appearance order, as a 1-D CArray of
1524
- self's dtype. Two seen-sets: `hoth` built from `other` is the probe set;
1524
+ self's data type. Two seen-sets: `hoth` built from `other` is the probe set;
1525
1525
  `hself` dedups self so each distinct value is decided once. Masked cells of
1526
1526
  either array do not participate. Distinctness is the discovery family's per
1527
1527
  lane (numeric `==` + NaN collapse + -0.0 == +0.0, object hash/eql? + NaN
@@ -1545,7 +1545,7 @@ fz_set_relation (VALUE self, VALUE rother, int keep_when_hit)
1545
1545
  break;
1546
1546
  default:
1547
1547
  rb_raise(rb_eCADataTypeError,
1548
- "set relation: numeric, object, or fixlen dtype required (got %d)", dt);
1548
+ "set relation: numeric, object, or fixlen data type required (got %d)", dt);
1549
1549
  }
1550
1550
  if ( ca->ndim < 1 ) {
1551
1551
  rb_raise(rb_eRuntimeError, "set relation: need ndim >= 1");
@@ -1555,7 +1555,7 @@ fz_set_relation (VALUE self, VALUE rother, int keep_when_hit)
1555
1555
  }
1556
1556
  GetCArray(rother, co);
1557
1557
  if ( co->data_type != dt || (dt == CA_FIXLEN && co->bytes != ca->bytes) ) {
1558
- rb_raise(rb_eCADataTypeError, "set relation: other dtype must match self (%d)", dt);
1558
+ rb_raise(rb_eCADataTypeError, "set relation: other data type must match self (%d)", dt);
1559
1559
  }
1560
1560
  if ( co->ndim < 1 ) {
1561
1561
  rb_raise(rb_eRuntimeError, "set relation: other need ndim >= 1");
@@ -1730,7 +1730,7 @@ rb_ca_set_union (VALUE self, VALUE rother)
1730
1730
  break;
1731
1731
  default:
1732
1732
  rb_raise(rb_eCADataTypeError,
1733
- "__union__: numeric, object, or fixlen dtype required (got %d)", dt);
1733
+ "__union__: numeric, object, or fixlen data type required (got %d)", dt);
1734
1734
  }
1735
1735
  if ( ca->ndim < 1 ) {
1736
1736
  rb_raise(rb_eRuntimeError, "__union__: need ndim >= 1");
@@ -1740,7 +1740,7 @@ rb_ca_set_union (VALUE self, VALUE rother)
1740
1740
  }
1741
1741
  GetCArray(rother, co);
1742
1742
  if ( co->data_type != dt || (dt == CA_FIXLEN && co->bytes != ca->bytes) ) {
1743
- rb_raise(rb_eCADataTypeError, "__union__: other dtype must match self (%d)", dt);
1743
+ rb_raise(rb_eCADataTypeError, "__union__: other data type must match self (%d)", dt);
1744
1744
  }
1745
1745
  if ( co->ndim < 1 ) {
1746
1746
  rb_raise(rb_eRuntimeError, "__union__: other need ndim >= 1");
@@ -1779,7 +1779,7 @@ rb_ca_set_union (VALUE self, VALUE rother)
1779
1779
  first-appearance (row-major flatten) order together with the number of times
1780
1780
  each occurs, one linear pass, no sort.
1781
1781
  Returns [levels, counts]:
1782
- levels = 1-D CArray of source dtype, the k distinct values in appearance
1782
+ levels = 1-D CArray of source data type, the k distinct values in appearance
1783
1783
  order (identical to __unique_flat__).
1784
1784
  counts = 1-D CA_INT64 of length k, counts[i] = occurrences of levels[i].
1785
1785
  Masked cells do not participate (skipped, not counted). Numeric distinctness
@@ -1806,7 +1806,7 @@ rb_ca_value_counts_flat (VALUE self)
1806
1806
  break;
1807
1807
  default:
1808
1808
  rb_raise(rb_eCADataTypeError,
1809
- "__value_counts_flat__: numeric, object, or fixlen dtype required (got %d)", dt);
1809
+ "__value_counts_flat__: numeric, object, or fixlen data type required (got %d)", dt);
1810
1810
  }
1811
1811
  if ( ca->ndim < 1 ) {
1812
1812
  rb_raise(rb_eRuntimeError, "__value_counts_flat__: need ndim >= 1");
@@ -1979,7 +1979,7 @@ rb_ca_nunique (VALUE self, VALUE vaxis, VALUE vkeep)
1979
1979
  break;
1980
1980
  default:
1981
1981
  rb_raise(rb_eCADataTypeError,
1982
- "__nunique__: numeric, object, or fixlen dtype required (got %d)", dt);
1982
+ "__nunique__: numeric, object, or fixlen data type required (got %d)", dt);
1983
1983
  }
1984
1984
  if ( ca->ndim < 1 ) {
1985
1985
  rb_raise(rb_eRuntimeError, "__nunique__: need ndim >= 1");
@@ -2126,7 +2126,7 @@ rb_ca_is_mode (VALUE self, VALUE vaxis)
2126
2126
  break;
2127
2127
  default:
2128
2128
  rb_raise(rb_eCADataTypeError,
2129
- "__is_mode__: numeric, object, or fixlen dtype required (got %d)", dt);
2129
+ "__is_mode__: numeric, object, or fixlen data type required (got %d)", dt);
2130
2130
  }
2131
2131
  if ( ca->ndim < 1 ) {
2132
2132
  rb_raise(rb_eRuntimeError, "__is_mode__: need ndim >= 1");
@@ -2344,7 +2344,7 @@ rb_ca_mode_axis (VALUE self, VALUE vaxis)
2344
2344
  break;
2345
2345
  default:
2346
2346
  rb_raise(rb_eCADataTypeError,
2347
- "__mode_axis__: numeric dtype required (got %d)", dt);
2347
+ "__mode_axis__: numeric data type required (got %d)", dt);
2348
2348
  }
2349
2349
  if ( ca->ndim < 1 ) {
2350
2350
  rb_raise(rb_eRuntimeError, "__mode_axis__: need ndim >= 1");
data/ext/carray_hold.c CHANGED
@@ -5,7 +5,7 @@
5
5
  (see devel/PROPOSAL_UNMASK_FILL_METHOD.md).
6
6
 
7
7
  Hold copies a cell's bytes into masked cells with no arithmetic and no
8
- per-dtype behavior, so a single ca->bytes-width memcpy walk covers every
8
+ per-type behavior, so a single ca->bytes-width memcpy walk covers every
9
9
  data_type -- numeric, complex, bool, object (VALUE-slot byte copy of an
10
10
  already-live value), fixlen, and Face storage. This native does forward
11
11
  hold along one axis only and returns a fresh same-shape entity; the
@@ -37,7 +37,6 @@ static ID ca_classifier_id_excl_end = 0;
37
37
  /* Symbol cache — see the range-macro comment above for why this
38
38
  file keeps its own copy independent of carray_access.c. */
39
39
 
40
- static VALUE ca_classifier_sym_star = Qundef;
41
40
  static VALUE ca_classifier_sym_perc = Qundef;
42
41
  static VALUE ca_classifier_sym_under = Qundef;
43
42
  static VALUE ca_classifier_sym_gt = Qundef; /* :> slab-iterator marker */
@@ -46,8 +45,7 @@ static VALUE ca_classifier_sym_tilde = Qundef; /* :~ rubber-dim alias for `fal
46
45
  static inline void
47
46
  ca_classifier_sym_cache_init (void)
48
47
  {
49
- if ( ca_classifier_sym_star == Qundef ) {
50
- ca_classifier_sym_star = ID2SYM(rb_intern("*"));
48
+ if ( ca_classifier_sym_perc == Qundef ) {
51
49
  ca_classifier_sym_perc = ID2SYM(rb_intern("%"));
52
50
  ca_classifier_sym_under = ID2SYM(rb_intern("_"));
53
51
  ca_classifier_sym_gt = ID2SYM(rb_intern(">"));
@@ -166,7 +164,7 @@ ca_classifier_try_address_fast_path (ca_classifier_ctx_t *ctx)
166
164
  /* Single-character alphabetic Symbols (`:a`-`:z` / `:A`-`:Z`) are
167
165
  reserved for future contraction notation. Raises
168
166
  NotImplementedError rather than the generic IndexError. The
169
- caller passes any Symbol that is not `:_` / `:*` / `:%`; a
167
+ caller passes any Symbol that is not `:_` / `:%`; a
170
168
  non-reserved Symbol returns without action. */
171
169
  static inline void
172
170
  ca_classifier_check_reserved_contraction_symbol (VALUE sym)
@@ -763,12 +761,6 @@ ca_classifier_try_argc1_special (ca_classifier_ctx_t *ctx)
763
761
  ca_type_name[cs->data_type]);
764
762
  }
765
763
 
766
- /* :* → UNBOUND_REPEAT. */
767
- if ( arg == ca_classifier_sym_star ) {
768
- info->type = CA_REG_UNBOUND_REPEAT;
769
- return 1;
770
- }
771
-
772
764
  /* ndim > 1 with Integer → ADDRESS. Fixnum was caught by the
773
765
  fast path; this branch handles Bignum. */
774
766
  if ( ctx->ca_ndim > 1 && rb_obj_is_kind_of(arg, rb_cInteger) ) {
@@ -832,7 +824,7 @@ rb_ca_scan_index_v2 (int ca_ndim, ca_size_t *ca_dim, ca_size_t ca_elements,
832
824
  }
833
825
 
834
826
  /* argv[0] = multi-char Symbol → METHOD_CALL. Single-char
835
- specials (:_ / :* / :%) fall through the strlen check and are
827
+ specials (:_ / :%) fall through the strlen check and are
836
828
  handled downstream (argc == 1 special / fast paths / main
837
829
  loop). Single-char alphabetic reserved-contraction Symbols
838
830
  also fall through here and are raised later by the per-axis
@@ -859,20 +851,15 @@ rb_ca_scan_index_v2 (int ca_ndim, ca_size_t *ca_dim, ca_size_t ca_elements,
859
851
  when argc == 1 && ndim == 1 falls through to the POINT 1-D
860
852
  classification below. */
861
853
 
862
- /* CAREFUL: pre-scan for :% / :*. Either Symbol at any position
863
- pins the final REG and short-circuits both the main loop and
864
- the argc / ndim validation below — skipping the pre-scan lets
865
- the ndim mismatch check fire before the Symbol is
866
- recognised. */
854
+ /* CAREFUL: pre-scan for :%. The Symbol at any position pins the
855
+ final REG and short-circuits both the main loop and the argc /
856
+ ndim validation below — skipping the pre-scan lets the ndim
857
+ mismatch check fire before the Symbol is recognised. */
867
858
  for (i = 0; i < ctx.argc; i++) {
868
859
  if ( ctx.argv[i] == ca_classifier_sym_perc ) {
869
860
  info->type = CA_REG_REPEAT;
870
861
  return;
871
862
  }
872
- if ( ctx.argv[i] == ca_classifier_sym_star ) {
873
- info->type = CA_REG_UNBOUND_REPEAT;
874
- return;
875
- }
876
863
  }
877
864
 
878
865
  ca_classifier_expand_rubber_dim(&ctx);
@@ -941,7 +928,6 @@ rb_ca_s_scan_index_v2 (VALUE self, VALUE rdim, VALUE ridx)
941
928
  case CA_REG_GRID:
942
929
  case CA_REG_MAPPING:
943
930
  case CA_REG_METHOD_CALL:
944
- case CA_REG_UNBOUND_REPEAT:
945
931
  case CA_REG_MEMBER:
946
932
  case CA_REG_ATTRIBUTE:
947
933
  break;
@@ -59,8 +59,24 @@ void ca_bit_pack (const boolean8_t *src, ca_size_t elements, ca_size_t pbytes,
59
59
  void ca_lazy_arena_enter (void);
60
60
  void ca_lazy_arena_exit (void);
61
61
  void *ca_lazy_arena_acquire (ca_size_t bytes);
62
+ void *ca_lazy_arena_acquire_object (ca_size_t n_elements);
62
63
  void ca_lazy_arena_release (void *ptr);
63
64
 
65
+ /* ---- CA_OBJECT GC guard (carray_lazy.c) ----------------------------------
66
+
67
+ A CA_OBJECT cell is a VALUE, and a materialise writes those cells into a
68
+ buffer no Ruby object owns. Object-lane kernels call rb_funcall per cell,
69
+ so a collection can happen halfway through and free what has been written
70
+ so far. Hold the buffer while it is exposed like that, and after the
71
+ materialise until a Ruby object takes ownership of it.
72
+
73
+ The cells must already be valid VALUEs, so a fresh buffer is Qnil-filled
74
+ before it is held. ca_gc_hold_push returns the depth to hand back to
75
+ ca_gc_hold_pop_to, so nested holds unwind in order. */
76
+
77
+ int ca_gc_hold_push (void *ptr, ca_size_t n_elements);
78
+ void ca_gc_hold_pop_to (int depth);
79
+
64
80
  /* Non-zero iff the object is an element-wise lazy view (CAMonOp / CABinOp /
65
81
  CABinCmp / CAMonCmp / CALazyMarker). The streaming branch of the
66
82
  mkkernel-generated reduction kernels tests this to decide whether it can
@@ -111,10 +127,10 @@ VALUE rb_ca_fake_new (VALUE cary, int8_t data_type, ca_size_t bytes);
111
127
  CARepeat *ca_repeat_new (CArray *carray, int8_t ndim, ca_size_t *count);
112
128
  VALUE rb_ca_repeat_new (VALUE cary, int8_t ndim, ca_size_t *count);
113
129
 
114
- /* ca_obj_unbound_repeat.c */
115
- VALUE rb_ca_ubrep_new (VALUE cary, int32_t rep_ndim, ca_size_t *rep_dim);
116
-
117
130
  /* ca_obj_reduce.c */
118
131
  CAReduce *ca_reduce_new (CArray *carray, ca_size_t count, ca_size_t offset);
119
132
 
133
+ /* carray_broadcast.c */
134
+ void ca_broadcast_to_destination (VALUE dst, volatile VALUE *src);
135
+
120
136
  #endif /* CARRAY_INTERNAL_H */
@@ -34,6 +34,7 @@ static inline VALUE BOOL2VAL (boolean8_t x) { return x ? Qtrue : Qfalse; }
34
34
  #endif
35
35
 
36
36
  #include "ca_op_powi.h"
37
+ #include "ca_op_cmplx64.h"
37
38
 
38
39
  /* ===== bincmp feq ============================================ */
39
40