numo-narray-alt 0.9.5 → 0.9.6

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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/README.md +13 -0
  4. data/ext/numo/narray/SFMT-params19937.h +12 -12
  5. data/ext/numo/narray/array.c +26 -2
  6. data/ext/numo/narray/data.c +70 -72
  7. data/ext/numo/narray/extconf.rb +0 -1
  8. data/ext/numo/narray/index.c +2 -2
  9. data/ext/numo/narray/kwargs.c +6 -6
  10. data/ext/numo/narray/math.c +10 -4
  11. data/ext/numo/narray/narray.c +80 -52
  12. data/ext/numo/narray/numo/narray.h +20 -20
  13. data/ext/numo/narray/numo/ndloop.h +1 -1
  14. data/ext/numo/narray/numo/template.h +80 -80
  15. data/ext/numo/narray/numo/types/bit.h +76 -0
  16. data/ext/numo/narray/numo/types/complex.h +2 -2
  17. data/ext/numo/narray/numo/types/complex_macro.h +27 -26
  18. data/ext/numo/narray/numo/types/float_macro.h +18 -17
  19. data/ext/numo/narray/numo/types/real_accum.h +22 -22
  20. data/ext/numo/narray/numo/types/robj_macro.h +15 -14
  21. data/ext/numo/narray/numo/types/xint_macro.h +50 -8
  22. data/ext/numo/narray/rand.c +7 -0
  23. data/ext/numo/narray/src/mh/mean.h +102 -0
  24. data/ext/numo/narray/src/mh/rms.h +102 -0
  25. data/ext/numo/narray/src/mh/stddev.h +103 -0
  26. data/ext/numo/narray/src/mh/var.h +102 -0
  27. data/ext/numo/narray/src/t_bit.c +121 -71
  28. data/ext/numo/narray/src/t_dcomplex.c +248 -387
  29. data/ext/numo/narray/src/t_dfloat.c +922 -1068
  30. data/ext/numo/narray/src/t_int16.c +282 -231
  31. data/ext/numo/narray/src/t_int32.c +282 -231
  32. data/ext/numo/narray/src/t_int64.c +281 -230
  33. data/ext/numo/narray/src/t_int8.c +282 -231
  34. data/ext/numo/narray/src/t_robject.c +278 -405
  35. data/ext/numo/narray/src/t_scomplex.c +246 -406
  36. data/ext/numo/narray/src/t_sfloat.c +916 -1058
  37. data/ext/numo/narray/src/t_uint16.c +282 -231
  38. data/ext/numo/narray/src/t_uint32.c +282 -231
  39. data/ext/numo/narray/src/t_uint64.c +282 -231
  40. data/ext/numo/narray/src/t_uint8.c +282 -231
  41. data/ext/numo/narray/struct.c +12 -7
  42. data/lib/numo/narray/extra.rb +8 -5
  43. metadata +6 -3
  44. data/ext/numo/narray/src/t_mean.c +0 -105
@@ -37,14 +37,23 @@ static ID id_to_a;
37
37
 
38
38
  #include <numo/types/int32.h>
39
39
 
40
- VALUE cT;
41
- extern VALUE cRT;
42
-
43
40
  /*
44
41
  class definition: Numo::Int32
45
42
  */
46
-
47
43
  VALUE cT;
44
+ extern VALUE cRT;
45
+
46
+ #include "mh/mean.h"
47
+ #include "mh/var.h"
48
+ #include "mh/stddev.h"
49
+ #include "mh/rms.h"
50
+
51
+ typedef int32_t int32; // Type aliases for shorter notation
52
+ // following the codebase naming convention.
53
+ DEF_NARRAY_INT_MEAN_METHOD_FUNC(int32, numo_cInt32)
54
+ DEF_NARRAY_INT_VAR_METHOD_FUNC(int32, numo_cInt32)
55
+ DEF_NARRAY_INT_STDDEV_METHOD_FUNC(int32, numo_cInt32)
56
+ DEF_NARRAY_INT_RMS_METHOD_FUNC(int32, numo_cInt32)
48
57
 
49
58
  static VALUE int32_store(VALUE, VALUE);
50
59
 
@@ -152,9 +161,9 @@ static VALUE int32_allocate(VALUE self) {
152
161
  /*
153
162
  Extract an element only if self is a dimensionless NArray.
154
163
  @overload extract
155
- @return [Numeric,Numo::NArray]
156
- --- Extract element value as Ruby Object if self is a dimensionless NArray,
157
- otherwise returns self.
164
+ @return [Numeric,Numo::NArray]
165
+ --- Extract element value as Ruby Object if self is a dimensionless NArray,
166
+ otherwise returns self.
158
167
  */
159
168
  static VALUE int32_extract(VALUE self) {
160
169
  volatile VALUE v;
@@ -896,8 +905,8 @@ static VALUE int32_store_array(VALUE self, VALUE rary) {
896
905
  /*
897
906
  Store elements to Numo::Int32 from other.
898
907
  @overload store(other)
899
- @param [Object] other
900
- @return [Numo::Int32] self
908
+ @param [Object] other
909
+ @return [Numo::Int32] self
901
910
  */
902
911
  static VALUE int32_store(VALUE self, VALUE obj) {
903
912
  VALUE r, klass;
@@ -1109,9 +1118,9 @@ static VALUE int32_cast_array(VALUE rary) {
1109
1118
  Cast object to Numo::Int32.
1110
1119
  @overload [](elements)
1111
1120
  @overload cast(array)
1112
- @param [Numeric,Array] elements
1113
- @param [Array] array
1114
- @return [Numo::Int32]
1121
+ @param [Numeric,Array] elements
1122
+ @param [Array] array
1123
+ @return [Numo::Int32]
1115
1124
  */
1116
1125
  static VALUE int32_s_cast(VALUE type, VALUE obj) {
1117
1126
  VALUE v;
@@ -1151,9 +1160,9 @@ static VALUE int32_s_cast(VALUE type, VALUE obj) {
1151
1160
  /*
1152
1161
  Multi-dimensional element reference.
1153
1162
  @overload [](dim0,...,dimL)
1154
- @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
1155
- dim0,...,dimL multi-dimensional indices.
1156
- @return [Numeric,Numo::Int32] an element or NArray view.
1163
+ @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
1164
+ dim0,...,dimL multi-dimensional indices.
1165
+ @return [Numeric,Numo::Int32] an element or NArray view.
1157
1166
  @see Numo::NArray#[]
1158
1167
  @see #[]=
1159
1168
  */
@@ -1174,10 +1183,10 @@ static VALUE int32_aref(int argc, VALUE* argv, VALUE self) {
1174
1183
  /*
1175
1184
  Multi-dimensional element assignment.
1176
1185
  @overload []=(dim0,...,dimL,val)
1177
- @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
1178
- dim0,...,dimL multi-dimensional indices.
1179
- @param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
1180
- @return [Numeric,Numo::NArray,Array] returns `val` (last argument).
1186
+ @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
1187
+ dim0,...,dimL multi-dimensional indices.
1188
+ @param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
1189
+ @return [Numeric,Numo::NArray,Array] returns `val` (last argument).
1181
1190
  @see Numo::NArray#[]=
1182
1191
  @see #[]
1183
1192
  */
@@ -1208,7 +1217,7 @@ static VALUE int32_aset(int argc, VALUE* argv, VALUE self) {
1208
1217
  /*
1209
1218
  return NArray with cast to the type of self.
1210
1219
  @overload coerce_cast(type)
1211
- @return [nil]
1220
+ @return [nil]
1212
1221
  */
1213
1222
  static VALUE int32_coerce_cast(VALUE self, VALUE type) {
1214
1223
  return Qnil;
@@ -1243,7 +1252,7 @@ static void iter_int32_to_a(na_loop_t* const lp) {
1243
1252
  /*
1244
1253
  Convert self to Array.
1245
1254
  @overload to_a
1246
- @return [Array]
1255
+ @return [Array]
1247
1256
  */
1248
1257
  static VALUE int32_to_a(VALUE self) {
1249
1258
  ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
@@ -1276,8 +1285,8 @@ static void iter_int32_fill(na_loop_t* const lp) {
1276
1285
  /*
1277
1286
  Fill elements with other.
1278
1287
  @overload fill other
1279
- @param [Numeric] other
1280
- @return [Numo::Int32] self.
1288
+ @param [Numeric] other
1289
+ @return [Numo::Int32] self.
1281
1290
  */
1282
1291
  static VALUE int32_fill(VALUE self, VALUE val) {
1283
1292
  ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
@@ -1330,8 +1339,8 @@ static void iter_int32_format(na_loop_t* const lp) {
1330
1339
  /*
1331
1340
  Format elements into strings.
1332
1341
  @overload format format
1333
- @param [String] format
1334
- @return [Numo::RObject] array of formatted strings.
1342
+ @param [String] format
1343
+ @return [Numo::RObject] array of formatted strings.
1335
1344
  */
1336
1345
  static VALUE int32_format(int argc, VALUE* argv, VALUE self) {
1337
1346
  VALUE fmt = Qnil;
@@ -1377,8 +1386,8 @@ static void iter_int32_format_to_a(na_loop_t* const lp) {
1377
1386
  /*
1378
1387
  Format elements into strings.
1379
1388
  @overload format_to_a format
1380
- @param [String] format
1381
- @return [Array] array of formatted strings.
1389
+ @param [String] format
1390
+ @return [Array] array of formatted strings.
1382
1391
  */
1383
1392
  static VALUE int32_format_to_a(int argc, VALUE* argv, VALUE self) {
1384
1393
  VALUE fmt = Qnil;
@@ -1397,7 +1406,7 @@ static VALUE iter_int32_inspect(char* ptr, size_t pos, VALUE fmt) {
1397
1406
  /*
1398
1407
  Returns a string containing a human-readable representation of NArray.
1399
1408
  @overload inspect
1400
- @return [String]
1409
+ @return [String]
1401
1410
  */
1402
1411
  static VALUE int32_inspect(VALUE ary) {
1403
1412
  return na_ndloop_inspect(ary, iter_int32_inspect, Qnil);
@@ -1431,9 +1440,9 @@ static void iter_int32_each(na_loop_t* const lp) {
1431
1440
  Calls the given block once for each element in self,
1432
1441
  passing that element as a parameter.
1433
1442
  @overload each
1434
- @return [Numo::NArray] self
1435
- For a block `{|x| ... }`,
1436
- @yieldparam [Numeric] x an element of NArray.
1443
+ @return [Numo::NArray] self
1444
+ For a block `{|x| ... }`,
1445
+ @yieldparam [Numeric] x an element of NArray.
1437
1446
  @see #each_with_index
1438
1447
  @see #map
1439
1448
  */
@@ -1510,7 +1519,7 @@ static void iter_int32_map(na_loop_t* const lp) {
1510
1519
  /*
1511
1520
  Unary map.
1512
1521
  @overload map
1513
- @return [Numo::Int32] map of self.
1522
+ @return [Numo::Int32] map of self.
1514
1523
  */
1515
1524
  static VALUE int32_map(VALUE self) {
1516
1525
  ndfunc_arg_in_t ain[1] = { { cT, 0 } };
@@ -1569,10 +1578,10 @@ static void iter_int32_each_with_index(na_loop_t* const lp) {
1569
1578
  Invokes the given block once for each element of self,
1570
1579
  passing that element and indices along each axis as parameters.
1571
1580
  @overload each_with_index
1572
- For a block `{|x,i,j,...| ... }`,
1573
- @yieldparam [Numeric] x an element
1574
- @yieldparam [Integer] i,j,... multitimensional indices
1575
- @return [Numo::NArray] self
1581
+ For a block `{|x,i,j,...| ... }`,
1582
+ @yieldparam [Numeric] x an element
1583
+ @yieldparam [Integer] i,j,... multitimensional indices
1584
+ @return [Numo::NArray] self
1576
1585
  @see #each
1577
1586
  @see #map_with_index
1578
1587
  */
@@ -1660,10 +1669,10 @@ static void iter_int32_map_with_index(na_loop_t* const lp) {
1660
1669
  Creates a new NArray containing the values returned by the block.
1661
1670
  Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
1662
1671
  @overload map_with_index
1663
- For a block `{|x,i,j,...| ... }`,
1664
- @yieldparam [Numeric] x an element
1665
- @yieldparam [Integer] i,j,... multitimensional indices
1666
- @return [Numo::NArray] mapped array
1672
+ For a block `{|x,i,j,...| ... }`,
1673
+ @yieldparam [Numeric] x an element
1674
+ @yieldparam [Integer] i,j,... multitimensional indices
1675
+ @return [Numo::NArray] mapped array
1667
1676
  @see #map
1668
1677
  @see #each_with_index
1669
1678
  */
@@ -1719,7 +1728,7 @@ static void iter_int32_abs(na_loop_t* const lp) {
1719
1728
  /*
1720
1729
  abs of self.
1721
1730
  @overload abs
1722
- @return [Numo::Int32] abs of self.
1731
+ @return [Numo::Int32] abs of self.
1723
1732
  */
1724
1733
  static VALUE int32_abs(VALUE self) {
1725
1734
  ndfunc_arg_in_t ain[1] = { { cT, 0 } };
@@ -1729,7 +1738,7 @@ static VALUE int32_abs(VALUE self) {
1729
1738
  return na_ndloop(&ndf, 1, self);
1730
1739
  }
1731
1740
 
1732
- #define check_intdivzero(y) \
1741
+ #define check_intdivzero(y) \
1733
1742
  {}
1734
1743
 
1735
1744
  static void iter_int32_add(na_loop_t* const lp) {
@@ -1831,8 +1840,8 @@ static VALUE int32_add_self(VALUE self, VALUE other) {
1831
1840
  /*
1832
1841
  Binary add.
1833
1842
  @overload + other
1834
- @param [Numo::NArray,Numeric] other
1835
- @return [Numo::NArray] self + other
1843
+ @param [Numo::NArray,Numeric] other
1844
+ @return [Numo::NArray] self + other
1836
1845
  */
1837
1846
  static VALUE int32_add(VALUE self, VALUE other) {
1838
1847
 
@@ -1847,7 +1856,7 @@ static VALUE int32_add(VALUE self, VALUE other) {
1847
1856
  }
1848
1857
  }
1849
1858
 
1850
- #define check_intdivzero(y) \
1859
+ #define check_intdivzero(y) \
1851
1860
  {}
1852
1861
 
1853
1862
  static void iter_int32_sub(na_loop_t* const lp) {
@@ -1949,8 +1958,8 @@ static VALUE int32_sub_self(VALUE self, VALUE other) {
1949
1958
  /*
1950
1959
  Binary sub.
1951
1960
  @overload - other
1952
- @param [Numo::NArray,Numeric] other
1953
- @return [Numo::NArray] self - other
1961
+ @param [Numo::NArray,Numeric] other
1962
+ @return [Numo::NArray] self - other
1954
1963
  */
1955
1964
  static VALUE int32_sub(VALUE self, VALUE other) {
1956
1965
 
@@ -1965,7 +1974,7 @@ static VALUE int32_sub(VALUE self, VALUE other) {
1965
1974
  }
1966
1975
  }
1967
1976
 
1968
- #define check_intdivzero(y) \
1977
+ #define check_intdivzero(y) \
1969
1978
  {}
1970
1979
 
1971
1980
  static void iter_int32_mul(na_loop_t* const lp) {
@@ -2067,8 +2076,8 @@ static VALUE int32_mul_self(VALUE self, VALUE other) {
2067
2076
  /*
2068
2077
  Binary mul.
2069
2078
  @overload * other
2070
- @param [Numo::NArray,Numeric] other
2071
- @return [Numo::NArray] self * other
2079
+ @param [Numo::NArray,Numeric] other
2080
+ @return [Numo::NArray] self * other
2072
2081
  */
2073
2082
  static VALUE int32_mul(VALUE self, VALUE other) {
2074
2083
 
@@ -2083,10 +2092,10 @@ static VALUE int32_mul(VALUE self, VALUE other) {
2083
2092
  }
2084
2093
  }
2085
2094
 
2086
- #define check_intdivzero(y) \
2087
- if ((y) == 0) { \
2088
- lp->err_type = rb_eZeroDivError; \
2089
- return; \
2095
+ #define check_intdivzero(y) \
2096
+ if ((y) == 0) { \
2097
+ lp->err_type = rb_eZeroDivError; \
2098
+ return; \
2090
2099
  }
2091
2100
 
2092
2101
  static void iter_int32_div(na_loop_t* const lp) {
@@ -2188,8 +2197,8 @@ static VALUE int32_div_self(VALUE self, VALUE other) {
2188
2197
  /*
2189
2198
  Binary div.
2190
2199
  @overload / other
2191
- @param [Numo::NArray,Numeric] other
2192
- @return [Numo::NArray] self / other
2200
+ @param [Numo::NArray,Numeric] other
2201
+ @return [Numo::NArray] self / other
2193
2202
  */
2194
2203
  static VALUE int32_div(VALUE self, VALUE other) {
2195
2204
 
@@ -2204,10 +2213,10 @@ static VALUE int32_div(VALUE self, VALUE other) {
2204
2213
  }
2205
2214
  }
2206
2215
 
2207
- #define check_intdivzero(y) \
2208
- if ((y) == 0) { \
2209
- lp->err_type = rb_eZeroDivError; \
2210
- return; \
2216
+ #define check_intdivzero(y) \
2217
+ if ((y) == 0) { \
2218
+ lp->err_type = rb_eZeroDivError; \
2219
+ return; \
2211
2220
  }
2212
2221
 
2213
2222
  static void iter_int32_mod(na_loop_t* const lp) {
@@ -2309,8 +2318,8 @@ static VALUE int32_mod_self(VALUE self, VALUE other) {
2309
2318
  /*
2310
2319
  Binary mod.
2311
2320
  @overload % other
2312
- @param [Numo::NArray,Numeric] other
2313
- @return [Numo::NArray] self % other
2321
+ @param [Numo::NArray,Numeric] other
2322
+ @return [Numo::NArray] self % other
2314
2323
  */
2315
2324
  static VALUE int32_mod(VALUE self, VALUE other) {
2316
2325
 
@@ -2359,8 +2368,8 @@ static VALUE int32_divmod_self(VALUE self, VALUE other) {
2359
2368
  /*
2360
2369
  Binary divmod.
2361
2370
  @overload divmod other
2362
- @param [Numo::NArray,Numeric] other
2363
- @return [Numo::NArray] divmod of self and other.
2371
+ @param [Numo::NArray,Numeric] other
2372
+ @return [Numo::NArray] divmod of self and other.
2364
2373
  */
2365
2374
  static VALUE int32_divmod(VALUE self, VALUE other) {
2366
2375
 
@@ -2427,8 +2436,8 @@ static VALUE int32_pow_self(VALUE self, VALUE other) {
2427
2436
  /*
2428
2437
  Binary power.
2429
2438
  @overload ** other
2430
- @param [Numo::NArray,Numeric] other
2431
- @return [Numo::NArray] self to the other-th power.
2439
+ @param [Numo::NArray,Numeric] other
2440
+ @return [Numo::NArray] self to the other-th power.
2432
2441
  */
2433
2442
  static VALUE int32_pow(VALUE self, VALUE other) {
2434
2443
 
@@ -2507,7 +2516,7 @@ static void iter_int32_minus(na_loop_t* const lp) {
2507
2516
  /*
2508
2517
  Unary minus.
2509
2518
  @overload -@
2510
- @return [Numo::Int32] minus of self.
2519
+ @return [Numo::Int32] minus of self.
2511
2520
  */
2512
2521
  static VALUE int32_minus(VALUE self) {
2513
2522
  ndfunc_arg_in_t ain[1] = { { cT, 0 } };
@@ -2582,7 +2591,7 @@ static void iter_int32_reciprocal(na_loop_t* const lp) {
2582
2591
  /*
2583
2592
  Unary reciprocal.
2584
2593
  @overload reciprocal
2585
- @return [Numo::Int32] reciprocal of self.
2594
+ @return [Numo::Int32] reciprocal of self.
2586
2595
  */
2587
2596
  static VALUE int32_reciprocal(VALUE self) {
2588
2597
  ndfunc_arg_in_t ain[1] = { { cT, 0 } };
@@ -2657,7 +2666,7 @@ static void iter_int32_sign(na_loop_t* const lp) {
2657
2666
  /*
2658
2667
  Unary sign.
2659
2668
  @overload sign
2660
- @return [Numo::Int32] sign of self.
2669
+ @return [Numo::Int32] sign of self.
2661
2670
  */
2662
2671
  static VALUE int32_sign(VALUE self) {
2663
2672
  ndfunc_arg_in_t ain[1] = { { cT, 0 } };
@@ -2732,7 +2741,7 @@ static void iter_int32_square(na_loop_t* const lp) {
2732
2741
  /*
2733
2742
  Unary square.
2734
2743
  @overload square
2735
- @return [Numo::Int32] square of self.
2744
+ @return [Numo::Int32] square of self.
2736
2745
  */
2737
2746
  static VALUE int32_square(VALUE self) {
2738
2747
  ndfunc_arg_in_t ain[1] = { { cT, 0 } };
@@ -2774,8 +2783,8 @@ static VALUE int32_eq_self(VALUE self, VALUE other) {
2774
2783
  /*
2775
2784
  Comparison eq other.
2776
2785
  @overload eq other
2777
- @param [Numo::NArray,Numeric] other
2778
- @return [Numo::Bit] result of self eq other.
2786
+ @param [Numo::NArray,Numeric] other
2787
+ @return [Numo::Bit] result of self eq other.
2779
2788
  */
2780
2789
  static VALUE int32_eq(VALUE self, VALUE other) {
2781
2790
 
@@ -2821,8 +2830,8 @@ static VALUE int32_ne_self(VALUE self, VALUE other) {
2821
2830
  /*
2822
2831
  Comparison ne other.
2823
2832
  @overload ne other
2824
- @param [Numo::NArray,Numeric] other
2825
- @return [Numo::Bit] result of self ne other.
2833
+ @param [Numo::NArray,Numeric] other
2834
+ @return [Numo::Bit] result of self ne other.
2826
2835
  */
2827
2836
  static VALUE int32_ne(VALUE self, VALUE other) {
2828
2837
 
@@ -2836,7 +2845,7 @@ static VALUE int32_ne(VALUE self, VALUE other) {
2836
2845
  }
2837
2846
  }
2838
2847
 
2839
- #define check_intdivzero(y) \
2848
+ #define check_intdivzero(y) \
2840
2849
  {}
2841
2850
 
2842
2851
  static void iter_int32_bit_and(na_loop_t* const lp) {
@@ -2938,8 +2947,8 @@ static VALUE int32_bit_and_self(VALUE self, VALUE other) {
2938
2947
  /*
2939
2948
  Binary bit_and.
2940
2949
  @overload & other
2941
- @param [Numo::NArray,Numeric] other
2942
- @return [Numo::NArray] self & other
2950
+ @param [Numo::NArray,Numeric] other
2951
+ @return [Numo::NArray] self & other
2943
2952
  */
2944
2953
  static VALUE int32_bit_and(VALUE self, VALUE other) {
2945
2954
 
@@ -2954,7 +2963,7 @@ static VALUE int32_bit_and(VALUE self, VALUE other) {
2954
2963
  }
2955
2964
  }
2956
2965
 
2957
- #define check_intdivzero(y) \
2966
+ #define check_intdivzero(y) \
2958
2967
  {}
2959
2968
 
2960
2969
  static void iter_int32_bit_or(na_loop_t* const lp) {
@@ -3056,8 +3065,8 @@ static VALUE int32_bit_or_self(VALUE self, VALUE other) {
3056
3065
  /*
3057
3066
  Binary bit_or.
3058
3067
  @overload | other
3059
- @param [Numo::NArray,Numeric] other
3060
- @return [Numo::NArray] self | other
3068
+ @param [Numo::NArray,Numeric] other
3069
+ @return [Numo::NArray] self | other
3061
3070
  */
3062
3071
  static VALUE int32_bit_or(VALUE self, VALUE other) {
3063
3072
 
@@ -3072,7 +3081,7 @@ static VALUE int32_bit_or(VALUE self, VALUE other) {
3072
3081
  }
3073
3082
  }
3074
3083
 
3075
- #define check_intdivzero(y) \
3084
+ #define check_intdivzero(y) \
3076
3085
  {}
3077
3086
 
3078
3087
  static void iter_int32_bit_xor(na_loop_t* const lp) {
@@ -3174,8 +3183,8 @@ static VALUE int32_bit_xor_self(VALUE self, VALUE other) {
3174
3183
  /*
3175
3184
  Binary bit_xor.
3176
3185
  @overload ^ other
3177
- @param [Numo::NArray,Numeric] other
3178
- @return [Numo::NArray] self ^ other
3186
+ @param [Numo::NArray,Numeric] other
3187
+ @return [Numo::NArray] self ^ other
3179
3188
  */
3180
3189
  static VALUE int32_bit_xor(VALUE self, VALUE other) {
3181
3190
 
@@ -3255,7 +3264,7 @@ static void iter_int32_bit_not(na_loop_t* const lp) {
3255
3264
  /*
3256
3265
  Unary bit_not.
3257
3266
  @overload ~
3258
- @return [Numo::Int32] bit_not of self.
3267
+ @return [Numo::Int32] bit_not of self.
3259
3268
  */
3260
3269
  static VALUE int32_bit_not(VALUE self) {
3261
3270
  ndfunc_arg_in_t ain[1] = { { cT, 0 } };
@@ -3265,7 +3274,7 @@ static VALUE int32_bit_not(VALUE self) {
3265
3274
  return na_ndloop(&ndf, 1, self);
3266
3275
  }
3267
3276
 
3268
- #define check_intdivzero(y) \
3277
+ #define check_intdivzero(y) \
3269
3278
  {}
3270
3279
 
3271
3280
  static void iter_int32_left_shift(na_loop_t* const lp) {
@@ -3367,8 +3376,8 @@ static VALUE int32_left_shift_self(VALUE self, VALUE other) {
3367
3376
  /*
3368
3377
  Binary left_shift.
3369
3378
  @overload << other
3370
- @param [Numo::NArray,Numeric] other
3371
- @return [Numo::NArray] self << other
3379
+ @param [Numo::NArray,Numeric] other
3380
+ @return [Numo::NArray] self << other
3372
3381
  */
3373
3382
  static VALUE int32_left_shift(VALUE self, VALUE other) {
3374
3383
 
@@ -3383,7 +3392,7 @@ static VALUE int32_left_shift(VALUE self, VALUE other) {
3383
3392
  }
3384
3393
  }
3385
3394
 
3386
- #define check_intdivzero(y) \
3395
+ #define check_intdivzero(y) \
3387
3396
  {}
3388
3397
 
3389
3398
  static void iter_int32_right_shift(na_loop_t* const lp) {
@@ -3485,8 +3494,8 @@ static VALUE int32_right_shift_self(VALUE self, VALUE other) {
3485
3494
  /*
3486
3495
  Binary right_shift.
3487
3496
  @overload >> other
3488
- @param [Numo::NArray,Numeric] other
3489
- @return [Numo::NArray] self >> other
3497
+ @param [Numo::NArray,Numeric] other
3498
+ @return [Numo::NArray] self >> other
3490
3499
  */
3491
3500
  static VALUE int32_right_shift(VALUE self, VALUE other) {
3492
3501
 
@@ -3533,8 +3542,8 @@ static VALUE int32_gt_self(VALUE self, VALUE other) {
3533
3542
  /*
3534
3543
  Comparison gt other.
3535
3544
  @overload gt other
3536
- @param [Numo::NArray,Numeric] other
3537
- @return [Numo::Bit] result of self gt other.
3545
+ @param [Numo::NArray,Numeric] other
3546
+ @return [Numo::Bit] result of self gt other.
3538
3547
  */
3539
3548
  static VALUE int32_gt(VALUE self, VALUE other) {
3540
3549
 
@@ -3580,8 +3589,8 @@ static VALUE int32_ge_self(VALUE self, VALUE other) {
3580
3589
  /*
3581
3590
  Comparison ge other.
3582
3591
  @overload ge other
3583
- @param [Numo::NArray,Numeric] other
3584
- @return [Numo::Bit] result of self ge other.
3592
+ @param [Numo::NArray,Numeric] other
3593
+ @return [Numo::Bit] result of self ge other.
3585
3594
  */
3586
3595
  static VALUE int32_ge(VALUE self, VALUE other) {
3587
3596
 
@@ -3627,8 +3636,8 @@ static VALUE int32_lt_self(VALUE self, VALUE other) {
3627
3636
  /*
3628
3637
  Comparison lt other.
3629
3638
  @overload lt other
3630
- @param [Numo::NArray,Numeric] other
3631
- @return [Numo::Bit] result of self lt other.
3639
+ @param [Numo::NArray,Numeric] other
3640
+ @return [Numo::Bit] result of self lt other.
3632
3641
  */
3633
3642
  static VALUE int32_lt(VALUE self, VALUE other) {
3634
3643
 
@@ -3674,8 +3683,8 @@ static VALUE int32_le_self(VALUE self, VALUE other) {
3674
3683
  /*
3675
3684
  Comparison le other.
3676
3685
  @overload le other
3677
- @param [Numo::NArray,Numeric] other
3678
- @return [Numo::Bit] result of self le other.
3686
+ @param [Numo::NArray,Numeric] other
3687
+ @return [Numo::Bit] result of self le other.
3679
3688
  */
3680
3689
  static VALUE int32_le(VALUE self, VALUE other) {
3681
3690
 
@@ -3758,9 +3767,9 @@ static void iter_int32_clip_max(na_loop_t* const lp) {
3758
3767
  Clip array elements by [min,max].
3759
3768
  If either of min or max is nil, one side is clipped.
3760
3769
  @overload clip(min,max)
3761
- @param [Numo::NArray,Numeric] min
3762
- @param [Numo::NArray,Numeric] max
3763
- @return [Numo::NArray] result of clip.
3770
+ @param [Numo::NArray,Numeric] min
3771
+ @param [Numo::NArray,Numeric] max
3772
+ @return [Numo::NArray] result of clip.
3764
3773
 
3765
3774
  @example
3766
3775
  a = Numo::Int32.new(10).seq
@@ -3821,10 +3830,10 @@ static void iter_int32_sum(na_loop_t* const lp) {
3821
3830
  /*
3822
3831
  sum of self.
3823
3832
  @overload sum(axis:nil, keepdims:false)
3824
- @param [Numeric,Array,Range] axis Performs sum along the axis.
3825
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3826
- dimensions with size one.
3827
- @return [Numo::Int32] returns result of sum.
3833
+ @param [Numeric,Array,Range] axis Performs sum along the axis.
3834
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3835
+ dimensions with size one.
3836
+ @return [Numo::Int32] returns result of sum.
3828
3837
  */
3829
3838
  static VALUE int32_sum(int argc, VALUE* argv, VALUE self) {
3830
3839
  VALUE v, reduce;
@@ -3854,10 +3863,10 @@ static void iter_int32_prod(na_loop_t* const lp) {
3854
3863
  /*
3855
3864
  prod of self.
3856
3865
  @overload prod(axis:nil, keepdims:false)
3857
- @param [Numeric,Array,Range] axis Performs prod along the axis.
3858
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3859
- dimensions with size one.
3860
- @return [Numo::Int32] returns result of prod.
3866
+ @param [Numeric,Array,Range] axis Performs prod along the axis.
3867
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3868
+ dimensions with size one.
3869
+ @return [Numo::Int32] returns result of prod.
3861
3870
  */
3862
3871
  static VALUE int32_prod(int argc, VALUE* argv, VALUE self) {
3863
3872
  VALUE v, reduce;
@@ -3887,10 +3896,10 @@ static void iter_int32_min(na_loop_t* const lp) {
3887
3896
  /*
3888
3897
  min of self.
3889
3898
  @overload min(axis:nil, keepdims:false)
3890
- @param [Numeric,Array,Range] axis Performs min along the axis.
3891
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3892
- dimensions with size one.
3893
- @return [Numo::Int32] returns result of min.
3899
+ @param [Numeric,Array,Range] axis Performs min along the axis.
3900
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3901
+ dimensions with size one.
3902
+ @return [Numo::Int32] returns result of min.
3894
3903
  */
3895
3904
  static VALUE int32_min(int argc, VALUE* argv, VALUE self) {
3896
3905
  VALUE v, reduce;
@@ -3920,10 +3929,10 @@ static void iter_int32_max(na_loop_t* const lp) {
3920
3929
  /*
3921
3930
  max of self.
3922
3931
  @overload max(axis:nil, keepdims:false)
3923
- @param [Numeric,Array,Range] axis Performs max along the axis.
3924
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3925
- dimensions with size one.
3926
- @return [Numo::Int32] returns result of max.
3932
+ @param [Numeric,Array,Range] axis Performs max along the axis.
3933
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3934
+ dimensions with size one.
3935
+ @return [Numo::Int32] returns result of max.
3927
3936
  */
3928
3937
  static VALUE int32_max(int argc, VALUE* argv, VALUE self) {
3929
3938
  VALUE v, reduce;
@@ -3953,10 +3962,10 @@ static void iter_int32_ptp(na_loop_t* const lp) {
3953
3962
  /*
3954
3963
  ptp of self.
3955
3964
  @overload ptp(axis:nil, keepdims:false)
3956
- @param [Numeric,Array,Range] axis Performs ptp along the axis.
3957
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3958
- dimensions with size one.
3959
- @return [Numo::Int32] returns result of ptp.
3965
+ @param [Numeric,Array,Range] axis Performs ptp along the axis.
3966
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3967
+ dimensions with size one.
3968
+ @return [Numo::Int32] returns result of ptp.
3960
3969
  */
3961
3970
  static VALUE int32_ptp(int argc, VALUE* argv, VALUE self) {
3962
3971
  VALUE v, reduce;
@@ -4008,9 +4017,9 @@ static void iter_int32_max_index_index32(na_loop_t* const lp) {
4008
4017
  /*
4009
4018
  Index of the maximum value.
4010
4019
  @overload max_index(axis:nil)
4011
- @param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat 1-d
4012
- indices**.
4013
- @return [Integer,Numo::Int] returns result indices.
4020
+ @param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat
4021
+ 1-d indices**.
4022
+ @return [Integer,Numo::Int] returns result indices.
4014
4023
  @see #argmax
4015
4024
  @see #max
4016
4025
 
@@ -4091,9 +4100,9 @@ static void iter_int32_min_index_index32(na_loop_t* const lp) {
4091
4100
  /*
4092
4101
  Index of the minimum value.
4093
4102
  @overload min_index(axis:nil)
4094
- @param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat 1-d
4095
- indices**.
4096
- @return [Integer,Numo::Int] returns result indices.
4103
+ @param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat
4104
+ 1-d indices**.
4105
+ @return [Integer,Numo::Int] returns result indices.
4097
4106
  @see #argmin
4098
4107
  @see #min
4099
4108
 
@@ -4172,9 +4181,9 @@ static void iter_int32_argmax_arg32(na_loop_t* const lp) {
4172
4181
  /*
4173
4182
  Index of the maximum value.
4174
4183
  @overload argmax(axis:nil)
4175
- @param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices
4176
- along the axis**.
4177
- @return [Integer,Numo::Int] returns the result indices.
4184
+ @param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices
4185
+ along the axis**.
4186
+ @return [Integer,Numo::Int] returns the result indices.
4178
4187
  @see #max_index
4179
4188
  @see #max
4180
4189
 
@@ -4250,9 +4259,9 @@ static void iter_int32_argmin_arg32(na_loop_t* const lp) {
4250
4259
  /*
4251
4260
  Index of the minimum value.
4252
4261
  @overload argmin(axis:nil)
4253
- @param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices
4254
- along the axis**.
4255
- @return [Integer,Numo::Int] returns the result indices.
4262
+ @param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices
4263
+ along the axis**.
4264
+ @return [Integer,Numo::Int] returns the result indices.
4256
4265
  @see #min_index
4257
4266
  @see #min
4258
4267
 
@@ -4311,10 +4320,10 @@ static void iter_int32_minmax(na_loop_t* const lp) {
4311
4320
  /*
4312
4321
  minmax of self.
4313
4322
  @overload minmax(axis:nil, keepdims:false)
4314
- @param [Numeric,Array,Range] axis Finds min-max along the axis.
4315
- @param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
4316
- as dimensions with size one.
4317
- @return [Numo::Int32,Numo::Int32] min and max of self.
4323
+ @param [Numeric,Array,Range] axis Finds min-max along the axis.
4324
+ @param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
4325
+ as dimensions with size one.
4326
+ @return [Numo::Int32,Numo::Int32] min and max of self.
4318
4327
  */
4319
4328
  static VALUE int32_minmax(int argc, VALUE* argv, VALUE self) {
4320
4329
  VALUE reduce;
@@ -4329,14 +4338,6 @@ static VALUE int32_minmax(int argc, VALUE* argv, VALUE self) {
4329
4338
  return na_ndloop(&ndf, 2, self, reduce);
4330
4339
  }
4331
4340
 
4332
- /*
4333
- Element-wise maximum of two arrays.
4334
-
4335
- @overload maximum(a1, a2)
4336
- @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
4337
- @return [Numo::Int32]
4338
- */
4339
-
4340
4341
  static void iter_int32_s_maximum(na_loop_t* const lp) {
4341
4342
  size_t i, n;
4342
4343
  char *p1, *p2, *p3;
@@ -4369,14 +4370,6 @@ static VALUE int32_s_maximum(int argc, VALUE* argv, VALUE mod) {
4369
4370
  return na_ndloop(&ndf, 2, a1, a2);
4370
4371
  }
4371
4372
 
4372
- /*
4373
- Element-wise minimum of two arrays.
4374
-
4375
- @overload minimum(a1, a2)
4376
- @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
4377
- @return [Numo::Int32]
4378
- */
4379
-
4380
4373
  static void iter_int32_s_minimum(na_loop_t* const lp) {
4381
4374
  size_t i, n;
4382
4375
  char *p1, *p2, *p3;
@@ -4574,13 +4567,13 @@ static VALUE int32_bincount_df(VALUE self, VALUE weight, size_t length) {
4574
4567
  Only Integer-types has this method.
4575
4568
 
4576
4569
  @overload bincount([weight], minlength:nil)
4577
- @param [SFloat or DFloat or Array] weight (optional) Array of
4578
- float values. Its size along last axis should be same as that of self.
4579
- @param [Integer] minlength (keyword, optional) Minimum size along
4580
- last axis for the output array.
4581
- @return [UInt32 or UInt64 or SFloat or DFloat]
4582
- Returns Float NArray if weight array is supplied,
4583
- otherwise returns UInt32 or UInt64 depending on the size along last axis.
4570
+ @param [SFloat or DFloat or Array] weight (optional) Array of
4571
+ float values. Its size along last axis should be same as that of self.
4572
+ @param [Integer] minlength (keyword, optional) Minimum size along
4573
+ last axis for the output array.
4574
+ @return [UInt32 or UInt64 or SFloat or DFloat]
4575
+ Returns Float NArray if weight array is supplied,
4576
+ otherwise returns UInt32 or UInt64 depending on the size along last axis.
4584
4577
  @example
4585
4578
  Numo::Int32[0..4].bincount
4586
4579
  # => Numo::UInt32#shape=[5]
@@ -4664,9 +4657,9 @@ static void iter_int32_cumsum(na_loop_t* const lp) {
4664
4657
  /*
4665
4658
  cumsum of self.
4666
4659
  @overload cumsum(axis:nil, nan:false)
4667
- @param [Numeric,Array,Range] axis Performs cumsum along the axis.
4668
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
4669
- @return [Numo::Int32] cumsum of self.
4660
+ @param [Numeric,Array,Range] axis Performs cumsum along the axis.
4661
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
4662
+ @return [Numo::Int32] cumsum of self.
4670
4663
  */
4671
4664
  static VALUE int32_cumsum(int argc, VALUE* argv, VALUE self) {
4672
4665
  VALUE reduce;
@@ -4703,9 +4696,9 @@ static void iter_int32_cumprod(na_loop_t* const lp) {
4703
4696
  /*
4704
4697
  cumprod of self.
4705
4698
  @overload cumprod(axis:nil, nan:false)
4706
- @param [Numeric,Array,Range] axis Performs cumprod along the axis.
4707
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
4708
- @return [Numo::Int32] cumprod of self.
4699
+ @param [Numeric,Array,Range] axis Performs cumprod along the axis.
4700
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
4701
+ @return [Numo::Int32] cumprod of self.
4709
4702
  */
4710
4703
  static VALUE int32_cumprod(int argc, VALUE* argv, VALUE self) {
4711
4704
  VALUE reduce;
@@ -4781,11 +4774,11 @@ static VALUE int32_mulsum_self(int argc, VALUE* argv, VALUE self) {
4781
4774
  Binary mulsum.
4782
4775
 
4783
4776
  @overload mulsum(other, axis:nil, keepdims:false)
4784
- @param [Numo::NArray,Numeric] other
4785
- @param [Numeric,Array,Range] axis Performs mulsum along the axis.
4786
- @param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
4787
- as dimensions with size one.
4788
- @return [Numo::NArray] mulsum of self and other.
4777
+ @param [Numo::NArray,Numeric] other
4778
+ @param [Numeric,Array,Range] axis Performs mulsum along the axis.
4779
+ @param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
4780
+ as dimensions with size one.
4781
+ @return [Numo::NArray] mulsum of self and other.
4789
4782
  */
4790
4783
  static VALUE int32_mulsum(int argc, VALUE* argv, VALUE self) {
4791
4784
  //
@@ -4854,9 +4847,9 @@ static void iter_int32_seq(na_loop_t* const lp) {
4854
4847
  beg+i*step
4855
4848
  where i is 1-dimensional index.
4856
4849
  @overload seq([beg,[step]])
4857
- @param [Numeric] beg beginning of sequence. (default=0)
4858
- @param [Numeric] step step of sequence. (default=1)
4859
- @return [Numo::Int32] self.
4850
+ @param [Numeric] beg beginning of sequence. (default=0)
4851
+ @param [Numeric] step step of sequence. (default=1)
4852
+ @return [Numo::Int32] self.
4860
4853
  @example
4861
4854
  Numo::DFloat.new(6).seq(1,-0.2)
4862
4855
  # => Numo::DFloat#shape=[6]
@@ -4866,7 +4859,7 @@ static void iter_int32_seq(na_loop_t* const lp) {
4866
4859
  # => Numo::DComplex#shape=[6]
4867
4860
  # [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
4868
4861
  */
4869
- static VALUE int32_seq(int argc, VALUE* args, VALUE self) {
4862
+ static VALUE int32_seq(int argc, VALUE* argv, VALUE self) {
4870
4863
  seq_opt_t* g;
4871
4864
  VALUE vbeg = Qnil, vstep = Qnil;
4872
4865
  ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
@@ -4876,7 +4869,7 @@ static VALUE int32_seq(int argc, VALUE* args, VALUE self) {
4876
4869
  g->beg = m_zero;
4877
4870
  g->step = m_one;
4878
4871
  g->count = 0;
4879
- rb_scan_args(argc, args, "02", &vbeg, &vstep);
4872
+ rb_scan_args(argc, argv, "02", &vbeg, &vstep);
4880
4873
  if (vbeg != Qnil) {
4881
4874
  g->beg = NUM2DBL(vbeg);
4882
4875
  }
@@ -4920,11 +4913,11 @@ static void iter_int32_eye(na_loop_t* const lp) {
4920
4913
  /*
4921
4914
  Eye: Set a value to diagonal components, set 0 to non-diagonal components.
4922
4915
  @overload eye([element,offset])
4923
- @param [Numeric] element Diagonal element to be stored. Default is 1.
4924
- @param [Integer] offset Diagonal offset from the main diagonal. The
4925
- default is 0. k>0 for diagonals above the main diagonal, and k<0
4926
- for diagonals below the main diagonal.
4927
- @return [Numo::Int32] eye of self.
4916
+ @param [Numeric] element Diagonal element to be stored. Default is 1.
4917
+ @param [Integer] offset Diagonal offset from the main diagonal. The
4918
+ default is 0. k>0 for diagonals above the main diagonal, and k<0
4919
+ for diagonals below the main diagonal.
4920
+ @return [Numo::Int32] eye of self.
4928
4921
  */
4929
4922
  static VALUE int32_eye(int argc, VALUE* argv, VALUE self) {
4930
4923
  ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
@@ -5056,10 +5049,10 @@ static void iter_int32_rand(na_loop_t* const lp) {
5056
5049
  /*
5057
5050
  Generate uniformly distributed random numbers on self narray.
5058
5051
  @overload rand([[low],high])
5059
- @param [Numeric] low lower inclusive boundary of random numbers. (default=0)
5060
- @param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
5061
- complex types)
5062
- @return [Numo::Int32] self.
5052
+ @param [Numeric] low lower inclusive boundary of random numbers. (default=0)
5053
+ @param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
5054
+ complex types)
5055
+ @return [Numo::Int32] self.
5063
5056
  @example
5064
5057
  Numo::DFloat.new(6).rand
5065
5058
  # => Numo::DFloat#shape=[6]
@@ -5073,14 +5066,14 @@ static void iter_int32_rand(na_loop_t* const lp) {
5073
5066
  # => Numo::Int32#shape=[6]
5074
5067
  # [4, 3, 3, 2, 4, 2]
5075
5068
  */
5076
- static VALUE int32_rand(int argc, VALUE* args, VALUE self) {
5069
+ static VALUE int32_rand(int argc, VALUE* argv, VALUE self) {
5077
5070
  rand_opt_t g;
5078
5071
  VALUE v1 = Qnil, v2 = Qnil;
5079
5072
  dtype high;
5080
5073
  ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
5081
5074
  ndfunc_t ndf = { iter_int32_rand, FULL_LOOP, 1, 0, ain, 0 };
5082
5075
 
5083
- rb_scan_args(argc, args, "11", &v1, &v2);
5076
+ rb_scan_args(argc, argv, "11", &v1, &v2);
5084
5077
  if (v2 == Qnil) {
5085
5078
  g.low = m_zero;
5086
5079
  g.max = high = m_num_to_data(v1);
@@ -5119,8 +5112,8 @@ static void iter_int32_poly(na_loop_t* const lp) {
5119
5112
  Calculate polynomial.
5120
5113
  `x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
5121
5114
  @overload poly a0, a1, ..., an
5122
- @param [Numo::NArray,Numeric] a0,a1,...,an
5123
- @return [Numo::Int32]
5115
+ @param [Numo::NArray,Numeric] a0,a1,...,an
5116
+ @return [Numo::Int32]
5124
5117
  */
5125
5118
  static VALUE int32_poly(VALUE self, VALUE args) {
5126
5119
  int argc, i;
@@ -5207,27 +5200,27 @@ static VALUE int32_poly(VALUE self, VALUE args) {
5207
5200
  * We have modified their original by adding a check for already-sorted input,
5208
5201
  * which seems to be a win per discussions on pgsql-hackers around 2006-03-21.
5209
5202
  */
5210
- #define swapcode(TYPE, parmi, parmj, n) \
5211
- do { \
5212
- size_t i = (n) / sizeof(TYPE); \
5213
- TYPE* pi = (TYPE*)(void*)(parmi); \
5214
- TYPE* pj = (TYPE*)(void*)(parmj); \
5215
- do { \
5216
- TYPE t = *pi; \
5217
- *pi++ = *pj; \
5218
- *pj++ = t; \
5219
- } while (--i > 0); \
5203
+ #define swapcode(TYPE, parmi, parmj, n) \
5204
+ do { \
5205
+ size_t i = (n) / sizeof(TYPE); \
5206
+ TYPE* pi = (TYPE*)(void*)(parmi); \
5207
+ TYPE* pj = (TYPE*)(void*)(parmj); \
5208
+ do { \
5209
+ TYPE t = *pi; \
5210
+ *pi++ = *pj; \
5211
+ *pj++ = t; \
5212
+ } while (--i > 0); \
5220
5213
  } while (0)
5221
5214
 
5222
5215
  #ifdef HAVE_STDINT_H
5223
- #define SWAPINIT(a, es) \
5224
- swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2 \
5225
- : (es) == sizeof(long) ? 0 \
5216
+ #define SWAPINIT(a, es) \
5217
+ swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2 \
5218
+ : (es) == sizeof(long) ? 0 \
5226
5219
  : 1;
5227
5220
  #else
5228
- #define SWAPINIT(a, es) \
5229
- swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 \
5230
- : (es) == sizeof(long) ? 0 \
5221
+ #define SWAPINIT(a, es) \
5222
+ swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 \
5223
+ : (es) == sizeof(long) ? 0 \
5231
5224
  : 1;
5232
5225
  #endif
5233
5226
 
@@ -5238,19 +5231,19 @@ static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
5238
5231
  swapcode(char, a, b, n);
5239
5232
  }
5240
5233
 
5241
- #define swap(a, b) \
5242
- if (swaptype == 0) { \
5243
- long t = *(long*)(void*)(a); \
5244
- *(long*)(void*)(a) = *(long*)(void*)(b); \
5245
- *(long*)(void*)(b) = t; \
5246
- } else \
5234
+ #define swap(a, b) \
5235
+ if (swaptype == 0) { \
5236
+ long t = *(long*)(void*)(a); \
5237
+ *(long*)(void*)(a) = *(long*)(void*)(b); \
5238
+ *(long*)(void*)(b) = t; \
5239
+ } else \
5247
5240
  swapfunc(a, b, es, swaptype)
5248
5241
 
5249
- #define vecswap(a, b, n) \
5242
+ #define vecswap(a, b, n) \
5250
5243
  if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
5251
5244
 
5252
- #define med3(a, b, c, _cmp) \
5253
- (cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) \
5245
+ #define med3(a, b, c, _cmp) \
5246
+ (cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) \
5254
5247
  : (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
5255
5248
  #endif
5256
5249
 
@@ -5341,8 +5334,8 @@ static void iter_int32_sort(na_loop_t* const lp) {
5341
5334
  /*
5342
5335
  sort of self.
5343
5336
  @overload sort(axis:nil)
5344
- @param [Numeric,Array,Range] axis Performs sort along the axis.
5345
- @return [Numo::Int32] returns result of sort.
5337
+ @param [Numeric,Array,Range] axis Performs sort along the axis.
5338
+ @return [Numo::Int32] returns result of sort.
5346
5339
  @example
5347
5340
  Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
5348
5341
  */
@@ -5561,8 +5554,8 @@ static void int32_index32_qsort(na_loop_t* const lp) {
5561
5554
  /*
5562
5555
  sort_index. Returns an index array of sort result.
5563
5556
  @overload sort_index(axis:nil)
5564
- @param [Numeric,Array,Range] axis Performs sort_index along the axis.
5565
- @return [Integer,Numo::Int] returns result index of sort_index.
5557
+ @param [Numeric,Array,Range] axis Performs sort_index along the axis.
5558
+ @return [Integer,Numo::Int] returns result index of sort_index.
5566
5559
  @example
5567
5560
  Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
5568
5561
  */
@@ -5626,10 +5619,10 @@ static void iter_int32_median(na_loop_t* const lp) {
5626
5619
  /*
5627
5620
  median of self.
5628
5621
  @overload median(axis:nil, keepdims:false)
5629
- @param [Numeric,Array,Range] axis Finds median along the axis.
5630
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
5631
- dimensions with size one.
5632
- @return [Numo::Int32] returns median of self.
5622
+ @param [Numeric,Array,Range] axis Finds median along the axis.
5623
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
5624
+ dimensions with size one.
5625
+ @return [Numo::Int32] returns median of self.
5633
5626
  */
5634
5627
 
5635
5628
  static VALUE int32_median(int argc, VALUE* argv, VALUE self) {
@@ -5668,13 +5661,15 @@ void Init_numo_int32(void) {
5668
5661
  id_ne = rb_intern("ne");
5669
5662
  id_to_a = rb_intern("to_a");
5670
5663
 
5671
- /*
5672
- Document-class: Numo::Int32
5673
-
5674
- */
5664
+ /**
5665
+ * Document-class: Numo::Int32
5666
+ *
5667
+ * 32-bit signed integer N-dimensional array.
5668
+ */
5675
5669
  cT = rb_define_class_under(mNumo, "Int32", cNArray);
5676
5670
 
5677
5671
  hCast = rb_hash_new();
5672
+ /* Upcasting rules of Int32. */
5678
5673
  rb_define_const(cT, "UPCAST", hCast);
5679
5674
  rb_hash_aset(hCast, rb_cArray, cT);
5680
5675
 
@@ -5701,15 +5696,15 @@ void Init_numo_int32(void) {
5701
5696
  rb_hash_aset(hCast, numo_cUInt8, cT);
5702
5697
  rb_obj_freeze(hCast);
5703
5698
 
5704
- /**/
5699
+ /* Element size of Int32 in bits. */
5705
5700
  rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
5706
- /**/
5701
+ /* Element size of Int32 in bytes. */
5707
5702
  rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
5708
- /**/
5703
+ /* Stride size of contiguous Int32 array. */
5709
5704
  rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
5710
- /**/
5705
+ /* The largest representable value of Int32. */
5711
5706
  rb_define_const(cT, "MAX", M_MAX);
5712
- /**/
5707
+ /* The smallest representable value of Int32. */
5713
5708
  rb_define_const(cT, "MIN", M_MIN);
5714
5709
  rb_define_alloc_func(cT, int32_s_alloc_func);
5715
5710
  rb_define_method(cT, "allocate", int32_allocate, 0);
@@ -5780,7 +5775,19 @@ void Init_numo_int32(void) {
5780
5775
  rb_define_method(cT, "argmax", int32_argmax, -1);
5781
5776
  rb_define_method(cT, "argmin", int32_argmin, -1);
5782
5777
  rb_define_method(cT, "minmax", int32_minmax, -1);
5778
+ /**
5779
+ * Element-wise maximum of two arrays.
5780
+ * @overload maximum(a1, a2)
5781
+ * @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
5782
+ * @return [Numo::Int32]
5783
+ */
5783
5784
  rb_define_module_function(cT, "maximum", int32_s_maximum, -1);
5785
+ /**
5786
+ * Element-wise minimum of two arrays.
5787
+ * @overload minimum(a1, a2)
5788
+ * @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
5789
+ * @return [Numo::Int32]
5790
+ */
5784
5791
  rb_define_module_function(cT, "minimum", int32_s_minimum, -1);
5785
5792
  rb_define_method(cT, "bincount", int32_bincount, -1);
5786
5793
  rb_define_method(cT, "cumsum", int32_cumsum, -1);
@@ -5797,4 +5804,48 @@ void Init_numo_int32(void) {
5797
5804
  rb_define_method(cT, "sort_index", int32_sort_index, -1);
5798
5805
  rb_define_method(cT, "median", int32_median, -1);
5799
5806
  rb_define_singleton_method(cT, "[]", int32_s_cast, -2);
5807
+ /**
5808
+ * mean of self.
5809
+ * @overload mean(axis: nil, keepdims: false, nan: false)
5810
+ * @param axis [Numeric, Array, Range] Performs mean along the axis.
5811
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
5812
+ * dimensions with size one.
5813
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
5814
+ * (avoid NaN for sum/mean etc, or return NaN for min/max etc).
5815
+ * @return [Numo::DFloat] returns result of mean.
5816
+ */
5817
+ rb_define_method(cT, "mean", int32_mean, -1);
5818
+ /**
5819
+ * var of self.
5820
+ * @overload var(axis: nil, keepdims: false, nan: false)
5821
+ * @param axis [Numeric, Array, Range] Performs var along the axis.
5822
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
5823
+ * dimensions with size one.
5824
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
5825
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
5826
+ * @return [Numo::DFloat] returns result of var.
5827
+ */
5828
+ rb_define_method(cT, "var", int32_var, -1);
5829
+ /**
5830
+ * stddev of self.
5831
+ * @overload stddev(axis: nil, keepdims: false, nan: false)
5832
+ * @param axis [Numeric, Array, Range] Performs stddev along the axis.
5833
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
5834
+ * dimensions with size one.
5835
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
5836
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
5837
+ * @return [Numo::DFloat] returns result of stddev.
5838
+ */
5839
+ rb_define_method(cT, "stddev", int32_stddev, -1);
5840
+ /**
5841
+ * rms of self.
5842
+ * @overload rms(axis: nil, keepdims: false, nan: false)
5843
+ * @param axis [Numeric, Array, Range] Performs rms along the axis.
5844
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
5845
+ * dimensions with size one.
5846
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
5847
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
5848
+ * @return [Numo::DFloat] returns result of rms.
5849
+ */
5850
+ rb_define_method(cT, "rms", int32_rms, -1);
5800
5851
  }