carray 1.3.6 → 1.5.3

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 (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,10 +3,8 @@
3
3
  ca_iter_dimension.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
 
@@ -15,13 +13,13 @@
15
13
 
16
14
  VALUE rb_cCADimIterator;
17
15
 
18
- /* rdoc:
16
+ /* yard:
19
17
  class CADimensionIterator < CAIterator # :nodoc:
20
18
  end
21
19
  */
22
20
 
23
21
  typedef struct {
24
- int8_t rank;
22
+ int8_t ndim;
25
23
  ca_size_t dim[CA_RANK_MAX];
26
24
  CArray *reference;
27
25
  CArray * (*kernel_at_addr)(void *, ca_size_t, CArray *);
@@ -50,14 +48,14 @@ ca_di_kernel_at_index (void *it, ca_size_t *idx, CArray *ref)
50
48
  else {
51
49
  CABlock *ck = (CABlock *)dit->kernel;
52
50
  kernel = ca_block_new(ref,
53
- ck->rank, ck->size0,
51
+ ck->ndim, ck->size0,
54
52
  ck->start, ck->step, ck->count,
55
53
  ck->offset);
56
54
  }
57
55
 
58
56
  ca_update_mask(kernel);
59
57
 
60
- for (i=0; i<dit->rank; i++) {
58
+ for (i=0; i<dit->ndim; i++) {
61
59
  val = idx[i];
62
60
  CA_CHECK_INDEX(val, dit->dim[i]);
63
61
  kernel->start[dit->symindex[i]] = val * kernel->step[dit->symindex[i]];
@@ -77,7 +75,7 @@ ca_di_kernel_at_addr (void *it, ca_size_t addr, CArray *ref)
77
75
  ca_size_t *dim = dit->dim;
78
76
  ca_size_t idx[CA_RANK_MAX];
79
77
  int8_t i;
80
- for (i=dit->rank-1; i>=0; i--) {
78
+ for (i=dit->ndim-1; i>=0; i--) {
81
79
  idx[i] = addr % dim[i];
82
80
  addr /= dim[i];
83
81
  }
@@ -94,7 +92,7 @@ ca_di_kernel_move_to_index (void *it, ca_size_t *idx, CArray *kern)
94
92
 
95
93
  ca_update_mask(kernel);
96
94
 
97
- for (i=0; i<dit->rank; i++) {
95
+ for (i=0; i<dit->ndim; i++) {
98
96
  val = idx[i];
99
97
  CA_CHECK_INDEX(val, dit->dim[i]);
100
98
  kernel->start[dit->symindex[i]] = val * kernel->step[dit->symindex[i]];
@@ -114,7 +112,7 @@ ca_di_kernel_move_to_addr (void *it, ca_size_t addr, CArray *ref)
114
112
  ca_size_t *dim = dit->dim;
115
113
  ca_size_t idx[CA_RANK_MAX];
116
114
  int8_t i;
117
- for (i=dit->rank-1; i>=0; i--) {
115
+ for (i=dit->ndim-1; i>=0; i--) {
118
116
  idx[i] = addr % dim[i];
119
117
  addr /= dim[i];
120
118
  }
@@ -129,7 +127,7 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
129
127
  volatile VALUE rindex, rker, rsymtbl;
130
128
  CADimIterator *it;
131
129
  CAIndexInfo blk_spec;
132
- int8_t rank;
130
+ int8_t ndim;
133
131
  int i, j, k;
134
132
 
135
133
  Data_Get_Struct(self, CADimIterator, it);
@@ -142,7 +140,7 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
142
140
 
143
141
  blk_spec = *info;
144
142
  blk_spec.type = CA_REG_BLOCK;
145
- for (i=0; i<info->rank; i++) {
143
+ for (i=0; i<info->ndim; i++) {
146
144
  if ( info->index_type[i] == CA_IDX_SYMBOL ) {
147
145
  blk_spec.index_type[i] = CA_IDX_ALL;
148
146
  rb_hash_aset(rsymtbl, ID2SYM(blk_spec.index[i].symbol.id), INT2NUM(i));
@@ -151,13 +149,13 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
151
149
 
152
150
  rref = rb_ca_ref_block(rref, &blk_spec);
153
151
 
154
- rindex = rb_ary_new2(info->rank);
155
- rank = 0;
152
+ rindex = rb_ary_new2(info->ndim);
153
+ ndim = 0;
156
154
 
157
155
  j = 0;
158
156
  k = 0;
159
157
 
160
- for (i=0; i<info->rank; i++) {
158
+ for (i=0; i<info->ndim; i++) {
161
159
  if ( info->index_type[i] == CA_IDX_SCALAR ) {
162
160
  rb_ary_store(rindex, i, SIZE2NUM(info->index[i].scalar));
163
161
  continue; /* escape from j++ */
@@ -165,8 +163,8 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
165
163
  else if ( info->index_type[i] == CA_IDX_SYMBOL ) {
166
164
  rb_ary_store(rindex, i, rb_ary_new3(1, SIZE2NUM(0)));
167
165
  it->symflag[j] = 1;
168
- it->symindex[rank] = j;
169
- rank++;
166
+ it->symindex[ndim] = j;
167
+ ndim++;
170
168
  }
171
169
  else if ( info->index_type[i] == CA_IDX_ALL ) {
172
170
  rb_ary_store(rindex, i, Qnil);
@@ -184,7 +182,7 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
184
182
 
185
183
  rker = rb_apply(rref, rb_intern("[]"), rindex);
186
184
 
187
- it->rank = rank;
185
+ it->ndim = ndim;
188
186
  Data_Get_Struct(rref, CArray, it->reference);
189
187
  Data_Get_Struct(rker, CArray, it->kernel);
190
188
  it->kernel_at_addr = ca_di_kernel_at_addr;
@@ -192,7 +190,7 @@ ca_di_setup (VALUE self, VALUE rref, CAIndexInfo *info)
192
190
  it->kernel_move_to_addr = ca_di_kernel_move_to_addr;
193
191
  it->kernel_move_to_index = ca_di_kernel_move_to_index;
194
192
 
195
- for (i=0; i<it->rank; i++) {
193
+ for (i=0; i<it->ndim; i++) {
196
194
  it->dim[i] = it->reference->dim[it->symindex[i]];
197
195
  }
198
196
 
@@ -239,7 +237,8 @@ rb_ca_dim_iterator (int argc, VALUE *argv, VALUE self)
239
237
 
240
238
  Data_Get_Struct(self, CArray, ca);
241
239
 
242
- rb_ca_scan_index(ca->rank, ca->dim, ca->elements, argc, argv, &info);
240
+ info.range_check = 1;
241
+ rb_ca_scan_index(ca->ndim, ca->dim, ca->elements, argc, argv, &info);
243
242
 
244
243
  obj = rb_di_s_allocate(rb_cCADimIterator);
245
244
  ca_di_setup(obj, self, &info);
@@ -258,7 +257,7 @@ rb_dim_iter_new (VALUE rref, CAIndexInfo *info)
258
257
  return obj;
259
258
  }
260
259
 
261
- /* rdoc:
260
+ /* yard:
262
261
  class CADimensionIterator
263
262
  def sym2dim (sym)
264
263
  end
@@ -3,17 +3,15 @@
3
3
  ca_iter_window.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
  typedef struct {
16
- int8_t rank;
14
+ int8_t ndim;
17
15
  ca_size_t dim[CA_RANK_MAX];
18
16
  CArray *reference;
19
17
  CArray * (*kernel_at_addr)(void *, ca_size_t, CArray *);
@@ -27,7 +25,7 @@ typedef struct {
27
25
 
28
26
  VALUE rb_cCAWindowIterator;
29
27
 
30
- /* rdoc:
28
+ /* yard:
31
29
  class CAWindowIterator < CAIterator # :nodoc:
32
30
  end
33
31
  */
@@ -59,7 +57,7 @@ ca_vi_kernel_at_index (void *it, ca_size_t *idx, CArray *ref)
59
57
 
60
58
  ca_update_mask(kernel);
61
59
 
62
- for (i=0; i<kernel->rank; i++) {
60
+ for (i=0; i<kernel->ndim; i++) {
63
61
  j = idx[i];
64
62
  CA_CHECK_INDEX(j, vit->dim[i]);
65
63
  kernel->start[i] = j - vit->offset[i];
@@ -78,7 +76,7 @@ ca_vi_kernel_at_addr (void *it, ca_size_t addr, CArray *ref)
78
76
  ca_size_t *dim = vit->dim;
79
77
  ca_size_t idx[CA_RANK_MAX];
80
78
  int8_t i;
81
- for (i=vit->rank-1; i>=0; i--) {
79
+ for (i=vit->ndim-1; i>=0; i--) {
82
80
  idx[i] = addr % dim[i];
83
81
  addr /= dim[i];
84
82
  }
@@ -97,7 +95,7 @@ ca_vi_kernel_move_to_index (void *it, ca_size_t *idx, CArray *kern)
97
95
 
98
96
  ca_update_mask(kernel);
99
97
 
100
- for (i=0; i<kernel->rank; i++) {
98
+ for (i=0; i<kernel->ndim; i++) {
101
99
  j = idx[i];
102
100
  CA_CHECK_INDEX(j, dim[i]);
103
101
  kernel->start[i] = j - offset[i];
@@ -116,7 +114,7 @@ ca_vi_kernel_move_to_addr (void *it, ca_size_t addr, CArray *ref)
116
114
  ca_size_t *dim = vit->dim;
117
115
  ca_size_t idx[CA_RANK_MAX];
118
116
  int8_t i;
119
- for (i=vit->rank-1; i>=0; i--) {
117
+ for (i=vit->ndim-1; i>=0; i--) {
120
118
  idx[i] = addr % dim[i];
121
119
  addr /= dim[i];
122
120
  }
@@ -136,12 +134,12 @@ ca_vi_setup (VALUE self, VALUE rref, VALUE rker)
136
134
  Data_Get_Struct(rref, CArray, ref);
137
135
  Data_Get_Struct(rker, CArray, ker);
138
136
 
139
- if ( ref->rank != ker->rank ) {
140
- rb_raise(rb_eRuntimeError, "rank mismatch between reference and kernel");
137
+ if ( ref->ndim != ker->ndim ) {
138
+ rb_raise(rb_eRuntimeError, "ndim mismatch between reference and kernel");
141
139
  }
142
140
 
143
- it->rank = ref->rank;
144
- memcpy(it->dim, ref->dim, it->rank * sizeof(ca_size_t));
141
+ it->ndim = ref->ndim;
142
+ memcpy(it->dim, ref->dim, it->ndim * sizeof(ca_size_t));
145
143
  it->reference = ref;
146
144
  it->kernel = ker;
147
145
  it->kernel_at_addr = ca_vi_kernel_at_addr;
@@ -149,7 +147,7 @@ ca_vi_setup (VALUE self, VALUE rref, VALUE rker)
149
147
  it->kernel_move_to_addr = ca_vi_kernel_move_to_addr;
150
148
  it->kernel_move_to_index = ca_vi_kernel_move_to_index;
151
149
 
152
- for (i=0; i<it->rank; i++) {
150
+ for (i=0; i<it->ndim; i++) {
153
151
  it->offset[i] = -(((CAWindow*)ker)->start[i]);
154
152
  }
155
153
 
@@ -3,10 +3,8 @@
3
3
  ca_obj_array.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
 
@@ -19,7 +17,7 @@
19
17
 
20
18
  VALUE rb_cCArray, rb_cCAWrap, rb_cCScalar, rb_cCAVirtual;
21
19
 
22
- /* rdoc:
20
+ /* yard:
23
21
  class CArray
24
22
  end
25
23
  class CAWrap < CArray # :nodoc:
@@ -42,7 +40,7 @@ double ca_mem_count = 0.0;
42
40
 
43
41
  /* Threshold for forced garbage collection and its default value */
44
42
  double ca_gc_interval;
45
- const double ca_default_gc_interval = 40.0; /* 40MB */
43
+ const double ca_default_gc_interval = 100.0; /* 100MB */
46
44
 
47
45
  #define MB (1024*1024)
48
46
 
@@ -60,27 +58,22 @@ ca_check_mem_count()
60
58
  }
61
59
  }
62
60
 
63
- /* rdoc:
64
- # returns the threshold of incremented memory (MB) used by carray object
65
- # until start GC.
66
- def CArray.gc_interval ()
67
- end
68
- # set the threshold of incremented memory (MB) used by carray object
69
- # until start GC.
70
- def CArray.gc_interval= (val)
71
- end
72
- # reset the counter for the GC start when the incremented memory
73
- # get larger than `CArray.gc_interval`.
74
- def CArray.reset_gc_interval ()
75
- end
76
- */
61
+ /* @private gc_interval
77
62
 
63
+ Returns the threshold of incremented memory (MB) used by carray object
64
+ until start GC.
65
+ */
78
66
  static VALUE
79
67
  rb_ca_get_gc_interval (VALUE self)
80
68
  {
81
69
  return rb_float_new(ca_gc_interval);
82
70
  }
83
71
 
72
+ /* @private gc_interval= (val)
73
+
74
+ Sets the threshold of incremented memory (MB) used by carray object
75
+ until start GC.
76
+ */
84
77
  static VALUE
85
78
  rb_ca_set_gc_interval (VALUE self, VALUE rth)
86
79
  {
@@ -92,6 +85,11 @@ rb_ca_set_gc_interval (VALUE self, VALUE rth)
92
85
  return rb_float_new(ca_gc_interval);
93
86
  }
94
87
 
88
+ /* @private reset_gc_inverval
89
+
90
+ Reset the counter for the GC start when the incremented memory
91
+ get larger than `CArray.gc_interval`.
92
+ */
95
93
  static VALUE
96
94
  rb_ca_reset_gc_interval (VALUE self)
97
95
  {
@@ -117,7 +115,7 @@ rb_ca_reset_gc_interval (VALUE self)
117
115
 
118
116
  static int
119
117
  carray_setup_i (CArray *ca,
120
- int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
118
+ int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
121
119
  CArray *mask, int allocate, int use_calloc)
122
120
  {
123
121
  ca_size_t elements;
@@ -127,14 +125,14 @@ carray_setup_i (CArray *ca,
127
125
 
128
126
  /* check arguments */
129
127
  CA_CHECK_DATA_TYPE(data_type);
130
- CA_CHECK_RANK(rank);
131
- CA_CHECK_DIM(rank, dim);
128
+ CA_CHECK_RANK(ndim);
129
+ CA_CHECK_DIM(ndim, dim);
132
130
  CA_CHECK_BYTES(data_type, bytes);
133
131
 
134
132
  /* calculate total number of elements */
135
133
  elements = 1;
136
134
  length = bytes;
137
- for (i=0; i<rank; i++) {
135
+ for (i=0; i<ndim; i++) {
138
136
  elements *= dim[i];
139
137
  length *= dim[i];
140
138
  }
@@ -153,11 +151,11 @@ carray_setup_i (CArray *ca,
153
151
 
154
152
  ca->data_type = data_type;
155
153
  ca->flags = 0;
156
- ca->rank = rank;
154
+ ca->ndim = ndim;
157
155
  ca->bytes = bytes;
158
156
  ca->elements = elements;
159
- ca->dim = ALLOC_N(ca_size_t, rank);
160
- memcpy(ca->dim, dim, rank*sizeof(ca_size_t));
157
+ ca->dim = ALLOC_N(ca_size_t, ndim);
158
+ memcpy(ca->dim, dim, ndim*sizeof(ca_size_t));
161
159
 
162
160
  if ( allocate ) { /* allocate == true */
163
161
 
@@ -201,26 +199,26 @@ carray_setup_i (CArray *ca,
201
199
 
202
200
  int
203
201
  carray_setup (CArray *ca,
204
- int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes, CArray *mask)
202
+ int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes, CArray *mask)
205
203
  {
206
- return carray_setup_i(ca, data_type, rank, dim, bytes, mask, 1, 0);
204
+ return carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 1, 0);
207
205
  }
208
206
 
209
207
  int
210
208
  carray_safe_setup (CArray *ca,
211
- int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes, CArray *mask)
209
+ int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes, CArray *mask)
212
210
  {
213
- return carray_setup_i(ca, data_type, rank, dim, bytes, mask, 1, 1);
211
+ return carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 1, 1);
214
212
  }
215
213
 
216
214
  int
217
215
  ca_wrap_setup (CArray *ca,
218
- int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
216
+ int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
219
217
  CArray *mask, char *ptr)
220
218
  {
221
219
  int ret;
222
220
 
223
- ret = carray_setup_i(ca, data_type, rank, dim, bytes, mask, 0, 0);
221
+ ret = carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 0, 0);
224
222
  if ( (!ptr) && (ca->elements != 0) ) {
225
223
  rb_raise(rb_eRuntimeError, "wrapping NULL pointer with an non-empty array");
226
224
  }
@@ -230,49 +228,49 @@ ca_wrap_setup (CArray *ca,
230
228
 
231
229
  int
232
230
  ca_wrap_setup_null (CArray *ca,
233
- int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
231
+ int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
234
232
  CArray *mask)
235
233
  {
236
234
  int ret;
237
235
 
238
- ret = carray_setup_i(ca, data_type, rank, dim, bytes, mask, 0, 0);
236
+ ret = carray_setup_i(ca, data_type, ndim, dim, bytes, mask, 0, 0);
239
237
  ca->ptr = NULL;
240
238
  return ret;
241
239
  }
242
240
 
243
241
  CArray *
244
- carray_new (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
242
+ carray_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
245
243
  CArray *mask)
246
244
  {
247
245
  CArray *ca = ALLOC(CArray);
248
- carray_setup(ca, data_type, rank, dim, bytes, mask);
246
+ carray_setup(ca, data_type, ndim, dim, bytes, mask);
249
247
  return ca;
250
248
  }
251
249
 
252
250
  CArray *
253
- carray_new_safe (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
251
+ carray_new_safe (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
254
252
  CArray *mask)
255
253
  {
256
254
  CArray *ca = ALLOC(CArray);
257
- carray_safe_setup(ca, data_type, rank, dim, bytes, mask);
255
+ carray_safe_setup(ca, data_type, ndim, dim, bytes, mask);
258
256
  return ca;
259
257
  }
260
258
 
261
259
  CAWrap *
262
- ca_wrap_new (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
260
+ ca_wrap_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
263
261
  CArray *mask, char *ptr)
264
262
  {
265
263
  CAWrap *ca = ALLOC(CAWrap);
266
- ca_wrap_setup(ca, data_type, rank, dim, bytes, mask, ptr);
264
+ ca_wrap_setup(ca, data_type, ndim, dim, bytes, mask, ptr);
267
265
  return ca;
268
266
  }
269
267
 
270
268
  CAWrap *
271
- ca_wrap_new_null (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
269
+ ca_wrap_new_null (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
272
270
  CArray *mask)
273
271
  {
274
272
  CAWrap *ca = ALLOC(CAWrap);
275
- ca_wrap_setup_null(ca, data_type, rank, dim, bytes, mask);
273
+ ca_wrap_setup_null(ca, data_type, ndim, dim, bytes, mask);
276
274
  return ca;
277
275
  }
278
276
 
@@ -313,7 +311,7 @@ cscalar_setup (CScalar *ca,
313
311
  ca->obj_type = CA_OBJ_SCALAR;
314
312
  ca->data_type = data_type;
315
313
  ca->flags = 0;
316
- ca->rank = 1;
314
+ ca->ndim = 1;
317
315
  ca->bytes = bytes;
318
316
  ca->elements = 1;
319
317
  ca->dim = &(ca->_dim);
@@ -388,7 +386,7 @@ ca_array_func_clone (void *ap)
388
386
  {
389
387
  CArray *ca = (CArray *) ap;
390
388
  CArray *co;
391
- co = carray_new(ca->data_type, ca->rank, ca->dim, ca->bytes, ca->mask);
389
+ co = carray_new(ca->data_type, ca->ndim, ca->dim, ca->bytes, ca->mask);
392
390
  memcpy(co->ptr, ca->ptr, ca_length(ca));
393
391
  return co;
394
392
  }
@@ -407,9 +405,9 @@ ca_array_func_ptr_at_index (void *ap, ca_size_t *idx)
407
405
  ca_size_t *dim = ca->dim;
408
406
  int8_t i;
409
407
  ca_size_t n;
410
- n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[rank-1] */
411
- for (i=1; i<ca->rank; i++) { /* + idx[1]*dim[1]*dim[2]*...*dim[rank-1] */
412
- n = dim[i]*n+idx[i]; /* ... + idx[rank-2]*dim[1] + idx[rank-1] */
408
+ n = idx[0]; /* n = idx[0]*dim[1]*dim[2]*...*dim[ndim-1] */
409
+ for (i=1; i<ca->ndim; i++) { /* + idx[1]*dim[1]*dim[2]*...*dim[ndim-1] */
410
+ n = dim[i]*n+idx[i]; /* ... + idx[ndim-2]*dim[1] + idx[ndim-1] */
413
411
  }
414
412
  return ca->ptr + ca->bytes * n;
415
413
  }
@@ -429,7 +427,7 @@ ca_array_func_fetch_index (void *ap, ca_size_t *idx, void *ptr)
429
427
  int8_t i;
430
428
  ca_size_t n;
431
429
  n = idx[0];
432
- for (i=1; i<ca->rank; i++) {
430
+ for (i=1; i<ca->ndim; i++) {
433
431
  n = dim[i]*n+idx[i];
434
432
  }
435
433
  memcpy(ptr, ca->ptr + ca->bytes * n, ca->bytes);
@@ -450,7 +448,7 @@ ca_array_func_store_index (void *ap, ca_size_t *idx, void *ptr)
450
448
  int8_t i;
451
449
  ca_size_t n;
452
450
  n = idx[0];
453
- for (i=1; i<ca->rank; i++) {
451
+ for (i=1; i<ca->ndim; i++) {
454
452
  n = dim[i]*n+idx[i];
455
453
  }
456
454
  memcpy(ca->ptr + ca->bytes * n, ptr, ca->bytes);
@@ -547,7 +545,7 @@ void
547
545
  ca_array_func_create_mask (void *ap)
548
546
  {
549
547
  CArray *ca = (CArray *) ap;
550
- ca->mask = carray_new_safe(CA_BOOLEAN, ca->rank, ca->dim, 0, NULL);
548
+ ca->mask = carray_new_safe(CA_BOOLEAN, ca->ndim, ca->dim, 0, NULL);
551
549
  }
552
550
 
553
551
  ca_operation_function_t ca_array_func = {
@@ -654,18 +652,27 @@ ca_operation_function_t ca_scalar_func = {
654
652
  /* ------------------------------------------------------------------- */
655
653
 
656
654
  VALUE
657
- rb_carray_new (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
655
+ rb_carray_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
658
656
  CArray *mask)
659
657
  {
660
- CArray *ca = carray_new(data_type, rank, dim, bytes, mask);
658
+ CArray *ca = carray_new(data_type, ndim, dim, bytes, mask);
661
659
  return ca_wrap_struct(ca);
662
660
  }
663
661
 
664
662
  VALUE
665
- rb_carray_new_safe (int8_t data_type, int8_t rank, ca_size_t *dim, ca_size_t bytes,
663
+ rb_carray_new_safe (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
666
664
  CArray *mask)
667
665
  {
668
- CArray *ca = carray_new_safe(data_type, rank, dim, bytes, mask);
666
+ CArray *ca = carray_new_safe(data_type, ndim, dim, bytes, mask);
667
+ return ca_wrap_struct(ca);
668
+ }
669
+
670
+
671
+ VALUE
672
+ rb_ca_wrap_new (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t bytes,
673
+ CArray *mask, char *ptr)
674
+ {
675
+ CAWrap *ca = ca_wrap_new(data_type, ndim, dim, bytes, mask, ptr);
669
676
  return ca_wrap_struct(ca);
670
677
  }
671
678
 
@@ -699,20 +706,16 @@ rb_ca_s_allocate (VALUE klass)
699
706
  return Data_Make_Struct(klass, CArray, ca_mark, ca_free, ca);
700
707
  }
701
708
 
702
- /* rdoc:
703
- # call-seq:
704
- # CArray.new(data_type, dim, bytes=0) { ... }
705
- #
706
- # Constructs a new CArray object of <i>data_type</i>, which has the
707
- # rank and the dimensions specified by an <code>Array</code> of
708
- # <code>Integer</code> or an argument list of <code>Integer</code>.
709
- # The byte size of each element for the fixed length data type
710
- # (<code>data_type == CA_FIXLEN</code>) is specified optional argument
711
- # <i>bytes</i>. Otherwise, this optional argument has no
712
- # effect. If the block is given, the new CArray
713
- # object will be initialized by the value returned from the block.
714
- def CArray.new(data_type, dim, bytes=0)
715
- end
709
+ /* @overload initialize(data_type, dim, bytes=0) { ... }
710
+
711
+ Constructs a new CArray object of <i>data_type</i>, which has the
712
+ ndim and the dimensions specified by an <code>Array</code> of
713
+ <code>Integer</code> or an argument list of <code>Integer</code>.
714
+ The byte size of each element for the fixed length data type
715
+ (<code>data_type == CA_FIXLEN</code>) is specified optional argument
716
+ <i>bytes</i>. Otherwise, this optional argument has no
717
+ effect. If the block is given, the new CArray
718
+ object will be initialized by the value returned from the block.
716
719
  */
717
720
 
718
721
  static VALUE
@@ -720,7 +723,7 @@ rb_ca_initialize (int argc, VALUE *argv, VALUE self)
720
723
  {
721
724
  volatile VALUE rtype, rdim, ropt, rbytes = Qnil;
722
725
  CArray *ca;
723
- int8_t data_type, rank;
726
+ int8_t data_type, ndim;
724
727
  ca_size_t dim[CA_RANK_MAX];
725
728
  ca_size_t bytes;
726
729
  int8_t i;
@@ -732,13 +735,13 @@ rb_ca_initialize (int argc, VALUE *argv, VALUE self)
732
735
  rb_ca_data_type_import(self, rtype);
733
736
 
734
737
  Check_Type(rdim, T_ARRAY);
735
- rank = RARRAY_LEN(rdim);
736
- for (i=0; i<rank; i++) {
738
+ ndim = RARRAY_LEN(rdim);
739
+ for (i=0; i<ndim; i++) {
737
740
  dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
738
741
  }
739
742
 
740
743
  Data_Get_Struct(self, CArray, ca);
741
- carray_safe_setup(ca, data_type, rank, dim, bytes, NULL);
744
+ carray_safe_setup(ca, data_type, ndim, dim, bytes, NULL);
742
745
 
743
746
  if ( rb_block_given_p() ) {
744
747
  volatile VALUE rval = rb_yield(self);
@@ -750,6 +753,12 @@ rb_ca_initialize (int argc, VALUE *argv, VALUE self)
750
753
  return Qnil;
751
754
  }
752
755
 
756
+ /* @overload fixlen(*dim, bytes: ) { ... }
757
+
758
+ (Construction)
759
+ Short-Hand of `CArray.new(:fixlen, dim, bytes: ) { ... }`
760
+ */
761
+
753
762
  static VALUE
754
763
  rb_ca_s_fixlen (int argc, VALUE *argv, VALUE klass)
755
764
  {
@@ -759,56 +768,184 @@ rb_ca_s_fixlen (int argc, VALUE *argv, VALUE klass)
759
768
  return rb_class_new_instance(3, args, klass);
760
769
  }
761
770
 
762
- #define rb_ca_s_type(type, code) \
763
- rb_ca_s_## type (int argc, VALUE *argv, VALUE klass) \
764
- { \
765
- volatile VALUE ropt = rb_pop_options(&argc, &argv); \
766
- volatile VALUE rdim = rb_ary_new4(argc, argv); \
767
- VALUE args[3] = { INT2NUM(code), rdim, ropt }; \
768
- return rb_class_new_instance(3, args, klass); \
771
+ #define rb_ca_s_body(code) \
772
+ { \
773
+ if ( argc == 0 ) { \
774
+ return ca_data_type_class(code); \
775
+ } \
776
+ else { \
777
+ volatile VALUE ropt = rb_pop_options(&argc, &argv); \
778
+ volatile VALUE rdim = rb_ary_new4(argc, argv); \
779
+ VALUE args[3] = { INT2NUM(code), rdim, ropt }; \
780
+ return rb_class_new_instance(3, args, klass); \
781
+ } \
769
782
  }
770
783
 
771
- /*
772
- * call-seq:
773
- * CArray.int8(dim0, dim1, ...) { ... } -> CArray
774
- * CArray.uint8(dim0, dim1, ...) { ... } -> CArray
775
- * CArray.int16(dim0, dim1, ...) { ... } -> CArray
776
- * CArray.uint16(dim0, dim1, ...) { ... } -> CArray
777
- * CArray.int32(dim0, dim1, ...) { ... } -> CArray
778
- * CArray.uint32(dim0, dim1, ...) { ... } -> CArray
779
- * CArray.int64(dim0, dim1, ...) { ... } -> CArray
780
- * CArray.uint64(dim0, dim1, ...) { ... } -> CArray
781
- * CArray.float32(dim0, dim1, ...) { ... } -> CArray
782
- * CArray.float64(dim0, dim1, ...) { ... } -> CArray
783
- * CArray.float128(dim0, dim1, ...) { ... } -> CArray
784
- * CArray.cmplx64(dim0, dim1, ...) { ... } -> CArray
785
- * CArray.cmplx128(dim0, dim1, ...) { ... } -> CArray
786
- * CArray.cmplx256(dim0, dim1, ...) { ... } -> CArray
787
- * CArray.object(dim0, dim1, ...) { ... } -> CArray
788
- *
789
- */
784
+ /* @overload boolean(*dim) { ... }
785
+
786
+ (Construction)
787
+ Short-Hand of `CArray.new(:boolean, dim, bytes: bytes) { ... }`
788
+ */
789
+ static VALUE rb_ca_s_boolean (int argc, VALUE *argv, VALUE klass)
790
+ {
791
+ rb_ca_s_body(CA_BOOLEAN);
792
+ }
793
+
794
+ /* @overload int8(*dim) { ... }
795
+
796
+ (Construction)
797
+ Short-Hand of `CArray.new(:int8, dim, bytes: bytes) { ... }`
798
+ */
799
+ static VALUE rb_ca_s_int8 (int argc, VALUE *argv, VALUE klass)
800
+ {
801
+ rb_ca_s_body(CA_INT8);
802
+ }
803
+
804
+ /* @overload uint8(*dim) { ... }
805
+
806
+ (Construction)
807
+ Short-Hand of `CArray.new(:uint8, dim, bytes: bytes) { ... }`
808
+ */
809
+ static VALUE rb_ca_s_uint8 (int argc, VALUE *argv, VALUE klass)
810
+ {
811
+ rb_ca_s_body(CA_UINT8);
812
+ }
813
+
814
+ /* @overload int16(*dim) { ... }
815
+
816
+ (Construction)
817
+ Short-Hand of `CArray.new(:int16, dim, bytes: bytes) { ... }`
818
+ */
819
+ static VALUE rb_ca_s_int16 (int argc, VALUE *argv, VALUE klass)
820
+ {
821
+ rb_ca_s_body(CA_INT16);
822
+ }
823
+
824
+ /* @overload uint16(*dim) { ... }
825
+
826
+ (Construction)
827
+ Short-Hand of `CArray.new(:uint16, dim, bytes: bytes) { ... }`
828
+ */
829
+ static VALUE rb_ca_s_uint16 (int argc, VALUE *argv, VALUE klass)
830
+ {
831
+ rb_ca_s_body(CA_UINT16);
832
+ }
833
+
834
+ /* @overload int32(*dim) { ... }
835
+
836
+ (Construction)
837
+ Short-Hand of `CArray.new(:int32, dim, bytes: bytes) { ... }`
838
+ */
839
+ static VALUE rb_ca_s_int32 (int argc, VALUE *argv, VALUE klass)
840
+ {
841
+ rb_ca_s_body(CA_INT32);
842
+ }
843
+
844
+ /* @overload uint32(*dim) { ... }
845
+
846
+ (Construction)
847
+ Short-Hand of `CArray.new(:uint32, dim, bytes: bytes) { ... }`
848
+ */
849
+ static VALUE rb_ca_s_uint32 (int argc, VALUE *argv, VALUE klass)
850
+ {
851
+ rb_ca_s_body(CA_UINT32);
852
+ }
853
+
854
+ /* @overload int64(*dim) { ... }
855
+
856
+ (Construction)
857
+ Short-Hand of `CArray.new(:int64, dim, bytes: bytes) { ... }`
858
+ */
859
+ static VALUE rb_ca_s_int64 (int argc, VALUE *argv, VALUE klass)
860
+ {
861
+ rb_ca_s_body(CA_INT64);
862
+ }
863
+
864
+ /* @overload uint64(*dim) { ... }
865
+
866
+ (Construction)
867
+ Short-Hand of `CArray.new(:uint64, dim, bytes: bytes) { ... }`
868
+ */
869
+ static VALUE rb_ca_s_uint64 (int argc, VALUE *argv, VALUE klass)
870
+ {
871
+ rb_ca_s_body(CA_UINT64);
872
+ }
873
+
874
+ /* @overload float32(*dim) { ... }
875
+
876
+ (Construction)
877
+ Short-Hand of `CArray.new(:float32, dim, bytes: bytes) { ... }`
878
+ */
879
+ static VALUE rb_ca_s_float32 (int argc, VALUE *argv, VALUE klass)
880
+ {
881
+ rb_ca_s_body(CA_FLOAT32);
882
+ }
883
+
884
+ /* @overload float64(*dim) { ... }
885
+
886
+ (Construction)
887
+ Short-Hand of `CArray.new(:float64, dim, bytes: bytes) { ... }`
888
+ */
889
+ static VALUE rb_ca_s_float64 (int argc, VALUE *argv, VALUE klass)
890
+ {
891
+ rb_ca_s_body(CA_FLOAT64);
892
+ }
893
+
894
+ /* @overload float128(*dim) { ... }
895
+
896
+ (Construction)
897
+ Short-Hand of `CArray.new(:float128, dim, bytes: bytes) { ... }`
898
+ */
899
+ static VALUE rb_ca_s_float128 (int argc, VALUE *argv, VALUE klass)
900
+ {
901
+ rb_ca_s_body(CA_FLOAT128);
902
+ }
790
903
 
791
- static VALUE rb_ca_s_VALUE();
792
-
793
- static VALUE rb_ca_s_type(boolean, CA_BOOLEAN);
794
- static VALUE rb_ca_s_type(int8, CA_INT8);
795
- static VALUE rb_ca_s_type(uint8, CA_UINT8);
796
- static VALUE rb_ca_s_type(int16, CA_INT16);
797
- static VALUE rb_ca_s_type(uint16, CA_UINT16);
798
- static VALUE rb_ca_s_type(int32, CA_INT32);
799
- static VALUE rb_ca_s_type(uint32, CA_UINT32);
800
- static VALUE rb_ca_s_type(int64, CA_INT64);
801
- static VALUE rb_ca_s_type(uint64, CA_UINT64);
802
- static VALUE rb_ca_s_type(float32, CA_FLOAT32);
803
- static VALUE rb_ca_s_type(float64, CA_FLOAT64);
804
- static VALUE rb_ca_s_type(float128, CA_FLOAT128);
805
904
  #ifdef HAVE_COMPLEX_H
806
- static VALUE rb_ca_s_type(cmplx64, CA_CMPLX64);
807
- static VALUE rb_ca_s_type(cmplx128, CA_CMPLX128);
808
- static VALUE rb_ca_s_type(cmplx256, CA_CMPLX256);
905
+ /* @overload cmplx64(*dim) { ... }
906
+
907
+ (Construction)
908
+ Short-Hand of `CArray.new(:cmplx64, dim, bytes: bytes) { ... }`
909
+ */
910
+ static VALUE rb_ca_s_cmplx64 (int argc, VALUE *argv, VALUE klass)
911
+ {
912
+ rb_ca_s_body(CA_CMPLX64);
913
+ }
914
+
915
+ /* @overload cmplx128(*dim) { ... }
916
+
917
+ (Construction)
918
+ Short-Hand of `CArray.new(:cmplx128, dim, bytes: bytes) { ... }`
919
+ */
920
+ static VALUE rb_ca_s_cmplx128 (int argc, VALUE *argv, VALUE klass)
921
+ {
922
+ rb_ca_s_body(CA_CMPLX128);
923
+ }
924
+
925
+ /* @overload cmplx256(*dim) { ... }
926
+
927
+ (Construction)
928
+ Short-Hand of `CArray.new(:cmplx256, dim, bytes: bytes) { ... }`
929
+ */
930
+ static VALUE rb_ca_s_cmplx256 (int argc, VALUE *argv, VALUE klass)
931
+ {
932
+ rb_ca_s_body(CA_CMPLX256);
933
+ }
809
934
  #endif
810
- static VALUE rb_ca_s_type(VALUE, CA_OBJECT);
811
935
 
936
+ /* @overload object(*dim) { ... }
937
+
938
+ (Construction)
939
+ Short-Hand of `CArray.new(:object, dim, bytes: bytes) { ... }`
940
+ */
941
+ static VALUE rb_ca_s_VALUE (int argc, VALUE *argv, VALUE klass)
942
+ {
943
+ rb_ca_s_body(CA_OBJECT);
944
+ }
945
+
946
+ /* @overload initialize_copy(other)
947
+
948
+ */
812
949
  static VALUE
813
950
  rb_ca_initialize_copy (VALUE self, VALUE other)
814
951
  {
@@ -820,16 +957,17 @@ rb_ca_initialize_copy (VALUE self, VALUE other)
820
957
  Data_Get_Struct(other, CArray, cs);
821
958
 
822
959
  ca_update_mask(cs);
823
- carray_setup(ca, cs->data_type, cs->rank, cs->dim, cs->bytes, cs->mask);
960
+ carray_setup(ca, cs->data_type, cs->ndim, cs->dim, cs->bytes, cs->mask);
824
961
 
825
962
  memcpy(ca->ptr, cs->ptr, ca_length(cs));
826
963
 
827
964
  return self;
828
965
  }
829
966
 
830
- /* rdoc:
831
- def CArray.wrap (data_type, dim, bytes=0) # { wrapped_object }
832
- end
967
+ /* @overload wrap (data_type, dim, bytes=0) { target }
968
+
969
+ [TBD] (Construction)
970
+ target should have method "wrap_as_carray(obj)"
833
971
  */
834
972
 
835
973
  static VALUE
@@ -837,7 +975,7 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
837
975
  {
838
976
  volatile VALUE obj, target, rtype, rdim, ropt, rbytes = Qnil;
839
977
  CArray *ca;
840
- int8_t data_type, rank;
978
+ int8_t data_type, ndim;
841
979
  ca_size_t dim[CA_RANK_MAX];
842
980
  ca_size_t bytes;
843
981
  int8_t i;
@@ -848,15 +986,15 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
848
986
  rb_ca_guess_type_and_bytes(rtype, rbytes, &data_type, &bytes);
849
987
 
850
988
  Check_Type(rdim, T_ARRAY);
851
- rank = RARRAY_LEN(rdim);
852
- for (i=0; i<rank; i++) {
989
+ ndim = RARRAY_LEN(rdim);
990
+ for (i=0; i<ndim; i++) {
853
991
  dim[i] = NUM2SIZE(rb_ary_entry(rdim, i));
854
992
  }
855
993
 
856
994
  target = rb_yield_values(0);
857
995
 
858
996
  obj = Data_Make_Struct(rb_cCAWrap, CAWrap, ca_mark, ca_free, ca);
859
- ca_wrap_setup_null(ca, data_type, rank, dim, bytes, NULL);
997
+ ca_wrap_setup_null(ca, data_type, ndim, dim, bytes, NULL);
860
998
 
861
999
  rb_funcall(target, rb_intern("wrap_as_carray"), 1, obj);
862
1000
  rb_ivar_set(obj, rb_intern("referred_object"), target);
@@ -865,13 +1003,13 @@ rb_ca_s_wrap (int argc, VALUE *argv, VALUE self)
865
1003
  }
866
1004
 
867
1005
  VALUE
868
- rb_carray_wrap_ptr (int8_t data_type, int8_t rank, ca_size_t *dim,
1006
+ rb_carray_wrap_ptr (int8_t data_type, int8_t ndim, ca_size_t *dim,
869
1007
  ca_size_t bytes, CArray *mask, char *ptr, VALUE refer)
870
1008
  {
871
1009
  volatile VALUE obj;
872
1010
  CArray *ca;
873
1011
 
874
- ca = ca_wrap_new(data_type, rank, dim, bytes, mask, ptr);
1012
+ ca = ca_wrap_new(data_type, ndim, dim, bytes, mask, ptr);
875
1013
  obj = ca_wrap_struct(ca);
876
1014
 
877
1015
  rb_ivar_set(obj, rb_intern("referred_object"), refer);
@@ -888,16 +1026,16 @@ rb_cs_s_allocate (VALUE klass)
888
1026
  return Data_Make_Struct(klass, CScalar, ca_mark, ca_free, ca);
889
1027
  }
890
1028
 
891
- /* rdoc:
892
- # call-seq:
893
- # CScalar.new(data_type, bytes=0) { ... }
894
- #
895
- # Constructs a new CScalar object of <i>data_type</i>.
896
- # The byte size of each element for the fixed length data type
897
- # (<code>data_type == CA_FIXLEN</code>) is specified optional argument
898
- # <i>bytes</i>. Otherwise, this optional argument has no
899
- # effect. If the block is given, the new CScalar
900
- # object will be initialized by the value returned from the block.
1029
+ /*
1030
+ call-seq:
1031
+ CScalar.new(data_type, bytes=0) { ... }
1032
+
1033
+ Constructs a new CScalar object of <i>data_type</i>.
1034
+ The byte size of each element for the fixed length data type
1035
+ (<code>data_type == CA_FIXLEN</code>) is specified optional argument
1036
+ <i>bytes</i>. Otherwise, this optional argument has no
1037
+ effect. If the block is given, the new CScalar
1038
+ object will be initialized by the value returned from the block.
901
1039
  def CScalar.new(data_type,bytes=0)
902
1040
  end
903
1041
  */
@@ -929,6 +1067,12 @@ rb_cs_initialize (int argc, VALUE *argv, VALUE self)
929
1067
  return Qnil;
930
1068
  }
931
1069
 
1070
+ /* @overload fixlen(*dim, bytes: ) { ... }
1071
+
1072
+ (Construction)
1073
+ Short-Hand of `CScalar.new(:fixlen, bytes: ) { ... }`
1074
+ */
1075
+
932
1076
  static VALUE
933
1077
  rb_cs_s_fixlen (int argc, VALUE *argv, VALUE klass)
934
1078
  {
@@ -940,8 +1084,7 @@ rb_cs_s_fixlen (int argc, VALUE *argv, VALUE klass)
940
1084
  return rb_class_new_instance(2, args, klass);
941
1085
  }
942
1086
 
943
- #define rb_cs_s_type(type, code) \
944
- rb_cs_s_## type (int argc, VALUE *argv, VALUE klass) \
1087
+ #define rb_cs_s_body(code) \
945
1088
  { \
946
1089
  volatile VALUE ropt = rb_pop_options(&argc, &argv); \
947
1090
  VALUE args[2] = { INT2NUM(code), ropt }; \
@@ -951,47 +1094,172 @@ rb_cs_s_## type (int argc, VALUE *argv, VALUE klass) \
951
1094
  return rb_class_new_instance(2, args, klass); \
952
1095
  }
953
1096
 
954
- static VALUE rb_cs_s_type(boolean, CA_BOOLEAN);
955
- static VALUE rb_cs_s_type(int8, CA_INT8);
956
- static VALUE rb_cs_s_type(uint8, CA_UINT8);
957
- static VALUE rb_cs_s_type(int16, CA_INT16);
958
- static VALUE rb_cs_s_type(uint16, CA_UINT16);
959
- static VALUE rb_cs_s_type(int32, CA_INT32);
960
- static VALUE rb_cs_s_type(uint32, CA_UINT32);
961
- static VALUE rb_cs_s_type(int64, CA_INT64);
962
- static VALUE rb_cs_s_type(uint64, CA_UINT64);
963
- static VALUE rb_cs_s_type(float32, CA_FLOAT32);
964
- static VALUE rb_cs_s_type(float64, CA_FLOAT64);
965
- static VALUE rb_cs_s_type(float128, CA_FLOAT128);
1097
+ /* @overload boolean() { ... }
1098
+
1099
+ (Construction)
1100
+ Short-Hand of `CArray.new(:boolean) { ... }`
1101
+ */
1102
+ static VALUE
1103
+ rb_cs_s_boolean (int argc, VALUE *argv, VALUE klass) {
1104
+ rb_cs_s_body(CA_BOOLEAN);
1105
+ }
1106
+
1107
+ /* @overload int8() { ... }
1108
+
1109
+ (Construction)
1110
+ Short-Hand of `CScalar.new(:int8) { ... }`
1111
+ */
1112
+ static VALUE
1113
+ rb_cs_s_int8 (int argc, VALUE *argv, VALUE klass) {
1114
+ rb_cs_s_body(CA_INT8);
1115
+ }
1116
+
1117
+ /* @overload uint8() { ... }
1118
+
1119
+ (Construction)
1120
+ Short-Hand of `CScalar.new(:uint8) { ... }`
1121
+ */
1122
+ static VALUE
1123
+ rb_cs_s_uint8 (int argc, VALUE *argv, VALUE klass) {
1124
+ rb_cs_s_body(CA_UINT8);
1125
+ }
1126
+
1127
+
1128
+ /* @overload int16() { ... }
1129
+
1130
+ (Construction)
1131
+ Short-Hand of `CScalar.new(:int16) { ... }`
1132
+ */
1133
+ static VALUE
1134
+ rb_cs_s_int16 (int argc, VALUE *argv, VALUE klass) {
1135
+ rb_cs_s_body(CA_INT16);
1136
+ }
1137
+
1138
+ /* @overload uint16() { ... }
1139
+
1140
+ (Construction)
1141
+ Short-Hand of `CScalar.new(:uint16) { ... }`
1142
+ */
1143
+ static VALUE
1144
+ rb_cs_s_uint16 (int argc, VALUE *argv, VALUE klass) {
1145
+ rb_cs_s_body(CA_UINT16);
1146
+ }
1147
+
1148
+ /* @overload int32() { ... }
1149
+
1150
+ (Construction)
1151
+ Short-Hand of `CScalar.new(:int32) { ... }`
1152
+ */
1153
+ static VALUE
1154
+ rb_cs_s_int32 (int argc, VALUE *argv, VALUE klass) {
1155
+ rb_cs_s_body(CA_INT32);
1156
+ }
1157
+
1158
+ /* @overload uint32() { ... }
1159
+
1160
+ (Construction)
1161
+ Short-Hand of `CScalar.new(:uint32) { ... }`
1162
+ */
1163
+ static VALUE
1164
+ rb_cs_s_uint32 (int argc, VALUE *argv, VALUE klass) {
1165
+ rb_cs_s_body(CA_UINT32);
1166
+ }
1167
+
1168
+ /* @overload int64() { ... }
1169
+
1170
+ (Construction)
1171
+ Short-Hand of `CScalar.new(:int64) { ... }`
1172
+ */
1173
+ static VALUE
1174
+ rb_cs_s_int64 (int argc, VALUE *argv, VALUE klass) {
1175
+ rb_cs_s_body(CA_INT64);
1176
+ }
1177
+
1178
+ /* @overload uint64() { ... }
1179
+
1180
+ (Construction)
1181
+ Short-Hand of `CScalar.new(:uint64) { ... }`
1182
+ */
1183
+ static VALUE
1184
+ rb_cs_s_uint64 (int argc, VALUE *argv, VALUE klass) {
1185
+ rb_cs_s_body(CA_UINT64);
1186
+ }
1187
+
1188
+ /* @overload float32() { ... }
1189
+
1190
+ (Construction)
1191
+ Short-Hand of `CScalar.new(:float32) { ... }`
1192
+ */
1193
+ static VALUE
1194
+ rb_cs_s_float32 (int argc, VALUE *argv, VALUE klass) {
1195
+ rb_cs_s_body(CA_FLOAT32);
1196
+ }
1197
+
1198
+ /* @overload float64() { ... }
1199
+
1200
+ (Construction)
1201
+ Short-Hand of `CScalar.new(:float64) { ... }`
1202
+ */
1203
+ static VALUE
1204
+ rb_cs_s_float64 (int argc, VALUE *argv, VALUE klass) {
1205
+ rb_cs_s_body(CA_FLOAT64);
1206
+ }
1207
+
1208
+ /* @overload float128() { ... }
1209
+
1210
+ (Construction)
1211
+ Short-Hand of `CScalar.new(:float128) { ... }`
1212
+ */
1213
+ static VALUE
1214
+ rb_cs_s_float128 (int argc, VALUE *argv, VALUE klass) {
1215
+ rb_cs_s_body(CA_FLOAT128);
1216
+ }
1217
+
966
1218
  #ifdef HAVE_COMPLEX_H
967
- static VALUE rb_cs_s_type(cmplx64, CA_CMPLX64);
968
- static VALUE rb_cs_s_type(cmplx128, CA_CMPLX128);
969
- static VALUE rb_cs_s_type(cmplx256, CA_CMPLX256);
1219
+ /* @overload cmplx64() { ... }
1220
+
1221
+ (Construction)
1222
+ Short-Hand of `CScalar.new(:cmplx64) { ... }`
1223
+ */
1224
+ static VALUE
1225
+ rb_cs_s_cmplx64 (int argc, VALUE *argv, VALUE klass) {
1226
+ rb_cs_s_body(CA_CMPLX64);
1227
+ }
1228
+
1229
+ /* @overload cmplx128() { ... }
1230
+
1231
+ (Construction)
1232
+ Short-Hand of `CScalar.new(:cmplx128) { ... }`
1233
+ */
1234
+ static VALUE
1235
+ rb_cs_s_cmplx128 (int argc, VALUE *argv, VALUE klass) {
1236
+ rb_cs_s_body(CA_CMPLX128);
1237
+ }
1238
+
1239
+ /* @overload cmplx256() { ... }
1240
+
1241
+ (Construction)
1242
+ Short-Hand of `CScalar.new(:cmplx256) { ... }`
1243
+ */
1244
+ static VALUE
1245
+ rb_cs_s_cmplx256 (int argc, VALUE *argv, VALUE klass) {
1246
+ rb_cs_s_body(CA_CMPLX256);
1247
+ }
970
1248
  #endif
971
- static VALUE rb_cs_s_type(VALUE, CA_OBJECT);
972
1249
 
973
- /*
974
- * call-seq:
975
- * CScalar.int8() { ... } -> CScalar
976
- * CScalar.uint8() { ... } -> CScalar
977
- * CScalar.int16() { ... } -> CScalar
978
- * CScalar.uint16() { ... } -> CScalar
979
- * CScalar.int32() { ... } -> CScalar
980
- * CScalar.uint32() { ... } -> CScalar
981
- * CScalar.int64() { ... } -> CScalar
982
- * CScalar.uint64() { ... } -> CScalar
983
- * CScalar.float32() { ... } -> CScalar
984
- * CScalar.float64() { ... } -> CScalar
985
- * CScalar.float128() { ... } -> CScalar
986
- * CScalar.cmplx64() { ... } -> CScalar
987
- * CScalar.cmplx128() { ... } -> CScalar
988
- * CScalar.cmplx256() { ... } -> CScalar
989
- * CScalar.object() { ... } -> CScalar
990
- *
991
- */
1250
+ /* @overload object() { ... }
992
1251
 
993
- static VALUE
994
- rb_cs_s_VALUE();
1252
+ (Construction)
1253
+ Short-Hand of `CScalar.new(:object) { ... }`
1254
+ */
1255
+ static VALUE
1256
+ rb_cs_s_VALUE (int argc, VALUE *argv, VALUE klass) {
1257
+ rb_cs_s_body(CA_OBJECT);
1258
+ }
1259
+
1260
+ /* @overload initialize_copy(other)
1261
+
1262
+ */
995
1263
 
996
1264
  static VALUE
997
1265
  rb_cs_initialize_copy (VALUE self, VALUE other)
@@ -1026,6 +1294,10 @@ rb_cs_coerce (VALUE self, VALUE other)
1026
1294
  }
1027
1295
  */
1028
1296
 
1297
+ /* @private
1298
+ @overload mem_usage
1299
+ */
1300
+
1029
1301
  static VALUE
1030
1302
  rb_ca_mem_usage (VALUE self)
1031
1303
  {
@@ -1041,7 +1313,10 @@ Init_ca_obj_array ()
1041
1313
 
1042
1314
  /* ------------------------------------------------------------------- */
1043
1315
  ca_gc_interval = ca_default_gc_interval;
1316
+
1317
+ /* @private */
1044
1318
  rb_define_const(rb_cCArray, "DEFAULT_GC_INTERVAL", rb_float_new(ca_default_gc_interval));
1319
+
1045
1320
  rb_define_singleton_method(rb_cCArray, "gc_interval", rb_ca_get_gc_interval, 0);
1046
1321
  rb_define_singleton_method(rb_cCArray, "gc_interval=", rb_ca_set_gc_interval, 1);
1047
1322
  rb_define_singleton_method(rb_cCArray, "reset_gc_interval", rb_ca_reset_gc_interval, 0);
@@ -1130,7 +1405,7 @@ Init_ca_obj_array ()
1130
1405
  }
1131
1406
 
1132
1407
 
1133
- /* rdoc:
1408
+ /* yard:
1134
1409
  # call-seq:
1135
1410
  # CArray.boolean(...) { init_value }
1136
1411
  # CArray.int8(...) { init_value }