carray 2.0.1 → 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 (386) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +6 -25
  3. data/CHANGELOG.md +338 -0
  4. data/{NEWS.md → CHANGELOG.v1.md} +3 -0
  5. data/LICENSE +1 -1
  6. data/README.md +120 -36
  7. data/carray.gemspec +32 -30
  8. data/ext/ca_array_pool.c +91 -0
  9. data/ext/ca_axis_descriptor.h +186 -0
  10. data/ext/ca_axis_dispatch.c +924 -0
  11. data/ext/ca_axis_group.c +1244 -0
  12. data/ext/ca_bincmp_dispatch.c +76 -0
  13. data/ext/ca_bincmp_dispatch.h +85 -0
  14. data/ext/ca_binop_dispatch.c +124 -0
  15. data/ext/ca_binop_dispatch.h +152 -0
  16. data/ext/ca_categorical_iterator.c +1375 -0
  17. data/ext/ca_compare.c +94 -0
  18. data/ext/ca_compare.h +26 -0
  19. data/ext/ca_composite_dispatch.c +414 -0
  20. data/ext/ca_composite_dispatch.h +116 -0
  21. data/ext/ca_for_buffer.h +96 -0
  22. data/ext/ca_for_each_element.h +239 -0
  23. data/ext/ca_group_iter.c +304 -0
  24. data/ext/ca_iter_substrate.h +325 -0
  25. data/ext/ca_kernel_iterator.c +4367 -0
  26. data/ext/ca_kernel_iterator.h +2596 -0
  27. data/ext/ca_moncmp_dispatch.c +37 -0
  28. data/ext/ca_moncmp_dispatch.h +62 -0
  29. data/ext/ca_monop_dispatch.c +200 -0
  30. data/ext/ca_monop_dispatch.h +235 -0
  31. data/ext/ca_obj_array.c +355 -359
  32. data/ext/ca_obj_bincmp.c +839 -0
  33. data/ext/ca_obj_binop.c +948 -0
  34. data/ext/ca_obj_bitarray.c +369 -164
  35. data/ext/ca_obj_bitfield.c +294 -234
  36. data/ext/ca_obj_block.c +189 -711
  37. data/ext/ca_obj_byte_swap.c +766 -0
  38. data/ext/ca_obj_const_string.c +967 -0
  39. data/ext/ca_obj_face.c +750 -0
  40. data/ext/ca_obj_face.h +279 -0
  41. data/ext/ca_obj_fake.c +239 -100
  42. data/ext/ca_obj_farray.c +54 -441
  43. data/ext/ca_obj_field.c +82 -529
  44. data/ext/ca_obj_fixlen_string.c +308 -0
  45. data/ext/ca_obj_grid.c +866 -440
  46. data/ext/ca_obj_meld.c +1039 -0
  47. data/ext/ca_obj_moncmp.c +588 -0
  48. data/ext/ca_obj_monop.c +1123 -0
  49. data/ext/ca_obj_object.c +866 -296
  50. data/ext/ca_obj_record.c +470 -0
  51. data/ext/ca_obj_reduce.c +97 -82
  52. data/ext/ca_obj_refer.c +593 -459
  53. data/ext/ca_obj_remap.c +475 -0
  54. data/ext/ca_obj_repeat.c +92 -477
  55. data/ext/ca_obj_roll.c +624 -0
  56. data/ext/ca_obj_select.c +344 -296
  57. data/ext/ca_obj_select_axis.c +1306 -0
  58. data/ext/ca_obj_shift.c +231 -793
  59. data/ext/ca_obj_source.c +78 -0
  60. data/ext/ca_obj_stack.c +1173 -0
  61. data/ext/ca_obj_stride.c +2584 -0
  62. data/ext/ca_obj_string.c +270 -0
  63. data/ext/ca_obj_tile.c +622 -0
  64. data/ext/ca_obj_time.c +548 -0
  65. data/ext/ca_obj_timedelta.c +437 -0
  66. data/ext/ca_obj_transpose.c +62 -516
  67. data/ext/ca_obj_triop.c +785 -0
  68. data/ext/ca_obj_window.c +1202 -565
  69. data/ext/ca_op_byte_swap.c +175 -0
  70. data/ext/ca_op_cmplx64.h +123 -0
  71. data/ext/ca_op_ipower.c +316 -0
  72. data/ext/ca_op_powi.h +88 -0
  73. data/ext/ca_sort_kernels.h +132 -0
  74. data/ext/ca_sweep_engine.c +473 -0
  75. data/ext/ca_sweep_engine.h +166 -0
  76. data/ext/ca_transform_common.c +235 -0
  77. data/ext/ca_triop_dispatch.c +55 -0
  78. data/ext/ca_triop_dispatch.h +62 -0
  79. data/ext/carray.h +810 -420
  80. data/ext/carray_access.c +873 -731
  81. data/ext/carray_attribute.c +98 -329
  82. data/ext/carray_bincount.c +255 -0
  83. data/ext/carray_broadcast.c +376 -0
  84. data/ext/carray_build_flags.h +3 -0
  85. data/ext/carray_call_cfunc.c +2897 -874
  86. data/ext/carray_call_cfunc.h +313 -0
  87. data/ext/carray_cast.c +1264 -315
  88. data/ext/carray_cast_func.rb +81 -40
  89. data/ext/carray_class.c +53 -63
  90. data/ext/carray_config.h +28 -0
  91. data/ext/carray_conversion.c +350 -346
  92. data/ext/carray_copy.c +168 -270
  93. data/ext/carray_core.c +1396 -206
  94. data/ext/carray_count.c +312 -0
  95. data/ext/carray_data_type.c +43 -19
  96. data/ext/carray_element.c +585 -213
  97. data/ext/carray_factorize.c +2542 -0
  98. data/ext/carray_generate.c +230 -559
  99. data/ext/carray_histogram.c +490 -0
  100. data/ext/carray_hold.c +228 -0
  101. data/ext/carray_index_classifier.c +1021 -0
  102. data/ext/carray_index_classifier.h +27 -0
  103. data/ext/carray_internal.h +136 -0
  104. data/ext/carray_kernels_bincmp.c +4446 -0
  105. data/ext/carray_kernels_binop.c +11001 -0
  106. data/ext/carray_kernels_init.c +1131 -0
  107. data/ext/carray_kernels_map.c +3467 -0
  108. data/ext/carray_kernels_moncmp.c +2097 -0
  109. data/ext/carray_kernels_monop.c +18313 -0
  110. data/ext/carray_kernels_reduce_aggregate.c +25837 -0
  111. data/ext/carray_kernels_reduce_boolean.c +330 -0
  112. data/ext/carray_kernels_reduce_cumulative.c +14593 -0
  113. data/ext/carray_kernels_reduce_extreme.c +16948 -0
  114. data/ext/carray_kernels_reduce_variance.c +3910 -0
  115. data/ext/carray_kernels_scan.c +3693 -0
  116. data/ext/carray_kernels_search.c +32138 -0
  117. data/ext/carray_kernels_sort.c +10626 -0
  118. data/ext/carray_kernels_triop.c +1392 -0
  119. data/ext/carray_lazy.c +737 -0
  120. data/ext/carray_loop.c +88 -200
  121. data/ext/carray_mask.c +853 -158
  122. data/ext/carray_math_kernel.h +120 -0
  123. data/ext/carray_mathfunc.c +10 -241
  124. data/ext/carray_median_percentile.c +1257 -0
  125. data/ext/carray_memory_view.c +1650 -0
  126. data/ext/carray_operator.c +1525 -320
  127. data/ext/carray_order.c +664 -1394
  128. data/ext/carray_partition.c +416 -0
  129. data/ext/carray_random.c +518 -0
  130. data/ext/carray_scatter.c +357 -0
  131. data/ext/carray_slab.c +1219 -0
  132. data/ext/carray_slab.h +84 -0
  133. data/ext/carray_sort.c +829 -0
  134. data/ext/carray_sort_kernel.c +620 -0
  135. data/ext/carray_struct.c +695 -0
  136. data/ext/carray_test.c +343 -229
  137. data/ext/carray_undef.c +34 -17
  138. data/ext/carray_utils.c +175 -74
  139. data/ext/extconf.rb +234 -55
  140. data/ext/mk_call_cfunc.rb +671 -0
  141. data/ext/mkkernel.rb +9096 -0
  142. data/ext/ruby_carray.c +211 -108
  143. data/ext/version.h +4 -14
  144. data/ext/version.rb +5 -13
  145. data/lib/carray/arrow_tensor.rb +401 -0
  146. data/lib/carray/attribute.rb +166 -0
  147. data/lib/carray/autoload_carray.rb +239 -0
  148. data/lib/carray/autoload_method_extension.rb +45 -0
  149. data/lib/carray/axis_group.rb +711 -0
  150. data/lib/carray/basics.rb +481 -0
  151. data/lib/carray/bincount_nd.rb +358 -0
  152. data/lib/carray/block_iterator.rb +614 -0
  153. data/lib/carray/boolean_reduce.rb +109 -0
  154. data/lib/carray/categorical.rb +561 -0
  155. data/lib/carray/categorical_iterator.rb +1084 -0
  156. data/lib/carray/complex.rb +150 -0
  157. data/lib/carray/conditional.rb +216 -0
  158. data/lib/carray/const_string.rb +228 -0
  159. data/lib/carray/construct.rb +160 -328
  160. data/lib/carray/core_extensions.rb +297 -0
  161. data/lib/carray/data_type_extension.rb +250 -0
  162. data/lib/carray/fixlen_string.rb +95 -0
  163. data/lib/carray/frame/concat.rb +132 -0
  164. data/lib/carray/frame/convert.rb +95 -0
  165. data/lib/carray/frame/csv_parser.rb +211 -0
  166. data/lib/carray/frame/frame.rb +642 -0
  167. data/lib/carray/frame/group.rb +186 -0
  168. data/lib/carray/frame/io.rb +321 -0
  169. data/lib/carray/frame/join.rb +248 -0
  170. data/lib/carray/frame/records.rb +99 -0
  171. data/lib/carray/frame/sort.rb +113 -0
  172. data/lib/carray/frame/verbs.rb +316 -0
  173. data/lib/carray/frame.rb +16 -0
  174. data/lib/carray/fuse_source.rb +123 -0
  175. data/lib/carray/fusion.rb +218 -0
  176. data/lib/carray/histogram.rb +512 -0
  177. data/lib/carray/inspect.rb +37 -26
  178. data/lib/carray/iterator.rb +58 -349
  179. data/lib/carray/lazy.rb +941 -0
  180. data/lib/carray/mask_gap_fill.rb +200 -0
  181. data/lib/carray/math.rb +78 -342
  182. data/lib/carray/meld_reduce.rb +289 -0
  183. data/lib/carray/methods/align_addr.rb +116 -0
  184. data/lib/carray/methods/bin.rb +128 -0
  185. data/lib/carray/methods/bincount.rb +87 -0
  186. data/lib/carray/methods/bit_string.rb +92 -0
  187. data/lib/carray/methods/broadcast.rb +63 -0
  188. data/lib/carray/methods/choose.rb +39 -0
  189. data/lib/carray/methods/composition.rb +280 -0
  190. data/lib/carray/methods/gather_nd.rb +206 -0
  191. data/lib/carray/methods/index.rb +39 -0
  192. data/lib/carray/methods/insert_block.rb +99 -0
  193. data/lib/carray/methods/is_in.rb +141 -0
  194. data/lib/carray/methods/join.rb +90 -0
  195. data/lib/carray/methods/locate_addr.rb +52 -0
  196. data/lib/carray/methods/mask_duplicates.rb +41 -0
  197. data/lib/carray/methods/meshgrid.rb +90 -0
  198. data/lib/carray/methods/mode.rb +126 -0
  199. data/lib/carray/methods/nunique.rb +46 -0
  200. data/lib/carray/methods/resize.rb +56 -0
  201. data/lib/carray/methods/snap.rb +161 -0
  202. data/lib/carray/methods/string_format.rb +57 -0
  203. data/lib/carray/methods/unique.rb +47 -0
  204. data/lib/carray/methods/value_counts.rb +71 -0
  205. data/lib/carray/mkmf.rb +124 -101
  206. data/lib/carray/runtime.rb +89 -0
  207. data/lib/carray/serialize.rb +478 -167
  208. data/lib/carray/slab_iterator.rb +305 -0
  209. data/lib/carray/stack.rb +291 -0
  210. data/lib/carray/string.rb +56 -180
  211. data/lib/carray/string_operation_extension.rb +289 -0
  212. data/lib/carray/struct.rb +335 -323
  213. data/lib/carray/struct_builder.rb +697 -0
  214. data/lib/carray/table.rb +41 -2
  215. data/lib/carray/time.rb +2654 -38
  216. data/lib/carray/window_iterator.rb +927 -0
  217. data/lib/carray.rb +55 -57
  218. data/yard-stubs/ca_obj_array.rb +385 -0
  219. data/yard-stubs/ca_obj_bitarray.rb +38 -0
  220. data/yard-stubs/ca_obj_bitfield.rb +43 -0
  221. data/yard-stubs/ca_obj_block.rb +73 -0
  222. data/yard-stubs/ca_obj_byte_swap.rb +56 -0
  223. data/yard-stubs/ca_obj_fake.rb +31 -0
  224. data/yard-stubs/ca_obj_farray.rb +32 -0
  225. data/yard-stubs/ca_obj_field.rb +45 -0
  226. data/yard-stubs/ca_obj_grid.rb +35 -0
  227. data/yard-stubs/ca_obj_refer.rb +72 -0
  228. data/yard-stubs/ca_obj_roll.rb +45 -0
  229. data/yard-stubs/ca_obj_shift.rb +43 -0
  230. data/yard-stubs/ca_obj_stride.rb +181 -0
  231. data/yard-stubs/ca_obj_tile.rb +29 -0
  232. data/yard-stubs/ca_obj_transpose.rb +40 -0
  233. data/yard-stubs/ca_obj_window.rb +49 -0
  234. data/yard-stubs/carray_access.rb +131 -0
  235. data/yard-stubs/carray_attribute.rb +246 -0
  236. data/yard-stubs/carray_broadcast.rb +37 -0
  237. data/yard-stubs/carray_cast.rb +489 -0
  238. data/yard-stubs/carray_class.rb +65 -0
  239. data/yard-stubs/carray_conversion.rb +76 -0
  240. data/yard-stubs/carray_copy.rb +79 -0
  241. data/yard-stubs/carray_core.rb +114 -0
  242. data/yard-stubs/carray_count.rb +79 -0
  243. data/yard-stubs/carray_element.rb +108 -0
  244. data/yard-stubs/carray_generate.rb +66 -0
  245. data/yard-stubs/carray_lazy.rb +23 -0
  246. data/yard-stubs/carray_loop.rb +140 -0
  247. data/yard-stubs/carray_mask.rb +259 -0
  248. data/yard-stubs/carray_math.rb +132 -0
  249. data/yard-stubs/carray_mathfunc.rb +45 -0
  250. data/yard-stubs/carray_median_percentile.rb +89 -0
  251. data/yard-stubs/carray_memory_view.rb +163 -0
  252. data/yard-stubs/carray_order.rb +312 -0
  253. data/yard-stubs/carray_random.rb +89 -0
  254. data/yard-stubs/carray_scatter.rb +106 -0
  255. data/yard-stubs/carray_slab.rb +57 -0
  256. data/yard-stubs/carray_sort.rb +163 -0
  257. data/yard-stubs/carray_test.rb +85 -0
  258. data/yard-stubs/carray_undef.rb +64 -0
  259. data/yard-stubs/carray_utils.rb +97 -0
  260. data/yard-stubs/ruby_carray.rb +193 -0
  261. metadata +220 -138
  262. data/Rakefile +0 -51
  263. data/TODO.md +0 -18
  264. data/ext/ca_iter_block.c +0 -257
  265. data/ext/ca_iter_dimension.c +0 -299
  266. data/ext/ca_iter_window.c +0 -214
  267. data/ext/ca_obj_mapping.c +0 -644
  268. data/ext/ca_obj_unbound_repeat.c +0 -529
  269. data/ext/carray_iterator.c +0 -641
  270. data/ext/carray_math.rb +0 -850
  271. data/ext/carray_numeric.c +0 -259
  272. data/ext/carray_sort_addr.c +0 -254
  273. data/ext/carray_stat.c +0 -2100
  274. data/ext/carray_stat_proc.rb +0 -1999
  275. data/ext/mkmath.rb +0 -741
  276. data/ext/ruby_ccomplex.c +0 -509
  277. data/ext/ruby_float_func.c +0 -86
  278. data/lib/carray/array.rb +0 -8
  279. data/lib/carray/autoload/autoload_base.rb +0 -19
  280. data/lib/carray/autoload/autoload_gem_cairo.rb +0 -9
  281. data/lib/carray/autoload/autoload_gem_ffi.rb +0 -9
  282. data/lib/carray/autoload/autoload_gem_gnuplot.rb +0 -2
  283. data/lib/carray/autoload/autoload_gem_io_csv.rb +0 -14
  284. data/lib/carray/autoload/autoload_gem_io_pg.rb +0 -6
  285. data/lib/carray/autoload/autoload_gem_io_sqlite3.rb +0 -12
  286. data/lib/carray/autoload/autoload_gem_narray.rb +0 -10
  287. data/lib/carray/autoload/autoload_gem_numo_narray.rb +0 -15
  288. data/lib/carray/autoload/autoload_gem_opencv.rb +0 -16
  289. data/lib/carray/autoload/autoload_gem_random.rb +0 -8
  290. data/lib/carray/autoload/autoload_gem_rmagick.rb +0 -23
  291. data/lib/carray/autoload/autoload_gem_zimg.rb +0 -3
  292. data/lib/carray/autoload/autoload_io_imagemagick.rb +0 -6
  293. data/lib/carray/autoload/autoload_math_histogram.rb +0 -5
  294. data/lib/carray/autoload/autoload_math_recurrence.rb +0 -6
  295. data/lib/carray/autoload/autoload_object_iterator.rb +0 -1
  296. data/lib/carray/autoload/autoload_object_link.rb +0 -1
  297. data/lib/carray/autoload/autoload_object_pack.rb +0 -2
  298. data/lib/carray/autoload.rb +0 -141
  299. data/lib/carray/basic.rb +0 -191
  300. data/lib/carray/broadcast.rb +0 -101
  301. data/lib/carray/compose.rb +0 -315
  302. data/lib/carray/convert.rb +0 -115
  303. data/lib/carray/info.rb +0 -110
  304. data/lib/carray/io/imagemagick.rb +0 -235
  305. data/lib/carray/mask.rb +0 -102
  306. data/lib/carray/math/histogram.rb +0 -177
  307. data/lib/carray/math/recurrence.rb +0 -93
  308. data/lib/carray/object/ca_obj_iterator.rb +0 -50
  309. data/lib/carray/object/ca_obj_link.rb +0 -50
  310. data/lib/carray/object/ca_obj_pack.rb +0 -99
  311. data/lib/carray/obsolete.rb +0 -256
  312. data/lib/carray/ordering.rb +0 -181
  313. data/lib/carray/testing.rb +0 -51
  314. data/lib/carray/transform.rb +0 -109
  315. data/mailmap +0 -1
  316. data/misc/Methods.ja.md +0 -182
  317. data/misc/NOTE +0 -51
  318. data/spec/Classes/CABitfield_spec.rb +0 -58
  319. data/spec/Classes/CABlockIterator_spec.rb +0 -114
  320. data/spec/Classes/CABlock_spec.rb +0 -205
  321. data/spec/Classes/CAField_spec.rb +0 -39
  322. data/spec/Classes/CAGrid_spec.rb +0 -75
  323. data/spec/Classes/CAMap_spec.rb +0 -0
  324. data/spec/Classes/CAMapping_spec.rb +0 -105
  325. data/spec/Classes/CAObject_attribute_spec.rb +0 -33
  326. data/spec/Classes/CAObject_spec.rb +0 -33
  327. data/spec/Classes/CARefer_spec.rb +0 -93
  328. data/spec/Classes/CARepeat_spec.rb +0 -65
  329. data/spec/Classes/CASelect_spec.rb +0 -22
  330. data/spec/Classes/CAShift_spec.rb +0 -16
  331. data/spec/Classes/CAStruct_spec.rb +0 -71
  332. data/spec/Classes/CATranspose_spec.rb +0 -60
  333. data/spec/Classes/CAUnboudRepeat_spec.rb +0 -102
  334. data/spec/Classes/CAWindow_spec.rb +0 -54
  335. data/spec/Classes/CAWrap_spec.rb +0 -8
  336. data/spec/Classes/CArray_spec.rb +0 -184
  337. data/spec/Classes/CScalar_spec.rb +0 -55
  338. data/spec/Features/feature_130_spec.rb +0 -19
  339. data/spec/Features/feature_attributes_spec.rb +0 -280
  340. data/spec/Features/feature_boolean_spec.rb +0 -98
  341. data/spec/Features/feature_broadcast.rb +0 -116
  342. data/spec/Features/feature_cast_function.rb +0 -19
  343. data/spec/Features/feature_cast_spec.rb +0 -33
  344. data/spec/Features/feature_class_spec.rb +0 -84
  345. data/spec/Features/feature_complex_spec.rb +0 -42
  346. data/spec/Features/feature_composite_spec.rb +0 -124
  347. data/spec/Features/feature_convert_spec.rb +0 -46
  348. data/spec/Features/feature_copy_spec.rb +0 -123
  349. data/spec/Features/feature_creation_spec.rb +0 -84
  350. data/spec/Features/feature_element_spec.rb +0 -144
  351. data/spec/Features/feature_extream_spec.rb +0 -54
  352. data/spec/Features/feature_generate_spec.rb +0 -74
  353. data/spec/Features/feature_index_spec.rb +0 -69
  354. data/spec/Features/feature_mask_spec.rb +0 -580
  355. data/spec/Features/feature_math_spec.rb +0 -97
  356. data/spec/Features/feature_order_spec.rb +0 -146
  357. data/spec/Features/feature_ref_store_spec.rb +0 -209
  358. data/spec/Features/feature_serialization_spec.rb +0 -125
  359. data/spec/Features/feature_stat_spec.rb +0 -397
  360. data/spec/Features/feature_virtual_spec.rb +0 -48
  361. data/spec/Features/method_eq_spec.rb +0 -81
  362. data/spec/Features/method_is_nan_spec.rb +0 -12
  363. data/spec/Features/method_map_spec.rb +0 -54
  364. data/spec/Features/method_max_with.rb +0 -20
  365. data/spec/Features/method_min_with.rb +0 -19
  366. data/spec/Features/method_ne_spec.rb +0 -18
  367. data/spec/Features/method_project_spec.rb +0 -188
  368. data/spec/Features/method_ref_spec.rb +0 -27
  369. data/spec/Features/method_round_spec.rb +0 -11
  370. data/spec/Features/method_s_linspace_spec.rb +0 -48
  371. data/spec/Features/method_s_span_spec.rb +0 -14
  372. data/spec/Features/method_seq_spec.rb +0 -47
  373. data/spec/Features/method_sort_with.rb +0 -43
  374. data/spec/Features/method_sorted_with.rb +0 -29
  375. data/spec/Features/method_span_spec.rb +0 -42
  376. data/spec/Features/method_wrap_readonly_spec.rb +0 -43
  377. data/spec/UnitTest/test_CAVirtual.rb +0 -214
  378. data/spec/spec_all.rb +0 -10
  379. data/utils/ca_ase.rb +0 -21
  380. data/utils/ca_methods.rb +0 -15
  381. data/utils/cast_checker.rb +0 -30
  382. data/utils/convert_test.rb +0 -73
  383. data/utils/extract_yard.rb +0 -22
  384. data/utils/guess_shape.rb +0 -76
  385. data/utils/monkey_patch_methods.rb +0 -62
  386. data/utils/remove_resource_fork.sh +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7f462cc0db93ae6cbe718b64ba1761c4f1aab048835566be238d1f958328c92
4
- data.tar.gz: 46289071d0a636d9025de050abeecd1e57223b28dc54bf1acef0e578df3365ce
3
+ metadata.gz: 3fd3c3099973bb94e29628f609cf27b65ccd9f318a5a707273fd86586e89e9a2
4
+ data.tar.gz: c9a01c64bc228fd8c4e92d2ef01043678608fa31f68a2a357f3ace5bf9f8b7af
5
5
  SHA512:
6
- metadata.gz: f36a13c5ae4a15f264577301683bf03fbc8367f017da1ec39831fe9d8b7161ec0f2721a16909a6d166ca6c784f8062a352f9b1b9f4b4e8135071de27c112579b
7
- data.tar.gz: 9cc760bcdb5c9108c7c341b9dd98e12330cf8931cd8ef28d09e603cab984959b287ee9d9e0dc0cb5673e1ad53bd9343ea0e2cf88647ebb81b6b9b557214e9914
6
+ metadata.gz: 84056c479f21558ffac49f051d4efdd6d34f4e7fa18218f097ab7ecabc3a7791782060358605c26265a90928ae2911253e5f6f6ca31acd3b70f3e069b5001bf5
7
+ data.tar.gz: a20917afb47f7c2ed0e3968678bd834680f41ceacf05d2c3771729d381ba7cb9a93c8e89aeca9f609a5811b9168b33fc446c1bd0cedc28c590c65eb02b070e2d
data/.yardopts CHANGED
@@ -1,32 +1,13 @@
1
1
  --markup markdown
2
+ --output-dir .yard-html
2
3
  --markup-provider redcarpet
3
4
  --no-private
4
5
  --exclude lib/carray/obsolete.rb
5
6
  --exclude lib/carray/autoload.rb
6
7
  --exclude 'lib/carray/autoload/'
7
8
  --readme README.md
8
- --files NEWS.md,TODO.md
9
- lib/carray.rb
10
- ext/ruby_carray.c
11
- ext/ca_obj_array.c
12
- ext/ca_obj_bitarray.c
13
- ext/ca_obj_bitfield.c
14
- ext/ca_obj_block.c
15
- ext/carray_attribute.c
16
- ext/carray_call_cfunc.c
17
- ext/carray_cast.c
18
- ext/carray_class.c
19
- ext/carray_conversion.c
20
- ext/carray_copy.c
21
- ext/carray_core.c
22
- ext/carray_data_type.c
23
- ext/carray_element.c
24
- ext/carray_generate.c
25
- ext/carray_loop.c
26
- ext/carray_mask.c
27
- ext/carray_operator.c
28
- ext/carray_order.c
29
- ext/carray_sort_addr.c
30
- ext/carray_test.c
31
- ext/carray_utils.c
32
-
9
+ --files CHANGELOG.md,CHANGELOG.v1.md
10
+ lib/carray.rb
11
+ lib/carray/**/*.rb
12
+ yard-stubs/**/*.rb
13
+ ext/carray_operator.c
data/CHANGELOG.md ADDED
@@ -0,0 +1,338 @@
1
+ # Changelog
2
+
3
+ Releases from 3.0.0 onward are recorded here. There is no separate NEWS
4
+ file: this is where to look for what changed between the version you have
5
+ and a newer one. The 1.x history, up to the 2.0.0 release, is in
6
+ [CHANGELOG.v1.md](CHANGELOG.v1.md); 2.0.1 went unrecorded.
7
+
8
+ <!-- Newest first, at both levels: a new release section goes above the
9
+ ones below it, and a new entry goes directly under its own release
10
+ heading -- not at the end of the section. The kind of change is
11
+ carried by the `- Fix:` / `- Change:` / `- New:` that opens the
12
+ entry; there are no per-kind subheadings.
13
+
14
+ A section is written newest-first while the release is open, and
15
+ sorted into New, Change, Fix when it closes -- in the same commit
16
+ that drops `(unreleased)`. Within Change, the ones that ask the
17
+ reader to change code come first. It is a reading order rather than
18
+ a classification: where it is not obvious, either place will do.
19
+
20
+ An entry says three things and stops: what changed, what to do about
21
+ it (the migration, the replacement, the condition under which nothing
22
+ changes), and what is excluded. It does not say how the code was
23
+ broken, name the internals that were fixed, break down where the
24
+ speed came from, or argue the design -- those belong in the commit
25
+ message. Two to six lines.
26
+
27
+ It is written for someone using the library, not someone working on
28
+ it: with no NEWS file, this is what a reader consults before
29
+ upgrading. An entry naming something only a C extension touches says
30
+ so in its opening words.
31
+
32
+ Every entry has to read on its own. Entries are looked at one at a
33
+ time and move about within a section, so none may lean on a
34
+ neighbour ("as well", "the producer above") or leave unnamed the
35
+ method, class or keyword it is about. -->
36
+
37
+ ## 3.0.1
38
+
39
+ - New: `CArray.jit_for`, `CArray.jit_each` and `CArray.jit_map` name a block
40
+ that is compiled rather than run. Compiling needs the carray-jit gem;
41
+ without it they raise `NotImplementedError`. An expression over whole
42
+ arrays wants `CArray.fuse`, which needs no compiler.
43
+
44
+ - New: every iterator answers `accumulate` beside `sum`; some of them did not.
45
+ It is the same fold kept in the source's own data type, where `sum` answers
46
+ in the type the core promotes to -- a window or tile count over `uint8` cells
47
+ stays one byte wide.
48
+
49
+ - New: `CArray::CoreExtensions` adds postfix math on `Complex`, so `a[0].tanh`
50
+ reads the way `a.tanh` does. It covers the seventeen functions a complex
51
+ array supports and agrees with the array form exactly, branch cuts and the
52
+ sign of a zero included. Opt in with `using CArray::CoreExtensions`.
53
+
54
+ - New: `ca_is_stride_family(ca)` in `carray.h`, for a C extension that folds a
55
+ view into `root->ptr + base + sum(idx[k] * strides[k])` itself. True for
56
+ CAStride, CARefer, CABlock, CARepeat, CATranspose, CAFarray and CAField and
57
+ the mask array of each, and for an externally installed view that shares
58
+ their operation table.
59
+
60
+ - New: `divmod` returns `[quotient, remainder]` element-wise with the quotient
61
+ floored, the pair Ruby's `Integer#divmod` and `Float#divmod` return. The
62
+ quotient keeps the receiver's data type.
63
+
64
+ - New: two optional CAObject callbacks take a partial fill as a region instead
65
+ of one `store_addr` per cell: `fill_block(starts, counts, steps, val)` for a
66
+ forward per-axis sub-region, `fill_addrs(addrs, val)` otherwise. Defining
67
+ neither keeps the old behaviour. Filling a 1000x1000 region of a 2000x2000
68
+ CAObject: 116 ms to 0.6 ms.
69
+
70
+ - New: `CAFrame#to_table` renders the frame as an aligned text table, and
71
+ `inspect` / `to_s` sit on it: `p df` summarises the first 8 and last 2 rows,
72
+ `puts df` prints the whole frame. `rows:` caps the printed rows, `precision:`
73
+ rounds float cells for display (default 6), masked cells show as `_`.
74
+
75
+ - New: `CAFrame#to_time` takes a `CATime::Grid`, positionally or as `unit:`, so
76
+ a netCDF `units` attribute goes in whole. The grid also carries an epoch phase
77
+ the `unit:` / `epoch:` pair cannot -- that pair reads the epoch on the coarse
78
+ grid and loses the time of day. The keyword form is unchanged.
79
+
80
+ - New: `CATime::Grid` packages the `(unit:, origin:)` pair that `#timesteps`,
81
+ `#snap` and `.from_timesteps` take, so it is built once and passed as one
82
+ value: `t.snap(g, direction: :floor)`, `t.timesteps(g)`, `g.at(k)`. It parses
83
+ and prints the udunits `"<unit> since <instant>"` form, holding a phased
84
+ origin that the keyword pair cannot (`"12 hours since 2017-11-30 09:00"`).
85
+ `CATime#grid` is the grid an array is stored on. Storage is unchanged.
86
+
87
+ - New: `CATime#snap(grid, direction:)` rounds to a tick grid, the shape
88
+ `CArray#snap` has for numbers. `#floor` / `#ceil` / `#round` are its
89
+ fixed-direction forms; their results and keyword forms are unchanged.
90
+
91
+ - New: a time element is taken directly as a start or origin literal, so a
92
+ `floor` / `ceil` / `to_unit` answer feeds back into `CArray.time`,
93
+ `time_range`, `time_series`, `CArray#time` and an `origin:`; it used to have
94
+ to go out through `DateTime` and be re-parsed. A `:M` or `:Y` element names
95
+ the first midnight of its granule. What an origin must satisfy is unchanged.
96
+
97
+ - New: `CArray.time` parses a year-month (`"2019-09"`) and a bare year
98
+ (`"2019"`), so the form a `:M` / `:Y` element prints reads back in. A
99
+ missing finer field names the head of that period.
100
+
101
+ - Change: `abs`, `abs2` and `arg` on a `cmplx64` array now return `float32`
102
+ instead of `float64` -- the width that type carries its real values in, the
103
+ same one `real` and `imag` already returned. `arg` on a `float32` array
104
+ likewise returns `float32` rather than widening. `cmplx128` and `float64`
105
+ are unchanged, and `arg` on an integer array still gives `float64`. To keep
106
+ the old width, add `.to_type(:float64)`.
107
+
108
+ - Change: `CArray.fuse` takes the expression rather than the arrays it is
109
+ over -- `CArray.fuse { (a + b) * c }` in place of
110
+ `CArray.fuse(a, b, c) { |x, y, z| (x + y) * z }`. What comes back is the
111
+ expression, so `x = CArray.fuse { ... }` now wants `.to_ca` for an array.
112
+ Where the block's source cannot be read -- an `irb` prompt, inside `eval` --
113
+ write `a.lazy + b.lazy`. `CArray.lazy(*args) { ... }` is gone.
114
+
115
+ - Change: a lazy expression (`a.lazy + b`, `CArray.fuse`) builds its mask when
116
+ something reads it, rather than when the expression is built. A mask set on
117
+ either operand after the expression was built is now seen; before, only the
118
+ left one was. `root_array` and `ancestors` now stop at a lazy operation
119
+ instead of walking into its left operand. Building a long masked expression
120
+ is also no longer quadratic in the length of the chain.
121
+
122
+ - Change: the top-level constant `CA_NIL` is now `CArray::UNSPECIFIED`
123
+ (`CA_UNSPECIFIED` in C). It is an internal sentinel for "the caller gave no
124
+ argument", not a value to pass in; `unmask`, `shift(fill_value:)` and
125
+ `window(fill_value:)` behave as before.
126
+
127
+ - Change: `group_by_category` reductions answer in the data type the core
128
+ reduction promotes the value to, instead of one chosen per reduction. `sum`
129
+ on an integer value now answers in float64 (`accumulate` is the spelling
130
+ that stays in the value's type), and `mean`, `variance` and `median` on an
131
+ object value stay exact. `sum` on a boolean value and `prod` or `mean` on a
132
+ complex one, which raised, now work.
133
+
134
+ - Change: the `:*` unbound repeat is retired. `a[:*, nil]` raises `IndexError`;
135
+ `CArray#unbound_repeat`, `CAUnboundRepeat` and `insert_axis(repeat: :*)` are
136
+ gone. Use `:_`, which gives the same shape and now stretches on a store as
137
+ well as in an operation. `CArray#broadcast_to` and
138
+ `CArray.meshgrid(sparse: true)` are unaffected.
139
+
140
+ - Change: a binary operation requires shapes to agree, or to differ only in
141
+ size-1 axes at equal ndim. `(3,2) + (2,3)` and `(3,2) + (6)` raise
142
+ `ArgumentError` where they used to answer in one operand's shape; flatten
143
+ both sides to combine the values in the order they lie. Comparisons, `fma`
144
+ and the lazy forms follow the same rule. Scalars are unaffected, but a
145
+ one-element 1-D array such as `CArray.int32(1)` counts as a shape.
146
+
147
+ - Change: an assignment requires the shapes to match. `t[] = src` with a
148
+ differently shaped source raises `RuntimeError`; use `src.flatten`. In
149
+ exchange a smaller source is repeated to fit, so `t[] = row[:_, nil, nil]`
150
+ and `t[] = col` (shape `(n,1)`) work where they used to raise. A 1-D side on
151
+ either end still passes, as do shapes differing only in size-1 axes; Ruby
152
+ Arrays and scalars are unchanged.
153
+
154
+ - Change: `to_ca` on a view derived from a lazy marker returns a new entity
155
+ rather than the view itself -- `a.lazy.shift(1, 0).to_ca`, inside a `fuse`
156
+ block or not. `copy` behaves as before.
157
+
158
+ - Change: `/` and `%` follow Ruby instead of C. Integer division floors and the
159
+ remainder carries the sign of the divisor; float `%` floors too, float `/` is
160
+ unchanged. For the old behaviour use `fmod`, which now takes integers as well
161
+ as floats.
162
+
163
+ - Change: `reminder` is removed -- it was IEEE 754 remainder on floats but C `%`
164
+ on integers. Use `fmod` for the truncated remainder. The IEEE form has no
165
+ replacement.
166
+
167
+ - Change: the result-type override of `CArray#conditional` and
168
+ `CArray.select` is now `data_type:`, spelled the way the rest of the
169
+ library spells it. There is no alias: `dtype:` raises `unknown keyword`.
170
+
171
+ - Change: a calendar-grid `origin:` given to the bucket-grid methods of a
172
+ `CATime` array -- `timesteps`, `snap`, `floor`, `ceil`, `round`,
173
+ `is_righttime` -- now has to be a month head (the 1st at 00:00); it used to
174
+ drop the day and time silently. A `:Y` tick likewise has to start in
175
+ January. `from_timesteps` already refused an off-grid origin.
176
+
177
+ - Change: the MemoryView producer emits the format vocabulary
178
+ `ruby/memory_view.h` specifies rather than PEP 3118's, so below 32 bits it
179
+ writes `c` / `C` / `s` / `S` in place of `b` / `B` / `h` / `H`. From 32 bits
180
+ up the two already agreed, and `?`, `Zf` / `Zd`, `T{...}` and `Ns` stay PEP
181
+ 3118, which Ruby has no spelling for. The consumer side already accepted
182
+ both, so views produced by 3.0.0 still import.
183
+
184
+ - Change: multiplying and dividing a `cmplx64` array (`*`, `/`, `rcp`,
185
+ `rcp_mul`) is computed in double and rounded once, so both are correctly
186
+ rounded; the old route could be off by about 1800 units in the last place.
187
+ A product that overflows a float but not a double no longer comes back NaN.
188
+ Division is 4.2-5.3x faster and multiplication 1.3x slower. `+`, `-` and
189
+ every `cmplx128` operation are unchanged.
190
+
191
+ - Change: element-wise math on a `float32` or `cmplx64` array is computed at
192
+ that width rather than widened and rounded back, so `sqrt`, `exp`, `log`,
193
+ the trigonometric and hyperbolic families, `atan2`, `hypot`, `abs` and `arg`
194
+ are 1.1-3.5x faster there and can move by a bit or two in the last place.
195
+ Complex `log`, `power`, `exp2` and `exp10` are unchanged, as are the
196
+ rounding, min / max, comparison and variance families and the wider types.
197
+
198
+ - Change: a rolling `sum`, `mean`, `prod`, `min`, `max`, `all` or `any` --
199
+ `a.windows(-1..1).sum` and the like -- over a window up to five cells wide on
200
+ every axis is 2-5x faster, and 1.3-4x over a masked source; `min_count:` and
201
+ `fill_value:` come along. `min`, `max` and `prod` answer exactly as before;
202
+ `sum` and `mean` may differ in the last bits. A wider window, or any other
203
+ reduction, is unchanged.
204
+
205
+ - Change: `CATime#to_unit` floors to a coarser grid instead of raising, and
206
+ crosses the calendar / fixed-length boundary (`:M` <-> `:D`) through
207
+ civil-date algebra. `:Y` / `:M` -> `:W` still raises.
208
+
209
+ - Change: `CATimedelta#to_unit` truncates toward zero instead of raising on a
210
+ coarser target. Crossing the calendar boundary still raises.
211
+
212
+ - Fix: `nextafter` on a `float32` array returned its own input. The step was
213
+ taken in double, and the next double above a float rounds back to that same
214
+ float. It now steps by one float32 ulp.
215
+
216
+ - Fix: a lazy expression over an object array (`CArray.object`,
217
+ `CA_OBJECT`) returned wrong values, and crashed when materialised
218
+ repeatedly. Affects `to_ca` and `copy` on a lazy view, an eager operation
219
+ with a lazy operand, and a reduction over one. Other data types were never
220
+ affected.
221
+
222
+ - Fix: reading a concatenated view (`CArray.concat`, `CAFrame.concat`)
223
+ backwards along the concatenated axis -- `m.reverse` and any other negative
224
+ step -- raised IndexError instead of answering.
225
+
226
+ - Fix: reading a lazy expression (`a.lazy + b`, `CArray.fuse`) with a step
227
+ other than one -- `expr[[0, 3, 2]]`, `expr.reverse` and the like -- returned
228
+ values the expression cannot produce, because its operands were read from
229
+ the wrong cells. Comparisons carried the same fault, `a.lazy > b` and
230
+ one-operand ones such as `a.lazy.is_nan` alike. Contiguous reads were never
231
+ affected.
232
+
233
+ - Fix: `a.value + b` raised `can not create mask array for the value array`
234
+ when `b` carried a mask. It now propagates `b`'s mask.
235
+
236
+ - Fix: a rolling window that does not cover the cell it is centred on --
237
+ `windows(1..2)`, the two cells after this one -- was read as if it started at
238
+ the array's edge, so every answer came out shifted by the range's start, and
239
+ `bounds: :truncate` produced anchors whose window did not fit. `windows(1..2)`
240
+ on `[1..8]` now sums to `[5, 7, 9, 11, 13, 15, 8, 0]`. A window that covers
241
+ its anchor, which is every centred one, is unaffected.
242
+
243
+ - Fix: storing a `Complex` into a `cmplx64` or `cmplx128` array kept the sign
244
+ of a negative zero real part only when the imaginary part was also negative,
245
+ so `Complex(-0.0, 0.0)` came back as `0.0+0.0i`. The sign of a zero picks the
246
+ side of a branch cut, so a value stored this way could be carried to the
247
+ wrong branch. All four sign combinations now round-trip, through element
248
+ assignment and through `to_type`.
249
+
250
+ - Fix: `sinh`, `cosh`, `tanh`, `asinh`, `acosh` and `atanh` on a complex array
251
+ gave the hyperbolic function of the real part alone: `cmplx128` and
252
+ `cmplx64` arrays came back with `tanh(Re z)` where `ctanh(z)` was meant,
253
+ wrong in both parts, and `acosh` and `atanh` also returned 0 or infinity
254
+ where the true value is finite. They now agree with C99 `complex.h`. Real
255
+ and object arrays were never affected.
256
+
257
+ - Fix: a C extension reading a view in column-major order -- axes and steps
258
+ reversed against the view's own -- got wrong values from a view with a
259
+ length-1 axis, such as `v[nil, :_]`, `v.reshape(n, 1)` or a one-column slice:
260
+ the first cell repeated, a read out of bounds, or a hang.
261
+ `carray-linalg-accelerate`'s `solve(a, b)` returned `b[0]` repeated for a
262
+ single-column right-hand side.
263
+
264
+ - Fix: an operation between two views of an array that computes its values --
265
+ a lazy expression such as `(a.lazy + b)`, or a `CAObject` over a file -- no
266
+ longer reads that source one cell at a time. `+`, `fma` and comparisons on
267
+ such a pair now run at the speed of copying each operand first, so the
268
+ `.copy` that worked around it is no longer needed. Single-operand
269
+ operations, copies, region transfers and reductions were already unaffected.
270
+
271
+ - Fix: views built inside a `CArray.fuse` block stay part of the expression
272
+ instead of dropping out of it, so a stencil written the natural way is fused.
273
+ `[]`, `shift`, `roll`, `flip`/`reverse`, `transpose`/`T`, `reshape`,
274
+ `flatten`, `window`, `diagonal`, `tile` and `refer` keep the chain;
275
+ `unbound_repeat` and `[:*, ...]` deliberately do not.
276
+
277
+ - Fix: a window or shift over a view parent no longer copies that parent in
278
+ full on every transfer. `a[nil, nil].shift(1, 0)` and friends now read at
279
+ parity with an entity parent and write several times faster.
280
+
281
+ - Fix: reductions over a bare `.lazy` marker no longer raise. Per-axis forms
282
+ and anything over a masked array failed, so `a.lazy.sum(axis: 0)` raised
283
+ while `a.lazy.sum` worked.
284
+
285
+ - Fix: `ca_test_flag` / `ca_set_flag` / `ca_unset_flag` in `carray.h`, which
286
+ only a C extension calls, did not parenthesise their flag argument, so
287
+ testing two flags at once was true for every array.
288
+
289
+ - Fix: a Face no longer hands back its storage bytes through the type casts.
290
+ `as_type`, `fake` and `CArray.wrap_writable` raise; `CArray.wrap_readonly`
291
+ converts as `to_type` does, which also makes `t.eq(o)` and `o.eq(t)` agree.
292
+ Reach the storage explicitly with `t.parent.fake(...)`. Numeric Faces are
293
+ unaffected.
294
+
295
+ - Fix: `arange` raised `NoMethodError` in every form; it builds the array now.
296
+ Integer arguments count exactly, so a step dividing the span evenly no longer
297
+ picks up an extra element. A zero step or a wrong argument count raises
298
+ `ArgumentError`.
299
+
300
+ - Fix: `from_timesteps` on a week grid answered Thursdays. The week grid counts
301
+ from the epoch, which is one, so it cannot hold an ISO Monday head; a week
302
+ bucket now answers on the day grid and round-trips against `floor` cell for
303
+ cell. A day-or-finer array keeps the Monday default, a week-stored array its
304
+ own epoch-anchored ticks.
305
+
306
+ - Fix: a masked cell decided whether a `CATime` conversion fit. The range
307
+ guards took their extremes with the mask stripped, so `to_unit` raised
308
+ `RangeError` over a wide value that was masked out. They now answer UNDEF
309
+ when there is nothing to bound -- an empty array, or every cell masked.
310
+
311
+ - Fix: `CATimedelta::Element#/` floored a negative duration, so `-30h / 4`
312
+ answered `-8h` where the array form answered `-7h`. A duration is a
313
+ magnitude, so it shrinks toward zero, matching the array form in all four
314
+ sign combinations.
315
+
316
+ - Fix: `CArray.time` no longer rolls a field that is out of range over into
317
+ another date. `"2019-02-31"` parsed to 2019-03-03, and `"201909"` -- a valid
318
+ YYMMDD to Ruby, 2020-19-09 -- to 2021-07; both now raise.
319
+
320
+ - Fix: `CATime#to_unit` and `CATimedelta#to_unit` were wrong between two
321
+ resolutions where neither tick is a whole multiple of the other: converting
322
+ 3 hours to a `"90 minutes"` grid gave 1 unit rather than 2.
323
+
324
+ - Fix: importing a MemoryView whose mask is published as `C` or `c` no longer
325
+ fails. The check knew only PEP 3118's `B`, `b` and `?`, so a producer that
326
+ spells a byte in Ruby's format vocabulary was refused.
327
+
328
+ ## 3.0.0
329
+
330
+ First public release. Earlier versions existed on RubyGems, but the library
331
+ was developed for the author's own use; 3.0 is where it is packaged,
332
+ documented and tested as something other people can pick up. It is not
333
+ source-compatible with 2.0.1.
334
+
335
+ See [README.md](README.md) for what the library does, and [docs/](docs/)
336
+ and [guides/](guides/) for the reference and the guides.
337
+
338
+ **Requires Ruby 3.0 or later** (3.1 for the MemoryView-backed paths).
@@ -1,6 +1,9 @@
1
1
  ChangeLog of Ruby/CArray
2
2
  ========================
3
3
 
4
+ Releases from 3.0.0 onward are in [CHANGELOG.md](CHANGELOG.md).
5
+ What follows is the history up to the 2.0.0 release; 2.0.1 went unrecorded.
6
+
4
7
  1.6.0 -> 2.0.0
5
8
  --------------
6
9
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2020 Hiroki Motoyoshi.
1
+ Copyright (c) 2005-2026 himotoyoshi.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
data/README.md CHANGED
@@ -1,56 +1,140 @@
1
- Ruby/CArray
2
- ===========
1
+ # Ruby/CArray
3
2
 
4
- Ruby/CArray is an extension library for the multi-dimensional array class.
3
+ Ruby/CArray is an extension library for the multi-dimensional array class. It provides arrays of a single, uniform data type, with indexing and slicing in many forms, element-wise arithmetic and mathematical functions, reductions and statistics over the whole array or along any axis, and broadcasting between shapes that differ in size-1 axes. The features listed below are in addition to these.
5
4
 
6
- Features
7
- --------
5
+ ## Status
8
6
 
9
- * Collection class for multidimensional array storing the value with uniform data type
10
- * Element-wise mathematical operations and functions
11
- * Statistical operation for the elements
12
- * Various methods for referencing data elements
13
- * Internally included element-wise mask to handle missing values
14
- * Indirect data manipulation to referent by virtual array
15
- * Special iterators (dimension, block, window, categorical)
16
- * User-defined array class with same multi-dimensional interfaces as CArray
17
- * Accessing the partial data in fixed length data via data_class interface
18
- * Wrapping the memory block owned by the other object (such as NArray).
7
+ 3.0.x still moves: behavior can change between releases — see [CHANGELOG.md](CHANGELOG.md). 3.1 is the first release meant to be depended on. Until then, treat it as a place to try things out.
19
8
 
20
- Requirements
21
- ------------
9
+ ## Features
22
10
 
23
- * Ruby 2.4.0 or later
24
- * C compiler
25
- + IEEE754 floating point number
26
- + C99 complex number
11
+ * Every array carries a per-element mask for missing values, respected by reductions and statistics
12
+ * Views compose without copying — a write through the outermost view reaches the source data
13
+ * MemoryView protocol on both sides: share buffers with other numerical libraries without copying
14
+ * Kernel-style iteration: run a Ruby block over each sub-array spanning the axes you choose
15
+ * Attach domain meaning (time, angle, quantity with units…) without changing storage — a Face
16
+ * Define your own array class in pure Ruby while keeping the full CArray interface
17
+ * Pack multiple values into one element as a record type
18
+ * Comes with a DataFrame (`CAFrame`) whose columns are plain CArrays, so masks and views keep working on them
27
19
 
28
- What is Ruby/CArray
29
- ------------------
20
+ Each of these is shown, briefly and with a runnable example, in [A tour of the features](docs/FeatureTour.md).
30
21
 
31
- Ruby/CArray is an extension library for the multi-dimensional numerical array class. The name "CArray" comes from a wrapper's meaning to a numerical array handled by the C language. CArray stores integers or floating-point numbers in memory block and treats them collectively to ensure efficient performance. Therefore, Ruby/CArray is suitable for numerical computation and data analysis.
22
+ ## Install
32
23
 
33
- #### Multi-dimensional uniform array ####
24
+ ```
25
+ gem install carray
26
+ ```
34
27
 
35
- CArray is a collection class that can store the array of values with a uniform data type of one of fixed-width integer (8,16,32,64bits), floating-point number (32,64bits), complex number (64,128bits), fixed-length string, ruby object. These values are stored in memory block as binary data. CArray has multi-dimensional interfaces for the array to access their values. The multi-dimensional array has the attributes of the dimension size (1,2,3,...) and the shape of dimension ([dim0], [dim0,dim1], [dim0,dim1,dim2],...) which define the size of array.
28
+ Or add it to your `Gemfile`:
36
29
 
37
- #### Collective mathematical operations ####
30
+ ```ruby
31
+ gem "carray"
32
+ ```
38
33
 
39
- CArray supports the collective calculation for the element-wise arithmetic operations and elementary mathematical functions. Additionally, some basic statistical summarization along specific dimensions are also provided.
34
+ Requires Ruby 3.0 or later.
40
35
 
41
- #### Referencing data and virtual arrays ####
36
+ On a multi-core machine, parallel `make` cuts install time noticeably:
42
37
 
43
- CArray provides various methods for referencing data, such as addressing, slicing, selection by condition, address mapping, grid reference, transposing, shifting, rolling, data type conversion, reshaping, and so on. These data referencing are realized by the creation of virtual arrays, so-called 'view'. The virtual array doesn't have its data and retrieves the data from the referent only on-demand, including dereferencing, copying, or calculation. Since virtual array classes are sub-class of CArray, it has the same interfaces to access data as CArray. The changes in a virtual array by storing data are also reflected in the referent (if not a read_only array). Multiple heterogeneous chains of reference are also allowed, although the trade-offs with performance must be carefully considered.
38
+ ```
39
+ MAKEFLAGS="-j$(nproc)" gem install carray # Linux
40
+ MAKEFLAGS="-j$(sysctl -n hw.ncpu)" gem install carray # macOS
41
+ ```
44
42
 
45
- #### Built-in element-wise mask handling ####
43
+ ## Quick example
46
44
 
47
- CArray possesses masked states about each element (so-called "element-wise mask"). By referring the element-wise mask, CArray can perform mathematical and statistical calculations on the data with missing values by appropriate handling of masked elements. , which include the propagation of mask state to result in element-wise arithmetics and ignoring the masked elements in a statistical calculation, and so on.
45
+ ```ruby
46
+ require "carray"
48
47
 
49
- #### User-defined array ####
48
+ # --- create a 2x3 array ---
49
+ a = CArray.float64(2, 3) { |i, j| i * 3 + j }
50
+ # => [ [ 0, 1, 2 ],
51
+ # [ 3, 4, 5 ] ]
50
52
 
51
- Users can define a new virtual array class in Ruby level or C-extension level with TemplateMethod pattern. They are defined as a subclass of CAObject in Ruby level and as a subclass of CAVirtual in C-extension level. In particular, at the Ruby level, you can easily define a CArray-like class by implementing just a few template methods.
53
+ # --- reductions over the whole array or along an axis ---
54
+ a.sum # => 15.0 over the whole array
55
+ a.sum(axis: 0) # => [ 3, 5, 7 ] sum down each column
56
+ a.sum(axis: 1) # => [ 3, 12 ] sum across each row
52
57
 
53
- License
54
- -------
58
+ # --- element-wise operations and functions ---
59
+ a + 1
60
+ # => [ [ 1, 2, 3 ],
61
+ # [ 4, 5, 6 ] ]
62
+
63
+ a.exp
64
+ # => [ [ 1.000, 2.718, 7.389 ],
65
+ # [ 20.086, 54.598, 148.413 ] ]
66
+
67
+ # --- select by condition ---
68
+ a[(a % 2).eq(0)] # => [ 0, 2, 4 ] the even elements
69
+
70
+ # --- views share storage with the original ---
71
+ a.reshape(3, 2)
72
+ # => [ [ 0, 1 ],
73
+ # [ 2, 3 ],
74
+ # [ 4, 5 ] ]
75
+
76
+ a.transpose
77
+ # => [ [ 0, 3 ],
78
+ # [ 1, 4 ],
79
+ # [ 2, 5 ] ]
80
+
81
+ a[0, nil] # => [ 0, 1, 2 ] the first row
82
+ a[nil, 0] # => [ 0, 3 ] the first column
83
+
84
+ a[nil, 1..2] # a block view of the last two columns
85
+ # => [ [ 1, 2 ],
86
+ # [ 4, 5 ] ]
87
+
88
+ # --- writing through a view updates the original ---
89
+ a[0, nil] = -1
90
+ a
91
+ # => [ [ -1, -1, -1 ],
92
+ # [ 3, 4, 5 ] ]
93
+
94
+ # --- missing values ---
95
+ b = CArray.float64(2, 3) { |i, j| i * 3 + j }
96
+ b[0, 1] = UNDEF # mark some missing values
97
+ b[1, 2] = UNDEF
98
+ b
99
+ # => [ [ 0, _, 2 ],
100
+ # [ 3, 4, _ ] ]
101
+
102
+ b.sum # => 9 missing values are ignored
103
+ b.sum(axis: 0) # => [ 3, 4, 2 ] (column sums)
104
+ b.sum(axis: 1) # => [ 2, 7 ] (row sums)
105
+
106
+ # the mask is not NaN: dropping it to NaN lets IEEE rules take over instead
107
+ b.strip_mask(Float::NAN).sum(axis: 0)
108
+ # => [ 3, NaN, NaN ] NaN propagates rather than being ignored
109
+ ```
110
+
111
+ ## Documentation
112
+
113
+ * [Introduction](guides/users/introduction.md) — what Ruby/CArray is
114
+ * [Getting started](guides/users/00_getting_started.md) — install, and a first array
115
+ * [Creating arrays](guides/users/01_creating_arrays.md) — constructors, data types, filling
116
+ * [Indexing and slicing](guides/users/02_indexing_and_slicing.md) — elements, rows, blocks, conditions
117
+ * [Indexer reference](guides/users/16_indexer_reference.md) — every form `[]` accepts
118
+ * [Element-wise operations](guides/users/03_elementwise.md) — arithmetic and mathematical functions
119
+ * [Broadcasting](guides/users/07_broadcasting.md) — shapes that differ
120
+ * [Views](guides/users/06_views.md) — referring to data without copying
121
+ * [Reduction and statistics](guides/users/04_reduction_and_statistics.md) — summaries, whole or per axis
122
+ * [Masks and missing values](guides/users/05_masks.md) — undefined elements, and how calculations treat them
123
+
124
+ ## Contributing
125
+
126
+ Bug reports and feature requests are welcome — please open an issue.
127
+
128
+ **Before opening a pull request, read [CONTRIBUTING.md](CONTRIBUTING.md).** It is short, and it says which form a contribution is best sent in. A small, self-contained bug fix is fine as a pull request. Anything larger is better started as an issue: code here gets rewritten as a matter of course, so a patch for a larger change is likely to end up reimplemented rather than merged, and describing the problem gets you further than writing one.
129
+
130
+ ## Credits
131
+
132
+ Up to version 2.0, CArray was authored by himotoyoshi.
133
+
134
+ CArray 3.0 was designed and reviewed by a human developer; the implementation was produced in collaboration with AI coding tools.
135
+
136
+ ## License
55
137
 
56
138
  MIT (after version 1.5.0)
139
+
140
+ Copyright (C) 2005-2026 himotoyoshi
data/carray.gemspec CHANGED
@@ -1,34 +1,36 @@
1
- Gem::Specification::new do |s|
2
-
3
- version = "2.0.1"
4
-
5
- files = Dir.glob("**/*") + [".yardopts"] -
6
- [
7
- Dir.glob("carray-*.gem"),
8
- Dir.glob("ext/**/{Makefile,mkmf.log}"),
9
- Dir.glob("**/*.{o,so,bundle}"),
10
- Dir.glob("**/*~"),
11
- Dir.glob("doc/**/*"),
12
- Dir.glob("test/**/*"),
13
- ].flatten
14
-
15
- s.platform = Gem::Platform::RUBY
1
+ Gem::Specification.new do |s|
16
2
  s.name = "carray"
17
- s.summary = "Multi-dimesional array class for Ruby"
3
+ s.version = "3.0.1"
4
+ s.authors = ["himotoyoshi"]
5
+ s.email = ["himotoyoshi@users.noreply.github.com"]
6
+ s.summary = "Multi-dimensional numerical array class for Ruby"
18
7
  s.description = <<-HERE
19
- Ruby/CArray is an extension library for the multi-dimensional numerical array
20
- class. The name "CArray" comes from the meaning of a wrapper to a numerical array
21
- handled by the C language. CArray stores integers or floating-point numbers in
22
- memory block and treats them collectively to ensure efficient performance.
23
- Therefore, Ruby/CArray is suitable for numerical computation and data analysis.
8
+ Ruby/CArray adds multi-dimensional numerical arrays to Ruby. Elements are held
9
+ in a single flat memory block, so whole-array work -- element-wise arithmetic,
10
+ reductions along any axis, sorting, searching -- runs in C. Slicing, transposing,
11
+ reshaping, and selecting by a boolean condition all return views that share
12
+ storage with the original array and can be chained freely; nothing is copied
13
+ until you ask for a copy. Any array, view included, can carry a mask marking
14
+ individual elements as undefined, and arrays are exchanged with other numerical
15
+ libraries without copying through Ruby's MemoryView protocol.
24
16
  HERE
25
- s.version = version
26
- s.author = "Hiroki Motoyoshi"
27
- s.email = ""
28
- s.license = 'MIT'
29
- s.homepage = 'https://github.com/himotoyoshi/carray'
30
- s.files = files
31
- s.extensions = [ "ext/extconf.rb" ]
32
- s.required_ruby_version = ">= 2.4.0"
17
+ s.homepage = "https://github.com/himotoyoshi/carray"
18
+ s.license = "MIT"
19
+ s.platform = Gem::Platform::RUBY
20
+ s.required_ruby_version = ">= 3.0"
21
+ s.files = [
22
+ *Dir.glob("lib/**/*.rb"),
23
+ *Dir.glob("yard-stubs/**/*.rb"),
24
+ *(Dir.glob("ext/*.c") - %w[ext/carray_kernels.c ext/carray_cast_func.c ext/carray_math.c]),
25
+ *Dir.glob("ext/*.h"),
26
+ *Dir.glob("ext/*.rb"),
27
+ "LICENSE",
28
+ "README.md",
29
+ "CHANGELOG.md",
30
+ "CHANGELOG.v1.md",
31
+ ".yardopts",
32
+ "carray.gemspec",
33
+ ].select { |f| File.file?(f) }
34
+ s.extensions = ["ext/extconf.rb"]
35
+ s.require_paths = ["lib", "ext"]
33
36
  end
34
-