carray 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (174) hide show
  1. checksums.yaml +4 -4
  2. data/{LICENSES → LICENSE} +0 -0
  3. data/NEWS.md +42 -0
  4. data/README.md +5 -5
  5. data/TODO.md +16 -0
  6. data/carray.gemspec +9 -5
  7. data/ext/ca_iter_block.c +3 -5
  8. data/ext/ca_iter_dimension.c +4 -5
  9. data/ext/ca_iter_window.c +2 -4
  10. data/ext/ca_obj_array.c +394 -124
  11. data/ext/ca_obj_bitarray.c +3 -5
  12. data/ext/ca_obj_bitfield.c +3 -5
  13. data/ext/ca_obj_block.c +6 -8
  14. data/ext/ca_obj_fake.c +3 -5
  15. data/ext/ca_obj_farray.c +3 -5
  16. data/ext/ca_obj_field.c +15 -17
  17. data/ext/ca_obj_grid.c +5 -6
  18. data/ext/ca_obj_mapping.c +2 -4
  19. data/ext/ca_obj_object.c +3 -5
  20. data/ext/ca_obj_reduce.c +2 -4
  21. data/ext/ca_obj_refer.c +5 -7
  22. data/ext/ca_obj_repeat.c +2 -4
  23. data/ext/ca_obj_select.c +2 -4
  24. data/ext/ca_obj_shift.c +3 -5
  25. data/ext/ca_obj_transpose.c +3 -5
  26. data/ext/ca_obj_unbound_repeat.c +58 -81
  27. data/ext/ca_obj_window.c +7 -9
  28. data/ext/carray.h +13 -8
  29. data/ext/carray_access.c +111 -18
  30. data/ext/carray_attribute.c +136 -197
  31. data/ext/carray_call_cfunc.c +1 -3
  32. data/ext/carray_cast.c +344 -143
  33. data/ext/carray_cast_func.rb +1 -2
  34. data/ext/carray_class.c +28 -36
  35. data/ext/carray_conversion.c +49 -59
  36. data/ext/carray_copy.c +16 -32
  37. data/ext/carray_core.c +51 -44
  38. data/ext/carray_element.c +25 -44
  39. data/ext/carray_generate.c +71 -50
  40. data/ext/carray_iterator.c +13 -15
  41. data/ext/carray_loop.c +53 -82
  42. data/ext/carray_mask.c +87 -117
  43. data/ext/carray_math.rb +8 -10
  44. data/ext/carray_mathfunc.c +1 -3
  45. data/ext/carray_numeric.c +19 -3
  46. data/ext/carray_operator.c +45 -32
  47. data/ext/carray_order.c +72 -65
  48. data/ext/carray_sort_addr.c +14 -21
  49. data/ext/carray_stat.c +1 -3
  50. data/ext/carray_stat_proc.rb +2 -4
  51. data/ext/carray_test.c +28 -30
  52. data/ext/carray_undef.c +1 -3
  53. data/ext/carray_utils.c +12 -4
  54. data/ext/extconf.rb +1 -1
  55. data/ext/mkmath.rb +1 -1
  56. data/ext/ruby_carray.c +11 -6
  57. data/ext/ruby_ccomplex.c +1 -3
  58. data/ext/ruby_float_func.c +1 -3
  59. data/ext/version.h +5 -7
  60. data/lib/carray.rb +2 -0
  61. data/lib/carray/autoload/autoload_gem_numo_narray.rb +6 -6
  62. data/lib/carray/broadcast.rb +45 -0
  63. data/lib/carray/construct.rb +21 -4
  64. data/lib/carray/iterator.rb +1 -0
  65. data/lib/carray/ordering.rb +28 -2
  66. data/spec/Classes/CABitfield_spec.rb +58 -0
  67. data/spec/Classes/CABlockIterator_spec.rb +114 -0
  68. data/spec/Classes/CABlock_spec.rb +205 -0
  69. data/spec/Classes/CAField_spec.rb +39 -0
  70. data/spec/Classes/CAGrid_spec.rb +75 -0
  71. data/spec/Classes/CAMap_spec.rb +0 -0
  72. data/{test/test_CAMapping.rb → spec/Classes/CAMapping_spec.rb} +35 -36
  73. data/spec/Classes/CAObject_attribute_spec.rb +33 -0
  74. data/spec/Classes/CAObject_spec.rb +33 -0
  75. data/spec/Classes/CARefer_spec.rb +93 -0
  76. data/spec/Classes/CARepeat_spec.rb +65 -0
  77. data/spec/Classes/CASelect_spec.rb +22 -0
  78. data/spec/Classes/CAShift_spec.rb +16 -0
  79. data/spec/Classes/CAStruct_spec.rb +71 -0
  80. data/{test/test_CATranspose.rb → spec/Classes/CATranspose_spec.rb} +20 -21
  81. data/spec/Classes/CAUnboudRepeat_spec.rb +78 -0
  82. data/spec/Classes/CAWindow_spec.rb +54 -0
  83. data/spec/Classes/CAWrap_spec.rb +8 -0
  84. data/{test/test_CArray.rb → spec/Classes/CArray_spec.rb} +48 -92
  85. data/spec/Classes/CScalar_spec.rb +55 -0
  86. data/spec/Features/feature_130_spec.rb +19 -0
  87. data/spec/Features/feature_attributes_spec.rb +280 -0
  88. data/spec/Features/feature_boolean_spec.rb +97 -0
  89. data/spec/Features/feature_broadcast.rb +100 -0
  90. data/spec/Features/feature_cast_function.rb +19 -0
  91. data/spec/Features/feature_cast_spec.rb +33 -0
  92. data/spec/Features/feature_class_spec.rb +84 -0
  93. data/spec/Features/feature_complex_spec.rb +42 -0
  94. data/{test/test_composite.rb → spec/Features/feature_composite_spec.rb} +17 -18
  95. data/spec/Features/feature_convert_spec.rb +46 -0
  96. data/spec/Features/feature_copy_spec.rb +123 -0
  97. data/spec/Features/feature_creation_spec.rb +84 -0
  98. data/spec/Features/feature_element_spec.rb +144 -0
  99. data/spec/Features/feature_extream_spec.rb +54 -0
  100. data/spec/Features/feature_generate_spec.rb +74 -0
  101. data/spec/Features/feature_index_spec.rb +69 -0
  102. data/spec/Features/feature_mask_spec.rb +574 -0
  103. data/spec/Features/feature_math_spec.rb +97 -0
  104. data/spec/Features/feature_order_spec.rb +146 -0
  105. data/spec/Features/feature_ref_store_spec.rb +209 -0
  106. data/spec/Features/feature_serialization_spec.rb +125 -0
  107. data/spec/Features/feature_stat_spec.rb +397 -0
  108. data/spec/Features/feature_virtual_spec.rb +48 -0
  109. data/spec/Features/method_eq_spec.rb +81 -0
  110. data/spec/Features/method_is_nan_spec.rb +12 -0
  111. data/spec/Features/method_map_spec.rb +54 -0
  112. data/spec/Features/method_max_with.rb +20 -0
  113. data/spec/Features/method_min_with.rb +19 -0
  114. data/spec/Features/method_ne_spec.rb +18 -0
  115. data/spec/Features/method_project_spec.rb +188 -0
  116. data/spec/Features/method_ref_spec.rb +27 -0
  117. data/spec/Features/method_round_spec.rb +11 -0
  118. data/spec/Features/method_s_linspace_spec.rb +48 -0
  119. data/spec/Features/method_s_span_spec.rb +14 -0
  120. data/spec/Features/method_seq_spec.rb +47 -0
  121. data/spec/Features/method_sort_with.rb +43 -0
  122. data/spec/Features/method_sorted_with.rb +29 -0
  123. data/spec/Features/method_span_spec.rb +42 -0
  124. data/spec/Features/method_wrap_readonly_spec.rb +43 -0
  125. data/{test → spec/UnitTest}/test_CAVirtual.rb +0 -0
  126. data/spec/spec_all.rb +0 -1
  127. data/utils/convert_test.rb +73 -0
  128. data/utils/{extract_rdoc.rb → extract_yard.rb} +7 -12
  129. metadata +77 -60
  130. data/spec/CABlockIterator/CABlockIterator_spec.rb +0 -113
  131. data/spec/CArray/bug/store_spec.rb +0 -27
  132. data/spec/CArray/index/repeat_spec.rb +0 -10
  133. data/spec/CArray/method/eq_spec.rb +0 -80
  134. data/spec/CArray/method/is_nan_spec.rb +0 -12
  135. data/spec/CArray/method/ne_spec.rb +0 -18
  136. data/spec/CArray/method/round_spec.rb +0 -11
  137. data/spec/CArray/object/_attribute_spec.rb +0 -32
  138. data/spec/CArray/object/s_new_spec.rb +0 -31
  139. data/spec/CArray/serialize/Serialization_spec.rb +0 -89
  140. data/test/test_130.rb +0 -23
  141. data/test/test_ALL.rb +0 -49
  142. data/test/test_CABitfield.rb +0 -59
  143. data/test/test_CABlock.rb +0 -208
  144. data/test/test_CAField.rb +0 -40
  145. data/test/test_CAGrid.rb +0 -76
  146. data/test/test_CAMmap.rb +0 -11
  147. data/test/test_CARefer.rb +0 -94
  148. data/test/test_CARepeat.rb +0 -66
  149. data/test/test_CASelect.rb +0 -23
  150. data/test/test_CAShift.rb +0 -17
  151. data/test/test_CAWindow.rb +0 -55
  152. data/test/test_CAWrap.rb +0 -9
  153. data/test/test_CComplex.rb +0 -83
  154. data/test/test_CScalar.rb +0 -91
  155. data/test/test_attribute.rb +0 -281
  156. data/test/test_block_iterator.rb +0 -17
  157. data/test/test_boolean.rb +0 -99
  158. data/test/test_cast.rb +0 -33
  159. data/test/test_class.rb +0 -85
  160. data/test/test_complex.rb +0 -43
  161. data/test/test_convert.rb +0 -79
  162. data/test/test_copy.rb +0 -141
  163. data/test/test_creation.rb +0 -85
  164. data/test/test_element.rb +0 -146
  165. data/test/test_extream.rb +0 -55
  166. data/test/test_generate.rb +0 -75
  167. data/test/test_index.rb +0 -71
  168. data/test/test_mask.rb +0 -578
  169. data/test/test_math.rb +0 -98
  170. data/test/test_order.rb +0 -147
  171. data/test/test_ref_store.rb +0 -211
  172. data/test/test_stat.rb +0 -406
  173. data/test/test_struct.rb +0 -72
  174. data/test/test_virtual.rb +0 -49
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9609f31c4eacaf87ca9881eff5e29e30cfde413086a30b0ee99e02d9142b105f
4
- data.tar.gz: 68c4a6919c28b78ee9c9fd7a469b65ef8069a6ceba880f37a1a32f37f3de24d2
3
+ metadata.gz: 519ed0ddc6f3cf2268a644428085e86ab3926aba4798400586e33e33b21a27e3
4
+ data.tar.gz: ea59dd3b333f4d707db96ce2a4f945a9c4508baa32a70bfbd1882a250b4279e3
5
5
  SHA512:
6
- metadata.gz: 910d317c356accdc8852490a209991443f964e2e9e3896b41b62456104699049fa99d59341a176eba752d83b49765044c1282b9b1a439f8ba949c661b2950689
7
- data.tar.gz: 7036c72836edf32445979d8d72312da7b2c8a68e9a15101f75caa4a6ea804d97254ba9cc76c99b8bde691d0049ca8474ab88924c0acfdc6e73b84d9098077d37
6
+ metadata.gz: 6fcf6cd610bbeaf160396ff553ea2ed8f0a4faff97836824b13f1e5d426b13bc068c7ae3c938b4f426a95a0e7928f58ae7c9af83d79b713f069ddbec4ab85cf7
7
+ data.tar.gz: d9bc322d676d67ea423ac9f370230d72c8331392b0fba7b77ee34712bf8e1b5d7b337dfdcfe79bf0b0fce374f88e78dcb197da433b46dc866d7142f358a1b0d9
File without changes
data/NEWS.md ADDED
@@ -0,0 +1,42 @@
1
+ ChangeLog of Ruby/CArray
2
+ ========================
3
+
4
+ 1.5.1 -> 1.5.2
5
+ --------------
6
+
7
+ * [New] Add new method 'CArray#sorted_with'
8
+ * [New] Add new method 'CArray#sort_with'
9
+ * [New] Add new method 'CArray#max_with'
10
+ * [New] Add new method 'CArray#min_with'
11
+ * [New] Add new method 'CArray.broadcast'
12
+ * [New] Add new method 'CArray#broadcast_to', 'CScalar#broadcast_to'
13
+ * [New] Add new API function `rb_ca_wrap_new`
14
+ * [Mod] Modify 'CArray#linspace' to return float64 array for integer arguments
15
+ * [Mod] Modify CAUnboundRepeat to have `ndim` same as the bounded array (before `ndim` same as parent array)
16
+ * [Mod] Depret the obsolete mothod 'CArray#dump'.
17
+ * [Mod] Depret the obsolete mothod 'CArray#load'.
18
+ * [Mod] Modify CArray.wrap_readonly to wrap string as array.
19
+ * [Fix] Add support for Integer (same as for Fixnum, Bignum)
20
+
21
+ 1.5.0 -> 1.5.1
22
+ --------------
23
+
24
+ * [New] Add data type classes like 'Float64' ... to provide the methods like 'CArray::Float64.linspace'
25
+ * [Mod] Modify 'CArray.float64' ... without aruguments to return the corresponding data type class
26
+ * [Fix] Move C extension files into 'ext/'
27
+ * [Fix] Rename member 'rank' to 'ndim' in struct CArray in C extension
28
+ * [Fix] Remove 'CArray#shuffle' (gone to 'carray-random' gem)
29
+ * [Fix] Remove dependencies on 'rb_secure()' and 'rb_safe_level()'
30
+ * [Fix] Modify 'CArray#span' to handle fractional step for integer array
31
+ * [Obsolete] Set obsolete flag to 'CAIterator#sort_with'
32
+
33
+ 1.4.0 -> 1.5.0
34
+ --------------
35
+
36
+ * [Mod] Remove 'Carray#random!' (gone to 'carray-random' gem)
37
+ * [Mod] Relocate file 'lib/carray/io/table.rb' to 'lib/carray/table.rb'
38
+ * [Mod] Rename class 'CA::TableMethods' to 'CArray::TableMethods'
39
+ * [Mod] Rename method 'CArray#cast_other' to 'CArray#cast_with'
40
+ * [Mod] Change license from "Ruby's" to "MIT"
41
+ * [Mod] Remove files 'COPYING', 'LEGAL'(for MT), 'GPL'
42
+ * [Fix] Fix bug lib/carray/struct.rb
data/README.md CHANGED
@@ -28,11 +28,11 @@ Requirements
28
28
  Directories
29
29
  -----------
30
30
 
31
- . - Ruby/CArray extension source codes
32
- lib - Ruby/CArray standard library in Ruby
33
- test - some unit tests (incomplete)
34
- spec - some rspec (incomplete)
35
- utils - support tools for development.
31
+ lib - Ruby sorce codes
32
+ ext - C extension source codes
33
+ utils - support tools for development
34
+ spec - rspec files
35
+ misc - misc files
36
36
 
37
37
  Licenses
38
38
  --------
data/TODO.md ADDED
@@ -0,0 +1,16 @@
1
+ ToDo List
2
+ =========
3
+
4
+ ToDo
5
+ -------
6
+
7
+ * Create spec
8
+ - str_format (cyclic format)
9
+ - CA_SIZE
10
+ * Remove RSTRUCT hack in carray_access.c for handling of Range object.
11
+ * Implement CArray.broadcast in C
12
+ * Solve abs probrems
13
+
14
+ Done
15
+ -------
16
+
@@ -1,6 +1,6 @@
1
1
  Gem::Specification::new do |s|
2
2
 
3
- version = "1.5.1"
3
+ version = "1.5.2"
4
4
 
5
5
  files = Dir.glob("**/*") - [
6
6
  Dir.glob("carray-*.gem"),
@@ -14,10 +14,14 @@ Gem::Specification::new do |s|
14
14
  s.name = "carray"
15
15
  s.summary = "Multi-dimesional array class for Ruby"
16
16
  s.description = <<-HERE
17
- CArray is a uniform multi-dimensional rectangular array class.
18
- It provides the various types of sub-arrays and references
19
- pointing the data elements of original array (slice, grid, selection ...).
20
- Element-wise masking and mathematical operations are natively supported.
17
+ Ruby/CArray is an extension library for the multi-dimensional array class.
18
+ CArray can store integers and floating point numbers to perform calculations
19
+ efficiently. Therefore, Ruby/CArray is suitable for numerical computation and data
20
+ analysis. Ruby/CArray has different features from other multidimensional array
21
+ libraries (narray, numo-narray, nmatrix), such as element-specific masks,
22
+ creation of reference arrays that can reflect changes to the referent,
23
+ the ability to access memory pointers of other objects, user-defined arrays,
24
+ and so on.
21
25
  HERE
22
26
  s.version = version
23
27
  s.author = "Hiroki Motoyoshi"
@@ -3,16 +3,14 @@
3
3
  ca_iter_block.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
- /* rdoc:
13
+ /* yard:
16
14
  class CABlockIterator < CAIterator # :nodoc:
17
15
  end
18
16
  */
@@ -202,7 +200,7 @@ rb_bi_initialize_copy (VALUE self, VALUE other)
202
200
  return self;
203
201
  }
204
202
 
205
- /* rdoc:
203
+ /* yard:
206
204
  class CArray
207
205
  # Create block iterator.
208
206
  def blocks (*args)
@@ -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,7 +13,7 @@
15
13
 
16
14
  VALUE rb_cCADimIterator;
17
15
 
18
- /* rdoc:
16
+ /* yard:
19
17
  class CADimensionIterator < CAIterator # :nodoc:
20
18
  end
21
19
  */
@@ -239,6 +237,7 @@ rb_ca_dim_iterator (int argc, VALUE *argv, VALUE self)
239
237
 
240
238
  Data_Get_Struct(self, CArray, ca);
241
239
 
240
+ info.range_check = 1;
242
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);
@@ -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,10 +3,8 @@
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
 
@@ -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
  */
@@ -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:
@@ -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
  {
@@ -669,6 +667,15 @@ rb_carray_new_safe (int8_t data_type, int8_t ndim, ca_size_t *dim, ca_size_t byt
669
667
  return ca_wrap_struct(ca);
670
668
  }
671
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);
676
+ return ca_wrap_struct(ca);
677
+ }
678
+
672
679
  VALUE
673
680
  rb_cscalar_new (int8_t data_type, ca_size_t bytes, CArray *mask)
674
681
  {
@@ -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
- # ndim 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
@@ -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,8 +768,7 @@ 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) \
771
+ #define rb_ca_s_body(code) \
764
772
  { \
765
773
  if ( argc == 0 ) { \
766
774
  return ca_data_type_class(code); \
@@ -773,47 +781,171 @@ rb_ca_s_## type (int argc, VALUE *argv, VALUE klass) \
773
781
  } \
774
782
  }
775
783
 
776
- /*
777
- * call-seq:
778
- * CArray.int8(dim0, dim1, ...) { ... } -> CArray
779
- * CArray.uint8(dim0, dim1, ...) { ... } -> CArray
780
- * CArray.int16(dim0, dim1, ...) { ... } -> CArray
781
- * CArray.uint16(dim0, dim1, ...) { ... } -> CArray
782
- * CArray.int32(dim0, dim1, ...) { ... } -> CArray
783
- * CArray.uint32(dim0, dim1, ...) { ... } -> CArray
784
- * CArray.int64(dim0, dim1, ...) { ... } -> CArray
785
- * CArray.uint64(dim0, dim1, ...) { ... } -> CArray
786
- * CArray.float32(dim0, dim1, ...) { ... } -> CArray
787
- * CArray.float64(dim0, dim1, ...) { ... } -> CArray
788
- * CArray.float128(dim0, dim1, ...) { ... } -> CArray
789
- * CArray.cmplx64(dim0, dim1, ...) { ... } -> CArray
790
- * CArray.cmplx128(dim0, dim1, ...) { ... } -> CArray
791
- * CArray.cmplx256(dim0, dim1, ...) { ... } -> CArray
792
- * CArray.object(dim0, dim1, ...) { ... } -> CArray
793
- *
794
- */
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
+ }
795
903
 
796
- static VALUE rb_ca_s_VALUE();
797
-
798
- static VALUE rb_ca_s_type(boolean, CA_BOOLEAN);
799
- static VALUE rb_ca_s_type(int8, CA_INT8);
800
- static VALUE rb_ca_s_type(uint8, CA_UINT8);
801
- static VALUE rb_ca_s_type(int16, CA_INT16);
802
- static VALUE rb_ca_s_type(uint16, CA_UINT16);
803
- static VALUE rb_ca_s_type(int32, CA_INT32);
804
- static VALUE rb_ca_s_type(uint32, CA_UINT32);
805
- static VALUE rb_ca_s_type(int64, CA_INT64);
806
- static VALUE rb_ca_s_type(uint64, CA_UINT64);
807
- static VALUE rb_ca_s_type(float32, CA_FLOAT32);
808
- static VALUE rb_ca_s_type(float64, CA_FLOAT64);
809
- static VALUE rb_ca_s_type(float128, CA_FLOAT128);
810
904
  #ifdef HAVE_COMPLEX_H
811
- static VALUE rb_ca_s_type(cmplx64, CA_CMPLX64);
812
- static VALUE rb_ca_s_type(cmplx128, CA_CMPLX128);
813
- 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
+ }
814
934
  #endif
815
- static VALUE rb_ca_s_type(VALUE, CA_OBJECT);
816
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
+ */
817
949
  static VALUE
818
950
  rb_ca_initialize_copy (VALUE self, VALUE other)
819
951
  {
@@ -832,9 +964,10 @@ rb_ca_initialize_copy (VALUE self, VALUE other)
832
964
  return self;
833
965
  }
834
966
 
835
- /* rdoc:
836
- def CArray.wrap (data_type, dim, bytes=0) # { wrapped_object }
837
- end
967
+ /* @overload wrap (data_type, dim, bytes=0) { target }
968
+
969
+ [TBD] (Construction)
970
+ target should have method "wrap_as_carray(obj)"
838
971
  */
839
972
 
840
973
  static VALUE
@@ -893,16 +1026,16 @@ rb_cs_s_allocate (VALUE klass)
893
1026
  return Data_Make_Struct(klass, CScalar, ca_mark, ca_free, ca);
894
1027
  }
895
1028
 
896
- /* rdoc:
897
- # call-seq:
898
- # CScalar.new(data_type, bytes=0) { ... }
899
- #
900
- # Constructs a new CScalar object of <i>data_type</i>.
901
- # The byte size of each element for the fixed length data type
902
- # (<code>data_type == CA_FIXLEN</code>) is specified optional argument
903
- # <i>bytes</i>. Otherwise, this optional argument has no
904
- # effect. If the block is given, the new CScalar
905
- # 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.
906
1039
  def CScalar.new(data_type,bytes=0)
907
1040
  end
908
1041
  */
@@ -934,6 +1067,12 @@ rb_cs_initialize (int argc, VALUE *argv, VALUE self)
934
1067
  return Qnil;
935
1068
  }
936
1069
 
1070
+ /* @overload fixlen(*dim, bytes: ) { ... }
1071
+
1072
+ (Construction)
1073
+ Short-Hand of `CScalar.new(:fixlen, bytes: ) { ... }`
1074
+ */
1075
+
937
1076
  static VALUE
938
1077
  rb_cs_s_fixlen (int argc, VALUE *argv, VALUE klass)
939
1078
  {
@@ -945,8 +1084,7 @@ rb_cs_s_fixlen (int argc, VALUE *argv, VALUE klass)
945
1084
  return rb_class_new_instance(2, args, klass);
946
1085
  }
947
1086
 
948
- #define rb_cs_s_type(type, code) \
949
- rb_cs_s_## type (int argc, VALUE *argv, VALUE klass) \
1087
+ #define rb_cs_s_body(code) \
950
1088
  { \
951
1089
  volatile VALUE ropt = rb_pop_options(&argc, &argv); \
952
1090
  VALUE args[2] = { INT2NUM(code), ropt }; \
@@ -956,47 +1094,172 @@ rb_cs_s_## type (int argc, VALUE *argv, VALUE klass) \
956
1094
  return rb_class_new_instance(2, args, klass); \
957
1095
  }
958
1096
 
959
- static VALUE rb_cs_s_type(boolean, CA_BOOLEAN);
960
- static VALUE rb_cs_s_type(int8, CA_INT8);
961
- static VALUE rb_cs_s_type(uint8, CA_UINT8);
962
- static VALUE rb_cs_s_type(int16, CA_INT16);
963
- static VALUE rb_cs_s_type(uint16, CA_UINT16);
964
- static VALUE rb_cs_s_type(int32, CA_INT32);
965
- static VALUE rb_cs_s_type(uint32, CA_UINT32);
966
- static VALUE rb_cs_s_type(int64, CA_INT64);
967
- static VALUE rb_cs_s_type(uint64, CA_UINT64);
968
- static VALUE rb_cs_s_type(float32, CA_FLOAT32);
969
- static VALUE rb_cs_s_type(float64, CA_FLOAT64);
970
- 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
+
971
1218
  #ifdef HAVE_COMPLEX_H
972
- static VALUE rb_cs_s_type(cmplx64, CA_CMPLX64);
973
- static VALUE rb_cs_s_type(cmplx128, CA_CMPLX128);
974
- 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
+ }
975
1248
  #endif
976
- static VALUE rb_cs_s_type(VALUE, CA_OBJECT);
977
1249
 
978
- /*
979
- * call-seq:
980
- * CScalar.int8() { ... } -> CScalar
981
- * CScalar.uint8() { ... } -> CScalar
982
- * CScalar.int16() { ... } -> CScalar
983
- * CScalar.uint16() { ... } -> CScalar
984
- * CScalar.int32() { ... } -> CScalar
985
- * CScalar.uint32() { ... } -> CScalar
986
- * CScalar.int64() { ... } -> CScalar
987
- * CScalar.uint64() { ... } -> CScalar
988
- * CScalar.float32() { ... } -> CScalar
989
- * CScalar.float64() { ... } -> CScalar
990
- * CScalar.float128() { ... } -> CScalar
991
- * CScalar.cmplx64() { ... } -> CScalar
992
- * CScalar.cmplx128() { ... } -> CScalar
993
- * CScalar.cmplx256() { ... } -> CScalar
994
- * CScalar.object() { ... } -> CScalar
995
- *
996
- */
1250
+ /* @overload object() { ... }
997
1251
 
998
- static VALUE
999
- 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
+ */
1000
1263
 
1001
1264
  static VALUE
1002
1265
  rb_cs_initialize_copy (VALUE self, VALUE other)
@@ -1031,6 +1294,10 @@ rb_cs_coerce (VALUE self, VALUE other)
1031
1294
  }
1032
1295
  */
1033
1296
 
1297
+ /* @private
1298
+ @overload mem_usage
1299
+ */
1300
+
1034
1301
  static VALUE
1035
1302
  rb_ca_mem_usage (VALUE self)
1036
1303
  {
@@ -1046,7 +1313,10 @@ Init_ca_obj_array ()
1046
1313
 
1047
1314
  /* ------------------------------------------------------------------- */
1048
1315
  ca_gc_interval = ca_default_gc_interval;
1316
+
1317
+ /* @private */
1049
1318
  rb_define_const(rb_cCArray, "DEFAULT_GC_INTERVAL", rb_float_new(ca_default_gc_interval));
1319
+
1050
1320
  rb_define_singleton_method(rb_cCArray, "gc_interval", rb_ca_get_gc_interval, 0);
1051
1321
  rb_define_singleton_method(rb_cCArray, "gc_interval=", rb_ca_set_gc_interval, 1);
1052
1322
  rb_define_singleton_method(rb_cCArray, "reset_gc_interval", rb_ca_reset_gc_interval, 0);
@@ -1135,7 +1405,7 @@ Init_ca_obj_array ()
1135
1405
  }
1136
1406
 
1137
1407
 
1138
- /* rdoc:
1408
+ /* yard:
1139
1409
  # call-seq:
1140
1410
  # CArray.boolean(...) { init_value }
1141
1411
  # CArray.int8(...) { init_value }