numo-narray-alt 0.9.4 → 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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -0
  3. data/README.md +22 -3
  4. data/Rakefile +8 -0
  5. data/ext/numo/narray/SFMT-params19937.h +16 -12
  6. data/ext/numo/narray/SFMT.c +12 -5
  7. data/ext/numo/narray/array.c +51 -21
  8. data/ext/numo/narray/data.c +88 -86
  9. data/ext/numo/narray/index.c +51 -28
  10. data/ext/numo/narray/kwargs.c +11 -9
  11. data/ext/numo/narray/math.c +14 -6
  12. data/ext/numo/narray/narray.c +93 -58
  13. data/ext/numo/narray/ndloop.c +52 -63
  14. data/ext/numo/narray/numo/intern.h +9 -3
  15. data/ext/numo/narray/numo/narray.h +20 -20
  16. data/ext/numo/narray/numo/ndloop.h +1 -1
  17. data/ext/numo/narray/numo/template.h +85 -81
  18. data/ext/numo/narray/numo/types/bit.h +76 -0
  19. data/ext/numo/narray/numo/types/complex.h +7 -3
  20. data/ext/numo/narray/numo/types/complex_macro.h +28 -25
  21. data/ext/numo/narray/numo/types/float_macro.h +21 -17
  22. data/ext/numo/narray/numo/types/real_accum.h +22 -22
  23. data/ext/numo/narray/numo/types/robj_macro.h +20 -12
  24. data/ext/numo/narray/numo/types/xint_macro.h +51 -8
  25. data/ext/numo/narray/rand.c +7 -0
  26. data/ext/numo/narray/src/mh/mean.h +102 -0
  27. data/ext/numo/narray/src/mh/rms.h +102 -0
  28. data/ext/numo/narray/src/mh/stddev.h +103 -0
  29. data/ext/numo/narray/src/mh/var.h +102 -0
  30. data/ext/numo/narray/src/t_bit.c +206 -147
  31. data/ext/numo/narray/src/t_dcomplex.c +531 -641
  32. data/ext/numo/narray/src/t_dfloat.c +1341 -1421
  33. data/ext/numo/narray/src/t_int16.c +562 -468
  34. data/ext/numo/narray/src/t_int32.c +562 -468
  35. data/ext/numo/narray/src/t_int64.c +561 -467
  36. data/ext/numo/narray/src/t_int8.c +520 -448
  37. data/ext/numo/narray/src/t_robject.c +519 -619
  38. data/ext/numo/narray/src/t_scomplex.c +524 -659
  39. data/ext/numo/narray/src/t_sfloat.c +1332 -1410
  40. data/ext/numo/narray/src/t_uint16.c +562 -468
  41. data/ext/numo/narray/src/t_uint32.c +562 -468
  42. data/ext/numo/narray/src/t_uint64.c +562 -468
  43. data/ext/numo/narray/src/t_uint8.c +522 -448
  44. data/ext/numo/narray/step.c +7 -2
  45. data/ext/numo/narray/struct.c +31 -24
  46. data/lib/numo/narray/extra.rb +74 -30
  47. data/numo-narray-alt.gemspec +38 -0
  48. metadata +10 -1
@@ -37,14 +37,23 @@ static ID id_to_a;
37
37
 
38
38
  #include <numo/types/int8.h>
39
39
 
40
- VALUE cT;
41
- extern VALUE cRT;
42
-
43
40
  /*
44
41
  class definition: Numo::Int8
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 int8_t int8; // Type aliases for shorter notation
52
+ // following the codebase naming convention.
53
+ DEF_NARRAY_INT_MEAN_METHOD_FUNC(int8, numo_cInt8)
54
+ DEF_NARRAY_INT_VAR_METHOD_FUNC(int8, numo_cInt8)
55
+ DEF_NARRAY_INT_STDDEV_METHOD_FUNC(int8, numo_cInt8)
56
+ DEF_NARRAY_INT_RMS_METHOD_FUNC(int8, numo_cInt8)
48
57
 
49
58
  static VALUE int8_store(VALUE, VALUE);
50
59
 
@@ -152,9 +161,9 @@ static VALUE int8_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 int8_extract(VALUE self) {
160
169
  volatile VALUE v;
@@ -238,8 +247,8 @@ static void iter_int8_store_bit(na_loop_t* const lp) {
238
247
  }
239
248
 
240
249
  static VALUE int8_store_bit(VALUE self, VALUE obj) {
241
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
242
- ndfunc_t ndf = {iter_int8_store_bit, FULL_LOOP, 2, 0, ain, 0};
250
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
251
+ ndfunc_t ndf = { iter_int8_store_bit, FULL_LOOP, 2, 0, ain, 0 };
243
252
 
244
253
  na_ndloop(&ndf, 2, self, obj);
245
254
  return self;
@@ -287,8 +296,8 @@ static void iter_int8_store_dfloat(na_loop_t* const lp) {
287
296
  }
288
297
 
289
298
  static VALUE int8_store_dfloat(VALUE self, VALUE obj) {
290
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
291
- ndfunc_t ndf = {iter_int8_store_dfloat, FULL_LOOP, 2, 0, ain, 0};
299
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
300
+ ndfunc_t ndf = { iter_int8_store_dfloat, FULL_LOOP, 2, 0, ain, 0 };
292
301
 
293
302
  na_ndloop(&ndf, 2, self, obj);
294
303
  return self;
@@ -336,8 +345,8 @@ static void iter_int8_store_sfloat(na_loop_t* const lp) {
336
345
  }
337
346
 
338
347
  static VALUE int8_store_sfloat(VALUE self, VALUE obj) {
339
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
340
- ndfunc_t ndf = {iter_int8_store_sfloat, FULL_LOOP, 2, 0, ain, 0};
348
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
349
+ ndfunc_t ndf = { iter_int8_store_sfloat, FULL_LOOP, 2, 0, ain, 0 };
341
350
 
342
351
  na_ndloop(&ndf, 2, self, obj);
343
352
  return self;
@@ -385,8 +394,8 @@ static void iter_int8_store_int64(na_loop_t* const lp) {
385
394
  }
386
395
 
387
396
  static VALUE int8_store_int64(VALUE self, VALUE obj) {
388
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
389
- ndfunc_t ndf = {iter_int8_store_int64, FULL_LOOP, 2, 0, ain, 0};
397
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
398
+ ndfunc_t ndf = { iter_int8_store_int64, FULL_LOOP, 2, 0, ain, 0 };
390
399
 
391
400
  na_ndloop(&ndf, 2, self, obj);
392
401
  return self;
@@ -434,8 +443,8 @@ static void iter_int8_store_int32(na_loop_t* const lp) {
434
443
  }
435
444
 
436
445
  static VALUE int8_store_int32(VALUE self, VALUE obj) {
437
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
438
- ndfunc_t ndf = {iter_int8_store_int32, FULL_LOOP, 2, 0, ain, 0};
446
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
447
+ ndfunc_t ndf = { iter_int8_store_int32, FULL_LOOP, 2, 0, ain, 0 };
439
448
 
440
449
  na_ndloop(&ndf, 2, self, obj);
441
450
  return self;
@@ -483,8 +492,8 @@ static void iter_int8_store_int16(na_loop_t* const lp) {
483
492
  }
484
493
 
485
494
  static VALUE int8_store_int16(VALUE self, VALUE obj) {
486
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
487
- ndfunc_t ndf = {iter_int8_store_int16, FULL_LOOP, 2, 0, ain, 0};
495
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
496
+ ndfunc_t ndf = { iter_int8_store_int16, FULL_LOOP, 2, 0, ain, 0 };
488
497
 
489
498
  na_ndloop(&ndf, 2, self, obj);
490
499
  return self;
@@ -532,8 +541,8 @@ static void iter_int8_store_int8(na_loop_t* const lp) {
532
541
  }
533
542
 
534
543
  static VALUE int8_store_int8(VALUE self, VALUE obj) {
535
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
536
- ndfunc_t ndf = {iter_int8_store_int8, FULL_LOOP, 2, 0, ain, 0};
544
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
545
+ ndfunc_t ndf = { iter_int8_store_int8, FULL_LOOP, 2, 0, ain, 0 };
537
546
 
538
547
  na_ndloop(&ndf, 2, self, obj);
539
548
  return self;
@@ -581,8 +590,8 @@ static void iter_int8_store_uint64(na_loop_t* const lp) {
581
590
  }
582
591
 
583
592
  static VALUE int8_store_uint64(VALUE self, VALUE obj) {
584
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
585
- ndfunc_t ndf = {iter_int8_store_uint64, FULL_LOOP, 2, 0, ain, 0};
593
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
594
+ ndfunc_t ndf = { iter_int8_store_uint64, FULL_LOOP, 2, 0, ain, 0 };
586
595
 
587
596
  na_ndloop(&ndf, 2, self, obj);
588
597
  return self;
@@ -630,8 +639,8 @@ static void iter_int8_store_uint32(na_loop_t* const lp) {
630
639
  }
631
640
 
632
641
  static VALUE int8_store_uint32(VALUE self, VALUE obj) {
633
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
634
- ndfunc_t ndf = {iter_int8_store_uint32, FULL_LOOP, 2, 0, ain, 0};
642
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
643
+ ndfunc_t ndf = { iter_int8_store_uint32, FULL_LOOP, 2, 0, ain, 0 };
635
644
 
636
645
  na_ndloop(&ndf, 2, self, obj);
637
646
  return self;
@@ -679,8 +688,8 @@ static void iter_int8_store_uint16(na_loop_t* const lp) {
679
688
  }
680
689
 
681
690
  static VALUE int8_store_uint16(VALUE self, VALUE obj) {
682
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
683
- ndfunc_t ndf = {iter_int8_store_uint16, FULL_LOOP, 2, 0, ain, 0};
691
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
692
+ ndfunc_t ndf = { iter_int8_store_uint16, FULL_LOOP, 2, 0, ain, 0 };
684
693
 
685
694
  na_ndloop(&ndf, 2, self, obj);
686
695
  return self;
@@ -728,8 +737,8 @@ static void iter_int8_store_uint8(na_loop_t* const lp) {
728
737
  }
729
738
 
730
739
  static VALUE int8_store_uint8(VALUE self, VALUE obj) {
731
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
732
- ndfunc_t ndf = {iter_int8_store_uint8, FULL_LOOP, 2, 0, ain, 0};
740
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
741
+ ndfunc_t ndf = { iter_int8_store_uint8, FULL_LOOP, 2, 0, ain, 0 };
733
742
 
734
743
  na_ndloop(&ndf, 2, self, obj);
735
744
  return self;
@@ -777,8 +786,8 @@ static void iter_int8_store_robject(na_loop_t* const lp) {
777
786
  }
778
787
 
779
788
  static VALUE int8_store_robject(VALUE self, VALUE obj) {
780
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
781
- ndfunc_t ndf = {iter_int8_store_robject, FULL_LOOP, 2, 0, ain, 0};
789
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
790
+ ndfunc_t ndf = { iter_int8_store_robject, FULL_LOOP, 2, 0, ain, 0 };
782
791
 
783
792
  na_ndloop(&ndf, 2, self, obj);
784
793
  return self;
@@ -886,8 +895,8 @@ loop_end:
886
895
  }
887
896
 
888
897
  static VALUE int8_store_array(VALUE self, VALUE rary) {
889
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {rb_cArray, 0}};
890
- ndfunc_t ndf = {iter_int8_store_array, FULL_LOOP, 2, 0, ain, 0};
898
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { rb_cArray, 0 } };
899
+ ndfunc_t ndf = { iter_int8_store_array, FULL_LOOP, 2, 0, ain, 0 };
891
900
 
892
901
  na_ndloop_store_rarray(&ndf, self, rary);
893
902
  return self;
@@ -896,8 +905,8 @@ static VALUE int8_store_array(VALUE self, VALUE rary) {
896
905
  /*
897
906
  Store elements to Numo::Int8 from other.
898
907
  @overload store(other)
899
- @param [Object] other
900
- @return [Numo::Int8] self
908
+ @param [Object] other
909
+ @return [Numo::Int8] self
901
910
  */
902
911
  static VALUE int8_store(VALUE self, VALUE obj) {
903
912
  VALUE r, klass;
@@ -982,8 +991,10 @@ static VALUE int8_store(VALUE self, VALUE obj) {
982
991
  }
983
992
  }
984
993
 
985
- rb_raise(nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
986
- rb_class2name(rb_obj_class(self)));
994
+ rb_raise(
995
+ nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
996
+ rb_class2name(rb_obj_class(self))
997
+ );
987
998
 
988
999
  return self;
989
1000
  }
@@ -1077,7 +1088,10 @@ static dtype int8_extract_data(VALUE obj) {
1077
1088
  return int8_extract_data(r);
1078
1089
  }
1079
1090
 
1080
- rb_raise(nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)), rb_class2name(cT));
1091
+ rb_raise(
1092
+ nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
1093
+ rb_class2name(cT)
1094
+ );
1081
1095
  }
1082
1096
  if (TYPE(obj) == T_ARRAY) {
1083
1097
  if (RARRAY_LEN(obj) != 1) {
@@ -1104,9 +1118,9 @@ static VALUE int8_cast_array(VALUE rary) {
1104
1118
  Cast object to Numo::Int8.
1105
1119
  @overload [](elements)
1106
1120
  @overload cast(array)
1107
- @param [Numeric,Array] elements
1108
- @param [Array] array
1109
- @return [Numo::Int8]
1121
+ @param [Numeric,Array] elements
1122
+ @param [Array] array
1123
+ @return [Numo::Int8]
1110
1124
  */
1111
1125
  static VALUE int8_s_cast(VALUE type, VALUE obj) {
1112
1126
  VALUE v;
@@ -1146,9 +1160,9 @@ static VALUE int8_s_cast(VALUE type, VALUE obj) {
1146
1160
  /*
1147
1161
  Multi-dimensional element reference.
1148
1162
  @overload [](dim0,...,dimL)
1149
- @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol] dim0,...,dimL multi-dimensional
1150
- indices.
1151
- @return [Numeric,Numo::Int8] 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::Int8] an element or NArray view.
1152
1166
  @see Numo::NArray#[]
1153
1167
  @see #[]=
1154
1168
  */
@@ -1169,10 +1183,10 @@ static VALUE int8_aref(int argc, VALUE* argv, VALUE self) {
1169
1183
  /*
1170
1184
  Multi-dimensional element assignment.
1171
1185
  @overload []=(dim0,...,dimL,val)
1172
- @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol] dim0,...,dimL multi-dimensional
1173
- indices.
1174
- @param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
1175
- @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).
1176
1190
  @see Numo::NArray#[]=
1177
1191
  @see #[]
1178
1192
  */
@@ -1203,7 +1217,7 @@ static VALUE int8_aset(int argc, VALUE* argv, VALUE self) {
1203
1217
  /*
1204
1218
  return NArray with cast to the type of self.
1205
1219
  @overload coerce_cast(type)
1206
- @return [nil]
1220
+ @return [nil]
1207
1221
  */
1208
1222
  static VALUE int8_coerce_cast(VALUE self, VALUE type) {
1209
1223
  return Qnil;
@@ -1238,12 +1252,12 @@ static void iter_int8_to_a(na_loop_t* const lp) {
1238
1252
  /*
1239
1253
  Convert self to Array.
1240
1254
  @overload to_a
1241
- @return [Array]
1255
+ @return [Array]
1242
1256
  */
1243
1257
  static VALUE int8_to_a(VALUE self) {
1244
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
1245
- ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
1246
- ndfunc_t ndf = {iter_int8_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
1258
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
1259
+ ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
1260
+ ndfunc_t ndf = { iter_int8_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
1247
1261
  return na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
1248
1262
  }
1249
1263
 
@@ -1271,12 +1285,12 @@ static void iter_int8_fill(na_loop_t* const lp) {
1271
1285
  /*
1272
1286
  Fill elements with other.
1273
1287
  @overload fill other
1274
- @param [Numeric] other
1275
- @return [Numo::Int8] self.
1288
+ @param [Numeric] other
1289
+ @return [Numo::Int8] self.
1276
1290
  */
1277
1291
  static VALUE int8_fill(VALUE self, VALUE val) {
1278
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_option}};
1279
- ndfunc_t ndf = {iter_int8_fill, FULL_LOOP, 2, 0, ain, 0};
1292
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
1293
+ ndfunc_t ndf = { iter_int8_fill, FULL_LOOP, 2, 0, ain, 0 };
1280
1294
 
1281
1295
  na_ndloop(&ndf, 2, self, val);
1282
1296
  return self;
@@ -1325,15 +1339,15 @@ static void iter_int8_format(na_loop_t* const lp) {
1325
1339
  /*
1326
1340
  Format elements into strings.
1327
1341
  @overload format format
1328
- @param [String] format
1329
- @return [Numo::RObject] array of formatted strings.
1342
+ @param [String] format
1343
+ @return [Numo::RObject] array of formatted strings.
1330
1344
  */
1331
1345
  static VALUE int8_format(int argc, VALUE* argv, VALUE self) {
1332
1346
  VALUE fmt = Qnil;
1333
1347
 
1334
- ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_option}};
1335
- ndfunc_arg_out_t aout[1] = {{numo_cRObject, 0}};
1336
- ndfunc_t ndf = {iter_int8_format, FULL_LOOP_NIP, 2, 1, ain, aout};
1348
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_option } };
1349
+ ndfunc_arg_out_t aout[1] = { { numo_cRObject, 0 } };
1350
+ ndfunc_t ndf = { iter_int8_format, FULL_LOOP_NIP, 2, 1, ain, aout };
1337
1351
 
1338
1352
  rb_scan_args(argc, argv, "01", &fmt);
1339
1353
  return na_ndloop(&ndf, 2, self, fmt);
@@ -1372,14 +1386,14 @@ static void iter_int8_format_to_a(na_loop_t* const lp) {
1372
1386
  /*
1373
1387
  Format elements into strings.
1374
1388
  @overload format_to_a format
1375
- @param [String] format
1376
- @return [Array] array of formatted strings.
1389
+ @param [String] format
1390
+ @return [Array] array of formatted strings.
1377
1391
  */
1378
1392
  static VALUE int8_format_to_a(int argc, VALUE* argv, VALUE self) {
1379
1393
  VALUE fmt = Qnil;
1380
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
1381
- ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
1382
- ndfunc_t ndf = {iter_int8_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
1394
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
1395
+ ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
1396
+ ndfunc_t ndf = { iter_int8_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
1383
1397
 
1384
1398
  rb_scan_args(argc, argv, "01", &fmt);
1385
1399
  return na_ndloop_cast_narray_to_rarray(&ndf, self, fmt);
@@ -1392,7 +1406,7 @@ static VALUE iter_int8_inspect(char* ptr, size_t pos, VALUE fmt) {
1392
1406
  /*
1393
1407
  Returns a string containing a human-readable representation of NArray.
1394
1408
  @overload inspect
1395
- @return [String]
1409
+ @return [String]
1396
1410
  */
1397
1411
  static VALUE int8_inspect(VALUE ary) {
1398
1412
  return na_ndloop_inspect(ary, iter_int8_inspect, Qnil);
@@ -1426,15 +1440,15 @@ static void iter_int8_each(na_loop_t* const lp) {
1426
1440
  Calls the given block once for each element in self,
1427
1441
  passing that element as a parameter.
1428
1442
  @overload each
1429
- @return [Numo::NArray] self
1430
- For a block `{|x| ... }`,
1431
- @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.
1432
1446
  @see #each_with_index
1433
1447
  @see #map
1434
1448
  */
1435
1449
  static VALUE int8_each(VALUE self) {
1436
- ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
1437
- ndfunc_t ndf = {iter_int8_each, FULL_LOOP_NIP, 1, 0, ain, 0};
1450
+ ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
1451
+ ndfunc_t ndf = { iter_int8_each, FULL_LOOP_NIP, 1, 0, ain, 0 };
1438
1452
 
1439
1453
  na_ndloop(&ndf, 1, self);
1440
1454
  return self;
@@ -1488,12 +1502,12 @@ static void iter_int8_map(na_loop_t* const lp) {
1488
1502
  /*
1489
1503
  Unary map.
1490
1504
  @overload map
1491
- @return [Numo::Int8] map of self.
1505
+ @return [Numo::Int8] map of self.
1492
1506
  */
1493
1507
  static VALUE int8_map(VALUE self) {
1494
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
1495
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
1496
- ndfunc_t ndf = {iter_int8_map, FULL_LOOP, 1, 1, ain, aout};
1508
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
1509
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
1510
+ ndfunc_t ndf = { iter_int8_map, FULL_LOOP, 1, 1, ain, aout };
1497
1511
 
1498
1512
  return na_ndloop(&ndf, 1, self);
1499
1513
  }
@@ -1547,16 +1561,16 @@ static void iter_int8_each_with_index(na_loop_t* const lp) {
1547
1561
  Invokes the given block once for each element of self,
1548
1562
  passing that element and indices along each axis as parameters.
1549
1563
  @overload each_with_index
1550
- For a block `{|x,i,j,...| ... }`,
1551
- @yieldparam [Numeric] x an element
1552
- @yieldparam [Integer] i,j,... multitimensional indices
1553
- @return [Numo::NArray] self
1564
+ For a block `{|x,i,j,...| ... }`,
1565
+ @yieldparam [Numeric] x an element
1566
+ @yieldparam [Integer] i,j,... multitimensional indices
1567
+ @return [Numo::NArray] self
1554
1568
  @see #each
1555
1569
  @see #map_with_index
1556
1570
  */
1557
1571
  static VALUE int8_each_with_index(VALUE self) {
1558
- ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
1559
- ndfunc_t ndf = {iter_int8_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0};
1572
+ ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
1573
+ ndfunc_t ndf = { iter_int8_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0 };
1560
1574
 
1561
1575
  na_ndloop_with_index(&ndf, 1, self);
1562
1576
  return self;
@@ -1638,17 +1652,17 @@ static void iter_int8_map_with_index(na_loop_t* const lp) {
1638
1652
  Creates a new NArray containing the values returned by the block.
1639
1653
  Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
1640
1654
  @overload map_with_index
1641
- For a block `{|x,i,j,...| ... }`,
1642
- @yieldparam [Numeric] x an element
1643
- @yieldparam [Integer] i,j,... multitimensional indices
1644
- @return [Numo::NArray] mapped array
1655
+ For a block `{|x,i,j,...| ... }`,
1656
+ @yieldparam [Numeric] x an element
1657
+ @yieldparam [Integer] i,j,... multitimensional indices
1658
+ @return [Numo::NArray] mapped array
1645
1659
  @see #map
1646
1660
  @see #each_with_index
1647
1661
  */
1648
1662
  static VALUE int8_map_with_index(VALUE self) {
1649
- ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
1650
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
1651
- ndfunc_t ndf = {iter_int8_map_with_index, FULL_LOOP, 1, 1, ain, aout};
1663
+ ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
1664
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
1665
+ ndfunc_t ndf = { iter_int8_map_with_index, FULL_LOOP, 1, 1, ain, aout };
1652
1666
 
1653
1667
  return na_ndloop_with_index(&ndf, 1, self);
1654
1668
  }
@@ -1697,17 +1711,17 @@ static void iter_int8_abs(na_loop_t* const lp) {
1697
1711
  /*
1698
1712
  abs of self.
1699
1713
  @overload abs
1700
- @return [Numo::Int8] abs of self.
1714
+ @return [Numo::Int8] abs of self.
1701
1715
  */
1702
1716
  static VALUE int8_abs(VALUE self) {
1703
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
1704
- ndfunc_arg_out_t aout[1] = {{cRT, 0}};
1705
- ndfunc_t ndf = {iter_int8_abs, FULL_LOOP, 1, 1, ain, aout};
1717
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
1718
+ ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
1719
+ ndfunc_t ndf = { iter_int8_abs, FULL_LOOP, 1, 1, ain, aout };
1706
1720
 
1707
1721
  return na_ndloop(&ndf, 1, self);
1708
1722
  }
1709
1723
 
1710
- #define check_intdivzero(y) \
1724
+ #define check_intdivzero(y) \
1711
1725
  {}
1712
1726
 
1713
1727
  static void iter_int8_add(na_loop_t* const lp) {
@@ -1767,9 +1781,9 @@ static void iter_int8_add(na_loop_t* const lp) {
1767
1781
  #undef check_intdivzero
1768
1782
 
1769
1783
  static VALUE int8_add_self(VALUE self, VALUE other) {
1770
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
1771
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
1772
- ndfunc_t ndf = {iter_int8_add, STRIDE_LOOP, 2, 1, ain, aout};
1784
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
1785
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
1786
+ ndfunc_t ndf = { iter_int8_add, STRIDE_LOOP, 2, 1, ain, aout };
1773
1787
 
1774
1788
  return na_ndloop(&ndf, 2, self, other);
1775
1789
  }
@@ -1777,8 +1791,8 @@ static VALUE int8_add_self(VALUE self, VALUE other) {
1777
1791
  /*
1778
1792
  Binary add.
1779
1793
  @overload + other
1780
- @param [Numo::NArray,Numeric] other
1781
- @return [Numo::NArray] self + other
1794
+ @param [Numo::NArray,Numeric] other
1795
+ @return [Numo::NArray] self + other
1782
1796
  */
1783
1797
  static VALUE int8_add(VALUE self, VALUE other) {
1784
1798
 
@@ -1793,7 +1807,7 @@ static VALUE int8_add(VALUE self, VALUE other) {
1793
1807
  }
1794
1808
  }
1795
1809
 
1796
- #define check_intdivzero(y) \
1810
+ #define check_intdivzero(y) \
1797
1811
  {}
1798
1812
 
1799
1813
  static void iter_int8_sub(na_loop_t* const lp) {
@@ -1853,9 +1867,9 @@ static void iter_int8_sub(na_loop_t* const lp) {
1853
1867
  #undef check_intdivzero
1854
1868
 
1855
1869
  static VALUE int8_sub_self(VALUE self, VALUE other) {
1856
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
1857
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
1858
- ndfunc_t ndf = {iter_int8_sub, STRIDE_LOOP, 2, 1, ain, aout};
1870
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
1871
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
1872
+ ndfunc_t ndf = { iter_int8_sub, STRIDE_LOOP, 2, 1, ain, aout };
1859
1873
 
1860
1874
  return na_ndloop(&ndf, 2, self, other);
1861
1875
  }
@@ -1863,8 +1877,8 @@ static VALUE int8_sub_self(VALUE self, VALUE other) {
1863
1877
  /*
1864
1878
  Binary sub.
1865
1879
  @overload - other
1866
- @param [Numo::NArray,Numeric] other
1867
- @return [Numo::NArray] self - other
1880
+ @param [Numo::NArray,Numeric] other
1881
+ @return [Numo::NArray] self - other
1868
1882
  */
1869
1883
  static VALUE int8_sub(VALUE self, VALUE other) {
1870
1884
 
@@ -1879,7 +1893,7 @@ static VALUE int8_sub(VALUE self, VALUE other) {
1879
1893
  }
1880
1894
  }
1881
1895
 
1882
- #define check_intdivzero(y) \
1896
+ #define check_intdivzero(y) \
1883
1897
  {}
1884
1898
 
1885
1899
  static void iter_int8_mul(na_loop_t* const lp) {
@@ -1939,9 +1953,9 @@ static void iter_int8_mul(na_loop_t* const lp) {
1939
1953
  #undef check_intdivzero
1940
1954
 
1941
1955
  static VALUE int8_mul_self(VALUE self, VALUE other) {
1942
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
1943
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
1944
- ndfunc_t ndf = {iter_int8_mul, STRIDE_LOOP, 2, 1, ain, aout};
1956
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
1957
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
1958
+ ndfunc_t ndf = { iter_int8_mul, STRIDE_LOOP, 2, 1, ain, aout };
1945
1959
 
1946
1960
  return na_ndloop(&ndf, 2, self, other);
1947
1961
  }
@@ -1949,8 +1963,8 @@ static VALUE int8_mul_self(VALUE self, VALUE other) {
1949
1963
  /*
1950
1964
  Binary mul.
1951
1965
  @overload * other
1952
- @param [Numo::NArray,Numeric] other
1953
- @return [Numo::NArray] self * other
1966
+ @param [Numo::NArray,Numeric] other
1967
+ @return [Numo::NArray] self * other
1954
1968
  */
1955
1969
  static VALUE int8_mul(VALUE self, VALUE other) {
1956
1970
 
@@ -1965,10 +1979,10 @@ static VALUE int8_mul(VALUE self, VALUE other) {
1965
1979
  }
1966
1980
  }
1967
1981
 
1968
- #define check_intdivzero(y) \
1969
- if ((y) == 0) { \
1970
- lp->err_type = rb_eZeroDivError; \
1971
- return; \
1982
+ #define check_intdivzero(y) \
1983
+ if ((y) == 0) { \
1984
+ lp->err_type = rb_eZeroDivError; \
1985
+ return; \
1972
1986
  }
1973
1987
 
1974
1988
  static void iter_int8_div(na_loop_t* const lp) {
@@ -2028,9 +2042,9 @@ static void iter_int8_div(na_loop_t* const lp) {
2028
2042
  #undef check_intdivzero
2029
2043
 
2030
2044
  static VALUE int8_div_self(VALUE self, VALUE other) {
2031
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2032
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2033
- ndfunc_t ndf = {iter_int8_div, STRIDE_LOOP, 2, 1, ain, aout};
2045
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2046
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2047
+ ndfunc_t ndf = { iter_int8_div, STRIDE_LOOP, 2, 1, ain, aout };
2034
2048
 
2035
2049
  return na_ndloop(&ndf, 2, self, other);
2036
2050
  }
@@ -2038,8 +2052,8 @@ static VALUE int8_div_self(VALUE self, VALUE other) {
2038
2052
  /*
2039
2053
  Binary div.
2040
2054
  @overload / other
2041
- @param [Numo::NArray,Numeric] other
2042
- @return [Numo::NArray] self / other
2055
+ @param [Numo::NArray,Numeric] other
2056
+ @return [Numo::NArray] self / other
2043
2057
  */
2044
2058
  static VALUE int8_div(VALUE self, VALUE other) {
2045
2059
 
@@ -2054,10 +2068,10 @@ static VALUE int8_div(VALUE self, VALUE other) {
2054
2068
  }
2055
2069
  }
2056
2070
 
2057
- #define check_intdivzero(y) \
2058
- if ((y) == 0) { \
2059
- lp->err_type = rb_eZeroDivError; \
2060
- return; \
2071
+ #define check_intdivzero(y) \
2072
+ if ((y) == 0) { \
2073
+ lp->err_type = rb_eZeroDivError; \
2074
+ return; \
2061
2075
  }
2062
2076
 
2063
2077
  static void iter_int8_mod(na_loop_t* const lp) {
@@ -2117,9 +2131,9 @@ static void iter_int8_mod(na_loop_t* const lp) {
2117
2131
  #undef check_intdivzero
2118
2132
 
2119
2133
  static VALUE int8_mod_self(VALUE self, VALUE other) {
2120
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2121
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2122
- ndfunc_t ndf = {iter_int8_mod, STRIDE_LOOP, 2, 1, ain, aout};
2134
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2135
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2136
+ ndfunc_t ndf = { iter_int8_mod, STRIDE_LOOP, 2, 1, ain, aout };
2123
2137
 
2124
2138
  return na_ndloop(&ndf, 2, self, other);
2125
2139
  }
@@ -2127,8 +2141,8 @@ static VALUE int8_mod_self(VALUE self, VALUE other) {
2127
2141
  /*
2128
2142
  Binary mod.
2129
2143
  @overload % other
2130
- @param [Numo::NArray,Numeric] other
2131
- @return [Numo::NArray] self % other
2144
+ @param [Numo::NArray,Numeric] other
2145
+ @return [Numo::NArray] self % other
2132
2146
  */
2133
2147
  static VALUE int8_mod(VALUE self, VALUE other) {
2134
2148
 
@@ -2167,9 +2181,9 @@ static void iter_int8_divmod(na_loop_t* const lp) {
2167
2181
  }
2168
2182
 
2169
2183
  static VALUE int8_divmod_self(VALUE self, VALUE other) {
2170
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2171
- ndfunc_arg_out_t aout[2] = {{cT, 0}, {cT, 0}};
2172
- ndfunc_t ndf = {iter_int8_divmod, STRIDE_LOOP, 2, 2, ain, aout};
2184
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2185
+ ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
2186
+ ndfunc_t ndf = { iter_int8_divmod, STRIDE_LOOP, 2, 2, ain, aout };
2173
2187
 
2174
2188
  return na_ndloop(&ndf, 2, self, other);
2175
2189
  }
@@ -2177,8 +2191,8 @@ static VALUE int8_divmod_self(VALUE self, VALUE other) {
2177
2191
  /*
2178
2192
  Binary divmod.
2179
2193
  @overload divmod other
2180
- @param [Numo::NArray,Numeric] other
2181
- @return [Numo::NArray] divmod of self and other.
2194
+ @param [Numo::NArray,Numeric] other
2195
+ @return [Numo::NArray] divmod of self and other.
2182
2196
  */
2183
2197
  static VALUE int8_divmod(VALUE self, VALUE other) {
2184
2198
 
@@ -2228,11 +2242,11 @@ static void iter_int8_pow_int32(na_loop_t* const lp) {
2228
2242
  }
2229
2243
 
2230
2244
  static VALUE int8_pow_self(VALUE self, VALUE other) {
2231
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2232
- ndfunc_arg_in_t ain_i[2] = {{cT, 0}, {numo_cInt32, 0}};
2233
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2234
- ndfunc_t ndf = {iter_int8_pow, STRIDE_LOOP, 2, 1, ain, aout};
2235
- ndfunc_t ndf_i = {iter_int8_pow_int32, STRIDE_LOOP, 2, 1, ain_i, aout};
2245
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2246
+ ndfunc_arg_in_t ain_i[2] = { { cT, 0 }, { numo_cInt32, 0 } };
2247
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2248
+ ndfunc_t ndf = { iter_int8_pow, STRIDE_LOOP, 2, 1, ain, aout };
2249
+ ndfunc_t ndf_i = { iter_int8_pow_int32, STRIDE_LOOP, 2, 1, ain_i, aout };
2236
2250
 
2237
2251
  // fixme : use na.integer?
2238
2252
  if (FIXNUM_P(other) || rb_obj_is_kind_of(other, numo_cInt32)) {
@@ -2245,8 +2259,8 @@ static VALUE int8_pow_self(VALUE self, VALUE other) {
2245
2259
  /*
2246
2260
  Binary power.
2247
2261
  @overload ** other
2248
- @param [Numo::NArray,Numeric] other
2249
- @return [Numo::NArray] self to the other-th power.
2262
+ @param [Numo::NArray,Numeric] other
2263
+ @return [Numo::NArray] self to the other-th power.
2250
2264
  */
2251
2265
  static VALUE int8_pow(VALUE self, VALUE other) {
2252
2266
 
@@ -2308,12 +2322,12 @@ static void iter_int8_minus(na_loop_t* const lp) {
2308
2322
  /*
2309
2323
  Unary minus.
2310
2324
  @overload -@
2311
- @return [Numo::Int8] minus of self.
2325
+ @return [Numo::Int8] minus of self.
2312
2326
  */
2313
2327
  static VALUE int8_minus(VALUE self) {
2314
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
2315
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2316
- ndfunc_t ndf = {iter_int8_minus, FULL_LOOP, 1, 1, ain, aout};
2328
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
2329
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2330
+ ndfunc_t ndf = { iter_int8_minus, FULL_LOOP, 1, 1, ain, aout };
2317
2331
 
2318
2332
  return na_ndloop(&ndf, 1, self);
2319
2333
  }
@@ -2366,12 +2380,12 @@ static void iter_int8_reciprocal(na_loop_t* const lp) {
2366
2380
  /*
2367
2381
  Unary reciprocal.
2368
2382
  @overload reciprocal
2369
- @return [Numo::Int8] reciprocal of self.
2383
+ @return [Numo::Int8] reciprocal of self.
2370
2384
  */
2371
2385
  static VALUE int8_reciprocal(VALUE self) {
2372
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
2373
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2374
- ndfunc_t ndf = {iter_int8_reciprocal, FULL_LOOP, 1, 1, ain, aout};
2386
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
2387
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2388
+ ndfunc_t ndf = { iter_int8_reciprocal, FULL_LOOP, 1, 1, ain, aout };
2375
2389
 
2376
2390
  return na_ndloop(&ndf, 1, self);
2377
2391
  }
@@ -2424,12 +2438,12 @@ static void iter_int8_sign(na_loop_t* const lp) {
2424
2438
  /*
2425
2439
  Unary sign.
2426
2440
  @overload sign
2427
- @return [Numo::Int8] sign of self.
2441
+ @return [Numo::Int8] sign of self.
2428
2442
  */
2429
2443
  static VALUE int8_sign(VALUE self) {
2430
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
2431
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2432
- ndfunc_t ndf = {iter_int8_sign, FULL_LOOP, 1, 1, ain, aout};
2444
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
2445
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2446
+ ndfunc_t ndf = { iter_int8_sign, FULL_LOOP, 1, 1, ain, aout };
2433
2447
 
2434
2448
  return na_ndloop(&ndf, 1, self);
2435
2449
  }
@@ -2482,12 +2496,12 @@ static void iter_int8_square(na_loop_t* const lp) {
2482
2496
  /*
2483
2497
  Unary square.
2484
2498
  @overload square
2485
- @return [Numo::Int8] square of self.
2499
+ @return [Numo::Int8] square of self.
2486
2500
  */
2487
2501
  static VALUE int8_square(VALUE self) {
2488
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
2489
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2490
- ndfunc_t ndf = {iter_int8_square, FULL_LOOP, 1, 1, ain, aout};
2502
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
2503
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2504
+ ndfunc_t ndf = { iter_int8_square, FULL_LOOP, 1, 1, ain, aout };
2491
2505
 
2492
2506
  return na_ndloop(&ndf, 1, self);
2493
2507
  }
@@ -2514,9 +2528,9 @@ static void iter_int8_eq(na_loop_t* const lp) {
2514
2528
  }
2515
2529
 
2516
2530
  static VALUE int8_eq_self(VALUE self, VALUE other) {
2517
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2518
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
2519
- ndfunc_t ndf = {iter_int8_eq, STRIDE_LOOP, 2, 1, ain, aout};
2531
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2532
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
2533
+ ndfunc_t ndf = { iter_int8_eq, STRIDE_LOOP, 2, 1, ain, aout };
2520
2534
 
2521
2535
  return na_ndloop(&ndf, 2, self, other);
2522
2536
  }
@@ -2524,8 +2538,8 @@ static VALUE int8_eq_self(VALUE self, VALUE other) {
2524
2538
  /*
2525
2539
  Comparison eq other.
2526
2540
  @overload eq other
2527
- @param [Numo::NArray,Numeric] other
2528
- @return [Numo::Bit] result of self eq other.
2541
+ @param [Numo::NArray,Numeric] other
2542
+ @return [Numo::Bit] result of self eq other.
2529
2543
  */
2530
2544
  static VALUE int8_eq(VALUE self, VALUE other) {
2531
2545
 
@@ -2561,9 +2575,9 @@ static void iter_int8_ne(na_loop_t* const lp) {
2561
2575
  }
2562
2576
 
2563
2577
  static VALUE int8_ne_self(VALUE self, VALUE other) {
2564
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2565
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
2566
- ndfunc_t ndf = {iter_int8_ne, STRIDE_LOOP, 2, 1, ain, aout};
2578
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2579
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
2580
+ ndfunc_t ndf = { iter_int8_ne, STRIDE_LOOP, 2, 1, ain, aout };
2567
2581
 
2568
2582
  return na_ndloop(&ndf, 2, self, other);
2569
2583
  }
@@ -2571,8 +2585,8 @@ static VALUE int8_ne_self(VALUE self, VALUE other) {
2571
2585
  /*
2572
2586
  Comparison ne other.
2573
2587
  @overload ne other
2574
- @param [Numo::NArray,Numeric] other
2575
- @return [Numo::Bit] result of self ne other.
2588
+ @param [Numo::NArray,Numeric] other
2589
+ @return [Numo::Bit] result of self ne other.
2576
2590
  */
2577
2591
  static VALUE int8_ne(VALUE self, VALUE other) {
2578
2592
 
@@ -2586,7 +2600,7 @@ static VALUE int8_ne(VALUE self, VALUE other) {
2586
2600
  }
2587
2601
  }
2588
2602
 
2589
- #define check_intdivzero(y) \
2603
+ #define check_intdivzero(y) \
2590
2604
  {}
2591
2605
 
2592
2606
  static void iter_int8_bit_and(na_loop_t* const lp) {
@@ -2646,9 +2660,9 @@ static void iter_int8_bit_and(na_loop_t* const lp) {
2646
2660
  #undef check_intdivzero
2647
2661
 
2648
2662
  static VALUE int8_bit_and_self(VALUE self, VALUE other) {
2649
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2650
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2651
- ndfunc_t ndf = {iter_int8_bit_and, STRIDE_LOOP, 2, 1, ain, aout};
2663
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2664
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2665
+ ndfunc_t ndf = { iter_int8_bit_and, STRIDE_LOOP, 2, 1, ain, aout };
2652
2666
 
2653
2667
  return na_ndloop(&ndf, 2, self, other);
2654
2668
  }
@@ -2656,8 +2670,8 @@ static VALUE int8_bit_and_self(VALUE self, VALUE other) {
2656
2670
  /*
2657
2671
  Binary bit_and.
2658
2672
  @overload & other
2659
- @param [Numo::NArray,Numeric] other
2660
- @return [Numo::NArray] self & other
2673
+ @param [Numo::NArray,Numeric] other
2674
+ @return [Numo::NArray] self & other
2661
2675
  */
2662
2676
  static VALUE int8_bit_and(VALUE self, VALUE other) {
2663
2677
 
@@ -2672,7 +2686,7 @@ static VALUE int8_bit_and(VALUE self, VALUE other) {
2672
2686
  }
2673
2687
  }
2674
2688
 
2675
- #define check_intdivzero(y) \
2689
+ #define check_intdivzero(y) \
2676
2690
  {}
2677
2691
 
2678
2692
  static void iter_int8_bit_or(na_loop_t* const lp) {
@@ -2732,9 +2746,9 @@ static void iter_int8_bit_or(na_loop_t* const lp) {
2732
2746
  #undef check_intdivzero
2733
2747
 
2734
2748
  static VALUE int8_bit_or_self(VALUE self, VALUE other) {
2735
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2736
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2737
- ndfunc_t ndf = {iter_int8_bit_or, STRIDE_LOOP, 2, 1, ain, aout};
2749
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2750
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2751
+ ndfunc_t ndf = { iter_int8_bit_or, STRIDE_LOOP, 2, 1, ain, aout };
2738
2752
 
2739
2753
  return na_ndloop(&ndf, 2, self, other);
2740
2754
  }
@@ -2742,8 +2756,8 @@ static VALUE int8_bit_or_self(VALUE self, VALUE other) {
2742
2756
  /*
2743
2757
  Binary bit_or.
2744
2758
  @overload | other
2745
- @param [Numo::NArray,Numeric] other
2746
- @return [Numo::NArray] self | other
2759
+ @param [Numo::NArray,Numeric] other
2760
+ @return [Numo::NArray] self | other
2747
2761
  */
2748
2762
  static VALUE int8_bit_or(VALUE self, VALUE other) {
2749
2763
 
@@ -2758,7 +2772,7 @@ static VALUE int8_bit_or(VALUE self, VALUE other) {
2758
2772
  }
2759
2773
  }
2760
2774
 
2761
- #define check_intdivzero(y) \
2775
+ #define check_intdivzero(y) \
2762
2776
  {}
2763
2777
 
2764
2778
  static void iter_int8_bit_xor(na_loop_t* const lp) {
@@ -2818,9 +2832,9 @@ static void iter_int8_bit_xor(na_loop_t* const lp) {
2818
2832
  #undef check_intdivzero
2819
2833
 
2820
2834
  static VALUE int8_bit_xor_self(VALUE self, VALUE other) {
2821
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2822
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2823
- ndfunc_t ndf = {iter_int8_bit_xor, STRIDE_LOOP, 2, 1, ain, aout};
2835
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2836
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2837
+ ndfunc_t ndf = { iter_int8_bit_xor, STRIDE_LOOP, 2, 1, ain, aout };
2824
2838
 
2825
2839
  return na_ndloop(&ndf, 2, self, other);
2826
2840
  }
@@ -2828,8 +2842,8 @@ static VALUE int8_bit_xor_self(VALUE self, VALUE other) {
2828
2842
  /*
2829
2843
  Binary bit_xor.
2830
2844
  @overload ^ other
2831
- @param [Numo::NArray,Numeric] other
2832
- @return [Numo::NArray] self ^ other
2845
+ @param [Numo::NArray,Numeric] other
2846
+ @return [Numo::NArray] self ^ other
2833
2847
  */
2834
2848
  static VALUE int8_bit_xor(VALUE self, VALUE other) {
2835
2849
 
@@ -2892,17 +2906,17 @@ static void iter_int8_bit_not(na_loop_t* const lp) {
2892
2906
  /*
2893
2907
  Unary bit_not.
2894
2908
  @overload ~
2895
- @return [Numo::Int8] bit_not of self.
2909
+ @return [Numo::Int8] bit_not of self.
2896
2910
  */
2897
2911
  static VALUE int8_bit_not(VALUE self) {
2898
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
2899
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2900
- ndfunc_t ndf = {iter_int8_bit_not, FULL_LOOP, 1, 1, ain, aout};
2912
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
2913
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2914
+ ndfunc_t ndf = { iter_int8_bit_not, FULL_LOOP, 1, 1, ain, aout };
2901
2915
 
2902
2916
  return na_ndloop(&ndf, 1, self);
2903
2917
  }
2904
2918
 
2905
- #define check_intdivzero(y) \
2919
+ #define check_intdivzero(y) \
2906
2920
  {}
2907
2921
 
2908
2922
  static void iter_int8_left_shift(na_loop_t* const lp) {
@@ -2962,9 +2976,9 @@ static void iter_int8_left_shift(na_loop_t* const lp) {
2962
2976
  #undef check_intdivzero
2963
2977
 
2964
2978
  static VALUE int8_left_shift_self(VALUE self, VALUE other) {
2965
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2966
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2967
- ndfunc_t ndf = {iter_int8_left_shift, STRIDE_LOOP, 2, 1, ain, aout};
2979
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2980
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2981
+ ndfunc_t ndf = { iter_int8_left_shift, STRIDE_LOOP, 2, 1, ain, aout };
2968
2982
 
2969
2983
  return na_ndloop(&ndf, 2, self, other);
2970
2984
  }
@@ -2972,8 +2986,8 @@ static VALUE int8_left_shift_self(VALUE self, VALUE other) {
2972
2986
  /*
2973
2987
  Binary left_shift.
2974
2988
  @overload << other
2975
- @param [Numo::NArray,Numeric] other
2976
- @return [Numo::NArray] self << other
2989
+ @param [Numo::NArray,Numeric] other
2990
+ @return [Numo::NArray] self << other
2977
2991
  */
2978
2992
  static VALUE int8_left_shift(VALUE self, VALUE other) {
2979
2993
 
@@ -2988,7 +3002,7 @@ static VALUE int8_left_shift(VALUE self, VALUE other) {
2988
3002
  }
2989
3003
  }
2990
3004
 
2991
- #define check_intdivzero(y) \
3005
+ #define check_intdivzero(y) \
2992
3006
  {}
2993
3007
 
2994
3008
  static void iter_int8_right_shift(na_loop_t* const lp) {
@@ -3048,9 +3062,9 @@ static void iter_int8_right_shift(na_loop_t* const lp) {
3048
3062
  #undef check_intdivzero
3049
3063
 
3050
3064
  static VALUE int8_right_shift_self(VALUE self, VALUE other) {
3051
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3052
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3053
- ndfunc_t ndf = {iter_int8_right_shift, STRIDE_LOOP, 2, 1, ain, aout};
3065
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3066
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3067
+ ndfunc_t ndf = { iter_int8_right_shift, STRIDE_LOOP, 2, 1, ain, aout };
3054
3068
 
3055
3069
  return na_ndloop(&ndf, 2, self, other);
3056
3070
  }
@@ -3058,8 +3072,8 @@ static VALUE int8_right_shift_self(VALUE self, VALUE other) {
3058
3072
  /*
3059
3073
  Binary right_shift.
3060
3074
  @overload >> other
3061
- @param [Numo::NArray,Numeric] other
3062
- @return [Numo::NArray] self >> other
3075
+ @param [Numo::NArray,Numeric] other
3076
+ @return [Numo::NArray] self >> other
3063
3077
  */
3064
3078
  static VALUE int8_right_shift(VALUE self, VALUE other) {
3065
3079
 
@@ -3096,9 +3110,9 @@ static void iter_int8_gt(na_loop_t* const lp) {
3096
3110
  }
3097
3111
 
3098
3112
  static VALUE int8_gt_self(VALUE self, VALUE other) {
3099
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3100
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3101
- ndfunc_t ndf = {iter_int8_gt, STRIDE_LOOP, 2, 1, ain, aout};
3113
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3114
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3115
+ ndfunc_t ndf = { iter_int8_gt, STRIDE_LOOP, 2, 1, ain, aout };
3102
3116
 
3103
3117
  return na_ndloop(&ndf, 2, self, other);
3104
3118
  }
@@ -3106,8 +3120,8 @@ static VALUE int8_gt_self(VALUE self, VALUE other) {
3106
3120
  /*
3107
3121
  Comparison gt other.
3108
3122
  @overload gt other
3109
- @param [Numo::NArray,Numeric] other
3110
- @return [Numo::Bit] result of self gt other.
3123
+ @param [Numo::NArray,Numeric] other
3124
+ @return [Numo::Bit] result of self gt other.
3111
3125
  */
3112
3126
  static VALUE int8_gt(VALUE self, VALUE other) {
3113
3127
 
@@ -3143,9 +3157,9 @@ static void iter_int8_ge(na_loop_t* const lp) {
3143
3157
  }
3144
3158
 
3145
3159
  static VALUE int8_ge_self(VALUE self, VALUE other) {
3146
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3147
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3148
- ndfunc_t ndf = {iter_int8_ge, STRIDE_LOOP, 2, 1, ain, aout};
3160
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3161
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3162
+ ndfunc_t ndf = { iter_int8_ge, STRIDE_LOOP, 2, 1, ain, aout };
3149
3163
 
3150
3164
  return na_ndloop(&ndf, 2, self, other);
3151
3165
  }
@@ -3153,8 +3167,8 @@ static VALUE int8_ge_self(VALUE self, VALUE other) {
3153
3167
  /*
3154
3168
  Comparison ge other.
3155
3169
  @overload ge other
3156
- @param [Numo::NArray,Numeric] other
3157
- @return [Numo::Bit] result of self ge other.
3170
+ @param [Numo::NArray,Numeric] other
3171
+ @return [Numo::Bit] result of self ge other.
3158
3172
  */
3159
3173
  static VALUE int8_ge(VALUE self, VALUE other) {
3160
3174
 
@@ -3190,9 +3204,9 @@ static void iter_int8_lt(na_loop_t* const lp) {
3190
3204
  }
3191
3205
 
3192
3206
  static VALUE int8_lt_self(VALUE self, VALUE other) {
3193
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3194
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3195
- ndfunc_t ndf = {iter_int8_lt, STRIDE_LOOP, 2, 1, ain, aout};
3207
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3208
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3209
+ ndfunc_t ndf = { iter_int8_lt, STRIDE_LOOP, 2, 1, ain, aout };
3196
3210
 
3197
3211
  return na_ndloop(&ndf, 2, self, other);
3198
3212
  }
@@ -3200,8 +3214,8 @@ static VALUE int8_lt_self(VALUE self, VALUE other) {
3200
3214
  /*
3201
3215
  Comparison lt other.
3202
3216
  @overload lt other
3203
- @param [Numo::NArray,Numeric] other
3204
- @return [Numo::Bit] result of self lt other.
3217
+ @param [Numo::NArray,Numeric] other
3218
+ @return [Numo::Bit] result of self lt other.
3205
3219
  */
3206
3220
  static VALUE int8_lt(VALUE self, VALUE other) {
3207
3221
 
@@ -3237,9 +3251,9 @@ static void iter_int8_le(na_loop_t* const lp) {
3237
3251
  }
3238
3252
 
3239
3253
  static VALUE int8_le_self(VALUE self, VALUE other) {
3240
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3241
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3242
- ndfunc_t ndf = {iter_int8_le, STRIDE_LOOP, 2, 1, ain, aout};
3254
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3255
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3256
+ ndfunc_t ndf = { iter_int8_le, STRIDE_LOOP, 2, 1, ain, aout };
3243
3257
 
3244
3258
  return na_ndloop(&ndf, 2, self, other);
3245
3259
  }
@@ -3247,8 +3261,8 @@ static VALUE int8_le_self(VALUE self, VALUE other) {
3247
3261
  /*
3248
3262
  Comparison le other.
3249
3263
  @overload le other
3250
- @param [Numo::NArray,Numeric] other
3251
- @return [Numo::Bit] result of self le other.
3264
+ @param [Numo::NArray,Numeric] other
3265
+ @return [Numo::Bit] result of self le other.
3252
3266
  */
3253
3267
  static VALUE int8_le(VALUE self, VALUE other) {
3254
3268
 
@@ -3331,9 +3345,9 @@ static void iter_int8_clip_max(na_loop_t* const lp) {
3331
3345
  Clip array elements by [min,max].
3332
3346
  If either of min or max is nil, one side is clipped.
3333
3347
  @overload clip(min,max)
3334
- @param [Numo::NArray,Numeric] min
3335
- @param [Numo::NArray,Numeric] max
3336
- @return [Numo::NArray] result of clip.
3348
+ @param [Numo::NArray,Numeric] min
3349
+ @param [Numo::NArray,Numeric] max
3350
+ @return [Numo::NArray] result of clip.
3337
3351
 
3338
3352
  @example
3339
3353
  a = Numo::Int32.new(10).seq
@@ -3358,11 +3372,11 @@ static void iter_int8_clip_max(na_loop_t* const lp) {
3358
3372
  # [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]
3359
3373
  */
3360
3374
  static VALUE int8_clip(VALUE self, VALUE min, VALUE max) {
3361
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {cT, 0}, {cT, 0}};
3362
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3363
- ndfunc_t ndf_min = {iter_int8_clip_min, STRIDE_LOOP, 2, 1, ain, aout};
3364
- ndfunc_t ndf_max = {iter_int8_clip_max, STRIDE_LOOP, 2, 1, ain, aout};
3365
- ndfunc_t ndf_both = {iter_int8_clip, STRIDE_LOOP, 3, 1, ain, aout};
3375
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { cT, 0 }, { cT, 0 } };
3376
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3377
+ ndfunc_t ndf_min = { iter_int8_clip_min, STRIDE_LOOP, 2, 1, ain, aout };
3378
+ ndfunc_t ndf_max = { iter_int8_clip_max, STRIDE_LOOP, 2, 1, ain, aout };
3379
+ ndfunc_t ndf_both = { iter_int8_clip, STRIDE_LOOP, 3, 1, ain, aout };
3366
3380
 
3367
3381
  if (RTEST(min)) {
3368
3382
  if (RTEST(max)) {
@@ -3394,15 +3408,16 @@ static void iter_int8_sum(na_loop_t* const lp) {
3394
3408
  /*
3395
3409
  sum of self.
3396
3410
  @overload sum(axis:nil, keepdims:false)
3397
- @param [Numeric,Array,Range] axis Performs sum along the axis.
3398
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
3399
- @return [Numo::Int8] returns result of sum.
3411
+ @param [Numeric,Array,Range] axis Performs sum along the axis.
3412
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3413
+ dimensions with size one.
3414
+ @return [Numo::Int8] returns result of sum.
3400
3415
  */
3401
3416
  static VALUE int8_sum(int argc, VALUE* argv, VALUE self) {
3402
3417
  VALUE v, reduce;
3403
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
3404
- ndfunc_arg_out_t aout[1] = {{numo_cInt64, 0}};
3405
- ndfunc_t ndf = {iter_int8_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
3418
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
3419
+ ndfunc_arg_out_t aout[1] = { { numo_cInt64, 0 } };
3420
+ ndfunc_t ndf = { iter_int8_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
3406
3421
 
3407
3422
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
3408
3423
 
@@ -3426,15 +3441,16 @@ static void iter_int8_prod(na_loop_t* const lp) {
3426
3441
  /*
3427
3442
  prod of self.
3428
3443
  @overload prod(axis:nil, keepdims:false)
3429
- @param [Numeric,Array,Range] axis Performs prod along the axis.
3430
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
3431
- @return [Numo::Int8] returns result of prod.
3444
+ @param [Numeric,Array,Range] axis Performs prod along the axis.
3445
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3446
+ dimensions with size one.
3447
+ @return [Numo::Int8] returns result of prod.
3432
3448
  */
3433
3449
  static VALUE int8_prod(int argc, VALUE* argv, VALUE self) {
3434
3450
  VALUE v, reduce;
3435
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
3436
- ndfunc_arg_out_t aout[1] = {{numo_cInt64, 0}};
3437
- ndfunc_t ndf = {iter_int8_prod, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
3451
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
3452
+ ndfunc_arg_out_t aout[1] = { { numo_cInt64, 0 } };
3453
+ ndfunc_t ndf = { iter_int8_prod, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
3438
3454
 
3439
3455
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
3440
3456
 
@@ -3458,15 +3474,16 @@ static void iter_int8_min(na_loop_t* const lp) {
3458
3474
  /*
3459
3475
  min of self.
3460
3476
  @overload min(axis:nil, keepdims:false)
3461
- @param [Numeric,Array,Range] axis Performs min along the axis.
3462
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
3463
- @return [Numo::Int8] returns result of min.
3477
+ @param [Numeric,Array,Range] axis Performs min along the axis.
3478
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3479
+ dimensions with size one.
3480
+ @return [Numo::Int8] returns result of min.
3464
3481
  */
3465
3482
  static VALUE int8_min(int argc, VALUE* argv, VALUE self) {
3466
3483
  VALUE v, reduce;
3467
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
3468
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3469
- ndfunc_t ndf = {iter_int8_min, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
3484
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
3485
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3486
+ ndfunc_t ndf = { iter_int8_min, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
3470
3487
 
3471
3488
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
3472
3489
 
@@ -3490,15 +3507,16 @@ static void iter_int8_max(na_loop_t* const lp) {
3490
3507
  /*
3491
3508
  max of self.
3492
3509
  @overload max(axis:nil, keepdims:false)
3493
- @param [Numeric,Array,Range] axis Performs max along the axis.
3494
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
3495
- @return [Numo::Int8] returns result of max.
3510
+ @param [Numeric,Array,Range] axis Performs max along the axis.
3511
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3512
+ dimensions with size one.
3513
+ @return [Numo::Int8] returns result of max.
3496
3514
  */
3497
3515
  static VALUE int8_max(int argc, VALUE* argv, VALUE self) {
3498
3516
  VALUE v, reduce;
3499
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
3500
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3501
- ndfunc_t ndf = {iter_int8_max, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
3517
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
3518
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3519
+ ndfunc_t ndf = { iter_int8_max, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
3502
3520
 
3503
3521
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
3504
3522
 
@@ -3522,15 +3540,16 @@ static void iter_int8_ptp(na_loop_t* const lp) {
3522
3540
  /*
3523
3541
  ptp of self.
3524
3542
  @overload ptp(axis:nil, keepdims:false)
3525
- @param [Numeric,Array,Range] axis Performs ptp along the axis.
3526
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
3527
- @return [Numo::Int8] returns result of ptp.
3543
+ @param [Numeric,Array,Range] axis Performs ptp along the axis.
3544
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3545
+ dimensions with size one.
3546
+ @return [Numo::Int8] returns result of ptp.
3528
3547
  */
3529
3548
  static VALUE int8_ptp(int argc, VALUE* argv, VALUE self) {
3530
3549
  VALUE v, reduce;
3531
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
3532
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3533
- ndfunc_t ndf = {iter_int8_ptp, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
3550
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
3551
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3552
+ ndfunc_t ndf = { iter_int8_ptp, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
3534
3553
 
3535
3554
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
3536
3555
 
@@ -3576,8 +3595,9 @@ static void iter_int8_max_index_index32(na_loop_t* const lp) {
3576
3595
  /*
3577
3596
  Index of the maximum value.
3578
3597
  @overload max_index(axis:nil)
3579
- @param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat 1-d indices**.
3580
- @return [Integer,Numo::Int] returns result indices.
3598
+ @param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat
3599
+ 1-d indices**.
3600
+ @return [Integer,Numo::Int] returns result indices.
3581
3601
  @see #argmax
3582
3602
  @see #max
3583
3603
 
@@ -3594,9 +3614,9 @@ static void iter_int8_max_index_index32(na_loop_t* const lp) {
3594
3614
  static VALUE int8_max_index(int argc, VALUE* argv, VALUE self) {
3595
3615
  narray_t* na;
3596
3616
  VALUE idx, reduce;
3597
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {Qnil, 0}, {sym_reduce, 0}};
3598
- ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
3599
- ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout};
3617
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { Qnil, 0 }, { sym_reduce, 0 } };
3618
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
3619
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout };
3600
3620
 
3601
3621
  GetNArray(self, na);
3602
3622
  if (na->ndim == 0) {
@@ -3658,8 +3678,9 @@ static void iter_int8_min_index_index32(na_loop_t* const lp) {
3658
3678
  /*
3659
3679
  Index of the minimum value.
3660
3680
  @overload min_index(axis:nil)
3661
- @param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat 1-d indices**.
3662
- @return [Integer,Numo::Int] returns result indices.
3681
+ @param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat
3682
+ 1-d indices**.
3683
+ @return [Integer,Numo::Int] returns result indices.
3663
3684
  @see #argmin
3664
3685
  @see #min
3665
3686
 
@@ -3676,9 +3697,9 @@ static void iter_int8_min_index_index32(na_loop_t* const lp) {
3676
3697
  static VALUE int8_min_index(int argc, VALUE* argv, VALUE self) {
3677
3698
  narray_t* na;
3678
3699
  VALUE idx, reduce;
3679
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {Qnil, 0}, {sym_reduce, 0}};
3680
- ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
3681
- ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout};
3700
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { Qnil, 0 }, { sym_reduce, 0 } };
3701
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
3702
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout };
3682
3703
 
3683
3704
  GetNArray(self, na);
3684
3705
  if (na->ndim == 0) {
@@ -3738,8 +3759,9 @@ static void iter_int8_argmax_arg32(na_loop_t* const lp) {
3738
3759
  /*
3739
3760
  Index of the maximum value.
3740
3761
  @overload argmax(axis:nil)
3741
- @param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices along the axis**.
3742
- @return [Integer,Numo::Int] returns the result indices.
3762
+ @param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices
3763
+ along the axis**.
3764
+ @return [Integer,Numo::Int] returns the result indices.
3743
3765
  @see #max_index
3744
3766
  @see #max
3745
3767
 
@@ -3756,9 +3778,9 @@ static void iter_int8_argmax_arg32(na_loop_t* const lp) {
3756
3778
  static VALUE int8_argmax(int argc, VALUE* argv, VALUE self) {
3757
3779
  narray_t* na;
3758
3780
  VALUE reduce;
3759
- ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_reduce, 0}};
3760
- ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
3761
- ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout};
3781
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } };
3782
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
3783
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout };
3762
3784
 
3763
3785
  GetNArray(self, na);
3764
3786
  if (na->ndim == 0) {
@@ -3815,8 +3837,9 @@ static void iter_int8_argmin_arg32(na_loop_t* const lp) {
3815
3837
  /*
3816
3838
  Index of the minimum value.
3817
3839
  @overload argmin(axis:nil)
3818
- @param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices along the axis**.
3819
- @return [Integer,Numo::Int] returns the result indices.
3840
+ @param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices
3841
+ along the axis**.
3842
+ @return [Integer,Numo::Int] returns the result indices.
3820
3843
  @see #min_index
3821
3844
  @see #min
3822
3845
 
@@ -3833,9 +3856,9 @@ static void iter_int8_argmin_arg32(na_loop_t* const lp) {
3833
3856
  static VALUE int8_argmin(int argc, VALUE* argv, VALUE self) {
3834
3857
  narray_t* na;
3835
3858
  VALUE reduce;
3836
- ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_reduce, 0}};
3837
- ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
3838
- ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout};
3859
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } };
3860
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
3861
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout };
3839
3862
 
3840
3863
  GetNArray(self, na);
3841
3864
  if (na->ndim == 0) {
@@ -3875,29 +3898,24 @@ static void iter_int8_minmax(na_loop_t* const lp) {
3875
3898
  /*
3876
3899
  minmax of self.
3877
3900
  @overload minmax(axis:nil, keepdims:false)
3878
- @param [Numeric,Array,Range] axis Finds min-max along the axis.
3879
- @param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
3880
- @return [Numo::Int8,Numo::Int8] min and max of self.
3901
+ @param [Numeric,Array,Range] axis Finds min-max along the axis.
3902
+ @param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
3903
+ as dimensions with size one.
3904
+ @return [Numo::Int8,Numo::Int8] min and max of self.
3881
3905
  */
3882
3906
  static VALUE int8_minmax(int argc, VALUE* argv, VALUE self) {
3883
3907
  VALUE reduce;
3884
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
3885
- ndfunc_arg_out_t aout[2] = {{cT, 0}, {cT, 0}};
3886
- ndfunc_t ndf = {iter_int8_minmax, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 2, ain, aout};
3908
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
3909
+ ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
3910
+ ndfunc_t ndf = {
3911
+ iter_int8_minmax, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 2, ain, aout
3912
+ };
3887
3913
 
3888
3914
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
3889
3915
 
3890
3916
  return na_ndloop(&ndf, 2, self, reduce);
3891
3917
  }
3892
3918
 
3893
- /*
3894
- Element-wise maximum of two arrays.
3895
-
3896
- @overload maximum(a1, a2)
3897
- @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
3898
- @return [Numo::Int8]
3899
- */
3900
-
3901
3919
  static void iter_int8_s_maximum(na_loop_t* const lp) {
3902
3920
  size_t i, n;
3903
3921
  char *p1, *p2, *p3;
@@ -3921,23 +3939,15 @@ static void iter_int8_s_maximum(na_loop_t* const lp) {
3921
3939
  static VALUE int8_s_maximum(int argc, VALUE* argv, VALUE mod) {
3922
3940
  VALUE a1 = Qnil;
3923
3941
  VALUE a2 = Qnil;
3924
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3925
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3926
- ndfunc_t ndf = {iter_int8_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout};
3942
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3943
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3944
+ ndfunc_t ndf = { iter_int8_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
3927
3945
 
3928
3946
  rb_scan_args(argc, argv, "20", &a1, &a2);
3929
3947
 
3930
3948
  return na_ndloop(&ndf, 2, a1, a2);
3931
3949
  }
3932
3950
 
3933
- /*
3934
- Element-wise minimum of two arrays.
3935
-
3936
- @overload minimum(a1, a2)
3937
- @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
3938
- @return [Numo::Int8]
3939
- */
3940
-
3941
3951
  static void iter_int8_s_minimum(na_loop_t* const lp) {
3942
3952
  size_t i, n;
3943
3953
  char *p1, *p2, *p3;
@@ -3961,9 +3971,9 @@ static void iter_int8_s_minimum(na_loop_t* const lp) {
3961
3971
  static VALUE int8_s_minimum(int argc, VALUE* argv, VALUE mod) {
3962
3972
  VALUE a1 = Qnil;
3963
3973
  VALUE a2 = Qnil;
3964
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3965
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3966
- ndfunc_t ndf = {iter_int8_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout};
3974
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3975
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3976
+ ndfunc_t ndf = { iter_int8_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
3967
3977
 
3968
3978
  rb_scan_args(argc, argv, "20", &a1, &a2);
3969
3979
 
@@ -4002,10 +4012,12 @@ static void iter_int8_bincount_32(na_loop_t* const lp) {
4002
4012
  }
4003
4013
 
4004
4014
  static VALUE int8_bincount_32(VALUE self, size_t length) {
4005
- size_t shape_out[1] = {length};
4006
- ndfunc_arg_in_t ain[1] = {{cT, 1}};
4007
- ndfunc_arg_out_t aout[1] = {{numo_cUInt32, 1, shape_out}};
4008
- ndfunc_t ndf = {iter_int8_bincount_32, NO_LOOP | NDF_STRIDE_LOOP | NDF_INDEX_LOOP, 1, 1, ain, aout};
4015
+ size_t shape_out[1] = { length };
4016
+ ndfunc_arg_in_t ain[1] = { { cT, 1 } };
4017
+ ndfunc_arg_out_t aout[1] = { { numo_cUInt32, 1, shape_out } };
4018
+ ndfunc_t ndf = {
4019
+ iter_int8_bincount_32, NO_LOOP | NDF_STRIDE_LOOP | NDF_INDEX_LOOP, 1, 1, ain, aout
4020
+ };
4009
4021
 
4010
4022
  return na_ndloop(&ndf, 1, self);
4011
4023
  }
@@ -4040,10 +4052,12 @@ static void iter_int8_bincount_64(na_loop_t* const lp) {
4040
4052
  }
4041
4053
 
4042
4054
  static VALUE int8_bincount_64(VALUE self, size_t length) {
4043
- size_t shape_out[1] = {length};
4044
- ndfunc_arg_in_t ain[1] = {{cT, 1}};
4045
- ndfunc_arg_out_t aout[1] = {{numo_cUInt64, 1, shape_out}};
4046
- ndfunc_t ndf = {iter_int8_bincount_64, NO_LOOP | NDF_STRIDE_LOOP | NDF_INDEX_LOOP, 1, 1, ain, aout};
4055
+ size_t shape_out[1] = { length };
4056
+ ndfunc_arg_in_t ain[1] = { { cT, 1 } };
4057
+ ndfunc_arg_out_t aout[1] = { { numo_cUInt64, 1, shape_out } };
4058
+ ndfunc_t ndf = {
4059
+ iter_int8_bincount_64, NO_LOOP | NDF_STRIDE_LOOP | NDF_INDEX_LOOP, 1, 1, ain, aout
4060
+ };
4047
4061
 
4048
4062
  return na_ndloop(&ndf, 1, self);
4049
4063
  }
@@ -4080,10 +4094,10 @@ static void iter_int8_bincount_sf(na_loop_t* const lp) {
4080
4094
  }
4081
4095
 
4082
4096
  static VALUE int8_bincount_sf(VALUE self, VALUE weight, size_t length) {
4083
- size_t shape_out[1] = {length};
4084
- ndfunc_arg_in_t ain[2] = {{cT, 1}, {numo_cSFloat, 1}};
4085
- ndfunc_arg_out_t aout[1] = {{numo_cSFloat, 1, shape_out}};
4086
- ndfunc_t ndf = {iter_int8_bincount_sf, NO_LOOP | NDF_STRIDE_LOOP, 2, 1, ain, aout};
4097
+ size_t shape_out[1] = { length };
4098
+ ndfunc_arg_in_t ain[2] = { { cT, 1 }, { numo_cSFloat, 1 } };
4099
+ ndfunc_arg_out_t aout[1] = { { numo_cSFloat, 1, shape_out } };
4100
+ ndfunc_t ndf = { iter_int8_bincount_sf, NO_LOOP | NDF_STRIDE_LOOP, 2, 1, ain, aout };
4087
4101
 
4088
4102
  return na_ndloop(&ndf, 2, self, weight);
4089
4103
  }
@@ -4117,10 +4131,10 @@ static void iter_int8_bincount_df(na_loop_t* const lp) {
4117
4131
  }
4118
4132
 
4119
4133
  static VALUE int8_bincount_df(VALUE self, VALUE weight, size_t length) {
4120
- size_t shape_out[1] = {length};
4121
- ndfunc_arg_in_t ain[2] = {{cT, 1}, {numo_cDFloat, 1}};
4122
- ndfunc_arg_out_t aout[1] = {{numo_cDFloat, 1, shape_out}};
4123
- ndfunc_t ndf = {iter_int8_bincount_df, NO_LOOP | NDF_STRIDE_LOOP, 2, 1, ain, aout};
4134
+ size_t shape_out[1] = { length };
4135
+ ndfunc_arg_in_t ain[2] = { { cT, 1 }, { numo_cDFloat, 1 } };
4136
+ ndfunc_arg_out_t aout[1] = { { numo_cDFloat, 1, shape_out } };
4137
+ ndfunc_t ndf = { iter_int8_bincount_df, NO_LOOP | NDF_STRIDE_LOOP, 2, 1, ain, aout };
4124
4138
 
4125
4139
  return na_ndloop(&ndf, 2, self, weight);
4126
4140
  }
@@ -4131,13 +4145,13 @@ static VALUE int8_bincount_df(VALUE self, VALUE weight, size_t length) {
4131
4145
  Only Integer-types has this method.
4132
4146
 
4133
4147
  @overload bincount([weight], minlength:nil)
4134
- @param [SFloat or DFloat or Array] weight (optional) Array of
4135
- float values. Its size along last axis should be same as that of self.
4136
- @param [Integer] minlength (keyword, optional) Minimum size along
4137
- last axis for the output array.
4138
- @return [UInt32 or UInt64 or SFloat or DFloat]
4139
- Returns Float NArray if weight array is supplied,
4140
- otherwise returns UInt32 or UInt64 depending on the size along last axis.
4148
+ @param [SFloat or DFloat or Array] weight (optional) Array of
4149
+ float values. Its size along last axis should be same as that of self.
4150
+ @param [Integer] minlength (keyword, optional) Minimum size along
4151
+ last axis for the output array.
4152
+ @return [UInt32 or UInt64 or SFloat or DFloat]
4153
+ Returns Float NArray if weight array is supplied,
4154
+ otherwise returns UInt32 or UInt64 depending on the size along last axis.
4141
4155
  @example
4142
4156
  Numo::Int32[0..4].bincount
4143
4157
  # => Numo::UInt32#shape=[5]
@@ -4160,9 +4174,9 @@ static VALUE int8_bincount_df(VALUE self, VALUE weight, size_t length) {
4160
4174
  */
4161
4175
  static VALUE int8_bincount(int argc, VALUE* argv, VALUE self) {
4162
4176
  VALUE weight = Qnil, kw = Qnil;
4163
- VALUE opts[1] = {Qundef};
4177
+ VALUE opts[1] = { Qundef };
4164
4178
  VALUE v, wclass;
4165
- ID table[1] = {id_minlength};
4179
+ ID table[1] = { id_minlength };
4166
4180
  size_t length, minlength;
4167
4181
 
4168
4182
  rb_scan_args(argc, argv, "01:", &weight, &kw);
@@ -4208,31 +4222,28 @@ static void iter_int8_cumsum(na_loop_t* const lp) {
4208
4222
  INIT_COUNTER(lp, i);
4209
4223
  INIT_PTR(lp, 0, p1, s1);
4210
4224
  INIT_PTR(lp, 1, p2, s2);
4211
- // printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
4212
4225
 
4213
4226
  GET_DATA_STRIDE(p1, s1, dtype, x);
4214
4227
  SET_DATA_STRIDE(p2, s2, dtype, x);
4215
- // printf("i=%lu x=%f\n",i,x);
4216
4228
  for (i--; i--;) {
4217
4229
  GET_DATA_STRIDE(p1, s1, dtype, y);
4218
4230
  m_cumsum(x, y);
4219
4231
  SET_DATA_STRIDE(p2, s2, dtype, x);
4220
- // printf("i=%lu x=%f\n",i,x);
4221
4232
  }
4222
4233
  }
4223
4234
 
4224
4235
  /*
4225
4236
  cumsum of self.
4226
4237
  @overload cumsum(axis:nil, nan:false)
4227
- @param [Numeric,Array,Range] axis Performs cumsum along the axis.
4228
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
4229
- @return [Numo::Int8] cumsum of self.
4238
+ @param [Numeric,Array,Range] axis Performs cumsum along the axis.
4239
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
4240
+ @return [Numo::Int8] cumsum of self.
4230
4241
  */
4231
4242
  static VALUE int8_cumsum(int argc, VALUE* argv, VALUE self) {
4232
4243
  VALUE reduce;
4233
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4234
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4235
- ndfunc_t ndf = {iter_int8_cumsum, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout};
4244
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
4245
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4246
+ ndfunc_t ndf = { iter_int8_cumsum, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout };
4236
4247
 
4237
4248
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
4238
4249
 
@@ -4248,31 +4259,30 @@ static void iter_int8_cumprod(na_loop_t* const lp) {
4248
4259
  INIT_COUNTER(lp, i);
4249
4260
  INIT_PTR(lp, 0, p1, s1);
4250
4261
  INIT_PTR(lp, 1, p2, s2);
4251
- // printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
4252
4262
 
4253
4263
  GET_DATA_STRIDE(p1, s1, dtype, x);
4254
4264
  SET_DATA_STRIDE(p2, s2, dtype, x);
4255
- // printf("i=%lu x=%f\n",i,x);
4256
4265
  for (i--; i--;) {
4257
4266
  GET_DATA_STRIDE(p1, s1, dtype, y);
4258
4267
  m_cumprod(x, y);
4259
4268
  SET_DATA_STRIDE(p2, s2, dtype, x);
4260
- // printf("i=%lu x=%f\n",i,x);
4261
4269
  }
4262
4270
  }
4263
4271
 
4264
4272
  /*
4265
4273
  cumprod of self.
4266
4274
  @overload cumprod(axis:nil, nan:false)
4267
- @param [Numeric,Array,Range] axis Performs cumprod along the axis.
4268
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
4269
- @return [Numo::Int8] cumprod of self.
4275
+ @param [Numeric,Array,Range] axis Performs cumprod along the axis.
4276
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
4277
+ @return [Numo::Int8] cumprod of self.
4270
4278
  */
4271
4279
  static VALUE int8_cumprod(int argc, VALUE* argv, VALUE self) {
4272
4280
  VALUE reduce;
4273
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4274
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4275
- ndfunc_t ndf = {iter_int8_cumprod, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout};
4281
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
4282
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4283
+ ndfunc_t ndf = {
4284
+ iter_int8_cumprod, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout
4285
+ };
4276
4286
 
4277
4287
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
4278
4288
 
@@ -4318,9 +4328,9 @@ static void iter_int8_mulsum(na_loop_t* const lp) {
4318
4328
  static VALUE int8_mulsum_self(int argc, VALUE* argv, VALUE self) {
4319
4329
  VALUE v, reduce;
4320
4330
  VALUE naryv[2];
4321
- ndfunc_arg_in_t ain[4] = {{cT, 0}, {cT, 0}, {sym_reduce, 0}, {sym_init, 0}};
4322
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4323
- ndfunc_t ndf = {iter_int8_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout};
4331
+ ndfunc_arg_in_t ain[4] = { { cT, 0 }, { cT, 0 }, { sym_reduce, 0 }, { sym_init, 0 } };
4332
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4333
+ ndfunc_t ndf = { iter_int8_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout };
4324
4334
 
4325
4335
  if (argc < 1) {
4326
4336
  rb_raise(rb_eArgError, "wrong number of arguments (%d for >=1)", argc);
@@ -4340,10 +4350,11 @@ static VALUE int8_mulsum_self(int argc, VALUE* argv, VALUE self) {
4340
4350
  Binary mulsum.
4341
4351
 
4342
4352
  @overload mulsum(other, axis:nil, keepdims:false)
4343
- @param [Numo::NArray,Numeric] other
4344
- @param [Numeric,Array,Range] axis Performs mulsum along the axis.
4345
- @param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
4346
- @return [Numo::NArray] mulsum of self and other.
4353
+ @param [Numo::NArray,Numeric] other
4354
+ @param [Numeric,Array,Range] axis Performs mulsum along the axis.
4355
+ @param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
4356
+ as dimensions with size one.
4357
+ @return [Numo::NArray] mulsum of self and other.
4347
4358
  */
4348
4359
  static VALUE int8_mulsum(int argc, VALUE* argv, VALUE self) {
4349
4360
  //
@@ -4412,9 +4423,9 @@ static void iter_int8_seq(na_loop_t* const lp) {
4412
4423
  beg+i*step
4413
4424
  where i is 1-dimensional index.
4414
4425
  @overload seq([beg,[step]])
4415
- @param [Numeric] beg beginning of sequence. (default=0)
4416
- @param [Numeric] step step of sequence. (default=1)
4417
- @return [Numo::Int8] self.
4426
+ @param [Numeric] beg beginning of sequence. (default=0)
4427
+ @param [Numeric] step step of sequence. (default=1)
4428
+ @return [Numo::Int8] self.
4418
4429
  @example
4419
4430
  Numo::DFloat.new(6).seq(1,-0.2)
4420
4431
  # => Numo::DFloat#shape=[6]
@@ -4424,17 +4435,17 @@ static void iter_int8_seq(na_loop_t* const lp) {
4424
4435
  # => Numo::DComplex#shape=[6]
4425
4436
  # [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
4426
4437
  */
4427
- static VALUE int8_seq(int argc, VALUE* args, VALUE self) {
4438
+ static VALUE int8_seq(int argc, VALUE* argv, VALUE self) {
4428
4439
  seq_opt_t* g;
4429
4440
  VALUE vbeg = Qnil, vstep = Qnil;
4430
- ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
4431
- ndfunc_t ndf = {iter_int8_seq, FULL_LOOP, 1, 0, ain, 0};
4441
+ ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
4442
+ ndfunc_t ndf = { iter_int8_seq, FULL_LOOP, 1, 0, ain, 0 };
4432
4443
 
4433
4444
  g = ALLOCA_N(seq_opt_t, 1);
4434
4445
  g->beg = m_zero;
4435
4446
  g->step = m_one;
4436
4447
  g->count = 0;
4437
- rb_scan_args(argc, args, "02", &vbeg, &vstep);
4448
+ rb_scan_args(argc, argv, "02", &vbeg, &vstep);
4438
4449
  if (vbeg != Qnil) {
4439
4450
  g->beg = NUM2DBL(vbeg);
4440
4451
  }
@@ -4478,15 +4489,15 @@ static void iter_int8_eye(na_loop_t* const lp) {
4478
4489
  /*
4479
4490
  Eye: Set a value to diagonal components, set 0 to non-diagonal components.
4480
4491
  @overload eye([element,offset])
4481
- @param [Numeric] element Diagonal element to be stored. Default is 1.
4482
- @param [Integer] offset Diagonal offset from the main diagonal. The
4483
- default is 0. k>0 for diagonals above the main diagonal, and k<0
4484
- for diagonals below the main diagonal.
4485
- @return [Numo::Int8] eye of self.
4492
+ @param [Numeric] element Diagonal element to be stored. Default is 1.
4493
+ @param [Integer] offset Diagonal offset from the main diagonal. The
4494
+ default is 0. k>0 for diagonals above the main diagonal, and k<0
4495
+ for diagonals below the main diagonal.
4496
+ @return [Numo::Int8] eye of self.
4486
4497
  */
4487
4498
  static VALUE int8_eye(int argc, VALUE* argv, VALUE self) {
4488
- ndfunc_arg_in_t ain[1] = {{OVERWRITE, 2}};
4489
- ndfunc_t ndf = {iter_int8_eye, NO_LOOP, 1, 0, ain, 0};
4499
+ ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
4500
+ ndfunc_t ndf = { iter_int8_eye, NO_LOOP, 1, 0, ain, 0 };
4490
4501
  ssize_t kofs;
4491
4502
  dtype data;
4492
4503
  char* g;
@@ -4516,17 +4527,21 @@ static VALUE int8_eye(int argc, VALUE* argv, VALUE self) {
4516
4527
  // Diagonal offset from the main diagonal.
4517
4528
  if (kofs >= 0) {
4518
4529
  if ((size_t)(kofs) >= na->shape[nd - 1]) {
4519
- rb_raise(rb_eArgError,
4520
- "invalid diagonal offset(%" SZF "d) for "
4521
- "last dimension size(%" SZF "d)",
4522
- kofs, na->shape[nd - 1]);
4530
+ rb_raise(
4531
+ rb_eArgError,
4532
+ "invalid diagonal offset(%" SZF "d) for "
4533
+ "last dimension size(%" SZF "d)",
4534
+ kofs, na->shape[nd - 1]
4535
+ );
4523
4536
  }
4524
4537
  } else {
4525
4538
  if ((size_t)(-kofs) >= na->shape[nd - 2]) {
4526
- rb_raise(rb_eArgError,
4527
- "invalid diagonal offset(%" SZF "d) for "
4528
- "last-1 dimension size(%" SZF "d)",
4529
- kofs, na->shape[nd - 2]);
4539
+ rb_raise(
4540
+ rb_eArgError,
4541
+ "invalid diagonal offset(%" SZF "d) for "
4542
+ "last-1 dimension size(%" SZF "d)",
4543
+ kofs, na->shape[nd - 2]
4544
+ );
4530
4545
  }
4531
4546
  }
4532
4547
 
@@ -4610,9 +4625,10 @@ static void iter_int8_rand(na_loop_t* const lp) {
4610
4625
  /*
4611
4626
  Generate uniformly distributed random numbers on self narray.
4612
4627
  @overload rand([[low],high])
4613
- @param [Numeric] low lower inclusive boundary of random numbers. (default=0)
4614
- @param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for complex types)
4615
- @return [Numo::Int8] self.
4628
+ @param [Numeric] low lower inclusive boundary of random numbers. (default=0)
4629
+ @param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
4630
+ complex types)
4631
+ @return [Numo::Int8] self.
4616
4632
  @example
4617
4633
  Numo::DFloat.new(6).rand
4618
4634
  # => Numo::DFloat#shape=[6]
@@ -4626,14 +4642,14 @@ static void iter_int8_rand(na_loop_t* const lp) {
4626
4642
  # => Numo::Int32#shape=[6]
4627
4643
  # [4, 3, 3, 2, 4, 2]
4628
4644
  */
4629
- static VALUE int8_rand(int argc, VALUE* args, VALUE self) {
4645
+ static VALUE int8_rand(int argc, VALUE* argv, VALUE self) {
4630
4646
  rand_opt_t g;
4631
4647
  VALUE v1 = Qnil, v2 = Qnil;
4632
4648
  dtype high;
4633
- ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
4634
- ndfunc_t ndf = {iter_int8_rand, FULL_LOOP, 1, 0, ain, 0};
4649
+ ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
4650
+ ndfunc_t ndf = { iter_int8_rand, FULL_LOOP, 1, 0, ain, 0 };
4635
4651
 
4636
- rb_scan_args(argc, args, "11", &v1, &v2);
4652
+ rb_scan_args(argc, argv, "11", &v1, &v2);
4637
4653
  if (v2 == Qnil) {
4638
4654
  g.low = m_zero;
4639
4655
  g.max = high = m_num_to_data(v1);
@@ -4672,15 +4688,15 @@ static void iter_int8_poly(na_loop_t* const lp) {
4672
4688
  Calculate polynomial.
4673
4689
  `x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
4674
4690
  @overload poly a0, a1, ..., an
4675
- @param [Numo::NArray,Numeric] a0,a1,...,an
4676
- @return [Numo::Int8]
4691
+ @param [Numo::NArray,Numeric] a0,a1,...,an
4692
+ @return [Numo::Int8]
4677
4693
  */
4678
4694
  static VALUE int8_poly(VALUE self, VALUE args) {
4679
4695
  int argc, i;
4680
4696
  VALUE* argv;
4681
4697
  volatile VALUE v, a;
4682
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4683
- ndfunc_t ndf = {iter_int8_poly, NO_LOOP, 0, 1, 0, aout};
4698
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4699
+ ndfunc_t ndf = { iter_int8_poly, NO_LOOP, 0, 1, 0, aout };
4684
4700
 
4685
4701
  argc = (int)RARRAY_LEN(args);
4686
4702
  ndf.nin = argc + 1;
@@ -4760,23 +4776,28 @@ static VALUE int8_poly(VALUE self, VALUE args) {
4760
4776
  * We have modified their original by adding a check for already-sorted input,
4761
4777
  * which seems to be a win per discussions on pgsql-hackers around 2006-03-21.
4762
4778
  */
4763
- #define swapcode(TYPE, parmi, parmj, n) \
4764
- do { \
4765
- size_t i = (n) / sizeof(TYPE); \
4766
- TYPE* pi = (TYPE*)(void*)(parmi); \
4767
- TYPE* pj = (TYPE*)(void*)(parmj); \
4768
- do { \
4769
- TYPE t = *pi; \
4770
- *pi++ = *pj; \
4771
- *pj++ = t; \
4772
- } while (--i > 0); \
4779
+ #define swapcode(TYPE, parmi, parmj, n) \
4780
+ do { \
4781
+ size_t i = (n) / sizeof(TYPE); \
4782
+ TYPE* pi = (TYPE*)(void*)(parmi); \
4783
+ TYPE* pj = (TYPE*)(void*)(parmj); \
4784
+ do { \
4785
+ TYPE t = *pi; \
4786
+ *pi++ = *pj; \
4787
+ *pj++ = t; \
4788
+ } while (--i > 0); \
4773
4789
  } while (0)
4774
4790
 
4775
4791
  #ifdef HAVE_STDINT_H
4776
- #define SWAPINIT(a, es) swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2 : (es) == sizeof(long) ? 0 : 1;
4792
+ #define SWAPINIT(a, es) \
4793
+ swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2 \
4794
+ : (es) == sizeof(long) ? 0 \
4795
+ : 1;
4777
4796
  #else
4778
- #define SWAPINIT(a, es) \
4779
- swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 : (es) == sizeof(long) ? 0 : 1;
4797
+ #define SWAPINIT(a, es) \
4798
+ swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 \
4799
+ : (es) == sizeof(long) ? 0 \
4800
+ : 1;
4780
4801
  #endif
4781
4802
 
4782
4803
  static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
@@ -4786,19 +4807,20 @@ static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
4786
4807
  swapcode(char, a, b, n);
4787
4808
  }
4788
4809
 
4789
- #define swap(a, b) \
4790
- if (swaptype == 0) { \
4791
- long t = *(long*)(void*)(a); \
4792
- *(long*)(void*)(a) = *(long*)(void*)(b); \
4793
- *(long*)(void*)(b) = t; \
4794
- } else \
4810
+ #define swap(a, b) \
4811
+ if (swaptype == 0) { \
4812
+ long t = *(long*)(void*)(a); \
4813
+ *(long*)(void*)(a) = *(long*)(void*)(b); \
4814
+ *(long*)(void*)(b) = t; \
4815
+ } else \
4795
4816
  swapfunc(a, b, es, swaptype)
4796
4817
 
4797
- #define vecswap(a, b, n) \
4818
+ #define vecswap(a, b, n) \
4798
4819
  if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
4799
4820
 
4800
- #define med3(a, b, c, _cmp) \
4801
- (cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) : (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
4821
+ #define med3(a, b, c, _cmp) \
4822
+ (cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) \
4823
+ : (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
4802
4824
  #endif
4803
4825
 
4804
4826
  #undef qsort_dtype
@@ -4888,15 +4910,15 @@ static void iter_int8_sort(na_loop_t* const lp) {
4888
4910
  /*
4889
4911
  sort of self.
4890
4912
  @overload sort(axis:nil)
4891
- @param [Numeric,Array,Range] axis Performs sort along the axis.
4892
- @return [Numo::Int8] returns result of sort.
4913
+ @param [Numeric,Array,Range] axis Performs sort along the axis.
4914
+ @return [Numo::Int8] returns result of sort.
4893
4915
  @example
4894
4916
  Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
4895
4917
  */
4896
4918
  static VALUE int8_sort(int argc, VALUE* argv, VALUE self) {
4897
4919
  VALUE reduce;
4898
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_reduce, 0}};
4899
- ndfunc_t ndf = {0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 0, ain, 0};
4920
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
4921
+ ndfunc_t ndf = { 0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 0, ain, 0 };
4900
4922
 
4901
4923
  if (!TEST_INPLACE(self)) {
4902
4924
  self = na_copy(self);
@@ -4997,7 +5019,8 @@ loop:
4997
5019
  pm = med3(pl, pm, pn, cmp);
4998
5020
  }
4999
5021
  swap(a, pm);
5000
- for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc; pb += es, pc -= es) {
5022
+ for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc;
5023
+ pb += es, pc -= es) {
5001
5024
  while (pb <= pc && (r = cmp(pb, a)) <= 0) {
5002
5025
  if (r == 0) {
5003
5026
  swap(pa, pb);
@@ -5044,7 +5067,6 @@ static void int8_index64_qsort(na_loop_t* const lp) {
5044
5067
 
5045
5068
  ptr = (char**)(lp->opt_ptr);
5046
5069
 
5047
- // printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
5048
5070
  // o_ptr=%lx,o_step=%ld)\n",(size_t)ptr,(size_t)d_ptr,(ssize_t)d_step,(size_t)i_ptr,(ssize_t)i_step,(size_t)o_ptr,(ssize_t)o_step);
5049
5071
 
5050
5072
  if (n == 1) {
@@ -5054,21 +5076,17 @@ static void int8_index64_qsort(na_loop_t* const lp) {
5054
5076
 
5055
5077
  for (i = 0; i < n; i++) {
5056
5078
  ptr[i] = d_ptr + d_step * i;
5057
- // printf("(%ld,%.3f)",i,*(double*)ptr[i]);
5058
5079
  }
5059
5080
 
5060
5081
  int8_index_qsort(ptr, n, sizeof(dtype*));
5061
5082
 
5062
5083
  // d_ptr = lp->args[0].ptr;
5063
- // printf("(d_ptr=%lx)\n",(size_t)d_ptr);
5064
5084
 
5065
5085
  for (i = 0; i < n; i++) {
5066
5086
  idx = (ptr[i] - d_ptr) / d_step;
5067
5087
  *(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
5068
- // printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
5069
5088
  o_ptr += o_step;
5070
5089
  }
5071
- // printf("\n");
5072
5090
  }
5073
5091
  #undef idx_t
5074
5092
 
@@ -5086,7 +5104,6 @@ static void int8_index32_qsort(na_loop_t* const lp) {
5086
5104
 
5087
5105
  ptr = (char**)(lp->opt_ptr);
5088
5106
 
5089
- // printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
5090
5107
  // o_ptr=%lx,o_step=%ld)\n",(size_t)ptr,(size_t)d_ptr,(ssize_t)d_step,(size_t)i_ptr,(ssize_t)i_step,(size_t)o_ptr,(ssize_t)o_step);
5091
5108
 
5092
5109
  if (n == 1) {
@@ -5096,29 +5113,25 @@ static void int8_index32_qsort(na_loop_t* const lp) {
5096
5113
 
5097
5114
  for (i = 0; i < n; i++) {
5098
5115
  ptr[i] = d_ptr + d_step * i;
5099
- // printf("(%ld,%.3f)",i,*(double*)ptr[i]);
5100
5116
  }
5101
5117
 
5102
5118
  int8_index_qsort(ptr, n, sizeof(dtype*));
5103
5119
 
5104
5120
  // d_ptr = lp->args[0].ptr;
5105
- // printf("(d_ptr=%lx)\n",(size_t)d_ptr);
5106
5121
 
5107
5122
  for (i = 0; i < n; i++) {
5108
5123
  idx = (ptr[i] - d_ptr) / d_step;
5109
5124
  *(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
5110
- // printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
5111
5125
  o_ptr += o_step;
5112
5126
  }
5113
- // printf("\n");
5114
5127
  }
5115
5128
  #undef idx_t
5116
5129
 
5117
5130
  /*
5118
5131
  sort_index. Returns an index array of sort result.
5119
5132
  @overload sort_index(axis:nil)
5120
- @param [Numeric,Array,Range] axis Performs sort_index along the axis.
5121
- @return [Integer,Numo::Int] returns result index of sort_index.
5133
+ @param [Numeric,Array,Range] axis Performs sort_index along the axis.
5134
+ @return [Integer,Numo::Int] returns result index of sort_index.
5122
5135
  @example
5123
5136
  Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
5124
5137
  */
@@ -5127,9 +5140,9 @@ static VALUE int8_sort_index(int argc, VALUE* argv, VALUE self) {
5127
5140
  narray_t* na;
5128
5141
  VALUE idx, tmp, reduce, res;
5129
5142
  char* buf;
5130
- ndfunc_arg_in_t ain[3] = {{cT, 0}, {0, 0}, {sym_reduce, 0}};
5131
- ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
5132
- ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_CUM, 3, 1, ain, aout};
5143
+ ndfunc_arg_in_t ain[3] = { { cT, 0 }, { 0, 0 }, { sym_reduce, 0 } };
5144
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
5145
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_CUM, 3, 1, ain, aout };
5133
5146
 
5134
5147
  GetNArray(self, na);
5135
5148
  if (na->ndim == 0) {
@@ -5182,16 +5195,17 @@ static void iter_int8_median(na_loop_t* const lp) {
5182
5195
  /*
5183
5196
  median of self.
5184
5197
  @overload median(axis:nil, keepdims:false)
5185
- @param [Numeric,Array,Range] axis Finds median along the axis.
5186
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
5187
- @return [Numo::Int8] returns median of self.
5198
+ @param [Numeric,Array,Range] axis Finds median along the axis.
5199
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
5200
+ dimensions with size one.
5201
+ @return [Numo::Int8] returns median of self.
5188
5202
  */
5189
5203
 
5190
5204
  static VALUE int8_median(int argc, VALUE* argv, VALUE self) {
5191
5205
  VALUE v, reduce;
5192
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_reduce, 0}};
5193
- ndfunc_arg_out_t aout[1] = {{INT2FIX(0), 0}};
5194
- ndfunc_t ndf = {0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
5206
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
5207
+ ndfunc_arg_out_t aout[1] = { { INT2FIX(0), 0 } };
5208
+ ndfunc_t ndf = { 0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
5195
5209
 
5196
5210
  self = na_copy(self); // as temporary buffer
5197
5211
 
@@ -5223,13 +5237,15 @@ void Init_numo_int8(void) {
5223
5237
  id_ne = rb_intern("ne");
5224
5238
  id_to_a = rb_intern("to_a");
5225
5239
 
5226
- /*
5227
- Document-class: Numo::Int8
5228
-
5229
- */
5240
+ /**
5241
+ * Document-class: Numo::Int8
5242
+ *
5243
+ * 8-bit signed integer N-dimensional array class.
5244
+ */
5230
5245
  cT = rb_define_class_under(mNumo, "Int8", cNArray);
5231
5246
 
5232
5247
  hCast = rb_hash_new();
5248
+ /* Upcasting rules of Int8. */
5233
5249
  rb_define_const(cT, "UPCAST", hCast);
5234
5250
  rb_hash_aset(hCast, rb_cArray, cT);
5235
5251
 
@@ -5256,15 +5272,15 @@ void Init_numo_int8(void) {
5256
5272
  rb_hash_aset(hCast, numo_cUInt8, numo_cInt16);
5257
5273
  rb_obj_freeze(hCast);
5258
5274
 
5259
- /**/
5275
+ /* Element size of Int8 in bits. */
5260
5276
  rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
5261
- /**/
5277
+ /* Element size of Int8 in bytes. */
5262
5278
  rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
5263
- /**/
5279
+ /* Stride size of contiguous Int8 array. */
5264
5280
  rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
5265
- /**/
5281
+ /* The largest representable value of Int8. */
5266
5282
  rb_define_const(cT, "MAX", M_MAX);
5267
- /**/
5283
+ /* The smallest representable value of Int8. */
5268
5284
  rb_define_const(cT, "MIN", M_MIN);
5269
5285
  rb_define_alloc_func(cT, int8_s_alloc_func);
5270
5286
  rb_define_method(cT, "allocate", int8_allocate, 0);
@@ -5335,7 +5351,19 @@ void Init_numo_int8(void) {
5335
5351
  rb_define_method(cT, "argmax", int8_argmax, -1);
5336
5352
  rb_define_method(cT, "argmin", int8_argmin, -1);
5337
5353
  rb_define_method(cT, "minmax", int8_minmax, -1);
5354
+ /**
5355
+ * Element-wise maximum of two arrays.
5356
+ * @overload maximum(a1, a2)
5357
+ * @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
5358
+ * @return [Numo::Int8]
5359
+ */
5338
5360
  rb_define_module_function(cT, "maximum", int8_s_maximum, -1);
5361
+ /**
5362
+ * Element-wise minimum of two arrays.
5363
+ * @overload minimum(a1, a2)
5364
+ * @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
5365
+ * @return [Numo::Int8]
5366
+ */
5339
5367
  rb_define_module_function(cT, "minimum", int8_s_minimum, -1);
5340
5368
  rb_define_method(cT, "bincount", int8_bincount, -1);
5341
5369
  rb_define_method(cT, "cumsum", int8_cumsum, -1);
@@ -5352,4 +5380,48 @@ void Init_numo_int8(void) {
5352
5380
  rb_define_method(cT, "sort_index", int8_sort_index, -1);
5353
5381
  rb_define_method(cT, "median", int8_median, -1);
5354
5382
  rb_define_singleton_method(cT, "[]", int8_s_cast, -2);
5383
+ /**
5384
+ * mean of self.
5385
+ * @overload mean(axis: nil, keepdims: false, nan: false)
5386
+ * @param axis [Numeric, Array, Range] Performs mean along the axis.
5387
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
5388
+ * dimensions with size one.
5389
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
5390
+ * (avoid NaN for sum/mean etc, or return NaN for min/max etc).
5391
+ * @return [Numo::DFloat] returns result of mean.
5392
+ */
5393
+ rb_define_method(cT, "mean", int8_mean, -1);
5394
+ /**
5395
+ * var of self.
5396
+ * @overload var(axis: nil, keepdims: false, nan: false)
5397
+ * @param axis [Numeric, Array, Range] Performs var along the axis.
5398
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
5399
+ * dimensions with size one.
5400
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
5401
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
5402
+ * @return [Numo::DFloat] returns result of var.
5403
+ */
5404
+ rb_define_method(cT, "var", int8_var, -1);
5405
+ /**
5406
+ * stddev of self.
5407
+ * @overload stddev(axis: nil, keepdims: false, nan: false)
5408
+ * @param axis [Numeric, Array, Range] Performs stddev along the axis.
5409
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
5410
+ * dimensions with size one.
5411
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
5412
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
5413
+ * @return [Numo::DFloat] returns result of stddev.
5414
+ */
5415
+ rb_define_method(cT, "stddev", int8_stddev, -1);
5416
+ /**
5417
+ * rms of self.
5418
+ * @overload rms(axis: nil, keepdims: false, nan: false)
5419
+ * @param axis [Numeric, Array, Range] Performs rms along the axis.
5420
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
5421
+ * dimensions with size one.
5422
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
5423
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
5424
+ * @return [Numo::DFloat] returns result of rms.
5425
+ */
5426
+ rb_define_method(cT, "rms", int8_rms, -1);
5355
5427
  }