carray 1.3.6 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (315) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +32 -0
  3. data/LICENSE +22 -0
  4. data/NEWS.md +65 -0
  5. data/README.md +23 -26
  6. data/Rakefile +31 -0
  7. data/TODO.md +17 -0
  8. data/carray.gemspec +24 -31
  9. data/{ca_iter_block.c → ext/ca_iter_block.c} +16 -18
  10. data/{ca_iter_dimension.c → ext/ca_iter_dimension.c} +20 -21
  11. data/{ca_iter_window.c → ext/ca_iter_window.c} +12 -14
  12. data/{ca_obj_array.c → ext/ca_obj_array.c} +451 -176
  13. data/{ca_obj_bitarray.c → ext/ca_obj_bitarray.c} +18 -23
  14. data/{ca_obj_bitfield.c → ext/ca_obj_bitfield.c} +12 -16
  15. data/{ca_obj_block.c → ext/ca_obj_block.c} +47 -54
  16. data/{ca_obj_fake.c → ext/ca_obj_fake.c} +10 -12
  17. data/{ca_obj_farray.c → ext/ca_obj_farray.c} +21 -23
  18. data/{ca_obj_field.c → ext/ca_obj_field.c} +30 -32
  19. data/{ca_obj_grid.c → ext/ca_obj_grid.c} +32 -33
  20. data/{ca_obj_mapping.c → ext/ca_obj_mapping.c} +11 -13
  21. data/{ca_obj_object.c → ext/ca_obj_object.c} +40 -42
  22. data/{ca_obj_reduce.c → ext/ca_obj_reduce.c} +3 -5
  23. data/{ca_obj_refer.c → ext/ca_obj_refer.c} +38 -40
  24. data/{ca_obj_repeat.c → ext/ca_obj_repeat.c} +45 -47
  25. data/{ca_obj_select.c → ext/ca_obj_select.c} +4 -6
  26. data/{ca_obj_shift.c → ext/ca_obj_shift.c} +26 -28
  27. data/{ca_obj_transpose.c → ext/ca_obj_transpose.c} +26 -28
  28. data/{ca_obj_unbound_repeat.c → ext/ca_obj_unbound_repeat.c} +106 -160
  29. data/{ca_obj_window.c → ext/ca_obj_window.c} +33 -35
  30. data/{carray.h → ext/carray.h} +90 -59
  31. data/{carray_access.c → ext/carray_access.c} +244 -109
  32. data/{carray_attribute.c → ext/carray_attribute.c} +161 -207
  33. data/{carray_call_cfunc.c → ext/carray_call_cfunc.c} +1 -3
  34. data/{carray_cast.c → ext/carray_cast.c} +350 -149
  35. data/{carray_cast_func.rb → ext/carray_cast_func.rb} +1 -2
  36. data/{carray_class.c → ext/carray_class.c} +28 -36
  37. data/{carray_conversion.c → ext/carray_conversion.c} +58 -70
  38. data/{carray_copy.c → ext/carray_copy.c} +34 -50
  39. data/{carray_core.c → ext/carray_core.c} +75 -62
  40. data/ext/carray_data_type.c +66 -0
  41. data/{carray_element.c → ext/carray_element.c} +34 -53
  42. data/{carray_generate.c → ext/carray_generate.c} +137 -50
  43. data/{carray_iterator.c → ext/carray_iterator.c} +53 -53
  44. data/{carray_loop.c → ext/carray_loop.c} +77 -106
  45. data/{carray_mask.c → ext/carray_mask.c} +95 -114
  46. data/{carray_math.rb → ext/carray_math.rb} +47 -31
  47. data/ext/{mathfunc/carray_mathfunc.c → carray_mathfunc.c} +1 -3
  48. data/{carray_numeric.c → ext/carray_numeric.c} +43 -46
  49. data/{carray_operator.c → ext/carray_operator.c} +72 -36
  50. data/{carray_order.c → ext/carray_order.c} +73 -217
  51. data/{carray_sort_addr.c → ext/carray_sort_addr.c} +14 -21
  52. data/{carray_stat.c → ext/carray_stat.c} +6 -8
  53. data/{carray_stat_proc.rb → ext/carray_stat_proc.rb} +25 -27
  54. data/{carray_test.c → ext/carray_test.c} +59 -51
  55. data/{carray_undef.c → ext/carray_undef.c} +1 -11
  56. data/{carray_utils.c → ext/carray_utils.c} +12 -4
  57. data/{extconf.rb → ext/extconf.rb} +1 -6
  58. data/{mkmath.rb → ext/mkmath.rb} +13 -3
  59. data/{ruby_carray.c → ext/ruby_carray.c} +20 -8
  60. data/{ruby_ccomplex.c → ext/ruby_ccomplex.c} +1 -3
  61. data/{ruby_float_func.c → ext/ruby_float_func.c} +1 -3
  62. data/ext/version.h +16 -0
  63. data/{version.rb → ext/version.rb} +0 -0
  64. data/lib/carray.rb +52 -10
  65. data/lib/carray/{base/autoload.rb → autoload.rb} +48 -8
  66. data/lib/carray/autoload/autoload_base.rb +1 -5
  67. data/lib/carray/autoload/autoload_gem_cairo.rb +9 -0
  68. data/lib/carray/autoload/autoload_gem_ffi.rb +9 -0
  69. data/lib/carray/autoload/autoload_gem_gnuplot.rb +2 -0
  70. data/lib/carray/autoload/autoload_gem_io_csv.rb +14 -0
  71. data/lib/carray/autoload/autoload_gem_io_pg.rb +6 -0
  72. data/lib/carray/autoload/autoload_gem_io_sqlite3.rb +12 -0
  73. data/lib/carray/autoload/autoload_gem_narray.rb +10 -0
  74. data/lib/carray/autoload/autoload_gem_numo_narray.rb +15 -0
  75. data/lib/carray/autoload/autoload_gem_opencv.rb +16 -0
  76. data/lib/carray/autoload/autoload_gem_random.rb +8 -0
  77. data/lib/carray/autoload/autoload_gem_rmagick.rb +23 -0
  78. data/lib/carray/autoload/{autoload_graphics_zimg.rb → autoload_gem_zimg.rb} +0 -0
  79. data/lib/carray/basic.rb +191 -0
  80. data/lib/carray/broadcast.rb +82 -0
  81. data/lib/carray/compose.rb +315 -0
  82. data/lib/carray/construct.rb +460 -0
  83. data/lib/carray/convert.rb +115 -0
  84. data/lib/carray/info.rb +1 -3
  85. data/lib/carray/{base/inspect.rb → inspect.rb} +9 -11
  86. data/lib/carray/io/imagemagick.rb +2 -4
  87. data/lib/carray/{base/iterator.rb → iterator.rb} +6 -6
  88. data/lib/carray/mask.rb +102 -0
  89. data/lib/carray/{base/math.rb → math.rb} +21 -53
  90. data/lib/carray/math/histogram.rb +8 -10
  91. data/lib/carray/math/recurrence.rb +1 -3
  92. data/lib/carray/mkmf.rb +9 -3
  93. data/lib/carray/object/ca_obj_iterator.rb +1 -3
  94. data/lib/carray/object/ca_obj_link.rb +1 -3
  95. data/lib/carray/object/ca_obj_pack.rb +9 -11
  96. data/lib/carray/obsolete.rb +270 -0
  97. data/lib/carray/ordering.rb +181 -0
  98. data/lib/carray/{base/serialize.rb → serialize.rb} +50 -66
  99. data/lib/carray/string.rb +188 -0
  100. data/lib/carray/{base/struct.rb → struct.rb} +19 -21
  101. data/lib/carray/{io/table.rb → table.rb} +1 -9
  102. data/lib/carray/testing.rb +51 -0
  103. data/lib/carray/time.rb +76 -0
  104. data/lib/carray/transform.rb +98 -0
  105. data/misc/Methods.ja.md +182 -0
  106. data/{NOTE → misc/NOTE} +0 -0
  107. data/spec/Classes/CABitfield_spec.rb +58 -0
  108. data/spec/Classes/CABlockIterator_spec.rb +114 -0
  109. data/spec/Classes/CABlock_spec.rb +205 -0
  110. data/spec/Classes/CAField_spec.rb +39 -0
  111. data/spec/Classes/CAGrid_spec.rb +75 -0
  112. data/spec/Classes/CAMap_spec.rb +0 -0
  113. data/{test/test_CAMapping.rb → spec/Classes/CAMapping_spec.rb} +35 -36
  114. data/spec/Classes/CAObject_attribute_spec.rb +33 -0
  115. data/spec/Classes/CAObject_spec.rb +33 -0
  116. data/spec/Classes/CARefer_spec.rb +93 -0
  117. data/spec/Classes/CARepeat_spec.rb +65 -0
  118. data/spec/Classes/CASelect_spec.rb +22 -0
  119. data/spec/Classes/CAShift_spec.rb +16 -0
  120. data/spec/Classes/CAStruct_spec.rb +71 -0
  121. data/{test/test_CATranspose.rb → spec/Classes/CATranspose_spec.rb} +20 -21
  122. data/spec/Classes/CAUnboudRepeat_spec.rb +102 -0
  123. data/spec/Classes/CAWindow_spec.rb +54 -0
  124. data/spec/Classes/CAWrap_spec.rb +8 -0
  125. data/{test/test_CArray.rb → spec/Classes/CArray_spec.rb} +48 -92
  126. data/spec/Classes/CScalar_spec.rb +55 -0
  127. data/spec/Features/feature_130_spec.rb +19 -0
  128. data/spec/Features/feature_attributes_spec.rb +280 -0
  129. data/spec/Features/feature_boolean_spec.rb +98 -0
  130. data/spec/Features/feature_broadcast.rb +116 -0
  131. data/spec/Features/feature_cast_function.rb +19 -0
  132. data/spec/Features/feature_cast_spec.rb +33 -0
  133. data/spec/Features/feature_class_spec.rb +84 -0
  134. data/spec/Features/feature_complex_spec.rb +42 -0
  135. data/{test/test_composite.rb → spec/Features/feature_composite_spec.rb} +17 -18
  136. data/spec/Features/feature_convert_spec.rb +46 -0
  137. data/spec/Features/feature_copy_spec.rb +123 -0
  138. data/spec/Features/feature_creation_spec.rb +84 -0
  139. data/spec/Features/feature_element_spec.rb +144 -0
  140. data/spec/Features/feature_extream_spec.rb +54 -0
  141. data/spec/Features/feature_generate_spec.rb +74 -0
  142. data/spec/Features/feature_index_spec.rb +69 -0
  143. data/spec/Features/feature_mask_spec.rb +580 -0
  144. data/spec/Features/feature_math_spec.rb +97 -0
  145. data/spec/Features/feature_order_spec.rb +146 -0
  146. data/spec/Features/feature_ref_store_spec.rb +209 -0
  147. data/spec/Features/feature_serialization_spec.rb +125 -0
  148. data/spec/Features/feature_stat_spec.rb +397 -0
  149. data/spec/Features/feature_virtual_spec.rb +48 -0
  150. data/spec/Features/method_eq_spec.rb +81 -0
  151. data/spec/Features/method_is_nan_spec.rb +12 -0
  152. data/spec/Features/method_map_spec.rb +54 -0
  153. data/spec/Features/method_max_with.rb +20 -0
  154. data/spec/Features/method_min_with.rb +19 -0
  155. data/spec/Features/method_ne_spec.rb +18 -0
  156. data/spec/Features/method_project_spec.rb +188 -0
  157. data/spec/Features/method_ref_spec.rb +27 -0
  158. data/spec/Features/method_round_spec.rb +11 -0
  159. data/spec/Features/method_s_linspace_spec.rb +48 -0
  160. data/spec/Features/method_s_span_spec.rb +14 -0
  161. data/spec/Features/method_seq_spec.rb +47 -0
  162. data/spec/Features/method_sort_with.rb +43 -0
  163. data/spec/Features/method_sorted_with.rb +29 -0
  164. data/spec/Features/method_span_spec.rb +42 -0
  165. data/spec/Features/method_wrap_readonly_spec.rb +43 -0
  166. data/{test → spec/UnitTest}/test_CAVirtual.rb +0 -0
  167. data/spec/spec_all.rb +0 -1
  168. data/utils/convert_test.rb +73 -0
  169. data/utils/{extract_rdoc.rb → extract_yard.rb} +7 -12
  170. data/{devel → utils}/guess_shape.rb +0 -0
  171. data/utils/{diff_method.rb → monkey_patch_methods.rb} +17 -7
  172. metadata +173 -316
  173. data/COPYING +0 -56
  174. data/GPL +0 -340
  175. data/Gemfile +0 -8
  176. data/Gemfile.lock +0 -33
  177. data/LEGAL +0 -50
  178. data/Makefile +0 -451
  179. data/TODO +0 -5
  180. data/carray_cast_func.c +0 -8670
  181. data/carray_config.h +0 -26
  182. data/carray_math.c +0 -24805
  183. data/carray_random.c +0 -531
  184. data/carray_stat_proc.c +0 -12170
  185. data/ext/calculus/carray_calculus.c +0 -931
  186. data/ext/calculus/carray_interp.c +0 -358
  187. data/ext/calculus/extconf.rb +0 -12
  188. data/ext/calculus/lib/autoload/autoload_math_calculus.rb +0 -2
  189. data/ext/calculus/lib/math/calculus.rb +0 -119
  190. data/ext/calculus/lib/math/interp/adapter_interp1d.rb +0 -31
  191. data/ext/fortio/extconf.rb +0 -3
  192. data/ext/fortio/lib/carray/autoload/autoload_fortran_format.rb +0 -5
  193. data/ext/fortio/lib/carray/io/fortran_format.rb +0 -43
  194. data/ext/fortio/lib/fortio.rb +0 -3
  195. data/ext/fortio/lib/fortio/fortran_format.rb +0 -605
  196. data/ext/fortio/lib/fortio/fortran_format.tab.rb +0 -536
  197. data/ext/fortio/lib/fortio/fortran_format.y +0 -215
  198. data/ext/fortio/lib/fortio/fortran_namelist.rb +0 -151
  199. data/ext/fortio/lib/fortio/fortran_namelist.tab.rb +0 -470
  200. data/ext/fortio/lib/fortio/fortran_namelist.y +0 -213
  201. data/ext/fortio/lib/fortio/fortran_sequential.rb +0 -345
  202. data/ext/fortio/ruby_fortio.c +0 -182
  203. data/ext/fortio/test/test_H.rb +0 -5
  204. data/ext/fortio/test/test_T.rb +0 -7
  205. data/ext/fortio/test/test_fortran_format.rb +0 -86
  206. data/ext/fortio/test/test_namelist.rb +0 -25
  207. data/ext/fortio/test/test_namelist_write.rb +0 -10
  208. data/ext/fortio/test/test_sequential.rb +0 -13
  209. data/ext/fortio/test/test_sequential2.rb +0 -13
  210. data/ext/fortio/work/test.rb +0 -10
  211. data/ext/fortio/work/test_e.rb +0 -19
  212. data/ext/fortio/work/test_ep.rb +0 -10
  213. data/ext/fortio/work/test_parse.rb +0 -12
  214. data/ext/imagemap/carray_imagemap.c +0 -495
  215. data/ext/imagemap/doc/call_graph.dot +0 -28
  216. data/ext/imagemap/draw.c +0 -567
  217. data/ext/imagemap/extconf.rb +0 -13
  218. data/ext/imagemap/lib/autoload/autoload_graphics_imagemap.rb +0 -1
  219. data/ext/imagemap/lib/graphics/imagemap.rb +0 -273
  220. data/ext/imagemap/lib/image_map.rb +0 -4
  221. data/ext/imagemap/test/swath_index.rb +0 -83
  222. data/ext/imagemap/test/swath_warp.rb +0 -99
  223. data/ext/imagemap/test/test.rb +0 -23
  224. data/ext/imagemap/test/test_image.rb +0 -42
  225. data/ext/imagemap/test/test_line.rb +0 -14
  226. data/ext/imagemap/test/test_rotate.rb +0 -17
  227. data/ext/imagemap/test/test_triangle.rb +0 -20
  228. data/ext/imagemap/test/test_warp.rb +0 -26
  229. data/ext/mathfunc/extconf.rb +0 -18
  230. data/ext/mathfunc/lib/autoload/autoload_math_mathfunc.rb +0 -1
  231. data/ext/mathfunc/lib/math/mathfunc.rb +0 -15
  232. data/ext/mathfunc/test/test_hypot.rb +0 -5
  233. data/ext/mathfunc/test/test_j0.rb +0 -22
  234. data/ext/mathfunc/test/test_jn.rb +0 -8
  235. data/ext/mathfunc/test/test_sph.rb +0 -9
  236. data/ext/narray/README +0 -22
  237. data/ext/narray/ca_wrap_narray.c +0 -500
  238. data/ext/narray/carray_narray.c +0 -21
  239. data/ext/narray/extconf.rb +0 -57
  240. data/ext/narray/lib/autoload/autoload_math_narray.rb +0 -1
  241. data/ext/narray/lib/autoload/autoload_math_narray_miss.rb +0 -11
  242. data/ext/narray/lib/math/narray.rb +0 -17
  243. data/ext/narray/lib/math/narray_miss.rb +0 -45
  244. data/lib/carray/autoload/autoload_graphics_gnuplot.rb +0 -2
  245. data/lib/carray/autoload/autoload_io_csv.rb +0 -14
  246. data/lib/carray/autoload/autoload_io_pg.rb +0 -6
  247. data/lib/carray/autoload/autoload_io_sqlite3.rb +0 -12
  248. data/lib/carray/autoload/autoload_io_table.rb +0 -1
  249. data/lib/carray/autoload/autoload_math_interp.rb +0 -4
  250. data/lib/carray/base/basic.rb +0 -1090
  251. data/lib/carray/base/obsolete.rb +0 -131
  252. data/lib/carray/graphics/gnuplot.rb +0 -2131
  253. data/lib/carray/graphics/zimg.rb +0 -296
  254. data/lib/carray/io/csv.rb +0 -572
  255. data/lib/carray/io/pg.rb +0 -101
  256. data/lib/carray/io/sqlite3.rb +0 -215
  257. data/lib/carray/math/interp.rb +0 -57
  258. data/lib/carray/math/interp/adapter_gsl_spline.rb +0 -47
  259. data/mkmf.log +0 -375
  260. data/mt19937ar.c +0 -182
  261. data/mt19937ar.h +0 -86
  262. data/rdoc_ext.rb +0 -1115
  263. data/rdoc_main.rb +0 -27
  264. data/rdoc_math.rb +0 -5
  265. data/rdoc_stat.rb +0 -31
  266. data/spec/CABlockIterator/CABlockIterator_spec.rb +0 -113
  267. data/spec/CArray/bug/store_spec.rb +0 -27
  268. data/spec/CArray/index/repeat_spec.rb +0 -10
  269. data/spec/CArray/method/eq_spec.rb +0 -80
  270. data/spec/CArray/method/is_nan_spec.rb +0 -12
  271. data/spec/CArray/method/ne_spec.rb +0 -18
  272. data/spec/CArray/method/round_spec.rb +0 -11
  273. data/spec/CArray/object/_attribute_spec.rb +0 -32
  274. data/spec/CArray/object/s_new_spec.rb +0 -31
  275. data/spec/CArray/serialize/Serialization_spec.rb +0 -89
  276. data/test/test_130.rb +0 -23
  277. data/test/test_ALL.rb +0 -51
  278. data/test/test_CABitfield.rb +0 -59
  279. data/test/test_CABlock.rb +0 -208
  280. data/test/test_CAField.rb +0 -40
  281. data/test/test_CAGrid.rb +0 -76
  282. data/test/test_CAMmap.rb +0 -11
  283. data/test/test_CARefer.rb +0 -94
  284. data/test/test_CARepeat.rb +0 -66
  285. data/test/test_CASelect.rb +0 -23
  286. data/test/test_CAShift.rb +0 -17
  287. data/test/test_CAWindow.rb +0 -55
  288. data/test/test_CAWrap.rb +0 -9
  289. data/test/test_CComplex.rb +0 -83
  290. data/test/test_CScalar.rb +0 -91
  291. data/test/test_attribute.rb +0 -281
  292. data/test/test_block_iterator.rb +0 -17
  293. data/test/test_boolean.rb +0 -99
  294. data/test/test_cast.rb +0 -33
  295. data/test/test_class.rb +0 -85
  296. data/test/test_complex.rb +0 -43
  297. data/test/test_convert.rb +0 -79
  298. data/test/test_copy.rb +0 -141
  299. data/test/test_creation.rb +0 -85
  300. data/test/test_element.rb +0 -146
  301. data/test/test_extream.rb +0 -55
  302. data/test/test_generate.rb +0 -75
  303. data/test/test_index.rb +0 -71
  304. data/test/test_mask.rb +0 -578
  305. data/test/test_math.rb +0 -98
  306. data/test/test_narray.rb +0 -64
  307. data/test/test_order.rb +0 -147
  308. data/test/test_random.rb +0 -15
  309. data/test/test_ref_store.rb +0 -211
  310. data/test/test_stat.rb +0 -414
  311. data/test/test_struct.rb +0 -72
  312. data/test/test_virtual.rb +0 -49
  313. data/utils/create_rdoc.sh +0 -9
  314. data/utils/make_tgz.sh +0 -3
  315. data/version.h +0 -18
@@ -3,39 +3,37 @@
3
3
  carray_loop.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
 
13
11
  #include "carray.h"
14
12
 
15
13
  static VALUE
16
- rb_ca_s_each_index_internal (int rank, VALUE *dim, uint8_t irank, VALUE ridx)
14
+ rb_ca_s_each_index_internal (int ndim, VALUE *dim, uint8_t indim, VALUE ridx)
17
15
  {
18
16
  volatile VALUE ret = Qnil;
19
- int32_t is_leaf = (irank == rank - 1);
17
+ int32_t is_leaf = (indim == ndim - 1);
20
18
  ca_size_t i;
21
19
 
22
- if ( NIL_P(dim[irank]) ) {
23
- rb_ary_store(ridx, irank, Qnil);
20
+ if ( NIL_P(dim[indim]) ) {
21
+ rb_ary_store(ridx, indim, Qnil);
24
22
  if ( is_leaf ) {
25
23
  ret = rb_yield_splat(rb_obj_clone(ridx));
26
24
  }
27
25
  else {
28
- ret = rb_ca_s_each_index_internal(rank, dim, irank+1, ridx);
26
+ ret = rb_ca_s_each_index_internal(ndim, dim, indim+1, ridx);
29
27
  }
30
28
  }
31
29
  else {
32
- for (i=0; i<NUM2SIZE(dim[irank]); i++) {
33
- rb_ary_store(ridx, irank, SIZE2NUM(i));
30
+ for (i=0; i<NUM2SIZE(dim[indim]); i++) {
31
+ rb_ary_store(ridx, indim, SIZE2NUM(i));
34
32
  if ( is_leaf ) {
35
33
  ret = rb_yield_splat(rb_obj_clone(ridx));
36
34
  }
37
35
  else {
38
- ret = rb_ca_s_each_index_internal(rank, dim, irank+1, ridx);
36
+ ret = rb_ca_s_each_index_internal(ndim, dim, indim+1, ridx);
39
37
  }
40
38
  }
41
39
  }
@@ -43,38 +41,32 @@ rb_ca_s_each_index_internal (int rank, VALUE *dim, uint8_t irank, VALUE ridx)
43
41
  return ret;
44
42
  }
45
43
 
46
- /* rdoc:
47
- # Iterates with the multi-dimensional indeces for the given
48
- # dimension numbers.
49
- #
50
- # CArray.each_index(3,2){|i,j| print "(#{i} #{j}) " }
51
- #
52
- # produces:
53
- #
54
- # (0 0) (0 1) (1 0) (1 1) (2 0) (2 1) (3 0) (3 1)
55
- #
56
- def CArray.each_index(*argv) # :yields: i0, i1, ...
57
- end
44
+ /* @overload each_index (*shape)
45
+
46
+ (Iterator) Iterates with the multi-dimensional indeces for the given
47
+ dimension numbers.
48
+
49
+ CArray.each_index(3,2){|i,j| print "(#{i} #{j}) " }
50
+ produces:
51
+ (0 0) (0 1) (1 0) (1 1) (2 0) (2 1) (3 0) (3 1)
58
52
  */
59
53
 
60
54
  static VALUE
61
- rb_ca_s_each_index (int rank, VALUE *dim, VALUE self)
55
+ rb_ca_s_each_index (int ndim, VALUE *dim, VALUE self)
62
56
  {
63
- volatile VALUE ridx = rb_ary_new2(rank);
57
+ volatile VALUE ridx = rb_ary_new2(ndim);
64
58
  #if RUBY_VERSION_CODE >= 190
65
- RETURN_ENUMERATOR(self, rank, dim);
59
+ RETURN_ENUMERATOR(self, ndim, dim);
66
60
  #endif
67
- return rb_ca_s_each_index_internal(rank, dim, 0, ridx);
61
+ return rb_ca_s_each_index_internal(ndim, dim, 0, ridx);
68
62
  }
69
63
 
70
64
  /* ------------------------------------------------------------------- */
71
65
 
72
- /* rdoc:
73
- class CArray
74
- #
75
- def each # :yields: v
76
- end
77
- end
66
+ /* @overload each () {|elem| ... }
67
+
68
+ (Iterator) Iterates all the elements of the object.
69
+
78
70
  */
79
71
 
80
72
  static VALUE
@@ -92,12 +84,10 @@ rb_ca_each (VALUE self)
92
84
  return ret;
93
85
  }
94
86
 
95
- /* rdoc:
96
- class CArray
97
- #
98
- def each_with_addr # :yields: v, addr
99
- end
100
- end
87
+ /* @overload each_with_addr () {|elem, addr| ... }
88
+
89
+ (Iterator) Iterates all the elements of the object.
90
+
101
91
  */
102
92
 
103
93
  static VALUE
@@ -115,12 +105,9 @@ rb_ca_each_with_addr (VALUE self)
115
105
  return ret;
116
106
  }
117
107
 
118
- /* rdoc:
119
- class CArray
120
- #
121
- def each_addr() # :yields: addr
122
- end
123
- end
108
+ /* @overload each_addr () {|addr| ... }
109
+
110
+ (Iterator) Iterates all address of the object.
124
111
  */
125
112
 
126
113
  static VALUE
@@ -145,7 +132,7 @@ rb_ca_each_index_internal (VALUE self, int8_t level, VALUE ridx)
145
132
  CArray *ca;
146
133
  ca_size_t i;
147
134
  Data_Get_Struct(self, CArray, ca);
148
- if ( level == ca->rank - 1 ) {
135
+ if ( level == ca->ndim - 1 ) {
149
136
  for (i=0; i<ca->dim[level]; i++) {
150
137
  rb_ary_store(ridx, level, SIZE2NUM(i));
151
138
  ret = rb_yield_splat(rb_obj_clone(ridx));
@@ -160,39 +147,33 @@ rb_ca_each_index_internal (VALUE self, int8_t level, VALUE ridx)
160
147
  return ret;
161
148
  }
162
149
 
163
- /* rdoc:
164
- class CArray
165
- # Iterates with the multi-dimensional indeces for the dimension of <i>ca</i>.
166
- #
167
- # CArray.int(3,2).each_index(){|i,j| print "(#{i} #{j}) " }
168
- #
169
- # <em>produces:</em>
170
- #
171
- # (0 0) (0 1) (1 0) (1 1) (2 0) (2 1) (3 0) (3 1)
172
- #
173
- def each_index # :yields: i0, i1, ...
174
- end
175
- end
150
+ /* @overload each_index () {|idx| ... }
151
+
152
+ (Iterator) Iterates all index of the object.
153
+
154
+ CArray.int(3,2).each_index(){|i,j| print "(#{i} #{j}) " }
155
+
156
+ <em>produces:</em>
157
+
158
+ (0 0) (0 1) (1 0) (1 1) (2 0) (2 1) (3 0) (3 1)
159
+
176
160
  */
177
161
 
178
162
  static VALUE
179
163
  rb_ca_each_index (VALUE self)
180
164
  {
181
165
  volatile VALUE ridx;
182
- int8_t rank = NUM2INT(rb_ca_rank(self));
183
- ridx = rb_ary_new2(rank);
166
+ int8_t ndim = NUM2INT(rb_ca_ndim(self));
167
+ ridx = rb_ary_new2(ndim);
184
168
  #if RUBY_VERSION_CODE >= 190
185
169
  RETURN_ENUMERATOR(self, 0, 0);
186
170
  #endif
187
171
  return rb_ca_each_index_internal(self, 0, ridx);
188
172
  }
189
173
 
190
- /* rdoc:
191
- class CArray
192
- #
193
- def map! # :yields: v
194
- end
195
- end
174
+ /* @overload map! () {|elem| ... }
175
+
176
+ (Iterator, Destructive) Iterates all elements of the object and stores the return from the block to the element.
196
177
  */
197
178
 
198
179
  static VALUE
@@ -225,7 +206,7 @@ rb_ca_each_with_index_internal (VALUE self,
225
206
  CArray *ca;
226
207
  ca_size_t i;
227
208
  Data_Get_Struct(self, CArray, ca);
228
- if ( level == ca->rank - 1 ) {
209
+ if ( level == ca->ndim - 1 ) {
229
210
  for (i=0; i<ca->dim[level]; i++) {
230
211
  idx[level] = i;
231
212
  rb_ary_store(ridx, level, SIZE2NUM(i));
@@ -243,12 +224,10 @@ rb_ca_each_with_index_internal (VALUE self,
243
224
  return ret;
244
225
  }
245
226
 
246
- /* rdoc:
247
- class CArray
248
- #
249
- def each_with_index # :yields: v, idx
250
- end
251
- end
227
+ /* @overload each_with_index () {|elem, idx| ... }
228
+
229
+ [TBD]
230
+
252
231
  */
253
232
 
254
233
  static VALUE
@@ -256,12 +235,12 @@ rb_ca_each_with_index (VALUE self)
256
235
  {
257
236
  volatile VALUE ridx, ret;
258
237
  ca_size_t idx[CA_RANK_MAX];
259
- int8_t rank = NUM2INT(rb_ca_rank(self));
238
+ int8_t ndim = NUM2INT(rb_ca_ndim(self));
260
239
  #if RUBY_VERSION_CODE >= 190
261
240
  RETURN_ENUMERATOR(self, 0, 0);
262
241
  #endif
263
242
  rb_ca_modify(self);
264
- ridx = rb_ary_new2(rank);
243
+ ridx = rb_ary_new2(ndim);
265
244
  ret = rb_ca_each_with_index_internal(self, 0, idx, ridx);
266
245
  return ret;
267
246
  }
@@ -274,7 +253,7 @@ rb_ca_map_with_index_bang_internal (VALUE self,
274
253
  CArray *ca;
275
254
  ca_size_t i;
276
255
  Data_Get_Struct(self, CArray, ca);
277
- if ( level == ca->rank - 1 ) {
256
+ if ( level == ca->ndim - 1 ) {
278
257
  volatile VALUE obj;
279
258
  for (i=0; i<ca->dim[level]; i++) {
280
259
  idx[level] = i;
@@ -293,12 +272,10 @@ rb_ca_map_with_index_bang_internal (VALUE self,
293
272
  }
294
273
  }
295
274
 
296
- /* rdoc:
297
- class CArray
298
- #
299
- def map_with_index! # :yields: v, idx
300
- end
301
- end
275
+ /* @overload map_with_index () {|elem, idx| ... }
276
+
277
+ [TBD]
278
+
302
279
  */
303
280
 
304
281
  static VALUE
@@ -307,14 +284,14 @@ rb_ca_map_with_index_bang (VALUE self)
307
284
  volatile VALUE ridx;
308
285
  CArray *ca;
309
286
  ca_size_t idx[CA_RANK_MAX];
310
- int8_t rank = NUM2INT(rb_ca_rank(self));
287
+ int8_t ndim = NUM2INT(rb_ca_ndim(self));
311
288
  #if RUBY_VERSION_CODE >= 190
312
289
  RETURN_ENUMERATOR(self, 0, 0);
313
290
  #endif
314
291
  rb_ca_modify(self);
315
292
  Data_Get_Struct(self, CArray, ca);
316
293
  ca_attach(ca);
317
- ridx = rb_ary_new2(rank);
294
+ ridx = rb_ary_new2(ndim);
318
295
  rb_ca_map_with_index_bang_internal(self, 0, idx, ridx);
319
296
  ca_sync(ca);
320
297
  ca_detach(ca);
@@ -329,7 +306,7 @@ rb_ca_map_index_bang_internal (VALUE self,
329
306
  CArray *ca;
330
307
  ca_size_t i;
331
308
  Data_Get_Struct(self, CArray, ca);
332
- if ( level == ca->rank - 1 ) {
309
+ if ( level == ca->ndim - 1 ) {
333
310
  volatile VALUE obj;
334
311
  for (i=0; i<ca->dim[level]; i++) {
335
312
  idx[level] = i;
@@ -347,12 +324,10 @@ rb_ca_map_index_bang_internal (VALUE self,
347
324
  }
348
325
  }
349
326
 
350
- /* rdoc:
351
- class CArray
352
- #
353
- def map_index! # :yields: i0, i1, ...
354
- end
355
- end
327
+ /* @overload map_index! () {|idx| ... }
328
+
329
+ [TBD]
330
+
356
331
  */
357
332
 
358
333
  static VALUE
@@ -361,26 +336,24 @@ rb_ca_map_index_bang (VALUE self)
361
336
  volatile VALUE ridx;
362
337
  CArray *ca;
363
338
  ca_size_t idx[CA_RANK_MAX];
364
- int8_t rank = NUM2INT(rb_ca_rank(self));
339
+ int8_t ndim = NUM2INT(rb_ca_ndim(self));
365
340
  #if RUBY_VERSION_CODE >= 190
366
341
  RETURN_ENUMERATOR(self, 0, 0);
367
342
  #endif
368
343
  rb_ca_modify(self);
369
344
  Data_Get_Struct(self, CArray, ca);
370
345
  ca_attach(ca);
371
- ridx = rb_ary_new2(rank);
346
+ ridx = rb_ary_new2(ndim);
372
347
  rb_ca_map_index_bang_internal(self, 0, idx, ridx);
373
348
  ca_sync(ca);
374
349
  ca_detach(ca);
375
350
  return self;
376
351
  }
377
352
 
378
- /* rdoc:
379
- class CArray
380
- #
381
- def map_with_addr! # :yields: v, addr
382
- end
383
- end
353
+ /* @overload map_with_addr! () {|elem, addr| ... }
354
+
355
+ [TBD]
356
+
384
357
  */
385
358
 
386
359
  static VALUE
@@ -406,12 +379,10 @@ rb_ca_map_with_addr_bang (VALUE self)
406
379
  }
407
380
 
408
381
 
409
- /* rdoc:
410
- class CArray
411
- #
412
- def map_addr! # :yields: addr
413
- end
414
- end
382
+ /* @overload map_addr! () {|addr| ... }
383
+
384
+ [TBD]
385
+
415
386
  */
416
387
 
417
388
  static VALUE
@@ -3,10 +3,8 @@
3
3
  carray_mask.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
 
@@ -565,12 +563,10 @@ ca_allocate_mask_iterator (int n, ...)
565
563
 
566
564
  /* ------------------------------------------------------------------- */
567
565
 
568
- /* rdoc:
569
- class CArray
570
- # Returns true if self has the mask array.
571
- def has_mask?()
572
- end
573
- end
566
+ /* @overload has_mask?
567
+
568
+ (Masking, Inquiry)
569
+ Returns true if self has the mask array.
574
570
  */
575
571
 
576
572
  VALUE
@@ -581,12 +577,10 @@ rb_ca_has_mask (VALUE self)
581
577
  return ( ca_has_mask(ca) ) ? Qtrue : Qfalse;
582
578
  }
583
579
 
584
- /* rdoc:
585
- class CArray
586
- # Returns true if self has at least one masked element.
587
- def any_masked?
588
- end
589
- end
580
+ /* @overload any_masked?
581
+
582
+ (Masking, Inquiry)
583
+ Returns true if self has at least one masked element.
590
584
  */
591
585
 
592
586
  VALUE
@@ -597,12 +591,10 @@ rb_ca_is_any_masked (VALUE self)
597
591
  return ( ca_is_any_masked(ca) ) ? Qtrue : Qfalse;
598
592
  }
599
593
 
600
- /* rdoc:
601
- class CArray
602
- # Returns true if all elements of self are masked.
603
- def all_masked?
604
- end
605
- end
594
+ /* @overload all_masked?
595
+
596
+ (Masking, Inquiry)
597
+ Returns true if all elements of self are masked.
606
598
  */
607
599
 
608
600
  VALUE
@@ -613,12 +605,10 @@ rb_ca_is_all_masked (VALUE self)
613
605
  return ( ca_is_all_masked(ca) ) ? Qtrue : Qfalse;
614
606
  }
615
607
 
616
- /* rdoc:
617
- class CArray
618
- private
619
- def create_mask
620
- end
621
- end
608
+ /* @overload create_mask
609
+
610
+ (Masking)
611
+ Creates mask array internally (private method)
622
612
  */
623
613
 
624
614
  static VALUE
@@ -631,12 +621,10 @@ rb_ca_create_mask (VALUE self)
631
621
  return Qnil;
632
622
  }
633
623
 
634
- /* rdoc:
635
- class CArray
636
- private
637
- def update_mask
638
- end
639
- end
624
+ /* @overload update_mask
625
+
626
+ (Masking)
627
+ Update mask array internally (private method)
640
628
  */
641
629
 
642
630
  /*
@@ -650,14 +638,12 @@ rb_ca_update_mask (VALUE self)
650
638
  }
651
639
  */
652
640
 
653
- /* rdoc:
654
- class CArray
655
- # Returns new array which refers the data of <code>self</code>.
656
- # The data of masked elements of <code>self</code> can be accessed
657
- # via the returned array. The value array can't be set mask.
658
- def value ()
659
- end
660
- end
641
+ /* @overload value
642
+
643
+ (Masking, Inquiry)
644
+ Returns new array which refers the data of <code>self</code>.
645
+ The data of masked elements of <code>self</code> can be accessed
646
+ via the returned array. The value array can't be set mask.
661
647
  */
662
648
 
663
649
  VALUE
@@ -668,7 +654,7 @@ rb_ca_value_array (VALUE self)
668
654
 
669
655
  Data_Get_Struct(self, CArray, ca);
670
656
 
671
- obj = rb_ca_refer_new(self, ca->data_type, ca->rank, ca->dim, ca->bytes, 0);
657
+ obj = rb_ca_refer_new(self, ca->data_type, ca->ndim, ca->dim, ca->bytes, 0);
672
658
  Data_Get_Struct(obj, CArray, co);
673
659
 
674
660
  ca_set_flag(co, CA_FLAG_VALUE_ARRAY);
@@ -676,13 +662,11 @@ rb_ca_value_array (VALUE self)
676
662
  return obj;
677
663
  }
678
664
 
679
- /* rdoc:
680
- class CArray
681
- # Returns new array which refers the mask state of <code>self</code>.
682
- # The mask array can't be set mask.
683
- def mask ()
684
- end
685
- end
665
+ /* @overload mask
666
+
667
+ (Masking, Inquiry)
668
+ Returns new array which refers the mask state of <code>self</code>.
669
+ The mask array can't be set mask.
686
670
  */
687
671
 
688
672
  VALUE
@@ -707,14 +691,12 @@ rb_ca_mask_array (VALUE self)
707
691
  }
708
692
  }
709
693
 
710
- /* rdoc:
711
- class CArray
712
- # Asigns <code>new_mask</code> to the mask array of <code>self</code>.
713
- # If <code>self</code> doesn't have a mask array, it will be created
714
- # before asignment.
715
- def mask= (new_mask)
716
- end
717
- end
694
+ /* @overload mask= (new_mask)
695
+
696
+ (Mask, Modification)
697
+ Asigns <code>new_mask</code> to the mask array of <code>self</code>.
698
+ If <code>self</code> doesn't have a mask array, it will be created
699
+ before asignment.
718
700
  */
719
701
 
720
702
  VALUE
@@ -756,14 +738,12 @@ rb_ca_set_mask (VALUE self, VALUE rval)
756
738
  }
757
739
  }
758
740
 
759
- /* rdoc:
760
- class CArray
761
- # Returns new boolean type array of same shape with <code>self</code>.
762
- # The returned array has 1 for the masked elements and
763
- # 0 for not-masked elements.
764
- def is_masked ()
765
- end
766
- end
741
+ /* @overload is_masked
742
+
743
+ (Masking, Element-Wise Inquiry)
744
+ Returns new boolean type array of same shape
745
+ with <code>self</code>. The returned array has 1 for the masked elements and
746
+ 0 for not-masked elements.
767
747
  */
768
748
 
769
749
  VALUE
@@ -777,7 +757,7 @@ rb_ca_is_masked (VALUE self)
777
757
 
778
758
  Data_Get_Struct(self, CArray, ca);
779
759
 
780
- co = carray_new(CA_BOOLEAN, ca->rank, ca->dim, ca->bytes, NULL);
760
+ co = carray_new(CA_BOOLEAN, ca->ndim, ca->dim, ca->bytes, NULL);
781
761
 
782
762
  ca_update_mask(ca);
783
763
  if ( ! ca->mask ) {
@@ -799,14 +779,12 @@ rb_ca_is_masked (VALUE self)
799
779
  return ca_wrap_struct(co);
800
780
  }
801
781
 
802
- /* rdoc:
803
- class CArray
804
- # Returns new boolean type array of same shape with <code>self</code>.
805
- # The returned array has 0 for the masked elements and
806
- # 1 for not-masked elements.
807
- def is_not_masked ()
808
- end
809
- end
782
+ /* @overload is_not_masked
783
+
784
+ (Masking, Element-Wise Inquiry)
785
+ Returns new boolean type array of same shape with <code>self</code>.
786
+ The returned array has 0 for the masked elements and
787
+ 1 for not-masked elements.
810
788
  */
811
789
 
812
790
  VALUE
@@ -820,7 +798,7 @@ rb_ca_is_not_masked (VALUE self)
820
798
 
821
799
  Data_Get_Struct(self, CArray, ca);
822
800
 
823
- co = carray_new(CA_BOOLEAN, ca->rank, ca->dim, ca->bytes, NULL);
801
+ co = carray_new(CA_BOOLEAN, ca->ndim, ca->dim, ca->bytes, NULL);
824
802
 
825
803
  ca_update_mask(ca);
826
804
  if ( ! ca->mask ) {
@@ -842,12 +820,10 @@ rb_ca_is_not_masked (VALUE self)
842
820
  return ca_wrap_struct(co);
843
821
  }
844
822
 
845
- /* rdoc:
846
- class CArray
847
- # Returns the number of masked elements.
848
- def count_masked ()
849
- end
850
- end
823
+ /* @overload count_masked
824
+
825
+ (Masking, Statistics)
826
+ Returns the number of masked elements.
851
827
  */
852
828
 
853
829
  VALUE
@@ -858,12 +834,10 @@ rb_ca_count_masked (VALUE self)
858
834
  return SIZE2NUM(ca_count_masked(ca));
859
835
  }
860
836
 
861
- /* rdoc:
862
- class CArray
863
- # Returns the number of not-masked elements.
864
- def count_not_masked ()
865
- end
866
- end
837
+ /* @overload count_not_masked
838
+
839
+ (Masking, Statistics)
840
+ Returns the number of not-masked elements.
867
841
  */
868
842
 
869
843
  VALUE
@@ -874,6 +848,15 @@ rb_ca_count_not_masked (VALUE self)
874
848
  return SIZE2NUM(ca_count_not_masked(ca));
875
849
  }
876
850
 
851
+ /* @overload unmask (fill_value = nil)
852
+
853
+ (Masking, Destructive)
854
+ Unmask all elements of the object.
855
+ If the optional argument <code>fill_value</code> is given,
856
+ the masked elements are filled by <code>fill_value</code>.
857
+ The returned array doesn't have the mask array.
858
+ */
859
+
877
860
  static VALUE
878
861
  rb_ca_unmask_method (int argc, VALUE *argv, VALUE self)
879
862
  {
@@ -917,15 +900,13 @@ rb_ca_mask_fill (VALUE self, VALUE fval)
917
900
  return rb_ca_unmask_method(1, &fval, self);
918
901
  }
919
902
 
920
- /* rdoc:
921
- class CArray
922
- # Returns new unmasked array.
923
- # If the optional argument <code>fill_value</code> is given,
924
- # the masked elements are filled by <code>fill_value</code>.
925
- # The returned array doesn't have the mask array.
926
- def unmask_copy (fill_value=nil)
927
- end
928
- end
903
+ /* @overload unmask_copy (fill_value = nil)
904
+
905
+ (Masking, Conversion)
906
+ Returns new unmasked array.
907
+ If the optional argument <code>fill_value</code> is given,
908
+ the masked elements are filled by <code>fill_value</code>.
909
+ The returned array doesn't have the mask array.
929
910
  */
930
911
 
931
912
  static VALUE
@@ -970,7 +951,11 @@ rb_ca_mask_fill_copy (VALUE self, VALUE fval)
970
951
  return rb_ca_unmask_copy_method(1, &fval, self);
971
952
  }
972
953
 
973
- /* CArray#invert_mask */
954
+ /* @overload invert_mask
955
+
956
+ (Masking, Destructive)
957
+ Inverts mask state.
958
+ */
974
959
 
975
960
  VALUE
976
961
  rb_ca_invert_mask (VALUE self)
@@ -981,13 +966,11 @@ rb_ca_invert_mask (VALUE self)
981
966
  return self;
982
967
  }
983
968
 
984
- /* rdoc:
985
- class CArray
986
- # Sets the mask array of <code>self</code> by the logical sum of
987
- # the mask states of <code>self</code> and arrays given in arguments.
988
- def inherit_mask (*argv)
989
- end
990
- end
969
+ /* @overload inherit_mask (*others):
970
+
971
+ (Masking, Destructive)
972
+ Sets the mask array of <code>self</code> by the logical sum of
973
+ the mask states of <code>self</code> and arrays given in arguments.
991
974
  */
992
975
 
993
976
  static VALUE
@@ -1062,13 +1045,11 @@ rb_ca_inherit_mask (VALUE self, int n, ...)
1062
1045
  return self;
1063
1046
  }
1064
1047
 
1065
- /* rdoc:
1066
- class CArray
1067
- # Sets the mask array of <code>self</code> by the logical sum of
1068
- # the mask states of arrays given in arguments.
1069
- def inherit_mask_replace (*argv)
1070
- end
1071
- end
1048
+ /* @overload inherit_mask_replace (*others)
1049
+ Sets the mask array of <code>self</code> by the logical sum of
1050
+ the mask states of arrays given in arguments.
1051
+ This method does not inherit the mask states of itself (different point
1052
+ from `CArray#inherit_mask`)
1072
1053
  */
1073
1054
 
1074
1055
  static VALUE
@@ -1168,9 +1149,9 @@ Init_carray_mask ()
1168
1149
  rb_define_method(rb_cCArray, "inherit_mask_replace",
1169
1150
  rb_ca_inherit_mask_replace_method, -1);
1170
1151
 
1171
- /* These methods go to lib/carray/base.rb. */
1172
- /* rb_define_method(rb_cCArray, "count_masked", rb_ca_count_masked, 0); */
1173
- /* rb_define_method(rb_cCArray, "count_not_masked", rb_ca_count_not_masked, 0); */
1152
+ /* These methods go to lib/carray/mask.rb. */
1153
+ /* def count_masked (*axis); end */
1154
+ /* def count_not_masked (*axis); end */
1174
1155
 
1175
1156
  }
1176
1157