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
@@ -54,14 +54,23 @@ static ID id_truncate;
54
54
 
55
55
  #include <numo/types/robject.h>
56
56
 
57
- VALUE cT;
58
- extern VALUE cRT;
59
-
60
57
  /*
61
58
  class definition: Numo::RObject
62
59
  */
63
-
64
60
  VALUE cT;
61
+ extern VALUE cRT;
62
+
63
+ #include "mh/mean.h"
64
+ #include "mh/var.h"
65
+ #include "mh/stddev.h"
66
+ #include "mh/rms.h"
67
+
68
+ typedef VALUE robject; // Type aliases for shorter notation
69
+ // following the codebase naming convention.
70
+ DEF_NARRAY_FLT_MEAN_METHOD_FUNC(robject, VALUE, numo_cRObject, numo_cRObject)
71
+ DEF_NARRAY_FLT_VAR_METHOD_FUNC(robject, VALUE, numo_cRObject, numo_cRObject)
72
+ DEF_NARRAY_FLT_STDDEV_METHOD_FUNC(robject, VALUE, numo_cRObject, numo_cRObject)
73
+ DEF_NARRAY_FLT_RMS_METHOD_FUNC(robject, VALUE, numo_cRObject, numo_cRObject)
65
74
 
66
75
  static VALUE robject_store(VALUE, VALUE);
67
76
 
@@ -191,9 +200,9 @@ static VALUE robject_allocate(VALUE self) {
191
200
  /*
192
201
  Extract an element only if self is a dimensionless NArray.
193
202
  @overload extract
194
- @return [Numeric,Numo::NArray]
195
- --- Extract element value as Ruby Object if self is a dimensionless NArray,
196
- otherwise returns self.
203
+ @return [Numeric,Numo::NArray]
204
+ --- Extract element value as Ruby Object if self is a dimensionless NArray,
205
+ otherwise returns self.
197
206
  */
198
207
  static VALUE robject_extract(VALUE self) {
199
208
  volatile VALUE v;
@@ -277,8 +286,8 @@ static void iter_robject_store_bit(na_loop_t* const lp) {
277
286
  }
278
287
 
279
288
  static VALUE robject_store_bit(VALUE self, VALUE obj) {
280
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
281
- ndfunc_t ndf = {iter_robject_store_bit, FULL_LOOP, 2, 0, ain, 0};
289
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
290
+ ndfunc_t ndf = { iter_robject_store_bit, FULL_LOOP, 2, 0, ain, 0 };
282
291
 
283
292
  na_ndloop(&ndf, 2, self, obj);
284
293
  return self;
@@ -326,8 +335,8 @@ static void iter_robject_store_dfloat(na_loop_t* const lp) {
326
335
  }
327
336
 
328
337
  static VALUE robject_store_dfloat(VALUE self, VALUE obj) {
329
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
330
- ndfunc_t ndf = {iter_robject_store_dfloat, FULL_LOOP, 2, 0, ain, 0};
338
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
339
+ ndfunc_t ndf = { iter_robject_store_dfloat, FULL_LOOP, 2, 0, ain, 0 };
331
340
 
332
341
  na_ndloop(&ndf, 2, self, obj);
333
342
  return self;
@@ -375,8 +384,8 @@ static void iter_robject_store_sfloat(na_loop_t* const lp) {
375
384
  }
376
385
 
377
386
  static VALUE robject_store_sfloat(VALUE self, VALUE obj) {
378
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
379
- ndfunc_t ndf = {iter_robject_store_sfloat, FULL_LOOP, 2, 0, ain, 0};
387
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
388
+ ndfunc_t ndf = { iter_robject_store_sfloat, FULL_LOOP, 2, 0, ain, 0 };
380
389
 
381
390
  na_ndloop(&ndf, 2, self, obj);
382
391
  return self;
@@ -424,8 +433,8 @@ static void iter_robject_store_int64(na_loop_t* const lp) {
424
433
  }
425
434
 
426
435
  static VALUE robject_store_int64(VALUE self, VALUE obj) {
427
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
428
- ndfunc_t ndf = {iter_robject_store_int64, FULL_LOOP, 2, 0, ain, 0};
436
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
437
+ ndfunc_t ndf = { iter_robject_store_int64, FULL_LOOP, 2, 0, ain, 0 };
429
438
 
430
439
  na_ndloop(&ndf, 2, self, obj);
431
440
  return self;
@@ -473,8 +482,8 @@ static void iter_robject_store_int32(na_loop_t* const lp) {
473
482
  }
474
483
 
475
484
  static VALUE robject_store_int32(VALUE self, VALUE obj) {
476
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
477
- ndfunc_t ndf = {iter_robject_store_int32, FULL_LOOP, 2, 0, ain, 0};
485
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
486
+ ndfunc_t ndf = { iter_robject_store_int32, FULL_LOOP, 2, 0, ain, 0 };
478
487
 
479
488
  na_ndloop(&ndf, 2, self, obj);
480
489
  return self;
@@ -522,8 +531,8 @@ static void iter_robject_store_int16(na_loop_t* const lp) {
522
531
  }
523
532
 
524
533
  static VALUE robject_store_int16(VALUE self, VALUE obj) {
525
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
526
- ndfunc_t ndf = {iter_robject_store_int16, FULL_LOOP, 2, 0, ain, 0};
534
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
535
+ ndfunc_t ndf = { iter_robject_store_int16, FULL_LOOP, 2, 0, ain, 0 };
527
536
 
528
537
  na_ndloop(&ndf, 2, self, obj);
529
538
  return self;
@@ -571,8 +580,8 @@ static void iter_robject_store_int8(na_loop_t* const lp) {
571
580
  }
572
581
 
573
582
  static VALUE robject_store_int8(VALUE self, VALUE obj) {
574
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
575
- ndfunc_t ndf = {iter_robject_store_int8, FULL_LOOP, 2, 0, ain, 0};
583
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
584
+ ndfunc_t ndf = { iter_robject_store_int8, FULL_LOOP, 2, 0, ain, 0 };
576
585
 
577
586
  na_ndloop(&ndf, 2, self, obj);
578
587
  return self;
@@ -620,8 +629,8 @@ static void iter_robject_store_uint64(na_loop_t* const lp) {
620
629
  }
621
630
 
622
631
  static VALUE robject_store_uint64(VALUE self, VALUE obj) {
623
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
624
- ndfunc_t ndf = {iter_robject_store_uint64, FULL_LOOP, 2, 0, ain, 0};
632
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
633
+ ndfunc_t ndf = { iter_robject_store_uint64, FULL_LOOP, 2, 0, ain, 0 };
625
634
 
626
635
  na_ndloop(&ndf, 2, self, obj);
627
636
  return self;
@@ -669,8 +678,8 @@ static void iter_robject_store_uint32(na_loop_t* const lp) {
669
678
  }
670
679
 
671
680
  static VALUE robject_store_uint32(VALUE self, VALUE obj) {
672
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
673
- ndfunc_t ndf = {iter_robject_store_uint32, FULL_LOOP, 2, 0, ain, 0};
681
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
682
+ ndfunc_t ndf = { iter_robject_store_uint32, FULL_LOOP, 2, 0, ain, 0 };
674
683
 
675
684
  na_ndloop(&ndf, 2, self, obj);
676
685
  return self;
@@ -718,8 +727,8 @@ static void iter_robject_store_uint16(na_loop_t* const lp) {
718
727
  }
719
728
 
720
729
  static VALUE robject_store_uint16(VALUE self, VALUE obj) {
721
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
722
- ndfunc_t ndf = {iter_robject_store_uint16, FULL_LOOP, 2, 0, ain, 0};
730
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
731
+ ndfunc_t ndf = { iter_robject_store_uint16, FULL_LOOP, 2, 0, ain, 0 };
723
732
 
724
733
  na_ndloop(&ndf, 2, self, obj);
725
734
  return self;
@@ -767,8 +776,8 @@ static void iter_robject_store_uint8(na_loop_t* const lp) {
767
776
  }
768
777
 
769
778
  static VALUE robject_store_uint8(VALUE self, VALUE obj) {
770
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
771
- ndfunc_t ndf = {iter_robject_store_uint8, FULL_LOOP, 2, 0, ain, 0};
779
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
780
+ ndfunc_t ndf = { iter_robject_store_uint8, FULL_LOOP, 2, 0, ain, 0 };
772
781
 
773
782
  na_ndloop(&ndf, 2, self, obj);
774
783
  return self;
@@ -816,8 +825,8 @@ static void iter_robject_store_robject(na_loop_t* const lp) {
816
825
  }
817
826
 
818
827
  static VALUE robject_store_robject(VALUE self, VALUE obj) {
819
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
820
- ndfunc_t ndf = {iter_robject_store_robject, FULL_LOOP, 2, 0, ain, 0};
828
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
829
+ ndfunc_t ndf = { iter_robject_store_robject, FULL_LOOP, 2, 0, ain, 0 };
821
830
 
822
831
  na_ndloop(&ndf, 2, self, obj);
823
832
  return self;
@@ -925,8 +934,8 @@ loop_end:
925
934
  }
926
935
 
927
936
  static VALUE robject_store_array(VALUE self, VALUE rary) {
928
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {rb_cArray, 0}};
929
- ndfunc_t ndf = {iter_robject_store_array, FULL_LOOP, 2, 0, ain, 0};
937
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { rb_cArray, 0 } };
938
+ ndfunc_t ndf = { iter_robject_store_array, FULL_LOOP, 2, 0, ain, 0 };
930
939
 
931
940
  na_ndloop_store_rarray(&ndf, self, rary);
932
941
  return self;
@@ -935,8 +944,8 @@ static VALUE robject_store_array(VALUE self, VALUE rary) {
935
944
  /*
936
945
  Store elements to Numo::RObject from other.
937
946
  @overload store(other)
938
- @param [Object] other
939
- @return [Numo::RObject] self
947
+ @param [Object] other
948
+ @return [Numo::RObject] self
940
949
  */
941
950
  static VALUE robject_store(VALUE self, VALUE obj) {
942
951
  VALUE r, klass;
@@ -1142,9 +1151,9 @@ static VALUE robject_cast_array(VALUE rary) {
1142
1151
  Cast object to Numo::RObject.
1143
1152
  @overload [](elements)
1144
1153
  @overload cast(array)
1145
- @param [Numeric,Array] elements
1146
- @param [Array] array
1147
- @return [Numo::RObject]
1154
+ @param [Numeric,Array] elements
1155
+ @param [Array] array
1156
+ @return [Numo::RObject]
1148
1157
  */
1149
1158
  static VALUE robject_s_cast(VALUE type, VALUE obj) {
1150
1159
  VALUE v;
@@ -1183,9 +1192,9 @@ static VALUE robject_s_cast(VALUE type, VALUE obj) {
1183
1192
  /*
1184
1193
  Multi-dimensional element reference.
1185
1194
  @overload [](dim0,...,dimL)
1186
- @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol] dim0,...,dimL multi-dimensional
1187
- indices.
1188
- @return [Numeric,Numo::RObject] an element or NArray view.
1195
+ @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
1196
+ dim0,...,dimL multi-dimensional indices.
1197
+ @return [Numeric,Numo::RObject] an element or NArray view.
1189
1198
  @see Numo::NArray#[]
1190
1199
  @see #[]=
1191
1200
  */
@@ -1206,10 +1215,10 @@ static VALUE robject_aref(int argc, VALUE* argv, VALUE self) {
1206
1215
  /*
1207
1216
  Multi-dimensional element assignment.
1208
1217
  @overload []=(dim0,...,dimL,val)
1209
- @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol] dim0,...,dimL multi-dimensional
1210
- indices.
1211
- @param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
1212
- @return [Numeric,Numo::NArray,Array] returns `val` (last argument).
1218
+ @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
1219
+ dim0,...,dimL multi-dimensional indices.
1220
+ @param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
1221
+ @return [Numeric,Numo::NArray,Array] returns `val` (last argument).
1213
1222
  @see Numo::NArray#[]=
1214
1223
  @see #[]
1215
1224
  */
@@ -1240,7 +1249,7 @@ static VALUE robject_aset(int argc, VALUE* argv, VALUE self) {
1240
1249
  /*
1241
1250
  return NArray with cast to the type of self.
1242
1251
  @overload coerce_cast(type)
1243
- @return [nil]
1252
+ @return [nil]
1244
1253
  */
1245
1254
  static VALUE robject_coerce_cast(VALUE self, VALUE type) {
1246
1255
  return Qnil;
@@ -1275,12 +1284,12 @@ static void iter_robject_to_a(na_loop_t* const lp) {
1275
1284
  /*
1276
1285
  Convert self to Array.
1277
1286
  @overload to_a
1278
- @return [Array]
1287
+ @return [Array]
1279
1288
  */
1280
1289
  static VALUE robject_to_a(VALUE self) {
1281
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
1282
- ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
1283
- ndfunc_t ndf = {iter_robject_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
1290
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
1291
+ ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
1292
+ ndfunc_t ndf = { iter_robject_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
1284
1293
  return na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
1285
1294
  }
1286
1295
 
@@ -1308,12 +1317,12 @@ static void iter_robject_fill(na_loop_t* const lp) {
1308
1317
  /*
1309
1318
  Fill elements with other.
1310
1319
  @overload fill other
1311
- @param [Numeric] other
1312
- @return [Numo::RObject] self.
1320
+ @param [Numeric] other
1321
+ @return [Numo::RObject] self.
1313
1322
  */
1314
1323
  static VALUE robject_fill(VALUE self, VALUE val) {
1315
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_option}};
1316
- ndfunc_t ndf = {iter_robject_fill, FULL_LOOP, 2, 0, ain, 0};
1324
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
1325
+ ndfunc_t ndf = { iter_robject_fill, FULL_LOOP, 2, 0, ain, 0 };
1317
1326
 
1318
1327
  na_ndloop(&ndf, 2, self, val);
1319
1328
  return self;
@@ -1362,15 +1371,15 @@ static void iter_robject_format(na_loop_t* const lp) {
1362
1371
  /*
1363
1372
  Format elements into strings.
1364
1373
  @overload format format
1365
- @param [String] format
1366
- @return [Numo::RObject] array of formatted strings.
1374
+ @param [String] format
1375
+ @return [Numo::RObject] array of formatted strings.
1367
1376
  */
1368
1377
  static VALUE robject_format(int argc, VALUE* argv, VALUE self) {
1369
1378
  VALUE fmt = Qnil;
1370
1379
 
1371
- ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_option}};
1372
- ndfunc_arg_out_t aout[1] = {{numo_cRObject, 0}};
1373
- ndfunc_t ndf = {iter_robject_format, FULL_LOOP_NIP, 2, 1, ain, aout};
1380
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_option } };
1381
+ ndfunc_arg_out_t aout[1] = { { numo_cRObject, 0 } };
1382
+ ndfunc_t ndf = { iter_robject_format, FULL_LOOP_NIP, 2, 1, ain, aout };
1374
1383
 
1375
1384
  rb_scan_args(argc, argv, "01", &fmt);
1376
1385
  return na_ndloop(&ndf, 2, self, fmt);
@@ -1409,14 +1418,14 @@ static void iter_robject_format_to_a(na_loop_t* const lp) {
1409
1418
  /*
1410
1419
  Format elements into strings.
1411
1420
  @overload format_to_a format
1412
- @param [String] format
1413
- @return [Array] array of formatted strings.
1421
+ @param [String] format
1422
+ @return [Array] array of formatted strings.
1414
1423
  */
1415
1424
  static VALUE robject_format_to_a(int argc, VALUE* argv, VALUE self) {
1416
1425
  VALUE fmt = Qnil;
1417
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
1418
- ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
1419
- ndfunc_t ndf = {iter_robject_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
1426
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
1427
+ ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
1428
+ ndfunc_t ndf = { iter_robject_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
1420
1429
 
1421
1430
  rb_scan_args(argc, argv, "01", &fmt);
1422
1431
  return na_ndloop_cast_narray_to_rarray(&ndf, self, fmt);
@@ -1429,7 +1438,7 @@ static VALUE iter_robject_inspect(char* ptr, size_t pos, VALUE fmt) {
1429
1438
  /*
1430
1439
  Returns a string containing a human-readable representation of NArray.
1431
1440
  @overload inspect
1432
- @return [String]
1441
+ @return [String]
1433
1442
  */
1434
1443
  static VALUE robject_inspect(VALUE ary) {
1435
1444
  return na_ndloop_inspect(ary, iter_robject_inspect, Qnil);
@@ -1463,15 +1472,15 @@ static void iter_robject_each(na_loop_t* const lp) {
1463
1472
  Calls the given block once for each element in self,
1464
1473
  passing that element as a parameter.
1465
1474
  @overload each
1466
- @return [Numo::NArray] self
1467
- For a block `{|x| ... }`,
1468
- @yieldparam [Numeric] x an element of NArray.
1475
+ @return [Numo::NArray] self
1476
+ For a block `{|x| ... }`,
1477
+ @yieldparam [Numeric] x an element of NArray.
1469
1478
  @see #each_with_index
1470
1479
  @see #map
1471
1480
  */
1472
1481
  static VALUE robject_each(VALUE self) {
1473
- ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
1474
- ndfunc_t ndf = {iter_robject_each, FULL_LOOP_NIP, 1, 0, ain, 0};
1482
+ ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
1483
+ ndfunc_t ndf = { iter_robject_each, FULL_LOOP_NIP, 1, 0, ain, 0 };
1475
1484
 
1476
1485
  na_ndloop(&ndf, 1, self);
1477
1486
  return self;
@@ -1525,12 +1534,12 @@ static void iter_robject_map(na_loop_t* const lp) {
1525
1534
  /*
1526
1535
  Unary map.
1527
1536
  @overload map
1528
- @return [Numo::RObject] map of self.
1537
+ @return [Numo::RObject] map of self.
1529
1538
  */
1530
1539
  static VALUE robject_map(VALUE self) {
1531
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
1532
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
1533
- ndfunc_t ndf = {iter_robject_map, FULL_LOOP, 1, 1, ain, aout};
1540
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
1541
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
1542
+ ndfunc_t ndf = { iter_robject_map, FULL_LOOP, 1, 1, ain, aout };
1534
1543
 
1535
1544
  return na_ndloop(&ndf, 1, self);
1536
1545
  }
@@ -1584,16 +1593,16 @@ static void iter_robject_each_with_index(na_loop_t* const lp) {
1584
1593
  Invokes the given block once for each element of self,
1585
1594
  passing that element and indices along each axis as parameters.
1586
1595
  @overload each_with_index
1587
- For a block `{|x,i,j,...| ... }`,
1588
- @yieldparam [Numeric] x an element
1589
- @yieldparam [Integer] i,j,... multitimensional indices
1590
- @return [Numo::NArray] self
1596
+ For a block `{|x,i,j,...| ... }`,
1597
+ @yieldparam [Numeric] x an element
1598
+ @yieldparam [Integer] i,j,... multitimensional indices
1599
+ @return [Numo::NArray] self
1591
1600
  @see #each
1592
1601
  @see #map_with_index
1593
1602
  */
1594
1603
  static VALUE robject_each_with_index(VALUE self) {
1595
- ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
1596
- ndfunc_t ndf = {iter_robject_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0};
1604
+ ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
1605
+ ndfunc_t ndf = { iter_robject_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0 };
1597
1606
 
1598
1607
  na_ndloop_with_index(&ndf, 1, self);
1599
1608
  return self;
@@ -1675,17 +1684,17 @@ static void iter_robject_map_with_index(na_loop_t* const lp) {
1675
1684
  Creates a new NArray containing the values returned by the block.
1676
1685
  Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
1677
1686
  @overload map_with_index
1678
- For a block `{|x,i,j,...| ... }`,
1679
- @yieldparam [Numeric] x an element
1680
- @yieldparam [Integer] i,j,... multitimensional indices
1681
- @return [Numo::NArray] mapped array
1687
+ For a block `{|x,i,j,...| ... }`,
1688
+ @yieldparam [Numeric] x an element
1689
+ @yieldparam [Integer] i,j,... multitimensional indices
1690
+ @return [Numo::NArray] mapped array
1682
1691
  @see #map
1683
1692
  @see #each_with_index
1684
1693
  */
1685
1694
  static VALUE robject_map_with_index(VALUE self) {
1686
- ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
1687
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
1688
- ndfunc_t ndf = {iter_robject_map_with_index, FULL_LOOP, 1, 1, ain, aout};
1695
+ ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
1696
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
1697
+ ndfunc_t ndf = { iter_robject_map_with_index, FULL_LOOP, 1, 1, ain, aout };
1689
1698
 
1690
1699
  return na_ndloop_with_index(&ndf, 1, self);
1691
1700
  }
@@ -1734,17 +1743,17 @@ static void iter_robject_abs(na_loop_t* const lp) {
1734
1743
  /*
1735
1744
  abs of self.
1736
1745
  @overload abs
1737
- @return [Numo::RObject] abs of self.
1746
+ @return [Numo::RObject] abs of self.
1738
1747
  */
1739
1748
  static VALUE robject_abs(VALUE self) {
1740
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
1741
- ndfunc_arg_out_t aout[1] = {{cRT, 0}};
1742
- ndfunc_t ndf = {iter_robject_abs, FULL_LOOP, 1, 1, ain, aout};
1749
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
1750
+ ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
1751
+ ndfunc_t ndf = { iter_robject_abs, FULL_LOOP, 1, 1, ain, aout };
1743
1752
 
1744
1753
  return na_ndloop(&ndf, 1, self);
1745
1754
  }
1746
1755
 
1747
- #define check_intdivzero(y) \
1756
+ #define check_intdivzero(y) \
1748
1757
  {}
1749
1758
 
1750
1759
  static void iter_robject_add(na_loop_t* const lp) {
@@ -1804,9 +1813,9 @@ static void iter_robject_add(na_loop_t* const lp) {
1804
1813
  #undef check_intdivzero
1805
1814
 
1806
1815
  static VALUE robject_add_self(VALUE self, VALUE other) {
1807
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
1808
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
1809
- ndfunc_t ndf = {iter_robject_add, STRIDE_LOOP, 2, 1, ain, aout};
1816
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
1817
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
1818
+ ndfunc_t ndf = { iter_robject_add, STRIDE_LOOP, 2, 1, ain, aout };
1810
1819
 
1811
1820
  return na_ndloop(&ndf, 2, self, other);
1812
1821
  }
@@ -1814,14 +1823,14 @@ static VALUE robject_add_self(VALUE self, VALUE other) {
1814
1823
  /*
1815
1824
  Binary add.
1816
1825
  @overload + other
1817
- @param [Numo::NArray,Numeric] other
1818
- @return [Numo::NArray] self + other
1826
+ @param [Numo::NArray,Numeric] other
1827
+ @return [Numo::NArray] self + other
1819
1828
  */
1820
1829
  static VALUE robject_add(VALUE self, VALUE other) {
1821
1830
  return robject_add_self(self, other);
1822
1831
  }
1823
1832
 
1824
- #define check_intdivzero(y) \
1833
+ #define check_intdivzero(y) \
1825
1834
  {}
1826
1835
 
1827
1836
  static void iter_robject_sub(na_loop_t* const lp) {
@@ -1881,9 +1890,9 @@ static void iter_robject_sub(na_loop_t* const lp) {
1881
1890
  #undef check_intdivzero
1882
1891
 
1883
1892
  static VALUE robject_sub_self(VALUE self, VALUE other) {
1884
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
1885
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
1886
- ndfunc_t ndf = {iter_robject_sub, STRIDE_LOOP, 2, 1, ain, aout};
1893
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
1894
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
1895
+ ndfunc_t ndf = { iter_robject_sub, STRIDE_LOOP, 2, 1, ain, aout };
1887
1896
 
1888
1897
  return na_ndloop(&ndf, 2, self, other);
1889
1898
  }
@@ -1891,14 +1900,14 @@ static VALUE robject_sub_self(VALUE self, VALUE other) {
1891
1900
  /*
1892
1901
  Binary sub.
1893
1902
  @overload - other
1894
- @param [Numo::NArray,Numeric] other
1895
- @return [Numo::NArray] self - other
1903
+ @param [Numo::NArray,Numeric] other
1904
+ @return [Numo::NArray] self - other
1896
1905
  */
1897
1906
  static VALUE robject_sub(VALUE self, VALUE other) {
1898
1907
  return robject_sub_self(self, other);
1899
1908
  }
1900
1909
 
1901
- #define check_intdivzero(y) \
1910
+ #define check_intdivzero(y) \
1902
1911
  {}
1903
1912
 
1904
1913
  static void iter_robject_mul(na_loop_t* const lp) {
@@ -1958,9 +1967,9 @@ static void iter_robject_mul(na_loop_t* const lp) {
1958
1967
  #undef check_intdivzero
1959
1968
 
1960
1969
  static VALUE robject_mul_self(VALUE self, VALUE other) {
1961
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
1962
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
1963
- ndfunc_t ndf = {iter_robject_mul, STRIDE_LOOP, 2, 1, ain, aout};
1970
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
1971
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
1972
+ ndfunc_t ndf = { iter_robject_mul, STRIDE_LOOP, 2, 1, ain, aout };
1964
1973
 
1965
1974
  return na_ndloop(&ndf, 2, self, other);
1966
1975
  }
@@ -1968,17 +1977,17 @@ static VALUE robject_mul_self(VALUE self, VALUE other) {
1968
1977
  /*
1969
1978
  Binary mul.
1970
1979
  @overload * other
1971
- @param [Numo::NArray,Numeric] other
1972
- @return [Numo::NArray] self * other
1980
+ @param [Numo::NArray,Numeric] other
1981
+ @return [Numo::NArray] self * other
1973
1982
  */
1974
1983
  static VALUE robject_mul(VALUE self, VALUE other) {
1975
1984
  return robject_mul_self(self, other);
1976
1985
  }
1977
1986
 
1978
- #define check_intdivzero(y) \
1979
- if ((y) == 0) { \
1980
- lp->err_type = rb_eZeroDivError; \
1981
- return; \
1987
+ #define check_intdivzero(y) \
1988
+ if ((y) == 0) { \
1989
+ lp->err_type = rb_eZeroDivError; \
1990
+ return; \
1982
1991
  }
1983
1992
 
1984
1993
  static void iter_robject_div(na_loop_t* const lp) {
@@ -2038,9 +2047,9 @@ static void iter_robject_div(na_loop_t* const lp) {
2038
2047
  #undef check_intdivzero
2039
2048
 
2040
2049
  static VALUE robject_div_self(VALUE self, VALUE other) {
2041
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2042
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2043
- ndfunc_t ndf = {iter_robject_div, STRIDE_LOOP, 2, 1, ain, aout};
2050
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2051
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2052
+ ndfunc_t ndf = { iter_robject_div, STRIDE_LOOP, 2, 1, ain, aout };
2044
2053
 
2045
2054
  return na_ndloop(&ndf, 2, self, other);
2046
2055
  }
@@ -2048,17 +2057,17 @@ static VALUE robject_div_self(VALUE self, VALUE other) {
2048
2057
  /*
2049
2058
  Binary div.
2050
2059
  @overload / other
2051
- @param [Numo::NArray,Numeric] other
2052
- @return [Numo::NArray] self / other
2060
+ @param [Numo::NArray,Numeric] other
2061
+ @return [Numo::NArray] self / other
2053
2062
  */
2054
2063
  static VALUE robject_div(VALUE self, VALUE other) {
2055
2064
  return robject_div_self(self, other);
2056
2065
  }
2057
2066
 
2058
- #define check_intdivzero(y) \
2059
- if ((y) == 0) { \
2060
- lp->err_type = rb_eZeroDivError; \
2061
- return; \
2067
+ #define check_intdivzero(y) \
2068
+ if ((y) == 0) { \
2069
+ lp->err_type = rb_eZeroDivError; \
2070
+ return; \
2062
2071
  }
2063
2072
 
2064
2073
  static void iter_robject_mod(na_loop_t* const lp) {
@@ -2118,9 +2127,9 @@ static void iter_robject_mod(na_loop_t* const lp) {
2118
2127
  #undef check_intdivzero
2119
2128
 
2120
2129
  static VALUE robject_mod_self(VALUE self, VALUE other) {
2121
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2122
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2123
- ndfunc_t ndf = {iter_robject_mod, STRIDE_LOOP, 2, 1, ain, aout};
2130
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2131
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2132
+ ndfunc_t ndf = { iter_robject_mod, STRIDE_LOOP, 2, 1, ain, aout };
2124
2133
 
2125
2134
  return na_ndloop(&ndf, 2, self, other);
2126
2135
  }
@@ -2128,8 +2137,8 @@ static VALUE robject_mod_self(VALUE self, VALUE other) {
2128
2137
  /*
2129
2138
  Binary mod.
2130
2139
  @overload % other
2131
- @param [Numo::NArray,Numeric] other
2132
- @return [Numo::NArray] self % other
2140
+ @param [Numo::NArray,Numeric] other
2141
+ @return [Numo::NArray] self % other
2133
2142
  */
2134
2143
  static VALUE robject_mod(VALUE self, VALUE other) {
2135
2144
  return robject_mod_self(self, other);
@@ -2159,9 +2168,9 @@ static void iter_robject_divmod(na_loop_t* const lp) {
2159
2168
  }
2160
2169
 
2161
2170
  static VALUE robject_divmod_self(VALUE self, VALUE other) {
2162
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2163
- ndfunc_arg_out_t aout[2] = {{cT, 0}, {cT, 0}};
2164
- ndfunc_t ndf = {iter_robject_divmod, STRIDE_LOOP, 2, 2, ain, aout};
2171
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2172
+ ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
2173
+ ndfunc_t ndf = { iter_robject_divmod, STRIDE_LOOP, 2, 2, ain, aout };
2165
2174
 
2166
2175
  return na_ndloop(&ndf, 2, self, other);
2167
2176
  }
@@ -2169,8 +2178,8 @@ static VALUE robject_divmod_self(VALUE self, VALUE other) {
2169
2178
  /*
2170
2179
  Binary divmod.
2171
2180
  @overload divmod other
2172
- @param [Numo::NArray,Numeric] other
2173
- @return [Numo::NArray] divmod of self and other.
2181
+ @param [Numo::NArray,Numeric] other
2182
+ @return [Numo::NArray] divmod of self and other.
2174
2183
  */
2175
2184
  static VALUE robject_divmod(VALUE self, VALUE other) {
2176
2185
  return robject_divmod_self(self, other);
@@ -2212,11 +2221,11 @@ static void iter_robject_pow_int32(na_loop_t* const lp) {
2212
2221
  }
2213
2222
 
2214
2223
  static VALUE robject_pow_self(VALUE self, VALUE other) {
2215
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2216
- ndfunc_arg_in_t ain_i[2] = {{cT, 0}, {numo_cInt32, 0}};
2217
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2218
- ndfunc_t ndf = {iter_robject_pow, STRIDE_LOOP, 2, 1, ain, aout};
2219
- ndfunc_t ndf_i = {iter_robject_pow_int32, STRIDE_LOOP, 2, 1, ain_i, aout};
2224
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2225
+ ndfunc_arg_in_t ain_i[2] = { { cT, 0 }, { numo_cInt32, 0 } };
2226
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2227
+ ndfunc_t ndf = { iter_robject_pow, STRIDE_LOOP, 2, 1, ain, aout };
2228
+ ndfunc_t ndf_i = { iter_robject_pow_int32, STRIDE_LOOP, 2, 1, ain_i, aout };
2220
2229
 
2221
2230
  // fixme : use na.integer?
2222
2231
  if (FIXNUM_P(other) || rb_obj_is_kind_of(other, numo_cInt32)) {
@@ -2229,8 +2238,8 @@ static VALUE robject_pow_self(VALUE self, VALUE other) {
2229
2238
  /*
2230
2239
  Binary power.
2231
2240
  @overload ** other
2232
- @param [Numo::NArray,Numeric] other
2233
- @return [Numo::NArray] self to the other-th power.
2241
+ @param [Numo::NArray,Numeric] other
2242
+ @return [Numo::NArray] self to the other-th power.
2234
2243
  */
2235
2244
  static VALUE robject_pow(VALUE self, VALUE other) {
2236
2245
  return robject_pow_self(self, other);
@@ -2284,12 +2293,12 @@ static void iter_robject_minus(na_loop_t* const lp) {
2284
2293
  /*
2285
2294
  Unary minus.
2286
2295
  @overload -@
2287
- @return [Numo::RObject] minus of self.
2296
+ @return [Numo::RObject] minus of self.
2288
2297
  */
2289
2298
  static VALUE robject_minus(VALUE self) {
2290
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
2291
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2292
- ndfunc_t ndf = {iter_robject_minus, FULL_LOOP, 1, 1, ain, aout};
2299
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
2300
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2301
+ ndfunc_t ndf = { iter_robject_minus, FULL_LOOP, 1, 1, ain, aout };
2293
2302
 
2294
2303
  return na_ndloop(&ndf, 1, self);
2295
2304
  }
@@ -2342,12 +2351,12 @@ static void iter_robject_reciprocal(na_loop_t* const lp) {
2342
2351
  /*
2343
2352
  Unary reciprocal.
2344
2353
  @overload reciprocal
2345
- @return [Numo::RObject] reciprocal of self.
2354
+ @return [Numo::RObject] reciprocal of self.
2346
2355
  */
2347
2356
  static VALUE robject_reciprocal(VALUE self) {
2348
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
2349
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2350
- ndfunc_t ndf = {iter_robject_reciprocal, FULL_LOOP, 1, 1, ain, aout};
2357
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
2358
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2359
+ ndfunc_t ndf = { iter_robject_reciprocal, FULL_LOOP, 1, 1, ain, aout };
2351
2360
 
2352
2361
  return na_ndloop(&ndf, 1, self);
2353
2362
  }
@@ -2400,12 +2409,12 @@ static void iter_robject_sign(na_loop_t* const lp) {
2400
2409
  /*
2401
2410
  Unary sign.
2402
2411
  @overload sign
2403
- @return [Numo::RObject] sign of self.
2412
+ @return [Numo::RObject] sign of self.
2404
2413
  */
2405
2414
  static VALUE robject_sign(VALUE self) {
2406
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
2407
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2408
- ndfunc_t ndf = {iter_robject_sign, FULL_LOOP, 1, 1, ain, aout};
2415
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
2416
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2417
+ ndfunc_t ndf = { iter_robject_sign, FULL_LOOP, 1, 1, ain, aout };
2409
2418
 
2410
2419
  return na_ndloop(&ndf, 1, self);
2411
2420
  }
@@ -2458,12 +2467,12 @@ static void iter_robject_square(na_loop_t* const lp) {
2458
2467
  /*
2459
2468
  Unary square.
2460
2469
  @overload square
2461
- @return [Numo::RObject] square of self.
2470
+ @return [Numo::RObject] square of self.
2462
2471
  */
2463
2472
  static VALUE robject_square(VALUE self) {
2464
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
2465
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2466
- ndfunc_t ndf = {iter_robject_square, FULL_LOOP, 1, 1, ain, aout};
2473
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
2474
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2475
+ ndfunc_t ndf = { iter_robject_square, FULL_LOOP, 1, 1, ain, aout };
2467
2476
 
2468
2477
  return na_ndloop(&ndf, 1, self);
2469
2478
  }
@@ -2490,9 +2499,9 @@ static void iter_robject_eq(na_loop_t* const lp) {
2490
2499
  }
2491
2500
 
2492
2501
  static VALUE robject_eq_self(VALUE self, VALUE other) {
2493
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2494
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
2495
- ndfunc_t ndf = {iter_robject_eq, STRIDE_LOOP, 2, 1, ain, aout};
2502
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2503
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
2504
+ ndfunc_t ndf = { iter_robject_eq, STRIDE_LOOP, 2, 1, ain, aout };
2496
2505
 
2497
2506
  return na_ndloop(&ndf, 2, self, other);
2498
2507
  }
@@ -2500,8 +2509,8 @@ static VALUE robject_eq_self(VALUE self, VALUE other) {
2500
2509
  /*
2501
2510
  Comparison eq other.
2502
2511
  @overload eq other
2503
- @param [Numo::NArray,Numeric] other
2504
- @return [Numo::Bit] result of self eq other.
2512
+ @param [Numo::NArray,Numeric] other
2513
+ @return [Numo::Bit] result of self eq other.
2505
2514
  */
2506
2515
  static VALUE robject_eq(VALUE self, VALUE other) {
2507
2516
  return robject_eq_self(self, other);
@@ -2529,9 +2538,9 @@ static void iter_robject_ne(na_loop_t* const lp) {
2529
2538
  }
2530
2539
 
2531
2540
  static VALUE robject_ne_self(VALUE self, VALUE other) {
2532
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2533
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
2534
- ndfunc_t ndf = {iter_robject_ne, STRIDE_LOOP, 2, 1, ain, aout};
2541
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2542
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
2543
+ ndfunc_t ndf = { iter_robject_ne, STRIDE_LOOP, 2, 1, ain, aout };
2535
2544
 
2536
2545
  return na_ndloop(&ndf, 2, self, other);
2537
2546
  }
@@ -2539,8 +2548,8 @@ static VALUE robject_ne_self(VALUE self, VALUE other) {
2539
2548
  /*
2540
2549
  Comparison ne other.
2541
2550
  @overload ne other
2542
- @param [Numo::NArray,Numeric] other
2543
- @return [Numo::Bit] result of self ne other.
2551
+ @param [Numo::NArray,Numeric] other
2552
+ @return [Numo::Bit] result of self ne other.
2544
2553
  */
2545
2554
  static VALUE robject_ne(VALUE self, VALUE other) {
2546
2555
  return robject_ne_self(self, other);
@@ -2568,9 +2577,9 @@ static void iter_robject_nearly_eq(na_loop_t* const lp) {
2568
2577
  }
2569
2578
 
2570
2579
  static VALUE robject_nearly_eq_self(VALUE self, VALUE other) {
2571
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2572
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
2573
- ndfunc_t ndf = {iter_robject_nearly_eq, STRIDE_LOOP, 2, 1, ain, aout};
2580
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2581
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
2582
+ ndfunc_t ndf = { iter_robject_nearly_eq, STRIDE_LOOP, 2, 1, ain, aout };
2574
2583
 
2575
2584
  return na_ndloop(&ndf, 2, self, other);
2576
2585
  }
@@ -2578,14 +2587,14 @@ static VALUE robject_nearly_eq_self(VALUE self, VALUE other) {
2578
2587
  /*
2579
2588
  Comparison nearly_eq other.
2580
2589
  @overload nearly_eq other
2581
- @param [Numo::NArray,Numeric] other
2582
- @return [Numo::Bit] result of self nearly_eq other.
2590
+ @param [Numo::NArray,Numeric] other
2591
+ @return [Numo::Bit] result of self nearly_eq other.
2583
2592
  */
2584
2593
  static VALUE robject_nearly_eq(VALUE self, VALUE other) {
2585
2594
  return robject_nearly_eq_self(self, other);
2586
2595
  }
2587
2596
 
2588
- #define check_intdivzero(y) \
2597
+ #define check_intdivzero(y) \
2589
2598
  {}
2590
2599
 
2591
2600
  static void iter_robject_bit_and(na_loop_t* const lp) {
@@ -2645,9 +2654,9 @@ static void iter_robject_bit_and(na_loop_t* const lp) {
2645
2654
  #undef check_intdivzero
2646
2655
 
2647
2656
  static VALUE robject_bit_and_self(VALUE self, VALUE other) {
2648
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2649
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2650
- ndfunc_t ndf = {iter_robject_bit_and, STRIDE_LOOP, 2, 1, ain, aout};
2657
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2658
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2659
+ ndfunc_t ndf = { iter_robject_bit_and, STRIDE_LOOP, 2, 1, ain, aout };
2651
2660
 
2652
2661
  return na_ndloop(&ndf, 2, self, other);
2653
2662
  }
@@ -2655,14 +2664,14 @@ static VALUE robject_bit_and_self(VALUE self, VALUE other) {
2655
2664
  /*
2656
2665
  Binary bit_and.
2657
2666
  @overload & other
2658
- @param [Numo::NArray,Numeric] other
2659
- @return [Numo::NArray] self & other
2667
+ @param [Numo::NArray,Numeric] other
2668
+ @return [Numo::NArray] self & other
2660
2669
  */
2661
2670
  static VALUE robject_bit_and(VALUE self, VALUE other) {
2662
2671
  return robject_bit_and_self(self, other);
2663
2672
  }
2664
2673
 
2665
- #define check_intdivzero(y) \
2674
+ #define check_intdivzero(y) \
2666
2675
  {}
2667
2676
 
2668
2677
  static void iter_robject_bit_or(na_loop_t* const lp) {
@@ -2722,9 +2731,9 @@ static void iter_robject_bit_or(na_loop_t* const lp) {
2722
2731
  #undef check_intdivzero
2723
2732
 
2724
2733
  static VALUE robject_bit_or_self(VALUE self, VALUE other) {
2725
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2726
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2727
- ndfunc_t ndf = {iter_robject_bit_or, STRIDE_LOOP, 2, 1, ain, aout};
2734
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2735
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2736
+ ndfunc_t ndf = { iter_robject_bit_or, STRIDE_LOOP, 2, 1, ain, aout };
2728
2737
 
2729
2738
  return na_ndloop(&ndf, 2, self, other);
2730
2739
  }
@@ -2732,14 +2741,14 @@ static VALUE robject_bit_or_self(VALUE self, VALUE other) {
2732
2741
  /*
2733
2742
  Binary bit_or.
2734
2743
  @overload | other
2735
- @param [Numo::NArray,Numeric] other
2736
- @return [Numo::NArray] self | other
2744
+ @param [Numo::NArray,Numeric] other
2745
+ @return [Numo::NArray] self | other
2737
2746
  */
2738
2747
  static VALUE robject_bit_or(VALUE self, VALUE other) {
2739
2748
  return robject_bit_or_self(self, other);
2740
2749
  }
2741
2750
 
2742
- #define check_intdivzero(y) \
2751
+ #define check_intdivzero(y) \
2743
2752
  {}
2744
2753
 
2745
2754
  static void iter_robject_bit_xor(na_loop_t* const lp) {
@@ -2799,9 +2808,9 @@ static void iter_robject_bit_xor(na_loop_t* const lp) {
2799
2808
  #undef check_intdivzero
2800
2809
 
2801
2810
  static VALUE robject_bit_xor_self(VALUE self, VALUE other) {
2802
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2803
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2804
- ndfunc_t ndf = {iter_robject_bit_xor, STRIDE_LOOP, 2, 1, ain, aout};
2811
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2812
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2813
+ ndfunc_t ndf = { iter_robject_bit_xor, STRIDE_LOOP, 2, 1, ain, aout };
2805
2814
 
2806
2815
  return na_ndloop(&ndf, 2, self, other);
2807
2816
  }
@@ -2809,8 +2818,8 @@ static VALUE robject_bit_xor_self(VALUE self, VALUE other) {
2809
2818
  /*
2810
2819
  Binary bit_xor.
2811
2820
  @overload ^ other
2812
- @param [Numo::NArray,Numeric] other
2813
- @return [Numo::NArray] self ^ other
2821
+ @param [Numo::NArray,Numeric] other
2822
+ @return [Numo::NArray] self ^ other
2814
2823
  */
2815
2824
  static VALUE robject_bit_xor(VALUE self, VALUE other) {
2816
2825
  return robject_bit_xor_self(self, other);
@@ -2864,17 +2873,17 @@ static void iter_robject_bit_not(na_loop_t* const lp) {
2864
2873
  /*
2865
2874
  Unary bit_not.
2866
2875
  @overload ~
2867
- @return [Numo::RObject] bit_not of self.
2876
+ @return [Numo::RObject] bit_not of self.
2868
2877
  */
2869
2878
  static VALUE robject_bit_not(VALUE self) {
2870
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
2871
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2872
- ndfunc_t ndf = {iter_robject_bit_not, FULL_LOOP, 1, 1, ain, aout};
2879
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
2880
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2881
+ ndfunc_t ndf = { iter_robject_bit_not, FULL_LOOP, 1, 1, ain, aout };
2873
2882
 
2874
2883
  return na_ndloop(&ndf, 1, self);
2875
2884
  }
2876
2885
 
2877
- #define check_intdivzero(y) \
2886
+ #define check_intdivzero(y) \
2878
2887
  {}
2879
2888
 
2880
2889
  static void iter_robject_left_shift(na_loop_t* const lp) {
@@ -2934,9 +2943,9 @@ static void iter_robject_left_shift(na_loop_t* const lp) {
2934
2943
  #undef check_intdivzero
2935
2944
 
2936
2945
  static VALUE robject_left_shift_self(VALUE self, VALUE other) {
2937
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2938
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2939
- ndfunc_t ndf = {iter_robject_left_shift, STRIDE_LOOP, 2, 1, ain, aout};
2946
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2947
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2948
+ ndfunc_t ndf = { iter_robject_left_shift, STRIDE_LOOP, 2, 1, ain, aout };
2940
2949
 
2941
2950
  return na_ndloop(&ndf, 2, self, other);
2942
2951
  }
@@ -2944,14 +2953,14 @@ static VALUE robject_left_shift_self(VALUE self, VALUE other) {
2944
2953
  /*
2945
2954
  Binary left_shift.
2946
2955
  @overload << other
2947
- @param [Numo::NArray,Numeric] other
2948
- @return [Numo::NArray] self << other
2956
+ @param [Numo::NArray,Numeric] other
2957
+ @return [Numo::NArray] self << other
2949
2958
  */
2950
2959
  static VALUE robject_left_shift(VALUE self, VALUE other) {
2951
2960
  return robject_left_shift_self(self, other);
2952
2961
  }
2953
2962
 
2954
- #define check_intdivzero(y) \
2963
+ #define check_intdivzero(y) \
2955
2964
  {}
2956
2965
 
2957
2966
  static void iter_robject_right_shift(na_loop_t* const lp) {
@@ -3011,9 +3020,9 @@ static void iter_robject_right_shift(na_loop_t* const lp) {
3011
3020
  #undef check_intdivzero
3012
3021
 
3013
3022
  static VALUE robject_right_shift_self(VALUE self, VALUE other) {
3014
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3015
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3016
- ndfunc_t ndf = {iter_robject_right_shift, STRIDE_LOOP, 2, 1, ain, aout};
3023
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3024
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3025
+ ndfunc_t ndf = { iter_robject_right_shift, STRIDE_LOOP, 2, 1, ain, aout };
3017
3026
 
3018
3027
  return na_ndloop(&ndf, 2, self, other);
3019
3028
  }
@@ -3021,8 +3030,8 @@ static VALUE robject_right_shift_self(VALUE self, VALUE other) {
3021
3030
  /*
3022
3031
  Binary right_shift.
3023
3032
  @overload >> other
3024
- @param [Numo::NArray,Numeric] other
3025
- @return [Numo::NArray] self >> other
3033
+ @param [Numo::NArray,Numeric] other
3034
+ @return [Numo::NArray] self >> other
3026
3035
  */
3027
3036
  static VALUE robject_right_shift(VALUE self, VALUE other) {
3028
3037
  return robject_right_shift_self(self, other);
@@ -3076,12 +3085,12 @@ static void iter_robject_floor(na_loop_t* const lp) {
3076
3085
  /*
3077
3086
  Unary floor.
3078
3087
  @overload floor
3079
- @return [Numo::RObject] floor of self.
3088
+ @return [Numo::RObject] floor of self.
3080
3089
  */
3081
3090
  static VALUE robject_floor(VALUE self) {
3082
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3083
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3084
- ndfunc_t ndf = {iter_robject_floor, FULL_LOOP, 1, 1, ain, aout};
3091
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3092
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3093
+ ndfunc_t ndf = { iter_robject_floor, FULL_LOOP, 1, 1, ain, aout };
3085
3094
 
3086
3095
  return na_ndloop(&ndf, 1, self);
3087
3096
  }
@@ -3134,12 +3143,12 @@ static void iter_robject_round(na_loop_t* const lp) {
3134
3143
  /*
3135
3144
  Unary round.
3136
3145
  @overload round
3137
- @return [Numo::RObject] round of self.
3146
+ @return [Numo::RObject] round of self.
3138
3147
  */
3139
3148
  static VALUE robject_round(VALUE self) {
3140
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3141
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3142
- ndfunc_t ndf = {iter_robject_round, FULL_LOOP, 1, 1, ain, aout};
3149
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3150
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3151
+ ndfunc_t ndf = { iter_robject_round, FULL_LOOP, 1, 1, ain, aout };
3143
3152
 
3144
3153
  return na_ndloop(&ndf, 1, self);
3145
3154
  }
@@ -3192,12 +3201,12 @@ static void iter_robject_ceil(na_loop_t* const lp) {
3192
3201
  /*
3193
3202
  Unary ceil.
3194
3203
  @overload ceil
3195
- @return [Numo::RObject] ceil of self.
3204
+ @return [Numo::RObject] ceil of self.
3196
3205
  */
3197
3206
  static VALUE robject_ceil(VALUE self) {
3198
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3199
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3200
- ndfunc_t ndf = {iter_robject_ceil, FULL_LOOP, 1, 1, ain, aout};
3207
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3208
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3209
+ ndfunc_t ndf = { iter_robject_ceil, FULL_LOOP, 1, 1, ain, aout };
3201
3210
 
3202
3211
  return na_ndloop(&ndf, 1, self);
3203
3212
  }
@@ -3250,12 +3259,12 @@ static void iter_robject_trunc(na_loop_t* const lp) {
3250
3259
  /*
3251
3260
  Unary trunc.
3252
3261
  @overload trunc
3253
- @return [Numo::RObject] trunc of self.
3262
+ @return [Numo::RObject] trunc of self.
3254
3263
  */
3255
3264
  static VALUE robject_trunc(VALUE self) {
3256
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3257
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3258
- ndfunc_t ndf = {iter_robject_trunc, FULL_LOOP, 1, 1, ain, aout};
3265
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3266
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3267
+ ndfunc_t ndf = { iter_robject_trunc, FULL_LOOP, 1, 1, ain, aout };
3259
3268
 
3260
3269
  return na_ndloop(&ndf, 1, self);
3261
3270
  }
@@ -3282,9 +3291,9 @@ static void iter_robject_gt(na_loop_t* const lp) {
3282
3291
  }
3283
3292
 
3284
3293
  static VALUE robject_gt_self(VALUE self, VALUE other) {
3285
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3286
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3287
- ndfunc_t ndf = {iter_robject_gt, STRIDE_LOOP, 2, 1, ain, aout};
3294
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3295
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3296
+ ndfunc_t ndf = { iter_robject_gt, STRIDE_LOOP, 2, 1, ain, aout };
3288
3297
 
3289
3298
  return na_ndloop(&ndf, 2, self, other);
3290
3299
  }
@@ -3292,8 +3301,8 @@ static VALUE robject_gt_self(VALUE self, VALUE other) {
3292
3301
  /*
3293
3302
  Comparison gt other.
3294
3303
  @overload gt other
3295
- @param [Numo::NArray,Numeric] other
3296
- @return [Numo::Bit] result of self gt other.
3304
+ @param [Numo::NArray,Numeric] other
3305
+ @return [Numo::Bit] result of self gt other.
3297
3306
  */
3298
3307
  static VALUE robject_gt(VALUE self, VALUE other) {
3299
3308
  return robject_gt_self(self, other);
@@ -3321,9 +3330,9 @@ static void iter_robject_ge(na_loop_t* const lp) {
3321
3330
  }
3322
3331
 
3323
3332
  static VALUE robject_ge_self(VALUE self, VALUE other) {
3324
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3325
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3326
- ndfunc_t ndf = {iter_robject_ge, STRIDE_LOOP, 2, 1, ain, aout};
3333
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3334
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3335
+ ndfunc_t ndf = { iter_robject_ge, STRIDE_LOOP, 2, 1, ain, aout };
3327
3336
 
3328
3337
  return na_ndloop(&ndf, 2, self, other);
3329
3338
  }
@@ -3331,8 +3340,8 @@ static VALUE robject_ge_self(VALUE self, VALUE other) {
3331
3340
  /*
3332
3341
  Comparison ge other.
3333
3342
  @overload ge other
3334
- @param [Numo::NArray,Numeric] other
3335
- @return [Numo::Bit] result of self ge other.
3343
+ @param [Numo::NArray,Numeric] other
3344
+ @return [Numo::Bit] result of self ge other.
3336
3345
  */
3337
3346
  static VALUE robject_ge(VALUE self, VALUE other) {
3338
3347
  return robject_ge_self(self, other);
@@ -3360,9 +3369,9 @@ static void iter_robject_lt(na_loop_t* const lp) {
3360
3369
  }
3361
3370
 
3362
3371
  static VALUE robject_lt_self(VALUE self, VALUE other) {
3363
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3364
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3365
- ndfunc_t ndf = {iter_robject_lt, STRIDE_LOOP, 2, 1, ain, aout};
3372
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3373
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3374
+ ndfunc_t ndf = { iter_robject_lt, STRIDE_LOOP, 2, 1, ain, aout };
3366
3375
 
3367
3376
  return na_ndloop(&ndf, 2, self, other);
3368
3377
  }
@@ -3370,8 +3379,8 @@ static VALUE robject_lt_self(VALUE self, VALUE other) {
3370
3379
  /*
3371
3380
  Comparison lt other.
3372
3381
  @overload lt other
3373
- @param [Numo::NArray,Numeric] other
3374
- @return [Numo::Bit] result of self lt other.
3382
+ @param [Numo::NArray,Numeric] other
3383
+ @return [Numo::Bit] result of self lt other.
3375
3384
  */
3376
3385
  static VALUE robject_lt(VALUE self, VALUE other) {
3377
3386
  return robject_lt_self(self, other);
@@ -3399,9 +3408,9 @@ static void iter_robject_le(na_loop_t* const lp) {
3399
3408
  }
3400
3409
 
3401
3410
  static VALUE robject_le_self(VALUE self, VALUE other) {
3402
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3403
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3404
- ndfunc_t ndf = {iter_robject_le, STRIDE_LOOP, 2, 1, ain, aout};
3411
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3412
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3413
+ ndfunc_t ndf = { iter_robject_le, STRIDE_LOOP, 2, 1, ain, aout };
3405
3414
 
3406
3415
  return na_ndloop(&ndf, 2, self, other);
3407
3416
  }
@@ -3409,8 +3418,8 @@ static VALUE robject_le_self(VALUE self, VALUE other) {
3409
3418
  /*
3410
3419
  Comparison le other.
3411
3420
  @overload le other
3412
- @param [Numo::NArray,Numeric] other
3413
- @return [Numo::Bit] result of self le other.
3421
+ @param [Numo::NArray,Numeric] other
3422
+ @return [Numo::Bit] result of self le other.
3414
3423
  */
3415
3424
  static VALUE robject_le(VALUE self, VALUE other) {
3416
3425
  return robject_le_self(self, other);
@@ -3485,9 +3494,9 @@ static void iter_robject_clip_max(na_loop_t* const lp) {
3485
3494
  Clip array elements by [min,max].
3486
3495
  If either of min or max is nil, one side is clipped.
3487
3496
  @overload clip(min,max)
3488
- @param [Numo::NArray,Numeric] min
3489
- @param [Numo::NArray,Numeric] max
3490
- @return [Numo::NArray] result of clip.
3497
+ @param [Numo::NArray,Numeric] min
3498
+ @param [Numo::NArray,Numeric] max
3499
+ @return [Numo::NArray] result of clip.
3491
3500
 
3492
3501
  @example
3493
3502
  a = Numo::Int32.new(10).seq
@@ -3512,11 +3521,11 @@ static void iter_robject_clip_max(na_loop_t* const lp) {
3512
3521
  # [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]
3513
3522
  */
3514
3523
  static VALUE robject_clip(VALUE self, VALUE min, VALUE max) {
3515
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {cT, 0}, {cT, 0}};
3516
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3517
- ndfunc_t ndf_min = {iter_robject_clip_min, STRIDE_LOOP, 2, 1, ain, aout};
3518
- ndfunc_t ndf_max = {iter_robject_clip_max, STRIDE_LOOP, 2, 1, ain, aout};
3519
- ndfunc_t ndf_both = {iter_robject_clip, STRIDE_LOOP, 3, 1, ain, aout};
3524
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { cT, 0 }, { cT, 0 } };
3525
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3526
+ ndfunc_t ndf_min = { iter_robject_clip_min, STRIDE_LOOP, 2, 1, ain, aout };
3527
+ ndfunc_t ndf_max = { iter_robject_clip_max, STRIDE_LOOP, 2, 1, ain, aout };
3528
+ ndfunc_t ndf_both = { iter_robject_clip, STRIDE_LOOP, 3, 1, ain, aout };
3520
3529
 
3521
3530
  if (RTEST(min)) {
3522
3531
  if (RTEST(max)) {
@@ -3565,12 +3574,12 @@ static void iter_robject_isnan(na_loop_t* const lp) {
3565
3574
  /*
3566
3575
  Condition of isnan.
3567
3576
  @overload isnan
3568
- @return [Numo::Bit] Condition of isnan.
3577
+ @return [Numo::Bit] Condition of isnan.
3569
3578
  */
3570
3579
  static VALUE robject_isnan(VALUE self) {
3571
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3572
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3573
- ndfunc_t ndf = {iter_robject_isnan, FULL_LOOP, 1, 1, ain, aout};
3580
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3581
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3582
+ ndfunc_t ndf = { iter_robject_isnan, FULL_LOOP, 1, 1, ain, aout };
3574
3583
 
3575
3584
  return na_ndloop(&ndf, 1, self);
3576
3585
  }
@@ -3607,12 +3616,12 @@ static void iter_robject_isinf(na_loop_t* const lp) {
3607
3616
  /*
3608
3617
  Condition of isinf.
3609
3618
  @overload isinf
3610
- @return [Numo::Bit] Condition of isinf.
3619
+ @return [Numo::Bit] Condition of isinf.
3611
3620
  */
3612
3621
  static VALUE robject_isinf(VALUE self) {
3613
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3614
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3615
- ndfunc_t ndf = {iter_robject_isinf, FULL_LOOP, 1, 1, ain, aout};
3622
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3623
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3624
+ ndfunc_t ndf = { iter_robject_isinf, FULL_LOOP, 1, 1, ain, aout };
3616
3625
 
3617
3626
  return na_ndloop(&ndf, 1, self);
3618
3627
  }
@@ -3649,12 +3658,12 @@ static void iter_robject_isposinf(na_loop_t* const lp) {
3649
3658
  /*
3650
3659
  Condition of isposinf.
3651
3660
  @overload isposinf
3652
- @return [Numo::Bit] Condition of isposinf.
3661
+ @return [Numo::Bit] Condition of isposinf.
3653
3662
  */
3654
3663
  static VALUE robject_isposinf(VALUE self) {
3655
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3656
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3657
- ndfunc_t ndf = {iter_robject_isposinf, FULL_LOOP, 1, 1, ain, aout};
3664
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3665
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3666
+ ndfunc_t ndf = { iter_robject_isposinf, FULL_LOOP, 1, 1, ain, aout };
3658
3667
 
3659
3668
  return na_ndloop(&ndf, 1, self);
3660
3669
  }
@@ -3691,12 +3700,12 @@ static void iter_robject_isneginf(na_loop_t* const lp) {
3691
3700
  /*
3692
3701
  Condition of isneginf.
3693
3702
  @overload isneginf
3694
- @return [Numo::Bit] Condition of isneginf.
3703
+ @return [Numo::Bit] Condition of isneginf.
3695
3704
  */
3696
3705
  static VALUE robject_isneginf(VALUE self) {
3697
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3698
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3699
- ndfunc_t ndf = {iter_robject_isneginf, FULL_LOOP, 1, 1, ain, aout};
3706
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3707
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3708
+ ndfunc_t ndf = { iter_robject_isneginf, FULL_LOOP, 1, 1, ain, aout };
3700
3709
 
3701
3710
  return na_ndloop(&ndf, 1, self);
3702
3711
  }
@@ -3733,12 +3742,12 @@ static void iter_robject_isfinite(na_loop_t* const lp) {
3733
3742
  /*
3734
3743
  Condition of isfinite.
3735
3744
  @overload isfinite
3736
- @return [Numo::Bit] Condition of isfinite.
3745
+ @return [Numo::Bit] Condition of isfinite.
3737
3746
  */
3738
3747
  static VALUE robject_isfinite(VALUE self) {
3739
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3740
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3741
- ndfunc_t ndf = {iter_robject_isfinite, FULL_LOOP, 1, 1, ain, aout};
3748
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3749
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3750
+ ndfunc_t ndf = { iter_robject_isfinite, FULL_LOOP, 1, 1, ain, aout };
3742
3751
 
3743
3752
  return na_ndloop(&ndf, 1, self);
3744
3753
  }
@@ -3769,16 +3778,18 @@ static void iter_robject_sum_nan(na_loop_t* const lp) {
3769
3778
  /*
3770
3779
  sum of self.
3771
3780
  @overload sum(axis:nil, keepdims:false, nan:false)
3772
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
3773
- @param [Numeric,Array,Range] axis Performs sum along the axis.
3774
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
3775
- @return [Numo::RObject] returns result of sum.
3781
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
3782
+ return NaN for min/max etc).
3783
+ @param [Numeric,Array,Range] axis Performs sum along the axis.
3784
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3785
+ dimensions with size one.
3786
+ @return [Numo::RObject] returns result of sum.
3776
3787
  */
3777
3788
  static VALUE robject_sum(int argc, VALUE* argv, VALUE self) {
3778
3789
  VALUE v, reduce;
3779
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
3780
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3781
- ndfunc_t ndf = {iter_robject_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
3790
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
3791
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3792
+ ndfunc_t ndf = { iter_robject_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
3782
3793
 
3783
3794
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_sum_nan);
3784
3795
 
@@ -3813,16 +3824,18 @@ static void iter_robject_prod_nan(na_loop_t* const lp) {
3813
3824
  /*
3814
3825
  prod of self.
3815
3826
  @overload prod(axis:nil, keepdims:false, nan:false)
3816
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
3817
- @param [Numeric,Array,Range] axis Performs prod along the axis.
3818
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
3819
- @return [Numo::RObject] returns result of prod.
3827
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
3828
+ return NaN for min/max etc).
3829
+ @param [Numeric,Array,Range] axis Performs prod along the axis.
3830
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3831
+ dimensions with size one.
3832
+ @return [Numo::RObject] returns result of prod.
3820
3833
  */
3821
3834
  static VALUE robject_prod(int argc, VALUE* argv, VALUE self) {
3822
3835
  VALUE v, reduce;
3823
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
3824
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3825
- ndfunc_t ndf = {iter_robject_prod, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
3836
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
3837
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3838
+ ndfunc_t ndf = { iter_robject_prod, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
3826
3839
 
3827
3840
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_prod_nan);
3828
3841
 
@@ -3831,182 +3844,6 @@ static VALUE robject_prod(int argc, VALUE* argv, VALUE self) {
3831
3844
  return robject_extract(v);
3832
3845
  }
3833
3846
 
3834
- static void iter_robject_mean(na_loop_t* const lp) {
3835
- size_t n;
3836
- char *p1, *p2;
3837
- ssize_t s1;
3838
-
3839
- INIT_COUNTER(lp, n);
3840
- INIT_PTR(lp, 0, p1, s1);
3841
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
3842
-
3843
- *(dtype*)p2 = f_mean(n, p1, s1);
3844
- }
3845
- static void iter_robject_mean_nan(na_loop_t* const lp) {
3846
- size_t n;
3847
- char *p1, *p2;
3848
- ssize_t s1;
3849
-
3850
- INIT_COUNTER(lp, n);
3851
- INIT_PTR(lp, 0, p1, s1);
3852
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
3853
-
3854
- *(dtype*)p2 = f_mean_nan(n, p1, s1);
3855
- }
3856
-
3857
- /*
3858
- mean of self.
3859
- @overload mean(axis:nil, keepdims:false, nan:false)
3860
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
3861
- @param [Numeric,Array,Range] axis Performs mean along the axis.
3862
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
3863
- @return [Numo::RObject] returns result of mean.
3864
- */
3865
- static VALUE robject_mean(int argc, VALUE* argv, VALUE self) {
3866
- VALUE v, reduce;
3867
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
3868
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3869
- ndfunc_t ndf = {iter_robject_mean, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
3870
-
3871
- reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_mean_nan);
3872
-
3873
- v = na_ndloop(&ndf, 2, self, reduce);
3874
-
3875
- return robject_extract(v);
3876
- }
3877
-
3878
- static void iter_robject_stddev(na_loop_t* const lp) {
3879
- size_t n;
3880
- char *p1, *p2;
3881
- ssize_t s1;
3882
-
3883
- INIT_COUNTER(lp, n);
3884
- INIT_PTR(lp, 0, p1, s1);
3885
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
3886
-
3887
- *(rtype*)p2 = f_stddev(n, p1, s1);
3888
- }
3889
- static void iter_robject_stddev_nan(na_loop_t* const lp) {
3890
- size_t n;
3891
- char *p1, *p2;
3892
- ssize_t s1;
3893
-
3894
- INIT_COUNTER(lp, n);
3895
- INIT_PTR(lp, 0, p1, s1);
3896
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
3897
-
3898
- *(rtype*)p2 = f_stddev_nan(n, p1, s1);
3899
- }
3900
-
3901
- /*
3902
- stddev of self.
3903
- @overload stddev(axis:nil, keepdims:false, nan:false)
3904
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
3905
- @param [Numeric,Array,Range] axis Performs stddev along the axis.
3906
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
3907
- @return [Numo::RObject] returns result of stddev.
3908
- */
3909
- static VALUE robject_stddev(int argc, VALUE* argv, VALUE self) {
3910
- VALUE v, reduce;
3911
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
3912
- ndfunc_arg_out_t aout[1] = {{cRT, 0}};
3913
- ndfunc_t ndf = {iter_robject_stddev, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
3914
-
3915
- reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_stddev_nan);
3916
-
3917
- v = na_ndloop(&ndf, 2, self, reduce);
3918
-
3919
- return rb_funcall(v, rb_intern("extract"), 0);
3920
- }
3921
-
3922
- static void iter_robject_var(na_loop_t* const lp) {
3923
- size_t n;
3924
- char *p1, *p2;
3925
- ssize_t s1;
3926
-
3927
- INIT_COUNTER(lp, n);
3928
- INIT_PTR(lp, 0, p1, s1);
3929
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
3930
-
3931
- *(rtype*)p2 = f_var(n, p1, s1);
3932
- }
3933
- static void iter_robject_var_nan(na_loop_t* const lp) {
3934
- size_t n;
3935
- char *p1, *p2;
3936
- ssize_t s1;
3937
-
3938
- INIT_COUNTER(lp, n);
3939
- INIT_PTR(lp, 0, p1, s1);
3940
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
3941
-
3942
- *(rtype*)p2 = f_var_nan(n, p1, s1);
3943
- }
3944
-
3945
- /*
3946
- var of self.
3947
- @overload var(axis:nil, keepdims:false, nan:false)
3948
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
3949
- @param [Numeric,Array,Range] axis Performs var along the axis.
3950
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
3951
- @return [Numo::RObject] returns result of var.
3952
- */
3953
- static VALUE robject_var(int argc, VALUE* argv, VALUE self) {
3954
- VALUE v, reduce;
3955
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
3956
- ndfunc_arg_out_t aout[1] = {{cRT, 0}};
3957
- ndfunc_t ndf = {iter_robject_var, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
3958
-
3959
- reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_var_nan);
3960
-
3961
- v = na_ndloop(&ndf, 2, self, reduce);
3962
-
3963
- return rb_funcall(v, rb_intern("extract"), 0);
3964
- }
3965
-
3966
- static void iter_robject_rms(na_loop_t* const lp) {
3967
- size_t n;
3968
- char *p1, *p2;
3969
- ssize_t s1;
3970
-
3971
- INIT_COUNTER(lp, n);
3972
- INIT_PTR(lp, 0, p1, s1);
3973
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
3974
-
3975
- *(rtype*)p2 = f_rms(n, p1, s1);
3976
- }
3977
- static void iter_robject_rms_nan(na_loop_t* const lp) {
3978
- size_t n;
3979
- char *p1, *p2;
3980
- ssize_t s1;
3981
-
3982
- INIT_COUNTER(lp, n);
3983
- INIT_PTR(lp, 0, p1, s1);
3984
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
3985
-
3986
- *(rtype*)p2 = f_rms_nan(n, p1, s1);
3987
- }
3988
-
3989
- /*
3990
- rms of self.
3991
- @overload rms(axis:nil, keepdims:false, nan:false)
3992
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
3993
- @param [Numeric,Array,Range] axis Performs rms along the axis.
3994
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
3995
- @return [Numo::RObject] returns result of rms.
3996
- */
3997
- static VALUE robject_rms(int argc, VALUE* argv, VALUE self) {
3998
- VALUE v, reduce;
3999
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4000
- ndfunc_arg_out_t aout[1] = {{cRT, 0}};
4001
- ndfunc_t ndf = {iter_robject_rms, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
4002
-
4003
- reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_rms_nan);
4004
-
4005
- v = na_ndloop(&ndf, 2, self, reduce);
4006
-
4007
- return rb_funcall(v, rb_intern("extract"), 0);
4008
- }
4009
-
4010
3847
  static void iter_robject_min(na_loop_t* const lp) {
4011
3848
  size_t n;
4012
3849
  char *p1, *p2;
@@ -4033,16 +3870,18 @@ static void iter_robject_min_nan(na_loop_t* const lp) {
4033
3870
  /*
4034
3871
  min of self.
4035
3872
  @overload min(axis:nil, keepdims:false, nan:false)
4036
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
4037
- @param [Numeric,Array,Range] axis Performs min along the axis.
4038
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
4039
- @return [Numo::RObject] returns result of min.
3873
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
3874
+ return NaN for min/max etc).
3875
+ @param [Numeric,Array,Range] axis Performs min along the axis.
3876
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3877
+ dimensions with size one.
3878
+ @return [Numo::RObject] returns result of min.
4040
3879
  */
4041
3880
  static VALUE robject_min(int argc, VALUE* argv, VALUE self) {
4042
3881
  VALUE v, reduce;
4043
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4044
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4045
- ndfunc_t ndf = {iter_robject_min, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
3882
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
3883
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3884
+ ndfunc_t ndf = { iter_robject_min, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
4046
3885
 
4047
3886
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_min_nan);
4048
3887
 
@@ -4077,16 +3916,18 @@ static void iter_robject_max_nan(na_loop_t* const lp) {
4077
3916
  /*
4078
3917
  max of self.
4079
3918
  @overload max(axis:nil, keepdims:false, nan:false)
4080
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
4081
- @param [Numeric,Array,Range] axis Performs max along the axis.
4082
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
4083
- @return [Numo::RObject] returns result of max.
3919
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
3920
+ return NaN for min/max etc).
3921
+ @param [Numeric,Array,Range] axis Performs max along the axis.
3922
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3923
+ dimensions with size one.
3924
+ @return [Numo::RObject] returns result of max.
4084
3925
  */
4085
3926
  static VALUE robject_max(int argc, VALUE* argv, VALUE self) {
4086
3927
  VALUE v, reduce;
4087
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4088
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4089
- ndfunc_t ndf = {iter_robject_max, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
3928
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
3929
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3930
+ ndfunc_t ndf = { iter_robject_max, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
4090
3931
 
4091
3932
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_max_nan);
4092
3933
 
@@ -4121,16 +3962,18 @@ static void iter_robject_ptp_nan(na_loop_t* const lp) {
4121
3962
  /*
4122
3963
  ptp of self.
4123
3964
  @overload ptp(axis:nil, keepdims:false, nan:false)
4124
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
4125
- @param [Numeric,Array,Range] axis Performs ptp along the axis.
4126
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
4127
- @return [Numo::RObject] returns result of ptp.
3965
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
3966
+ return NaN for min/max etc).
3967
+ @param [Numeric,Array,Range] axis Performs ptp along the axis.
3968
+ @param [TrueClass] keepdims If true, the reduced axes are left in the result array as
3969
+ dimensions with size one.
3970
+ @return [Numo::RObject] returns result of ptp.
4128
3971
  */
4129
3972
  static VALUE robject_ptp(int argc, VALUE* argv, VALUE self) {
4130
3973
  VALUE v, reduce;
4131
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4132
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4133
- ndfunc_t ndf = {iter_robject_ptp, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
3974
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
3975
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3976
+ ndfunc_t ndf = { iter_robject_ptp, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
4134
3977
 
4135
3978
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_ptp_nan);
4136
3979
 
@@ -4210,9 +4053,10 @@ static void iter_robject_max_index_index32_nan(na_loop_t* const lp) {
4210
4053
  /*
4211
4054
  Index of the maximum value.
4212
4055
  @overload max_index(axis:nil, nan:false)
4213
- @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
4214
- @param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat 1-d indices**.
4215
- @return [Integer,Numo::Int] returns result indices.
4056
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
4057
+ @param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat
4058
+ 1-d indices**.
4059
+ @return [Integer,Numo::Int] returns result indices.
4216
4060
  @see #argmax
4217
4061
  @see #max
4218
4062
 
@@ -4229,9 +4073,9 @@ static void iter_robject_max_index_index32_nan(na_loop_t* const lp) {
4229
4073
  static VALUE robject_max_index(int argc, VALUE* argv, VALUE self) {
4230
4074
  narray_t* na;
4231
4075
  VALUE idx, reduce;
4232
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {Qnil, 0}, {sym_reduce, 0}};
4233
- ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
4234
- ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout};
4076
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { Qnil, 0 }, { sym_reduce, 0 } };
4077
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
4078
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout };
4235
4079
 
4236
4080
  GetNArray(self, na);
4237
4081
  if (na->ndim == 0) {
@@ -4242,14 +4086,16 @@ static VALUE robject_max_index(int argc, VALUE* argv, VALUE self) {
4242
4086
  idx = nary_new(numo_cInt64, na->ndim, na->shape);
4243
4087
  ndf.func = iter_robject_max_index_index64;
4244
4088
 
4245
- reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_max_index_index64_nan);
4089
+ reduce =
4090
+ na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_max_index_index64_nan);
4246
4091
 
4247
4092
  } else {
4248
4093
  aout[0].type = numo_cInt32;
4249
4094
  idx = nary_new(numo_cInt32, na->ndim, na->shape);
4250
4095
  ndf.func = iter_robject_max_index_index32;
4251
4096
 
4252
- reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_max_index_index32_nan);
4097
+ reduce =
4098
+ na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_max_index_index32_nan);
4253
4099
  }
4254
4100
  rb_funcall(idx, rb_intern("seq"), 0);
4255
4101
 
@@ -4327,9 +4173,10 @@ static void iter_robject_min_index_index32_nan(na_loop_t* const lp) {
4327
4173
  /*
4328
4174
  Index of the minimum value.
4329
4175
  @overload min_index(axis:nil, nan:false)
4330
- @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
4331
- @param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat 1-d indices**.
4332
- @return [Integer,Numo::Int] returns result indices.
4176
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
4177
+ @param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat
4178
+ 1-d indices**.
4179
+ @return [Integer,Numo::Int] returns result indices.
4333
4180
  @see #argmin
4334
4181
  @see #min
4335
4182
 
@@ -4346,9 +4193,9 @@ static void iter_robject_min_index_index32_nan(na_loop_t* const lp) {
4346
4193
  static VALUE robject_min_index(int argc, VALUE* argv, VALUE self) {
4347
4194
  narray_t* na;
4348
4195
  VALUE idx, reduce;
4349
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {Qnil, 0}, {sym_reduce, 0}};
4350
- ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
4351
- ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout};
4196
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { Qnil, 0 }, { sym_reduce, 0 } };
4197
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
4198
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout };
4352
4199
 
4353
4200
  GetNArray(self, na);
4354
4201
  if (na->ndim == 0) {
@@ -4359,14 +4206,16 @@ static VALUE robject_min_index(int argc, VALUE* argv, VALUE self) {
4359
4206
  idx = nary_new(numo_cInt64, na->ndim, na->shape);
4360
4207
  ndf.func = iter_robject_min_index_index64;
4361
4208
 
4362
- reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_min_index_index64_nan);
4209
+ reduce =
4210
+ na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_min_index_index64_nan);
4363
4211
 
4364
4212
  } else {
4365
4213
  aout[0].type = numo_cInt32;
4366
4214
  idx = nary_new(numo_cInt32, na->ndim, na->shape);
4367
4215
  ndf.func = iter_robject_min_index_index32;
4368
4216
 
4369
- reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_min_index_index32_nan);
4217
+ reduce =
4218
+ na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_min_index_index32_nan);
4370
4219
  }
4371
4220
  rb_funcall(idx, rb_intern("seq"), 0);
4372
4221
 
@@ -4440,9 +4289,10 @@ static void iter_robject_argmax_arg32_nan(na_loop_t* const lp) {
4440
4289
  /*
4441
4290
  Index of the maximum value.
4442
4291
  @overload argmax(axis:nil, nan:false)
4443
- @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
4444
- @param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices along the axis**.
4445
- @return [Integer,Numo::Int] returns the result indices.
4292
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
4293
+ @param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices
4294
+ along the axis**.
4295
+ @return [Integer,Numo::Int] returns the result indices.
4446
4296
  @see #max_index
4447
4297
  @see #max
4448
4298
 
@@ -4459,9 +4309,9 @@ static void iter_robject_argmax_arg32_nan(na_loop_t* const lp) {
4459
4309
  static VALUE robject_argmax(int argc, VALUE* argv, VALUE self) {
4460
4310
  narray_t* na;
4461
4311
  VALUE reduce;
4462
- ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_reduce, 0}};
4463
- ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
4464
- ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout};
4312
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } };
4313
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
4314
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout };
4465
4315
 
4466
4316
  GetNArray(self, na);
4467
4317
  if (na->ndim == 0) {
@@ -4550,9 +4400,10 @@ static void iter_robject_argmin_arg32_nan(na_loop_t* const lp) {
4550
4400
  /*
4551
4401
  Index of the minimum value.
4552
4402
  @overload argmin(axis:nil, nan:false)
4553
- @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
4554
- @param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices along the axis**.
4555
- @return [Integer,Numo::Int] returns the result indices.
4403
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
4404
+ @param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices
4405
+ along the axis**.
4406
+ @return [Integer,Numo::Int] returns the result indices.
4556
4407
  @see #min_index
4557
4408
  @see #min
4558
4409
 
@@ -4569,9 +4420,9 @@ static void iter_robject_argmin_arg32_nan(na_loop_t* const lp) {
4569
4420
  static VALUE robject_argmin(int argc, VALUE* argv, VALUE self) {
4570
4421
  narray_t* na;
4571
4422
  VALUE reduce;
4572
- ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_reduce, 0}};
4573
- ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
4574
- ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout};
4423
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } };
4424
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
4425
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout };
4575
4426
 
4576
4427
  GetNArray(self, na);
4577
4428
  if (na->ndim == 0) {
@@ -4625,32 +4476,25 @@ static void iter_robject_minmax_nan(na_loop_t* const lp) {
4625
4476
  /*
4626
4477
  minmax of self.
4627
4478
  @overload minmax(axis:nil, keepdims:false, nan:false)
4628
- @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
4629
- @param [Numeric,Array,Range] axis Finds min-max along the axis.
4630
- @param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
4631
- @return [Numo::RObject,Numo::RObject] min and max of self.
4479
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
4480
+ @param [Numeric,Array,Range] axis Finds min-max along the axis.
4481
+ @param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
4482
+ as dimensions with size one.
4483
+ @return [Numo::RObject,Numo::RObject] min and max of self.
4632
4484
  */
4633
4485
  static VALUE robject_minmax(int argc, VALUE* argv, VALUE self) {
4634
4486
  VALUE reduce;
4635
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4636
- ndfunc_arg_out_t aout[2] = {{cT, 0}, {cT, 0}};
4637
- ndfunc_t ndf = {iter_robject_minmax, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 2, ain, aout};
4487
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
4488
+ ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
4489
+ ndfunc_t ndf = {
4490
+ iter_robject_minmax, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 2, ain, aout
4491
+ };
4638
4492
 
4639
4493
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_minmax_nan);
4640
4494
 
4641
4495
  return na_ndloop(&ndf, 2, self, reduce);
4642
4496
  }
4643
4497
 
4644
- /*
4645
- Element-wise maximum of two arrays.
4646
-
4647
- @overload maximum(a1, a2, nan:false)
4648
- @param [Numo::NArray,Numeric] a1 The array to be compared.
4649
- @param [Numo::NArray,Numeric] a2 The array to be compared.
4650
- @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
4651
- @return [Numo::RObject]
4652
- */
4653
-
4654
4498
  static void iter_robject_s_maximum(na_loop_t* const lp) {
4655
4499
  size_t i, n;
4656
4500
  char *p1, *p2, *p3;
@@ -4693,13 +4537,13 @@ static void iter_robject_s_maximum_nan(na_loop_t* const lp) {
4693
4537
  static VALUE robject_s_maximum(int argc, VALUE* argv, VALUE mod) {
4694
4538
  VALUE a1 = Qnil;
4695
4539
  VALUE a2 = Qnil;
4696
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
4697
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4698
- ndfunc_t ndf = {iter_robject_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout};
4540
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
4541
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4542
+ ndfunc_t ndf = { iter_robject_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
4699
4543
 
4700
4544
  VALUE kw_hash = Qnil;
4701
- ID kw_table[1] = {id_nan};
4702
- VALUE opts[1] = {Qundef};
4545
+ ID kw_table[1] = { id_nan };
4546
+ VALUE opts[1] = { Qundef };
4703
4547
 
4704
4548
  rb_scan_args(argc, argv, "20:", &a1, &a2, &kw_hash);
4705
4549
  rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
@@ -4714,10 +4558,10 @@ static VALUE robject_s_maximum(int argc, VALUE* argv, VALUE mod) {
4714
4558
  Element-wise minimum of two arrays.
4715
4559
 
4716
4560
  @overload minimum(a1, a2, nan:false)
4717
- @param [Numo::NArray,Numeric] a1 The array to be compared.
4718
- @param [Numo::NArray,Numeric] a2 The array to be compared.
4719
- @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
4720
- @return [Numo::RObject]
4561
+ @param [Numo::NArray,Numeric] a1 The array to be compared.
4562
+ @param [Numo::NArray,Numeric] a2 The array to be compared.
4563
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
4564
+ @return [Numo::RObject]
4721
4565
  */
4722
4566
 
4723
4567
  static void iter_robject_s_minimum(na_loop_t* const lp) {
@@ -4762,13 +4606,13 @@ static void iter_robject_s_minimum_nan(na_loop_t* const lp) {
4762
4606
  static VALUE robject_s_minimum(int argc, VALUE* argv, VALUE mod) {
4763
4607
  VALUE a1 = Qnil;
4764
4608
  VALUE a2 = Qnil;
4765
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
4766
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4767
- ndfunc_t ndf = {iter_robject_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout};
4609
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
4610
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4611
+ ndfunc_t ndf = { iter_robject_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
4768
4612
 
4769
4613
  VALUE kw_hash = Qnil;
4770
- ID kw_table[1] = {id_nan};
4771
- VALUE opts[1] = {Qundef};
4614
+ ID kw_table[1] = { id_nan };
4615
+ VALUE opts[1] = { Qundef };
4772
4616
 
4773
4617
  rb_scan_args(argc, argv, "20:", &a1, &a2, &kw_hash);
4774
4618
  rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
@@ -4788,16 +4632,13 @@ static void iter_robject_cumsum(na_loop_t* const lp) {
4788
4632
  INIT_COUNTER(lp, i);
4789
4633
  INIT_PTR(lp, 0, p1, s1);
4790
4634
  INIT_PTR(lp, 1, p2, s2);
4791
- // printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
4792
4635
 
4793
4636
  GET_DATA_STRIDE(p1, s1, dtype, x);
4794
4637
  SET_DATA_STRIDE(p2, s2, dtype, x);
4795
- // printf("i=%lu x=%f\n",i,x);
4796
4638
  for (i--; i--;) {
4797
4639
  GET_DATA_STRIDE(p1, s1, dtype, y);
4798
4640
  m_cumsum(x, y);
4799
4641
  SET_DATA_STRIDE(p2, s2, dtype, x);
4800
- // printf("i=%lu x=%f\n",i,x);
4801
4642
  }
4802
4643
  }
4803
4644
  static void iter_robject_cumsum_nan(na_loop_t* const lp) {
@@ -4809,31 +4650,30 @@ static void iter_robject_cumsum_nan(na_loop_t* const lp) {
4809
4650
  INIT_COUNTER(lp, i);
4810
4651
  INIT_PTR(lp, 0, p1, s1);
4811
4652
  INIT_PTR(lp, 1, p2, s2);
4812
- // printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
4813
4653
 
4814
4654
  GET_DATA_STRIDE(p1, s1, dtype, x);
4815
4655
  SET_DATA_STRIDE(p2, s2, dtype, x);
4816
- // printf("i=%lu x=%f\n",i,x);
4817
4656
  for (i--; i--;) {
4818
4657
  GET_DATA_STRIDE(p1, s1, dtype, y);
4819
4658
  m_cumsum_nan(x, y);
4820
4659
  SET_DATA_STRIDE(p2, s2, dtype, x);
4821
- // printf("i=%lu x=%f\n",i,x);
4822
4660
  }
4823
4661
  }
4824
4662
 
4825
4663
  /*
4826
4664
  cumsum of self.
4827
4665
  @overload cumsum(axis:nil, nan:false)
4828
- @param [Numeric,Array,Range] axis Performs cumsum along the axis.
4829
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
4830
- @return [Numo::RObject] cumsum of self.
4666
+ @param [Numeric,Array,Range] axis Performs cumsum along the axis.
4667
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
4668
+ @return [Numo::RObject] cumsum of self.
4831
4669
  */
4832
4670
  static VALUE robject_cumsum(int argc, VALUE* argv, VALUE self) {
4833
4671
  VALUE reduce;
4834
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4835
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4836
- ndfunc_t ndf = {iter_robject_cumsum, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout};
4672
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
4673
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4674
+ ndfunc_t ndf = {
4675
+ iter_robject_cumsum, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout
4676
+ };
4837
4677
 
4838
4678
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_cumsum_nan);
4839
4679
 
@@ -4849,16 +4689,13 @@ static void iter_robject_cumprod(na_loop_t* const lp) {
4849
4689
  INIT_COUNTER(lp, i);
4850
4690
  INIT_PTR(lp, 0, p1, s1);
4851
4691
  INIT_PTR(lp, 1, p2, s2);
4852
- // printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
4853
4692
 
4854
4693
  GET_DATA_STRIDE(p1, s1, dtype, x);
4855
4694
  SET_DATA_STRIDE(p2, s2, dtype, x);
4856
- // printf("i=%lu x=%f\n",i,x);
4857
4695
  for (i--; i--;) {
4858
4696
  GET_DATA_STRIDE(p1, s1, dtype, y);
4859
4697
  m_cumprod(x, y);
4860
4698
  SET_DATA_STRIDE(p2, s2, dtype, x);
4861
- // printf("i=%lu x=%f\n",i,x);
4862
4699
  }
4863
4700
  }
4864
4701
  static void iter_robject_cumprod_nan(na_loop_t* const lp) {
@@ -4870,31 +4707,30 @@ static void iter_robject_cumprod_nan(na_loop_t* const lp) {
4870
4707
  INIT_COUNTER(lp, i);
4871
4708
  INIT_PTR(lp, 0, p1, s1);
4872
4709
  INIT_PTR(lp, 1, p2, s2);
4873
- // printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
4874
4710
 
4875
4711
  GET_DATA_STRIDE(p1, s1, dtype, x);
4876
4712
  SET_DATA_STRIDE(p2, s2, dtype, x);
4877
- // printf("i=%lu x=%f\n",i,x);
4878
4713
  for (i--; i--;) {
4879
4714
  GET_DATA_STRIDE(p1, s1, dtype, y);
4880
4715
  m_cumprod_nan(x, y);
4881
4716
  SET_DATA_STRIDE(p2, s2, dtype, x);
4882
- // printf("i=%lu x=%f\n",i,x);
4883
4717
  }
4884
4718
  }
4885
4719
 
4886
4720
  /*
4887
4721
  cumprod of self.
4888
4722
  @overload cumprod(axis:nil, nan:false)
4889
- @param [Numeric,Array,Range] axis Performs cumprod along the axis.
4890
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
4891
- @return [Numo::RObject] cumprod of self.
4723
+ @param [Numeric,Array,Range] axis Performs cumprod along the axis.
4724
+ @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
4725
+ @return [Numo::RObject] cumprod of self.
4892
4726
  */
4893
4727
  static VALUE robject_cumprod(int argc, VALUE* argv, VALUE self) {
4894
4728
  VALUE reduce;
4895
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4896
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4897
- ndfunc_t ndf = {iter_robject_cumprod, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout};
4729
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
4730
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4731
+ ndfunc_t ndf = {
4732
+ iter_robject_cumprod, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout
4733
+ };
4898
4734
 
4899
4735
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_cumprod_nan);
4900
4736
 
@@ -4974,9 +4810,9 @@ static void iter_robject_mulsum_nan(na_loop_t* const lp) {
4974
4810
  static VALUE robject_mulsum_self(int argc, VALUE* argv, VALUE self) {
4975
4811
  VALUE v, reduce;
4976
4812
  VALUE naryv[2];
4977
- ndfunc_arg_in_t ain[4] = {{cT, 0}, {cT, 0}, {sym_reduce, 0}, {sym_init, 0}};
4978
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4979
- ndfunc_t ndf = {iter_robject_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout};
4813
+ ndfunc_arg_in_t ain[4] = { { cT, 0 }, { cT, 0 }, { sym_reduce, 0 }, { sym_init, 0 } };
4814
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4815
+ ndfunc_t ndf = { iter_robject_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout };
4980
4816
 
4981
4817
  if (argc < 1) {
4982
4818
  rb_raise(rb_eArgError, "wrong number of arguments (%d for >=1)", argc);
@@ -4996,11 +4832,12 @@ static VALUE robject_mulsum_self(int argc, VALUE* argv, VALUE self) {
4996
4832
  Binary mulsum.
4997
4833
 
4998
4834
  @overload mulsum(other, axis:nil, keepdims:false, nan:false)
4999
- @param [Numo::NArray,Numeric] other
5000
- @param [Numeric,Array,Range] axis Performs mulsum along the axis.
5001
- @param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
5002
- @param [TrueClass] nan (keyword) If true, apply NaN-aware algorithm (avoid NaN if exists).
5003
- @return [Numo::NArray] mulsum of self and other.
4835
+ @param [Numo::NArray,Numeric] other
4836
+ @param [Numeric,Array,Range] axis Performs mulsum along the axis.
4837
+ @param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
4838
+ as dimensions with size one.
4839
+ @param [TrueClass] nan (keyword) If true, apply NaN-aware algorithm (avoid NaN if exists).
4840
+ @return [Numo::NArray] mulsum of self and other.
5004
4841
  */
5005
4842
  static VALUE robject_mulsum(int argc, VALUE* argv, VALUE self) {
5006
4843
  //
@@ -5059,9 +4896,9 @@ static void iter_robject_seq(na_loop_t* const lp) {
5059
4896
  beg+i*step
5060
4897
  where i is 1-dimensional index.
5061
4898
  @overload seq([beg,[step]])
5062
- @param [Numeric] beg beginning of sequence. (default=0)
5063
- @param [Numeric] step step of sequence. (default=1)
5064
- @return [Numo::RObject] self.
4899
+ @param [Numeric] beg beginning of sequence. (default=0)
4900
+ @param [Numeric] step step of sequence. (default=1)
4901
+ @return [Numo::RObject] self.
5065
4902
  @example
5066
4903
  Numo::DFloat.new(6).seq(1,-0.2)
5067
4904
  # => Numo::DFloat#shape=[6]
@@ -5071,17 +4908,17 @@ static void iter_robject_seq(na_loop_t* const lp) {
5071
4908
  # => Numo::DComplex#shape=[6]
5072
4909
  # [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
5073
4910
  */
5074
- static VALUE robject_seq(int argc, VALUE* args, VALUE self) {
4911
+ static VALUE robject_seq(int argc, VALUE* argv, VALUE self) {
5075
4912
  seq_opt_t* g;
5076
4913
  VALUE vbeg = Qnil, vstep = Qnil;
5077
- ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
5078
- ndfunc_t ndf = {iter_robject_seq, FULL_LOOP, 1, 0, ain, 0};
4914
+ ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
4915
+ ndfunc_t ndf = { iter_robject_seq, FULL_LOOP, 1, 0, ain, 0 };
5079
4916
 
5080
4917
  g = ALLOCA_N(seq_opt_t, 1);
5081
4918
  g->beg = m_zero;
5082
4919
  g->step = m_one;
5083
4920
  g->count = 0;
5084
- rb_scan_args(argc, args, "02", &vbeg, &vstep);
4921
+ rb_scan_args(argc, argv, "02", &vbeg, &vstep);
5085
4922
  if (vbeg != Qnil) {
5086
4923
  g->beg = m_num_to_data(vbeg);
5087
4924
  }
@@ -5140,10 +4977,10 @@ static void iter_robject_logseq(na_loop_t* const lp) {
5140
4977
  Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
5141
4978
 
5142
4979
  @overload logseq(beg,step,[base])
5143
- @param [Numeric] beg The beginning of sequence.
5144
- @param [Numeric] step The step of sequence.
5145
- @param [Numeric] base The base of log space. (default=10)
5146
- @return [Numo::RObject] self.
4980
+ @param [Numeric] beg The beginning of sequence.
4981
+ @param [Numeric] step The step of sequence.
4982
+ @param [Numeric] base The base of log space. (default=10)
4983
+ @return [Numo::RObject] self.
5147
4984
 
5148
4985
  @example
5149
4986
  Numo::DFloat.new(5).logseq(4,-1,2)
@@ -5154,14 +4991,14 @@ static void iter_robject_logseq(na_loop_t* const lp) {
5154
4991
  # => Numo::DComplex#shape=[5]
5155
4992
  # [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
5156
4993
  */
5157
- static VALUE robject_logseq(int argc, VALUE* args, VALUE self) {
4994
+ static VALUE robject_logseq(int argc, VALUE* argv, VALUE self) {
5158
4995
  logseq_opt_t* g;
5159
4996
  VALUE vbeg, vstep, vbase;
5160
- ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
5161
- ndfunc_t ndf = {iter_robject_logseq, FULL_LOOP, 1, 0, ain, 0};
4997
+ ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
4998
+ ndfunc_t ndf = { iter_robject_logseq, FULL_LOOP, 1, 0, ain, 0 };
5162
4999
 
5163
5000
  g = ALLOCA_N(logseq_opt_t, 1);
5164
- rb_scan_args(argc, args, "21", &vbeg, &vstep, &vbase);
5001
+ rb_scan_args(argc, argv, "21", &vbeg, &vstep, &vbase);
5165
5002
  g->beg = m_num_to_data(vbeg);
5166
5003
  g->step = m_num_to_data(vstep);
5167
5004
  if (vbase == Qnil) {
@@ -5205,15 +5042,15 @@ static void iter_robject_eye(na_loop_t* const lp) {
5205
5042
  /*
5206
5043
  Eye: Set a value to diagonal components, set 0 to non-diagonal components.
5207
5044
  @overload eye([element,offset])
5208
- @param [Numeric] element Diagonal element to be stored. Default is 1.
5209
- @param [Integer] offset Diagonal offset from the main diagonal. The
5210
- default is 0. k>0 for diagonals above the main diagonal, and k<0
5211
- for diagonals below the main diagonal.
5212
- @return [Numo::RObject] eye of self.
5045
+ @param [Numeric] element Diagonal element to be stored. Default is 1.
5046
+ @param [Integer] offset Diagonal offset from the main diagonal. The
5047
+ default is 0. k>0 for diagonals above the main diagonal, and k<0
5048
+ for diagonals below the main diagonal.
5049
+ @return [Numo::RObject] eye of self.
5213
5050
  */
5214
5051
  static VALUE robject_eye(int argc, VALUE* argv, VALUE self) {
5215
- ndfunc_arg_in_t ain[1] = {{OVERWRITE, 2}};
5216
- ndfunc_t ndf = {iter_robject_eye, NO_LOOP, 1, 0, ain, 0};
5052
+ ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
5053
+ ndfunc_t ndf = { iter_robject_eye, NO_LOOP, 1, 0, ain, 0 };
5217
5054
  ssize_t kofs;
5218
5055
  dtype data;
5219
5056
  char* g;
@@ -5243,17 +5080,21 @@ static VALUE robject_eye(int argc, VALUE* argv, VALUE self) {
5243
5080
  // Diagonal offset from the main diagonal.
5244
5081
  if (kofs >= 0) {
5245
5082
  if ((size_t)(kofs) >= na->shape[nd - 1]) {
5246
- rb_raise(rb_eArgError,
5247
- "invalid diagonal offset(%" SZF "d) for "
5248
- "last dimension size(%" SZF "d)",
5249
- kofs, na->shape[nd - 1]);
5083
+ rb_raise(
5084
+ rb_eArgError,
5085
+ "invalid diagonal offset(%" SZF "d) for "
5086
+ "last dimension size(%" SZF "d)",
5087
+ kofs, na->shape[nd - 1]
5088
+ );
5250
5089
  }
5251
5090
  } else {
5252
5091
  if ((size_t)(-kofs) >= na->shape[nd - 2]) {
5253
- rb_raise(rb_eArgError,
5254
- "invalid diagonal offset(%" SZF "d) for "
5255
- "last-1 dimension size(%" SZF "d)",
5256
- kofs, na->shape[nd - 2]);
5092
+ rb_raise(
5093
+ rb_eArgError,
5094
+ "invalid diagonal offset(%" SZF "d) for "
5095
+ "last-1 dimension size(%" SZF "d)",
5096
+ kofs, na->shape[nd - 2]
5097
+ );
5257
5098
  }
5258
5099
  }
5259
5100
 
@@ -5302,9 +5143,10 @@ static void iter_robject_rand(na_loop_t* const lp) {
5302
5143
  /*
5303
5144
  Generate uniformly distributed random numbers on self narray.
5304
5145
  @overload rand([[low],high])
5305
- @param [Numeric] low lower inclusive boundary of random numbers. (default=0)
5306
- @param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for complex types)
5307
- @return [Numo::RObject] self.
5146
+ @param [Numeric] low lower inclusive boundary of random numbers. (default=0)
5147
+ @param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
5148
+ complex types)
5149
+ @return [Numo::RObject] self.
5308
5150
  @example
5309
5151
  Numo::DFloat.new(6).rand
5310
5152
  # => Numo::DFloat#shape=[6]
@@ -5318,14 +5160,14 @@ static void iter_robject_rand(na_loop_t* const lp) {
5318
5160
  # => Numo::Int32#shape=[6]
5319
5161
  # [4, 3, 3, 2, 4, 2]
5320
5162
  */
5321
- static VALUE robject_rand(int argc, VALUE* args, VALUE self) {
5163
+ static VALUE robject_rand(int argc, VALUE* argv, VALUE self) {
5322
5164
  rand_opt_t g;
5323
5165
  VALUE v1 = Qnil, v2 = Qnil;
5324
5166
  dtype high;
5325
- ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
5326
- ndfunc_t ndf = {iter_robject_rand, FULL_LOOP, 1, 0, ain, 0};
5167
+ ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
5168
+ ndfunc_t ndf = { iter_robject_rand, FULL_LOOP, 1, 0, ain, 0 };
5327
5169
 
5328
- rb_scan_args(argc, args, "02", &v1, &v2);
5170
+ rb_scan_args(argc, argv, "02", &v1, &v2);
5329
5171
  if (v2 == Qnil) {
5330
5172
  g.low = m_zero;
5331
5173
  if (v1 == Qnil) {
@@ -5366,15 +5208,15 @@ static void iter_robject_poly(na_loop_t* const lp) {
5366
5208
  Calculate polynomial.
5367
5209
  `x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
5368
5210
  @overload poly a0, a1, ..., an
5369
- @param [Numo::NArray,Numeric] a0,a1,...,an
5370
- @return [Numo::RObject]
5211
+ @param [Numo::NArray,Numeric] a0,a1,...,an
5212
+ @return [Numo::RObject]
5371
5213
  */
5372
5214
  static VALUE robject_poly(VALUE self, VALUE args) {
5373
5215
  int argc, i;
5374
5216
  VALUE* argv;
5375
5217
  volatile VALUE v, a;
5376
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
5377
- ndfunc_t ndf = {iter_robject_poly, NO_LOOP, 0, 1, 0, aout};
5218
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
5219
+ ndfunc_t ndf = { iter_robject_poly, NO_LOOP, 0, 1, 0, aout };
5378
5220
 
5379
5221
  argc = (int)RARRAY_LEN(args);
5380
5222
  ndf.nin = argc + 1;
@@ -5430,13 +5272,15 @@ void Init_numo_robject(void) {
5430
5272
  id_to_a = rb_intern("to_a");
5431
5273
  id_truncate = rb_intern("truncate");
5432
5274
 
5433
- /*
5434
- Document-class: Numo::RObject
5435
-
5436
- */
5275
+ /**
5276
+ * Document-class: Numo::RObject
5277
+ *
5278
+ * Ruby object N-dimensional array class.
5279
+ */
5437
5280
  cT = rb_define_class_under(mNumo, "RObject", cNArray);
5438
5281
 
5439
5282
  hCast = rb_hash_new();
5283
+ /* Upcasting rules of RObject. */
5440
5284
  rb_define_const(cT, "UPCAST", hCast);
5441
5285
  rb_hash_aset(hCast, rb_cArray, cT);
5442
5286
 
@@ -5462,11 +5306,11 @@ void Init_numo_robject(void) {
5462
5306
  rb_hash_aset(hCast, numo_cUInt8, numo_cRObject);
5463
5307
  rb_obj_freeze(hCast);
5464
5308
 
5465
- /**/
5309
+ /* Element size of RObject in bits. */
5466
5310
  rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
5467
- /**/
5311
+ /* Element size of RObject in bytes. */
5468
5312
  rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
5469
- /**/
5313
+ /* Stride size of contiguous RObject array. */
5470
5314
  rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
5471
5315
  rb_undef_method(rb_singleton_class(cT), "from_binary");
5472
5316
  rb_undef_method(cT, "to_binary");
@@ -5540,9 +5384,49 @@ void Init_numo_robject(void) {
5540
5384
  rb_define_method(cT, "isfinite", robject_isfinite, 0);
5541
5385
  rb_define_method(cT, "sum", robject_sum, -1);
5542
5386
  rb_define_method(cT, "prod", robject_prod, -1);
5387
+ /**
5388
+ * mean of self.
5389
+ * @overload mean(axis: nil, keepdims: false, nan: false)
5390
+ * @param axis [Numeric, Array, Range] Performs mean along the axis.
5391
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
5392
+ * dimensions with size one.
5393
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
5394
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
5395
+ * @return [Numo::RObject] returns result of mean.
5396
+ */
5543
5397
  rb_define_method(cT, "mean", robject_mean, -1);
5544
- rb_define_method(cT, "stddev", robject_stddev, -1);
5398
+ /**
5399
+ * var of self.
5400
+ * @overload var(axis: nil, keepdims: false, nan: false)
5401
+ * @param axis [Numeric, Array, Range] Performs var along the axis.
5402
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
5403
+ * dimensions with size one.
5404
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
5405
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
5406
+ * @return [Numo::RObject] returns result of var.
5407
+ */
5545
5408
  rb_define_method(cT, "var", robject_var, -1);
5409
+ /**
5410
+ * stddev of self.
5411
+ * @overload stddev(axis: nil, keepdims: false, nan: false)
5412
+ * @param axis [Numeric, Array, Range] Performs stddev along the axis.
5413
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
5414
+ * dimensions with size one.
5415
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
5416
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
5417
+ * @return [Numo::RObject] returns result of stddev.
5418
+ */
5419
+ rb_define_method(cT, "stddev", robject_stddev, -1);
5420
+ /**
5421
+ * rms of self.
5422
+ * @overload rms(axis: nil, keepdims: false, nan: false)
5423
+ * @param axis [Numeric, Array, Range] Performs rms along the axis.
5424
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
5425
+ * dimensions with size one.
5426
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
5427
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
5428
+ * @return [Numo::RObject] returns result of rms.
5429
+ */
5546
5430
  rb_define_method(cT, "rms", robject_rms, -1);
5547
5431
  rb_define_method(cT, "min", robject_min, -1);
5548
5432
  rb_define_method(cT, "max", robject_max, -1);
@@ -5552,7 +5436,23 @@ void Init_numo_robject(void) {
5552
5436
  rb_define_method(cT, "argmax", robject_argmax, -1);
5553
5437
  rb_define_method(cT, "argmin", robject_argmin, -1);
5554
5438
  rb_define_method(cT, "minmax", robject_minmax, -1);
5439
+ /**
5440
+ * Element-wise maximum of two arrays.
5441
+ * @overload maximum(a1, a2, nan:false)
5442
+ * @param [Numo::NArray,Numeric] a1 The array to be compared.
5443
+ * @param [Numo::NArray,Numeric] a2 The array to be compared.
5444
+ * @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
5445
+ * @return [Numo::RObject]
5446
+ */
5555
5447
  rb_define_module_function(cT, "maximum", robject_s_maximum, -1);
5448
+ /**
5449
+ * Element-wise minimum of two arrays.
5450
+ * @overload minimum(a1, a2, nan:false)
5451
+ * @param [Numo::NArray,Numeric] a1 The array to be compared.
5452
+ * @param [Numo::NArray,Numeric] a2 The array to be compared.
5453
+ * @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
5454
+ * @return [Numo::RObject]
5455
+ */
5556
5456
  rb_define_module_function(cT, "minimum", robject_s_minimum, -1);
5557
5457
  rb_define_method(cT, "cumsum", robject_cumsum, -1);
5558
5458
  rb_define_method(cT, "cumprod", robject_cumprod, -1);