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
@@ -36,14 +36,23 @@ static ID id_to_a;
36
36
 
37
37
  #include <numo/types/dfloat.h>
38
38
 
39
- VALUE cT;
40
- extern VALUE cRT;
41
-
42
39
  /*
43
40
  class definition: Numo::DFloat
44
41
  */
45
-
46
42
  VALUE cT;
43
+ extern VALUE cRT;
44
+
45
+ #include "mh/mean.h"
46
+ #include "mh/var.h"
47
+ #include "mh/stddev.h"
48
+ #include "mh/rms.h"
49
+
50
+ typedef double dfloat; // Type aliases for shorter notation
51
+ // following the codebase naming convention.
52
+ DEF_NARRAY_FLT_MEAN_METHOD_FUNC(dfloat, double, numo_cDFloat, numo_cDFloat)
53
+ DEF_NARRAY_FLT_VAR_METHOD_FUNC(dfloat, double, numo_cDFloat, numo_cDFloat)
54
+ DEF_NARRAY_FLT_STDDEV_METHOD_FUNC(dfloat, double, numo_cDFloat, numo_cDFloat)
55
+ DEF_NARRAY_FLT_RMS_METHOD_FUNC(dfloat, double, numo_cDFloat, numo_cDFloat)
47
56
 
48
57
  static VALUE dfloat_store(VALUE, VALUE);
49
58
 
@@ -148,13 +157,6 @@ static VALUE dfloat_allocate(VALUE self) {
148
157
  return self;
149
158
  }
150
159
 
151
- /*
152
- Extract an element only if self is a dimensionless NArray.
153
- @overload extract
154
- @return [Numeric,Numo::NArray]
155
- --- Extract element value as Ruby Object if self is a dimensionless NArray,
156
- otherwise returns self.
157
- */
158
160
  static VALUE dfloat_extract(VALUE self) {
159
161
  volatile VALUE v;
160
162
  char* ptr;
@@ -237,8 +239,8 @@ static void iter_dfloat_store_bit(na_loop_t* const lp) {
237
239
  }
238
240
 
239
241
  static VALUE dfloat_store_bit(VALUE self, VALUE obj) {
240
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
241
- ndfunc_t ndf = {iter_dfloat_store_bit, FULL_LOOP, 2, 0, ain, 0};
242
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
243
+ ndfunc_t ndf = { iter_dfloat_store_bit, FULL_LOOP, 2, 0, ain, 0 };
242
244
 
243
245
  na_ndloop(&ndf, 2, self, obj);
244
246
  return self;
@@ -286,8 +288,8 @@ static void iter_dfloat_store_dfloat(na_loop_t* const lp) {
286
288
  }
287
289
 
288
290
  static VALUE dfloat_store_dfloat(VALUE self, VALUE obj) {
289
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
290
- ndfunc_t ndf = {iter_dfloat_store_dfloat, FULL_LOOP, 2, 0, ain, 0};
291
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
292
+ ndfunc_t ndf = { iter_dfloat_store_dfloat, FULL_LOOP, 2, 0, ain, 0 };
291
293
 
292
294
  na_ndloop(&ndf, 2, self, obj);
293
295
  return self;
@@ -335,8 +337,8 @@ static void iter_dfloat_store_sfloat(na_loop_t* const lp) {
335
337
  }
336
338
 
337
339
  static VALUE dfloat_store_sfloat(VALUE self, VALUE obj) {
338
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
339
- ndfunc_t ndf = {iter_dfloat_store_sfloat, FULL_LOOP, 2, 0, ain, 0};
340
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
341
+ ndfunc_t ndf = { iter_dfloat_store_sfloat, FULL_LOOP, 2, 0, ain, 0 };
340
342
 
341
343
  na_ndloop(&ndf, 2, self, obj);
342
344
  return self;
@@ -384,8 +386,8 @@ static void iter_dfloat_store_int64(na_loop_t* const lp) {
384
386
  }
385
387
 
386
388
  static VALUE dfloat_store_int64(VALUE self, VALUE obj) {
387
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
388
- ndfunc_t ndf = {iter_dfloat_store_int64, FULL_LOOP, 2, 0, ain, 0};
389
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
390
+ ndfunc_t ndf = { iter_dfloat_store_int64, FULL_LOOP, 2, 0, ain, 0 };
389
391
 
390
392
  na_ndloop(&ndf, 2, self, obj);
391
393
  return self;
@@ -433,8 +435,8 @@ static void iter_dfloat_store_int32(na_loop_t* const lp) {
433
435
  }
434
436
 
435
437
  static VALUE dfloat_store_int32(VALUE self, VALUE obj) {
436
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
437
- ndfunc_t ndf = {iter_dfloat_store_int32, FULL_LOOP, 2, 0, ain, 0};
438
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
439
+ ndfunc_t ndf = { iter_dfloat_store_int32, FULL_LOOP, 2, 0, ain, 0 };
438
440
 
439
441
  na_ndloop(&ndf, 2, self, obj);
440
442
  return self;
@@ -482,8 +484,8 @@ static void iter_dfloat_store_int16(na_loop_t* const lp) {
482
484
  }
483
485
 
484
486
  static VALUE dfloat_store_int16(VALUE self, VALUE obj) {
485
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
486
- ndfunc_t ndf = {iter_dfloat_store_int16, FULL_LOOP, 2, 0, ain, 0};
487
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
488
+ ndfunc_t ndf = { iter_dfloat_store_int16, FULL_LOOP, 2, 0, ain, 0 };
487
489
 
488
490
  na_ndloop(&ndf, 2, self, obj);
489
491
  return self;
@@ -531,8 +533,8 @@ static void iter_dfloat_store_int8(na_loop_t* const lp) {
531
533
  }
532
534
 
533
535
  static VALUE dfloat_store_int8(VALUE self, VALUE obj) {
534
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
535
- ndfunc_t ndf = {iter_dfloat_store_int8, FULL_LOOP, 2, 0, ain, 0};
536
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
537
+ ndfunc_t ndf = { iter_dfloat_store_int8, FULL_LOOP, 2, 0, ain, 0 };
536
538
 
537
539
  na_ndloop(&ndf, 2, self, obj);
538
540
  return self;
@@ -580,8 +582,8 @@ static void iter_dfloat_store_uint64(na_loop_t* const lp) {
580
582
  }
581
583
 
582
584
  static VALUE dfloat_store_uint64(VALUE self, VALUE obj) {
583
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
584
- ndfunc_t ndf = {iter_dfloat_store_uint64, FULL_LOOP, 2, 0, ain, 0};
585
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
586
+ ndfunc_t ndf = { iter_dfloat_store_uint64, FULL_LOOP, 2, 0, ain, 0 };
585
587
 
586
588
  na_ndloop(&ndf, 2, self, obj);
587
589
  return self;
@@ -629,8 +631,8 @@ static void iter_dfloat_store_uint32(na_loop_t* const lp) {
629
631
  }
630
632
 
631
633
  static VALUE dfloat_store_uint32(VALUE self, VALUE obj) {
632
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
633
- ndfunc_t ndf = {iter_dfloat_store_uint32, FULL_LOOP, 2, 0, ain, 0};
634
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
635
+ ndfunc_t ndf = { iter_dfloat_store_uint32, FULL_LOOP, 2, 0, ain, 0 };
634
636
 
635
637
  na_ndloop(&ndf, 2, self, obj);
636
638
  return self;
@@ -678,8 +680,8 @@ static void iter_dfloat_store_uint16(na_loop_t* const lp) {
678
680
  }
679
681
 
680
682
  static VALUE dfloat_store_uint16(VALUE self, VALUE obj) {
681
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
682
- ndfunc_t ndf = {iter_dfloat_store_uint16, FULL_LOOP, 2, 0, ain, 0};
683
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
684
+ ndfunc_t ndf = { iter_dfloat_store_uint16, FULL_LOOP, 2, 0, ain, 0 };
683
685
 
684
686
  na_ndloop(&ndf, 2, self, obj);
685
687
  return self;
@@ -727,8 +729,8 @@ static void iter_dfloat_store_uint8(na_loop_t* const lp) {
727
729
  }
728
730
 
729
731
  static VALUE dfloat_store_uint8(VALUE self, VALUE obj) {
730
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
731
- ndfunc_t ndf = {iter_dfloat_store_uint8, FULL_LOOP, 2, 0, ain, 0};
732
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
733
+ ndfunc_t ndf = { iter_dfloat_store_uint8, FULL_LOOP, 2, 0, ain, 0 };
732
734
 
733
735
  na_ndloop(&ndf, 2, self, obj);
734
736
  return self;
@@ -776,8 +778,8 @@ static void iter_dfloat_store_robject(na_loop_t* const lp) {
776
778
  }
777
779
 
778
780
  static VALUE dfloat_store_robject(VALUE self, VALUE obj) {
779
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
780
- ndfunc_t ndf = {iter_dfloat_store_robject, FULL_LOOP, 2, 0, ain, 0};
781
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
782
+ ndfunc_t ndf = { iter_dfloat_store_robject, FULL_LOOP, 2, 0, ain, 0 };
781
783
 
782
784
  na_ndloop(&ndf, 2, self, obj);
783
785
  return self;
@@ -885,19 +887,13 @@ loop_end:
885
887
  }
886
888
 
887
889
  static VALUE dfloat_store_array(VALUE self, VALUE rary) {
888
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {rb_cArray, 0}};
889
- ndfunc_t ndf = {iter_dfloat_store_array, FULL_LOOP, 2, 0, ain, 0};
890
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { rb_cArray, 0 } };
891
+ ndfunc_t ndf = { iter_dfloat_store_array, FULL_LOOP, 2, 0, ain, 0 };
890
892
 
891
893
  na_ndloop_store_rarray(&ndf, self, rary);
892
894
  return self;
893
895
  }
894
896
 
895
- /*
896
- Store elements to Numo::DFloat from other.
897
- @overload store(other)
898
- @param [Object] other
899
- @return [Numo::DFloat] self
900
- */
901
897
  static VALUE dfloat_store(VALUE self, VALUE obj) {
902
898
  VALUE r, klass;
903
899
 
@@ -981,8 +977,10 @@ static VALUE dfloat_store(VALUE self, VALUE obj) {
981
977
  }
982
978
  }
983
979
 
984
- rb_raise(nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
985
- rb_class2name(rb_obj_class(self)));
980
+ rb_raise(
981
+ nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
982
+ rb_class2name(rb_obj_class(self))
983
+ );
986
984
 
987
985
  return self;
988
986
  }
@@ -1076,7 +1074,10 @@ static dtype dfloat_extract_data(VALUE obj) {
1076
1074
  return dfloat_extract_data(r);
1077
1075
  }
1078
1076
 
1079
- rb_raise(nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)), rb_class2name(cT));
1077
+ rb_raise(
1078
+ nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
1079
+ rb_class2name(cT)
1080
+ );
1080
1081
  }
1081
1082
  if (TYPE(obj) == T_ARRAY) {
1082
1083
  if (RARRAY_LEN(obj) != 1) {
@@ -1099,14 +1100,6 @@ static VALUE dfloat_cast_array(VALUE rary) {
1099
1100
  return nary;
1100
1101
  }
1101
1102
 
1102
- /*
1103
- Cast object to Numo::DFloat.
1104
- @overload [](elements)
1105
- @overload cast(array)
1106
- @param [Numeric,Array] elements
1107
- @param [Array] array
1108
- @return [Numo::DFloat]
1109
- */
1110
1103
  static VALUE dfloat_s_cast(VALUE type, VALUE obj) {
1111
1104
  VALUE v;
1112
1105
  narray_t* na;
@@ -1142,15 +1135,6 @@ static VALUE dfloat_s_cast(VALUE type, VALUE obj) {
1142
1135
  return Qnil;
1143
1136
  }
1144
1137
 
1145
- /*
1146
- Multi-dimensional element reference.
1147
- @overload [](dim0,...,dimL)
1148
- @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol] dim0,...,dimL multi-dimensional
1149
- indices.
1150
- @return [Numeric,Numo::DFloat] an element or NArray view.
1151
- @see Numo::NArray#[]
1152
- @see #[]=
1153
- */
1154
1138
  static VALUE dfloat_aref(int argc, VALUE* argv, VALUE self) {
1155
1139
  int nd;
1156
1140
  size_t pos;
@@ -1165,16 +1149,6 @@ static VALUE dfloat_aref(int argc, VALUE* argv, VALUE self) {
1165
1149
  }
1166
1150
  }
1167
1151
 
1168
- /*
1169
- Multi-dimensional element assignment.
1170
- @overload []=(dim0,...,dimL,val)
1171
- @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol] dim0,...,dimL multi-dimensional
1172
- indices.
1173
- @param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
1174
- @return [Numeric,Numo::NArray,Array] returns `val` (last argument).
1175
- @see Numo::NArray#[]=
1176
- @see #[]
1177
- */
1178
1152
  static VALUE dfloat_aset(int argc, VALUE* argv, VALUE self) {
1179
1153
  int nd;
1180
1154
  size_t pos;
@@ -1199,11 +1173,6 @@ static VALUE dfloat_aset(int argc, VALUE* argv, VALUE self) {
1199
1173
  return argv[argc];
1200
1174
  }
1201
1175
 
1202
- /*
1203
- return NArray with cast to the type of self.
1204
- @overload coerce_cast(type)
1205
- @return [nil]
1206
- */
1207
1176
  static VALUE dfloat_coerce_cast(VALUE self, VALUE type) {
1208
1177
  return Qnil;
1209
1178
  }
@@ -1234,15 +1203,10 @@ static void iter_dfloat_to_a(na_loop_t* const lp) {
1234
1203
  }
1235
1204
  }
1236
1205
 
1237
- /*
1238
- Convert self to Array.
1239
- @overload to_a
1240
- @return [Array]
1241
- */
1242
1206
  static VALUE dfloat_to_a(VALUE self) {
1243
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
1244
- ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
1245
- ndfunc_t ndf = {iter_dfloat_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
1207
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
1208
+ ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
1209
+ ndfunc_t ndf = { iter_dfloat_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
1246
1210
  return na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
1247
1211
  }
1248
1212
 
@@ -1267,15 +1231,9 @@ static void iter_dfloat_fill(na_loop_t* const lp) {
1267
1231
  }
1268
1232
  }
1269
1233
 
1270
- /*
1271
- Fill elements with other.
1272
- @overload fill other
1273
- @param [Numeric] other
1274
- @return [Numo::DFloat] self.
1275
- */
1276
1234
  static VALUE dfloat_fill(VALUE self, VALUE val) {
1277
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_option}};
1278
- ndfunc_t ndf = {iter_dfloat_fill, FULL_LOOP, 2, 0, ain, 0};
1235
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
1236
+ ndfunc_t ndf = { iter_dfloat_fill, FULL_LOOP, 2, 0, ain, 0 };
1279
1237
 
1280
1238
  na_ndloop(&ndf, 2, self, val);
1281
1239
  return self;
@@ -1321,18 +1279,12 @@ static void iter_dfloat_format(na_loop_t* const lp) {
1321
1279
  }
1322
1280
  }
1323
1281
 
1324
- /*
1325
- Format elements into strings.
1326
- @overload format format
1327
- @param [String] format
1328
- @return [Numo::RObject] array of formatted strings.
1329
- */
1330
1282
  static VALUE dfloat_format(int argc, VALUE* argv, VALUE self) {
1331
1283
  VALUE fmt = Qnil;
1332
1284
 
1333
- ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_option}};
1334
- ndfunc_arg_out_t aout[1] = {{numo_cRObject, 0}};
1335
- ndfunc_t ndf = {iter_dfloat_format, FULL_LOOP_NIP, 2, 1, ain, aout};
1285
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_option } };
1286
+ ndfunc_arg_out_t aout[1] = { { numo_cRObject, 0 } };
1287
+ ndfunc_t ndf = { iter_dfloat_format, FULL_LOOP_NIP, 2, 1, ain, aout };
1336
1288
 
1337
1289
  rb_scan_args(argc, argv, "01", &fmt);
1338
1290
  return na_ndloop(&ndf, 2, self, fmt);
@@ -1368,17 +1320,11 @@ static void iter_dfloat_format_to_a(na_loop_t* const lp) {
1368
1320
  }
1369
1321
  }
1370
1322
 
1371
- /*
1372
- Format elements into strings.
1373
- @overload format_to_a format
1374
- @param [String] format
1375
- @return [Array] array of formatted strings.
1376
- */
1377
1323
  static VALUE dfloat_format_to_a(int argc, VALUE* argv, VALUE self) {
1378
1324
  VALUE fmt = Qnil;
1379
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
1380
- ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
1381
- ndfunc_t ndf = {iter_dfloat_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
1325
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
1326
+ ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
1327
+ ndfunc_t ndf = { iter_dfloat_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
1382
1328
 
1383
1329
  rb_scan_args(argc, argv, "01", &fmt);
1384
1330
  return na_ndloop_cast_narray_to_rarray(&ndf, self, fmt);
@@ -1388,11 +1334,6 @@ static VALUE iter_dfloat_inspect(char* ptr, size_t pos, VALUE fmt) {
1388
1334
  return format_dfloat(fmt, (dtype*)(ptr + pos));
1389
1335
  }
1390
1336
 
1391
- /*
1392
- Returns a string containing a human-readable representation of NArray.
1393
- @overload inspect
1394
- @return [String]
1395
- */
1396
1337
  static VALUE dfloat_inspect(VALUE ary) {
1397
1338
  return na_ndloop_inspect(ary, iter_dfloat_inspect, Qnil);
1398
1339
  }
@@ -1421,19 +1362,9 @@ static void iter_dfloat_each(na_loop_t* const lp) {
1421
1362
  }
1422
1363
  }
1423
1364
 
1424
- /*
1425
- Calls the given block once for each element in self,
1426
- passing that element as a parameter.
1427
- @overload each
1428
- @return [Numo::NArray] self
1429
- For a block `{|x| ... }`,
1430
- @yieldparam [Numeric] x an element of NArray.
1431
- @see #each_with_index
1432
- @see #map
1433
- */
1434
1365
  static VALUE dfloat_each(VALUE self) {
1435
- ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
1436
- ndfunc_t ndf = {iter_dfloat_each, FULL_LOOP_NIP, 1, 0, ain, 0};
1366
+ ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
1367
+ ndfunc_t ndf = { iter_dfloat_each, FULL_LOOP_NIP, 1, 0, ain, 0 };
1437
1368
 
1438
1369
  na_ndloop(&ndf, 1, self);
1439
1370
  return self;
@@ -1501,15 +1432,10 @@ static void iter_dfloat_map(na_loop_t* const lp) {
1501
1432
  }
1502
1433
  }
1503
1434
 
1504
- /*
1505
- Unary map.
1506
- @overload map
1507
- @return [Numo::DFloat] map of self.
1508
- */
1509
1435
  static VALUE dfloat_map(VALUE self) {
1510
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
1511
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
1512
- ndfunc_t ndf = {iter_dfloat_map, FULL_LOOP, 1, 1, ain, aout};
1436
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
1437
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
1438
+ ndfunc_t ndf = { iter_dfloat_map, FULL_LOOP, 1, 1, ain, aout };
1513
1439
 
1514
1440
  return na_ndloop(&ndf, 1, self);
1515
1441
  }
@@ -1559,20 +1485,9 @@ static void iter_dfloat_each_with_index(na_loop_t* const lp) {
1559
1485
  }
1560
1486
  }
1561
1487
 
1562
- /*
1563
- Invokes the given block once for each element of self,
1564
- passing that element and indices along each axis as parameters.
1565
- @overload each_with_index
1566
- For a block `{|x,i,j,...| ... }`,
1567
- @yieldparam [Numeric] x an element
1568
- @yieldparam [Integer] i,j,... multitimensional indices
1569
- @return [Numo::NArray] self
1570
- @see #each
1571
- @see #map_with_index
1572
- */
1573
1488
  static VALUE dfloat_each_with_index(VALUE self) {
1574
- ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
1575
- ndfunc_t ndf = {iter_dfloat_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0};
1489
+ ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
1490
+ ndfunc_t ndf = { iter_dfloat_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0 };
1576
1491
 
1577
1492
  na_ndloop_with_index(&ndf, 1, self);
1578
1493
  return self;
@@ -1648,23 +1563,10 @@ static void iter_dfloat_map_with_index(na_loop_t* const lp) {
1648
1563
  }
1649
1564
  }
1650
1565
 
1651
- /*
1652
- Invokes the given block once for each element of self,
1653
- passing that element and indices along each axis as parameters.
1654
- Creates a new NArray containing the values returned by the block.
1655
- Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
1656
- @overload map_with_index
1657
- For a block `{|x,i,j,...| ... }`,
1658
- @yieldparam [Numeric] x an element
1659
- @yieldparam [Integer] i,j,... multitimensional indices
1660
- @return [Numo::NArray] mapped array
1661
- @see #map
1662
- @see #each_with_index
1663
- */
1664
1566
  static VALUE dfloat_map_with_index(VALUE self) {
1665
- ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
1666
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
1667
- ndfunc_t ndf = {iter_dfloat_map_with_index, FULL_LOOP, 1, 1, ain, aout};
1567
+ ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
1568
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
1569
+ ndfunc_t ndf = { iter_dfloat_map_with_index, FULL_LOOP, 1, 1, ain, aout };
1668
1570
 
1669
1571
  return na_ndloop_with_index(&ndf, 1, self);
1670
1572
  }
@@ -1710,20 +1612,15 @@ static void iter_dfloat_abs(na_loop_t* const lp) {
1710
1612
  }
1711
1613
  }
1712
1614
 
1713
- /*
1714
- abs of self.
1715
- @overload abs
1716
- @return [Numo::DFloat] abs of self.
1717
- */
1718
1615
  static VALUE dfloat_abs(VALUE self) {
1719
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
1720
- ndfunc_arg_out_t aout[1] = {{cRT, 0}};
1721
- ndfunc_t ndf = {iter_dfloat_abs, FULL_LOOP, 1, 1, ain, aout};
1616
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
1617
+ ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
1618
+ ndfunc_t ndf = { iter_dfloat_abs, FULL_LOOP, 1, 1, ain, aout };
1722
1619
 
1723
1620
  return na_ndloop(&ndf, 1, self);
1724
1621
  }
1725
1622
 
1726
- #define check_intdivzero(y) \
1623
+ #define check_intdivzero(y) \
1727
1624
  {}
1728
1625
 
1729
1626
  static void iter_dfloat_add(na_loop_t* const lp) {
@@ -1748,14 +1645,20 @@ static void iter_dfloat_add(na_loop_t* const lp) {
1748
1645
  INIT_PTR(lp, 2, p3, s3);
1749
1646
 
1750
1647
  //
1751
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) && is_aligned(p3, sizeof(dtype))) {
1648
+ if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
1649
+ is_aligned(p3, sizeof(dtype))) {
1752
1650
 
1753
1651
  if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
1754
1652
  #ifdef __SSE2__
1755
1653
  // Check number of elements. & Check same alignment.
1756
- if ((n >= num_pack) && is_same_aligned3(&((dtype*)p1)[i], &((dtype*)p2)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
1654
+ if ((n >= num_pack) &&
1655
+ is_same_aligned3(
1656
+ &((dtype*)p1)[i], &((dtype*)p2)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE
1657
+ )) {
1757
1658
  // Calculate up to the position just before the start of SIMD computation.
1758
- cnt = get_count_of_elements_not_aligned_to_simd_size(&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype));
1659
+ cnt = get_count_of_elements_not_aligned_to_simd_size(
1660
+ &((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
1661
+ );
1759
1662
  #endif
1760
1663
  if (p1 == p3) { // inplace case
1761
1664
  #ifdef __SSE2__
@@ -1816,7 +1719,8 @@ static void iter_dfloat_add(na_loop_t* const lp) {
1816
1719
  return;
1817
1720
  }
1818
1721
 
1819
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) && is_aligned_step(s3, sizeof(dtype))) {
1722
+ if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
1723
+ is_aligned_step(s3, sizeof(dtype))) {
1820
1724
  //
1821
1725
 
1822
1726
  if (s2 == 0) { // Broadcasting from scalar value.
@@ -1827,9 +1731,12 @@ static void iter_dfloat_add(na_loop_t* const lp) {
1827
1731
  b = _mm_load1_pd(&((dtype*)p2)[0]);
1828
1732
 
1829
1733
  // Check number of elements. & Check same alignment.
1830
- if ((n >= num_pack) && is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
1734
+ if ((n >= num_pack) &&
1735
+ is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
1831
1736
  // Calculate up to the position just before the start of SIMD computation.
1832
- cnt = get_count_of_elements_not_aligned_to_simd_size(&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype));
1737
+ cnt = get_count_of_elements_not_aligned_to_simd_size(
1738
+ &((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
1739
+ );
1833
1740
  #endif
1834
1741
  if (p1 == p3) { // inplace case
1835
1742
  #ifdef __SSE2__
@@ -1924,19 +1831,13 @@ static void iter_dfloat_add(na_loop_t* const lp) {
1924
1831
  #undef check_intdivzero
1925
1832
 
1926
1833
  static VALUE dfloat_add_self(VALUE self, VALUE other) {
1927
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
1928
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
1929
- ndfunc_t ndf = {iter_dfloat_add, STRIDE_LOOP, 2, 1, ain, aout};
1834
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
1835
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
1836
+ ndfunc_t ndf = { iter_dfloat_add, STRIDE_LOOP, 2, 1, ain, aout };
1930
1837
 
1931
1838
  return na_ndloop(&ndf, 2, self, other);
1932
1839
  }
1933
1840
 
1934
- /*
1935
- Binary add.
1936
- @overload + other
1937
- @param [Numo::NArray,Numeric] other
1938
- @return [Numo::NArray] self + other
1939
- */
1940
1841
  static VALUE dfloat_add(VALUE self, VALUE other) {
1941
1842
 
1942
1843
  VALUE klass, v;
@@ -1950,7 +1851,7 @@ static VALUE dfloat_add(VALUE self, VALUE other) {
1950
1851
  }
1951
1852
  }
1952
1853
 
1953
- #define check_intdivzero(y) \
1854
+ #define check_intdivzero(y) \
1954
1855
  {}
1955
1856
 
1956
1857
  static void iter_dfloat_sub(na_loop_t* const lp) {
@@ -1975,14 +1876,20 @@ static void iter_dfloat_sub(na_loop_t* const lp) {
1975
1876
  INIT_PTR(lp, 2, p3, s3);
1976
1877
 
1977
1878
  //
1978
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) && is_aligned(p3, sizeof(dtype))) {
1879
+ if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
1880
+ is_aligned(p3, sizeof(dtype))) {
1979
1881
 
1980
1882
  if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
1981
1883
  #ifdef __SSE2__
1982
1884
  // Check number of elements. & Check same alignment.
1983
- if ((n >= num_pack) && is_same_aligned3(&((dtype*)p1)[i], &((dtype*)p2)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
1885
+ if ((n >= num_pack) &&
1886
+ is_same_aligned3(
1887
+ &((dtype*)p1)[i], &((dtype*)p2)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE
1888
+ )) {
1984
1889
  // Calculate up to the position just before the start of SIMD computation.
1985
- cnt = get_count_of_elements_not_aligned_to_simd_size(&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype));
1890
+ cnt = get_count_of_elements_not_aligned_to_simd_size(
1891
+ &((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
1892
+ );
1986
1893
  #endif
1987
1894
  if (p1 == p3) { // inplace case
1988
1895
  #ifdef __SSE2__
@@ -2044,7 +1951,8 @@ static void iter_dfloat_sub(na_loop_t* const lp) {
2044
1951
  return;
2045
1952
  }
2046
1953
 
2047
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) && is_aligned_step(s3, sizeof(dtype))) {
1954
+ if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
1955
+ is_aligned_step(s3, sizeof(dtype))) {
2048
1956
  //
2049
1957
 
2050
1958
  if (s2 == 0) { // Broadcasting from scalar value.
@@ -2055,9 +1963,12 @@ static void iter_dfloat_sub(na_loop_t* const lp) {
2055
1963
  b = _mm_load1_pd(&((dtype*)p2)[0]);
2056
1964
 
2057
1965
  // Check number of elements. & Check same alignment.
2058
- if ((n >= num_pack) && is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
1966
+ if ((n >= num_pack) &&
1967
+ is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
2059
1968
  // Calculate up to the position just before the start of SIMD computation.
2060
- cnt = get_count_of_elements_not_aligned_to_simd_size(&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype));
1969
+ cnt = get_count_of_elements_not_aligned_to_simd_size(
1970
+ &((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
1971
+ );
2061
1972
  #endif
2062
1973
  if (p1 == p3) { // inplace case
2063
1974
  #ifdef __SSE2__
@@ -2153,19 +2064,13 @@ static void iter_dfloat_sub(na_loop_t* const lp) {
2153
2064
  #undef check_intdivzero
2154
2065
 
2155
2066
  static VALUE dfloat_sub_self(VALUE self, VALUE other) {
2156
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2157
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2158
- ndfunc_t ndf = {iter_dfloat_sub, STRIDE_LOOP, 2, 1, ain, aout};
2067
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2068
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2069
+ ndfunc_t ndf = { iter_dfloat_sub, STRIDE_LOOP, 2, 1, ain, aout };
2159
2070
 
2160
2071
  return na_ndloop(&ndf, 2, self, other);
2161
2072
  }
2162
2073
 
2163
- /*
2164
- Binary sub.
2165
- @overload - other
2166
- @param [Numo::NArray,Numeric] other
2167
- @return [Numo::NArray] self - other
2168
- */
2169
2074
  static VALUE dfloat_sub(VALUE self, VALUE other) {
2170
2075
 
2171
2076
  VALUE klass, v;
@@ -2179,7 +2084,7 @@ static VALUE dfloat_sub(VALUE self, VALUE other) {
2179
2084
  }
2180
2085
  }
2181
2086
 
2182
- #define check_intdivzero(y) \
2087
+ #define check_intdivzero(y) \
2183
2088
  {}
2184
2089
 
2185
2090
  static void iter_dfloat_mul(na_loop_t* const lp) {
@@ -2204,14 +2109,20 @@ static void iter_dfloat_mul(na_loop_t* const lp) {
2204
2109
  INIT_PTR(lp, 2, p3, s3);
2205
2110
 
2206
2111
  //
2207
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) && is_aligned(p3, sizeof(dtype))) {
2112
+ if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
2113
+ is_aligned(p3, sizeof(dtype))) {
2208
2114
 
2209
2115
  if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
2210
2116
  #ifdef __SSE2__
2211
2117
  // Check number of elements. & Check same alignment.
2212
- if ((n >= num_pack) && is_same_aligned3(&((dtype*)p1)[i], &((dtype*)p2)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
2118
+ if ((n >= num_pack) &&
2119
+ is_same_aligned3(
2120
+ &((dtype*)p1)[i], &((dtype*)p2)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE
2121
+ )) {
2213
2122
  // Calculate up to the position just before the start of SIMD computation.
2214
- cnt = get_count_of_elements_not_aligned_to_simd_size(&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype));
2123
+ cnt = get_count_of_elements_not_aligned_to_simd_size(
2124
+ &((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
2125
+ );
2215
2126
  #endif
2216
2127
  if (p1 == p3) { // inplace case
2217
2128
  #ifdef __SSE2__
@@ -2273,7 +2184,8 @@ static void iter_dfloat_mul(na_loop_t* const lp) {
2273
2184
  return;
2274
2185
  }
2275
2186
 
2276
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) && is_aligned_step(s3, sizeof(dtype))) {
2187
+ if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
2188
+ is_aligned_step(s3, sizeof(dtype))) {
2277
2189
  //
2278
2190
 
2279
2191
  if (s2 == 0) { // Broadcasting from scalar value.
@@ -2284,9 +2196,12 @@ static void iter_dfloat_mul(na_loop_t* const lp) {
2284
2196
  b = _mm_load1_pd(&((dtype*)p2)[0]);
2285
2197
 
2286
2198
  // Check number of elements. & Check same alignment.
2287
- if ((n >= num_pack) && is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
2199
+ if ((n >= num_pack) &&
2200
+ is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
2288
2201
  // Calculate up to the position just before the start of SIMD computation.
2289
- cnt = get_count_of_elements_not_aligned_to_simd_size(&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype));
2202
+ cnt = get_count_of_elements_not_aligned_to_simd_size(
2203
+ &((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
2204
+ );
2290
2205
  #endif
2291
2206
  if (p1 == p3) { // inplace case
2292
2207
  #ifdef __SSE2__
@@ -2382,19 +2297,13 @@ static void iter_dfloat_mul(na_loop_t* const lp) {
2382
2297
  #undef check_intdivzero
2383
2298
 
2384
2299
  static VALUE dfloat_mul_self(VALUE self, VALUE other) {
2385
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2386
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2387
- ndfunc_t ndf = {iter_dfloat_mul, STRIDE_LOOP, 2, 1, ain, aout};
2300
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2301
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2302
+ ndfunc_t ndf = { iter_dfloat_mul, STRIDE_LOOP, 2, 1, ain, aout };
2388
2303
 
2389
2304
  return na_ndloop(&ndf, 2, self, other);
2390
2305
  }
2391
2306
 
2392
- /*
2393
- Binary mul.
2394
- @overload * other
2395
- @param [Numo::NArray,Numeric] other
2396
- @return [Numo::NArray] self * other
2397
- */
2398
2307
  static VALUE dfloat_mul(VALUE self, VALUE other) {
2399
2308
 
2400
2309
  VALUE klass, v;
@@ -2408,7 +2317,7 @@ static VALUE dfloat_mul(VALUE self, VALUE other) {
2408
2317
  }
2409
2318
  }
2410
2319
 
2411
- #define check_intdivzero(y) \
2320
+ #define check_intdivzero(y) \
2412
2321
  {}
2413
2322
 
2414
2323
  static void iter_dfloat_div(na_loop_t* const lp) {
@@ -2433,14 +2342,20 @@ static void iter_dfloat_div(na_loop_t* const lp) {
2433
2342
  INIT_PTR(lp, 2, p3, s3);
2434
2343
 
2435
2344
  //
2436
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) && is_aligned(p3, sizeof(dtype))) {
2345
+ if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
2346
+ is_aligned(p3, sizeof(dtype))) {
2437
2347
 
2438
2348
  if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
2439
2349
  #ifdef __SSE2__
2440
2350
  // Check number of elements. & Check same alignment.
2441
- if ((n >= num_pack) && is_same_aligned3(&((dtype*)p1)[i], &((dtype*)p2)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
2351
+ if ((n >= num_pack) &&
2352
+ is_same_aligned3(
2353
+ &((dtype*)p1)[i], &((dtype*)p2)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE
2354
+ )) {
2442
2355
  // Calculate up to the position just before the start of SIMD computation.
2443
- cnt = get_count_of_elements_not_aligned_to_simd_size(&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype));
2356
+ cnt = get_count_of_elements_not_aligned_to_simd_size(
2357
+ &((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
2358
+ );
2444
2359
  #endif
2445
2360
  if (p1 == p3) { // inplace case
2446
2361
  #ifdef __SSE2__
@@ -2500,7 +2415,8 @@ static void iter_dfloat_div(na_loop_t* const lp) {
2500
2415
  return;
2501
2416
  }
2502
2417
 
2503
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) && is_aligned_step(s3, sizeof(dtype))) {
2418
+ if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
2419
+ is_aligned_step(s3, sizeof(dtype))) {
2504
2420
  //
2505
2421
 
2506
2422
  if (s2 == 0) { // Broadcasting from scalar value.
@@ -2511,9 +2427,12 @@ static void iter_dfloat_div(na_loop_t* const lp) {
2511
2427
  b = _mm_load1_pd(&((dtype*)p2)[0]);
2512
2428
 
2513
2429
  // Check number of elements. & Check same alignment.
2514
- if ((n >= num_pack) && is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
2430
+ if ((n >= num_pack) &&
2431
+ is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
2515
2432
  // Calculate up to the position just before the start of SIMD computation.
2516
- cnt = get_count_of_elements_not_aligned_to_simd_size(&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype));
2433
+ cnt = get_count_of_elements_not_aligned_to_simd_size(
2434
+ &((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
2435
+ );
2517
2436
  #endif
2518
2437
  if (p1 == p3) { // inplace case
2519
2438
  #ifdef __SSE2__
@@ -2611,19 +2530,13 @@ static void iter_dfloat_div(na_loop_t* const lp) {
2611
2530
  #undef check_intdivzero
2612
2531
 
2613
2532
  static VALUE dfloat_div_self(VALUE self, VALUE other) {
2614
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2615
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2616
- ndfunc_t ndf = {iter_dfloat_div, STRIDE_LOOP, 2, 1, ain, aout};
2533
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2534
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2535
+ ndfunc_t ndf = { iter_dfloat_div, STRIDE_LOOP, 2, 1, ain, aout };
2617
2536
 
2618
2537
  return na_ndloop(&ndf, 2, self, other);
2619
2538
  }
2620
2539
 
2621
- /*
2622
- Binary div.
2623
- @overload / other
2624
- @param [Numo::NArray,Numeric] other
2625
- @return [Numo::NArray] self / other
2626
- */
2627
2540
  static VALUE dfloat_div(VALUE self, VALUE other) {
2628
2541
 
2629
2542
  VALUE klass, v;
@@ -2637,7 +2550,7 @@ static VALUE dfloat_div(VALUE self, VALUE other) {
2637
2550
  }
2638
2551
  }
2639
2552
 
2640
- #define check_intdivzero(y) \
2553
+ #define check_intdivzero(y) \
2641
2554
  {}
2642
2555
 
2643
2556
  static void iter_dfloat_mod(na_loop_t* const lp) {
@@ -2652,7 +2565,8 @@ static void iter_dfloat_mod(na_loop_t* const lp) {
2652
2565
  INIT_PTR(lp, 2, p3, s3);
2653
2566
 
2654
2567
  //
2655
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) && is_aligned(p3, sizeof(dtype))) {
2568
+ if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
2569
+ is_aligned(p3, sizeof(dtype))) {
2656
2570
 
2657
2571
  if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
2658
2572
  if (p1 == p3) { // inplace case
@@ -2669,7 +2583,8 @@ static void iter_dfloat_mod(na_loop_t* const lp) {
2669
2583
  return;
2670
2584
  }
2671
2585
 
2672
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) && is_aligned_step(s3, sizeof(dtype))) {
2586
+ if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
2587
+ is_aligned_step(s3, sizeof(dtype))) {
2673
2588
  //
2674
2589
 
2675
2590
  if (s2 == 0) { // Broadcasting from scalar value.
@@ -2727,19 +2642,13 @@ static void iter_dfloat_mod(na_loop_t* const lp) {
2727
2642
  #undef check_intdivzero
2728
2643
 
2729
2644
  static VALUE dfloat_mod_self(VALUE self, VALUE other) {
2730
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2731
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2732
- ndfunc_t ndf = {iter_dfloat_mod, STRIDE_LOOP, 2, 1, ain, aout};
2645
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2646
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2647
+ ndfunc_t ndf = { iter_dfloat_mod, STRIDE_LOOP, 2, 1, ain, aout };
2733
2648
 
2734
2649
  return na_ndloop(&ndf, 2, self, other);
2735
2650
  }
2736
2651
 
2737
- /*
2738
- Binary mod.
2739
- @overload % other
2740
- @param [Numo::NArray,Numeric] other
2741
- @return [Numo::NArray] self % other
2742
- */
2743
2652
  static VALUE dfloat_mod(VALUE self, VALUE other) {
2744
2653
 
2745
2654
  VALUE klass, v;
@@ -2773,19 +2682,13 @@ static void iter_dfloat_divmod(na_loop_t* const lp) {
2773
2682
  }
2774
2683
 
2775
2684
  static VALUE dfloat_divmod_self(VALUE self, VALUE other) {
2776
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2777
- ndfunc_arg_out_t aout[2] = {{cT, 0}, {cT, 0}};
2778
- ndfunc_t ndf = {iter_dfloat_divmod, STRIDE_LOOP, 2, 2, ain, aout};
2685
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2686
+ ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
2687
+ ndfunc_t ndf = { iter_dfloat_divmod, STRIDE_LOOP, 2, 2, ain, aout };
2779
2688
 
2780
2689
  return na_ndloop(&ndf, 2, self, other);
2781
2690
  }
2782
2691
 
2783
- /*
2784
- Binary divmod.
2785
- @overload divmod other
2786
- @param [Numo::NArray,Numeric] other
2787
- @return [Numo::NArray] divmod of self and other.
2788
- */
2789
2692
  static VALUE dfloat_divmod(VALUE self, VALUE other) {
2790
2693
 
2791
2694
  VALUE klass, v;
@@ -2834,11 +2737,11 @@ static void iter_dfloat_pow_int32(na_loop_t* const lp) {
2834
2737
  }
2835
2738
 
2836
2739
  static VALUE dfloat_pow_self(VALUE self, VALUE other) {
2837
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
2838
- ndfunc_arg_in_t ain_i[2] = {{cT, 0}, {numo_cInt32, 0}};
2839
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2840
- ndfunc_t ndf = {iter_dfloat_pow, STRIDE_LOOP, 2, 1, ain, aout};
2841
- ndfunc_t ndf_i = {iter_dfloat_pow_int32, STRIDE_LOOP, 2, 1, ain_i, aout};
2740
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
2741
+ ndfunc_arg_in_t ain_i[2] = { { cT, 0 }, { numo_cInt32, 0 } };
2742
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2743
+ ndfunc_t ndf = { iter_dfloat_pow, STRIDE_LOOP, 2, 1, ain, aout };
2744
+ ndfunc_t ndf_i = { iter_dfloat_pow_int32, STRIDE_LOOP, 2, 1, ain_i, aout };
2842
2745
 
2843
2746
  // fixme : use na.integer?
2844
2747
  if (FIXNUM_P(other) || rb_obj_is_kind_of(other, numo_cInt32)) {
@@ -2848,12 +2751,6 @@ static VALUE dfloat_pow_self(VALUE self, VALUE other) {
2848
2751
  }
2849
2752
  }
2850
2753
 
2851
- /*
2852
- Binary power.
2853
- @overload ** other
2854
- @param [Numo::NArray,Numeric] other
2855
- @return [Numo::NArray] self to the other-th power.
2856
- */
2857
2754
  static VALUE dfloat_pow(VALUE self, VALUE other) {
2858
2755
 
2859
2756
  VALUE klass, v;
@@ -2928,15 +2825,10 @@ static void iter_dfloat_minus(na_loop_t* const lp) {
2928
2825
  }
2929
2826
  }
2930
2827
 
2931
- /*
2932
- Unary minus.
2933
- @overload -@
2934
- @return [Numo::DFloat] minus of self.
2935
- */
2936
2828
  static VALUE dfloat_minus(VALUE self) {
2937
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
2938
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
2939
- ndfunc_t ndf = {iter_dfloat_minus, FULL_LOOP, 1, 1, ain, aout};
2829
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
2830
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2831
+ ndfunc_t ndf = { iter_dfloat_minus, FULL_LOOP, 1, 1, ain, aout };
2940
2832
 
2941
2833
  return na_ndloop(&ndf, 1, self);
2942
2834
  }
@@ -3003,15 +2895,10 @@ static void iter_dfloat_reciprocal(na_loop_t* const lp) {
3003
2895
  }
3004
2896
  }
3005
2897
 
3006
- /*
3007
- Unary reciprocal.
3008
- @overload reciprocal
3009
- @return [Numo::DFloat] reciprocal of self.
3010
- */
3011
2898
  static VALUE dfloat_reciprocal(VALUE self) {
3012
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3013
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3014
- ndfunc_t ndf = {iter_dfloat_reciprocal, FULL_LOOP, 1, 1, ain, aout};
2899
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
2900
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2901
+ ndfunc_t ndf = { iter_dfloat_reciprocal, FULL_LOOP, 1, 1, ain, aout };
3015
2902
 
3016
2903
  return na_ndloop(&ndf, 1, self);
3017
2904
  }
@@ -3078,15 +2965,10 @@ static void iter_dfloat_sign(na_loop_t* const lp) {
3078
2965
  }
3079
2966
  }
3080
2967
 
3081
- /*
3082
- Unary sign.
3083
- @overload sign
3084
- @return [Numo::DFloat] sign of self.
3085
- */
3086
2968
  static VALUE dfloat_sign(VALUE self) {
3087
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3088
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3089
- ndfunc_t ndf = {iter_dfloat_sign, FULL_LOOP, 1, 1, ain, aout};
2969
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
2970
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
2971
+ ndfunc_t ndf = { iter_dfloat_sign, FULL_LOOP, 1, 1, ain, aout };
3090
2972
 
3091
2973
  return na_ndloop(&ndf, 1, self);
3092
2974
  }
@@ -3153,15 +3035,10 @@ static void iter_dfloat_square(na_loop_t* const lp) {
3153
3035
  }
3154
3036
  }
3155
3037
 
3156
- /*
3157
- Unary square.
3158
- @overload square
3159
- @return [Numo::DFloat] square of self.
3160
- */
3161
3038
  static VALUE dfloat_square(VALUE self) {
3162
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3163
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3164
- ndfunc_t ndf = {iter_dfloat_square, FULL_LOOP, 1, 1, ain, aout};
3039
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3040
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3041
+ ndfunc_t ndf = { iter_dfloat_square, FULL_LOOP, 1, 1, ain, aout };
3165
3042
 
3166
3043
  return na_ndloop(&ndf, 1, self);
3167
3044
  }
@@ -3188,19 +3065,13 @@ static void iter_dfloat_eq(na_loop_t* const lp) {
3188
3065
  }
3189
3066
 
3190
3067
  static VALUE dfloat_eq_self(VALUE self, VALUE other) {
3191
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3192
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3193
- ndfunc_t ndf = {iter_dfloat_eq, STRIDE_LOOP, 2, 1, ain, aout};
3068
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3069
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3070
+ ndfunc_t ndf = { iter_dfloat_eq, STRIDE_LOOP, 2, 1, ain, aout };
3194
3071
 
3195
3072
  return na_ndloop(&ndf, 2, self, other);
3196
3073
  }
3197
3074
 
3198
- /*
3199
- Comparison eq other.
3200
- @overload eq other
3201
- @param [Numo::NArray,Numeric] other
3202
- @return [Numo::Bit] result of self eq other.
3203
- */
3204
3075
  static VALUE dfloat_eq(VALUE self, VALUE other) {
3205
3076
 
3206
3077
  VALUE klass, v;
@@ -3235,19 +3106,13 @@ static void iter_dfloat_ne(na_loop_t* const lp) {
3235
3106
  }
3236
3107
 
3237
3108
  static VALUE dfloat_ne_self(VALUE self, VALUE other) {
3238
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3239
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3240
- ndfunc_t ndf = {iter_dfloat_ne, STRIDE_LOOP, 2, 1, ain, aout};
3109
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3110
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3111
+ ndfunc_t ndf = { iter_dfloat_ne, STRIDE_LOOP, 2, 1, ain, aout };
3241
3112
 
3242
3113
  return na_ndloop(&ndf, 2, self, other);
3243
3114
  }
3244
3115
 
3245
- /*
3246
- Comparison ne other.
3247
- @overload ne other
3248
- @param [Numo::NArray,Numeric] other
3249
- @return [Numo::Bit] result of self ne other.
3250
- */
3251
3116
  static VALUE dfloat_ne(VALUE self, VALUE other) {
3252
3117
 
3253
3118
  VALUE klass, v;
@@ -3282,19 +3147,13 @@ static void iter_dfloat_nearly_eq(na_loop_t* const lp) {
3282
3147
  }
3283
3148
 
3284
3149
  static VALUE dfloat_nearly_eq_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_dfloat_nearly_eq, STRIDE_LOOP, 2, 1, ain, aout};
3150
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3151
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3152
+ ndfunc_t ndf = { iter_dfloat_nearly_eq, STRIDE_LOOP, 2, 1, ain, aout };
3288
3153
 
3289
3154
  return na_ndloop(&ndf, 2, self, other);
3290
3155
  }
3291
3156
 
3292
- /*
3293
- Comparison nearly_eq other.
3294
- @overload nearly_eq other
3295
- @param [Numo::NArray,Numeric] other
3296
- @return [Numo::Bit] result of self nearly_eq other.
3297
- */
3298
3157
  static VALUE dfloat_nearly_eq(VALUE self, VALUE other) {
3299
3158
 
3300
3159
  VALUE klass, v;
@@ -3369,15 +3228,10 @@ static void iter_dfloat_floor(na_loop_t* const lp) {
3369
3228
  }
3370
3229
  }
3371
3230
 
3372
- /*
3373
- Unary floor.
3374
- @overload floor
3375
- @return [Numo::DFloat] floor of self.
3376
- */
3377
3231
  static VALUE dfloat_floor(VALUE self) {
3378
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3379
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3380
- ndfunc_t ndf = {iter_dfloat_floor, FULL_LOOP, 1, 1, ain, aout};
3232
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3233
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3234
+ ndfunc_t ndf = { iter_dfloat_floor, FULL_LOOP, 1, 1, ain, aout };
3381
3235
 
3382
3236
  return na_ndloop(&ndf, 1, self);
3383
3237
  }
@@ -3444,15 +3298,10 @@ static void iter_dfloat_round(na_loop_t* const lp) {
3444
3298
  }
3445
3299
  }
3446
3300
 
3447
- /*
3448
- Unary round.
3449
- @overload round
3450
- @return [Numo::DFloat] round of self.
3451
- */
3452
3301
  static VALUE dfloat_round(VALUE self) {
3453
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3454
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3455
- ndfunc_t ndf = {iter_dfloat_round, FULL_LOOP, 1, 1, ain, aout};
3302
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3303
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3304
+ ndfunc_t ndf = { iter_dfloat_round, FULL_LOOP, 1, 1, ain, aout };
3456
3305
 
3457
3306
  return na_ndloop(&ndf, 1, self);
3458
3307
  }
@@ -3519,15 +3368,10 @@ static void iter_dfloat_ceil(na_loop_t* const lp) {
3519
3368
  }
3520
3369
  }
3521
3370
 
3522
- /*
3523
- Unary ceil.
3524
- @overload ceil
3525
- @return [Numo::DFloat] ceil of self.
3526
- */
3527
3371
  static VALUE dfloat_ceil(VALUE self) {
3528
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3529
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3530
- ndfunc_t ndf = {iter_dfloat_ceil, FULL_LOOP, 1, 1, ain, aout};
3372
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3373
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3374
+ ndfunc_t ndf = { iter_dfloat_ceil, FULL_LOOP, 1, 1, ain, aout };
3531
3375
 
3532
3376
  return na_ndloop(&ndf, 1, self);
3533
3377
  }
@@ -3594,15 +3438,10 @@ static void iter_dfloat_trunc(na_loop_t* const lp) {
3594
3438
  }
3595
3439
  }
3596
3440
 
3597
- /*
3598
- Unary trunc.
3599
- @overload trunc
3600
- @return [Numo::DFloat] trunc of self.
3601
- */
3602
3441
  static VALUE dfloat_trunc(VALUE self) {
3603
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3604
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3605
- ndfunc_t ndf = {iter_dfloat_trunc, FULL_LOOP, 1, 1, ain, aout};
3442
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3443
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3444
+ ndfunc_t ndf = { iter_dfloat_trunc, FULL_LOOP, 1, 1, ain, aout };
3606
3445
 
3607
3446
  return na_ndloop(&ndf, 1, self);
3608
3447
  }
@@ -3669,20 +3508,15 @@ static void iter_dfloat_rint(na_loop_t* const lp) {
3669
3508
  }
3670
3509
  }
3671
3510
 
3672
- /*
3673
- Unary rint.
3674
- @overload rint
3675
- @return [Numo::DFloat] rint of self.
3676
- */
3677
3511
  static VALUE dfloat_rint(VALUE self) {
3678
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3679
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3680
- ndfunc_t ndf = {iter_dfloat_rint, FULL_LOOP, 1, 1, ain, aout};
3512
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3513
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3514
+ ndfunc_t ndf = { iter_dfloat_rint, FULL_LOOP, 1, 1, ain, aout };
3681
3515
 
3682
3516
  return na_ndloop(&ndf, 1, self);
3683
3517
  }
3684
3518
 
3685
- #define check_intdivzero(y) \
3519
+ #define check_intdivzero(y) \
3686
3520
  {}
3687
3521
 
3688
3522
  static void iter_dfloat_copysign(na_loop_t* const lp) {
@@ -3697,7 +3531,8 @@ static void iter_dfloat_copysign(na_loop_t* const lp) {
3697
3531
  INIT_PTR(lp, 2, p3, s3);
3698
3532
 
3699
3533
  //
3700
- if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) && is_aligned(p3, sizeof(dtype))) {
3534
+ if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
3535
+ is_aligned(p3, sizeof(dtype))) {
3701
3536
 
3702
3537
  if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
3703
3538
  if (p1 == p3) { // inplace case
@@ -3714,7 +3549,8 @@ static void iter_dfloat_copysign(na_loop_t* const lp) {
3714
3549
  return;
3715
3550
  }
3716
3551
 
3717
- if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) && is_aligned_step(s3, sizeof(dtype))) {
3552
+ if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
3553
+ is_aligned_step(s3, sizeof(dtype))) {
3718
3554
  //
3719
3555
 
3720
3556
  if (s2 == 0) { // Broadcasting from scalar value.
@@ -3772,19 +3608,13 @@ static void iter_dfloat_copysign(na_loop_t* const lp) {
3772
3608
  #undef check_intdivzero
3773
3609
 
3774
3610
  static VALUE dfloat_copysign_self(VALUE self, VALUE other) {
3775
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3776
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
3777
- ndfunc_t ndf = {iter_dfloat_copysign, STRIDE_LOOP, 2, 1, ain, aout};
3611
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3612
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3613
+ ndfunc_t ndf = { iter_dfloat_copysign, STRIDE_LOOP, 2, 1, ain, aout };
3778
3614
 
3779
3615
  return na_ndloop(&ndf, 2, self, other);
3780
3616
  }
3781
3617
 
3782
- /*
3783
- Binary copysign.
3784
- @overload copysign other
3785
- @param [Numo::NArray,Numeric] other
3786
- @return [Numo::NArray] self copysign other
3787
- */
3788
3618
  static VALUE dfloat_copysign(VALUE self, VALUE other) {
3789
3619
 
3790
3620
  VALUE klass, v;
@@ -3827,15 +3657,10 @@ static void iter_dfloat_signbit(na_loop_t* const lp) {
3827
3657
  }
3828
3658
  }
3829
3659
 
3830
- /*
3831
- Condition of signbit.
3832
- @overload signbit
3833
- @return [Numo::Bit] Condition of signbit.
3834
- */
3835
3660
  static VALUE dfloat_signbit(VALUE self) {
3836
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3837
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3838
- ndfunc_t ndf = {iter_dfloat_signbit, FULL_LOOP, 1, 1, ain, aout};
3661
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3662
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3663
+ ndfunc_t ndf = { iter_dfloat_signbit, FULL_LOOP, 1, 1, ain, aout };
3839
3664
 
3840
3665
  return na_ndloop(&ndf, 1, self);
3841
3666
  }
@@ -3857,15 +3682,10 @@ static void iter_dfloat_modf(na_loop_t* const lp) {
3857
3682
  }
3858
3683
  }
3859
3684
 
3860
- /*
3861
- modf of self.
3862
- @overload modf
3863
- @return [Numo::DFloat] modf of self.
3864
- */
3865
3685
  static VALUE dfloat_modf(VALUE self) {
3866
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
3867
- ndfunc_arg_out_t aout[2] = {{cT, 0}, {cT, 0}};
3868
- ndfunc_t ndf = {iter_dfloat_modf, STRIDE_LOOP, 1, 2, ain, aout};
3686
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3687
+ ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
3688
+ ndfunc_t ndf = { iter_dfloat_modf, STRIDE_LOOP, 1, 2, ain, aout };
3869
3689
 
3870
3690
  return na_ndloop(&ndf, 1, self);
3871
3691
  }
@@ -3892,19 +3712,13 @@ static void iter_dfloat_gt(na_loop_t* const lp) {
3892
3712
  }
3893
3713
 
3894
3714
  static VALUE dfloat_gt_self(VALUE self, VALUE other) {
3895
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3896
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3897
- ndfunc_t ndf = {iter_dfloat_gt, STRIDE_LOOP, 2, 1, ain, aout};
3715
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3716
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3717
+ ndfunc_t ndf = { iter_dfloat_gt, STRIDE_LOOP, 2, 1, ain, aout };
3898
3718
 
3899
3719
  return na_ndloop(&ndf, 2, self, other);
3900
3720
  }
3901
3721
 
3902
- /*
3903
- Comparison gt other.
3904
- @overload gt other
3905
- @param [Numo::NArray,Numeric] other
3906
- @return [Numo::Bit] result of self gt other.
3907
- */
3908
3722
  static VALUE dfloat_gt(VALUE self, VALUE other) {
3909
3723
 
3910
3724
  VALUE klass, v;
@@ -3939,19 +3753,13 @@ static void iter_dfloat_ge(na_loop_t* const lp) {
3939
3753
  }
3940
3754
 
3941
3755
  static VALUE dfloat_ge_self(VALUE self, VALUE other) {
3942
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3943
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3944
- ndfunc_t ndf = {iter_dfloat_ge, STRIDE_LOOP, 2, 1, ain, aout};
3756
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3757
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3758
+ ndfunc_t ndf = { iter_dfloat_ge, STRIDE_LOOP, 2, 1, ain, aout };
3945
3759
 
3946
3760
  return na_ndloop(&ndf, 2, self, other);
3947
3761
  }
3948
3762
 
3949
- /*
3950
- Comparison ge other.
3951
- @overload ge other
3952
- @param [Numo::NArray,Numeric] other
3953
- @return [Numo::Bit] result of self ge other.
3954
- */
3955
3763
  static VALUE dfloat_ge(VALUE self, VALUE other) {
3956
3764
 
3957
3765
  VALUE klass, v;
@@ -3986,19 +3794,13 @@ static void iter_dfloat_lt(na_loop_t* const lp) {
3986
3794
  }
3987
3795
 
3988
3796
  static VALUE dfloat_lt_self(VALUE self, VALUE other) {
3989
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
3990
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
3991
- ndfunc_t ndf = {iter_dfloat_lt, STRIDE_LOOP, 2, 1, ain, aout};
3797
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3798
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3799
+ ndfunc_t ndf = { iter_dfloat_lt, STRIDE_LOOP, 2, 1, ain, aout };
3992
3800
 
3993
3801
  return na_ndloop(&ndf, 2, self, other);
3994
3802
  }
3995
3803
 
3996
- /*
3997
- Comparison lt other.
3998
- @overload lt other
3999
- @param [Numo::NArray,Numeric] other
4000
- @return [Numo::Bit] result of self lt other.
4001
- */
4002
3804
  static VALUE dfloat_lt(VALUE self, VALUE other) {
4003
3805
 
4004
3806
  VALUE klass, v;
@@ -4033,19 +3835,13 @@ static void iter_dfloat_le(na_loop_t* const lp) {
4033
3835
  }
4034
3836
 
4035
3837
  static VALUE dfloat_le_self(VALUE self, VALUE other) {
4036
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
4037
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
4038
- ndfunc_t ndf = {iter_dfloat_le, STRIDE_LOOP, 2, 1, ain, aout};
3838
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
3839
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3840
+ ndfunc_t ndf = { iter_dfloat_le, STRIDE_LOOP, 2, 1, ain, aout };
4039
3841
 
4040
3842
  return na_ndloop(&ndf, 2, self, other);
4041
3843
  }
4042
3844
 
4043
- /*
4044
- Comparison le other.
4045
- @overload le other
4046
- @param [Numo::NArray,Numeric] other
4047
- @return [Numo::Bit] result of self le other.
4048
- */
4049
3845
  static VALUE dfloat_le(VALUE self, VALUE other) {
4050
3846
 
4051
3847
  VALUE klass, v;
@@ -4123,42 +3919,12 @@ static void iter_dfloat_clip_max(na_loop_t* const lp) {
4123
3919
  }
4124
3920
  }
4125
3921
 
4126
- /*
4127
- Clip array elements by [min,max].
4128
- If either of min or max is nil, one side is clipped.
4129
- @overload clip(min,max)
4130
- @param [Numo::NArray,Numeric] min
4131
- @param [Numo::NArray,Numeric] max
4132
- @return [Numo::NArray] result of clip.
4133
-
4134
- @example
4135
- a = Numo::Int32.new(10).seq
4136
- # => Numo::Int32#shape=[10]
4137
- # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
4138
-
4139
- a.clip(1,8)
4140
- # => Numo::Int32#shape=[10]
4141
- # [1, 1, 2, 3, 4, 5, 6, 7, 8, 8]
4142
-
4143
- a.inplace.clip(3,6)
4144
- a
4145
- # => Numo::Int32#shape=[10]
4146
- # [3, 3, 3, 3, 4, 5, 6, 6, 6, 6]
4147
-
4148
- b = Numo::Int32.new(10).seq
4149
- # => Numo::Int32#shape=[10]
4150
- # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
4151
-
4152
- b.clip([3,4,1,1,1,4,4,4,4,4], 8)
4153
- # => Numo::Int32#shape=[10]
4154
- # [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]
4155
- */
4156
3922
  static VALUE dfloat_clip(VALUE self, VALUE min, VALUE max) {
4157
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {cT, 0}, {cT, 0}};
4158
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4159
- ndfunc_t ndf_min = {iter_dfloat_clip_min, STRIDE_LOOP, 2, 1, ain, aout};
4160
- ndfunc_t ndf_max = {iter_dfloat_clip_max, STRIDE_LOOP, 2, 1, ain, aout};
4161
- ndfunc_t ndf_both = {iter_dfloat_clip, STRIDE_LOOP, 3, 1, ain, aout};
3923
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { cT, 0 }, { cT, 0 } };
3924
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
3925
+ ndfunc_t ndf_min = { iter_dfloat_clip_min, STRIDE_LOOP, 2, 1, ain, aout };
3926
+ ndfunc_t ndf_max = { iter_dfloat_clip_max, STRIDE_LOOP, 2, 1, ain, aout };
3927
+ ndfunc_t ndf_both = { iter_dfloat_clip, STRIDE_LOOP, 3, 1, ain, aout };
4162
3928
 
4163
3929
  if (RTEST(min)) {
4164
3930
  if (RTEST(max)) {
@@ -4204,15 +3970,10 @@ static void iter_dfloat_isnan(na_loop_t* const lp) {
4204
3970
  }
4205
3971
  }
4206
3972
 
4207
- /*
4208
- Condition of isnan.
4209
- @overload isnan
4210
- @return [Numo::Bit] Condition of isnan.
4211
- */
4212
3973
  static VALUE dfloat_isnan(VALUE self) {
4213
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
4214
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
4215
- ndfunc_t ndf = {iter_dfloat_isnan, FULL_LOOP, 1, 1, ain, aout};
3974
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
3975
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
3976
+ ndfunc_t ndf = { iter_dfloat_isnan, FULL_LOOP, 1, 1, ain, aout };
4216
3977
 
4217
3978
  return na_ndloop(&ndf, 1, self);
4218
3979
  }
@@ -4246,15 +4007,10 @@ static void iter_dfloat_isinf(na_loop_t* const lp) {
4246
4007
  }
4247
4008
  }
4248
4009
 
4249
- /*
4250
- Condition of isinf.
4251
- @overload isinf
4252
- @return [Numo::Bit] Condition of isinf.
4253
- */
4254
4010
  static VALUE dfloat_isinf(VALUE self) {
4255
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
4256
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
4257
- ndfunc_t ndf = {iter_dfloat_isinf, FULL_LOOP, 1, 1, ain, aout};
4011
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
4012
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
4013
+ ndfunc_t ndf = { iter_dfloat_isinf, FULL_LOOP, 1, 1, ain, aout };
4258
4014
 
4259
4015
  return na_ndloop(&ndf, 1, self);
4260
4016
  }
@@ -4288,15 +4044,10 @@ static void iter_dfloat_isposinf(na_loop_t* const lp) {
4288
4044
  }
4289
4045
  }
4290
4046
 
4291
- /*
4292
- Condition of isposinf.
4293
- @overload isposinf
4294
- @return [Numo::Bit] Condition of isposinf.
4295
- */
4296
4047
  static VALUE dfloat_isposinf(VALUE self) {
4297
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
4298
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
4299
- ndfunc_t ndf = {iter_dfloat_isposinf, FULL_LOOP, 1, 1, ain, aout};
4048
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
4049
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
4050
+ ndfunc_t ndf = { iter_dfloat_isposinf, FULL_LOOP, 1, 1, ain, aout };
4300
4051
 
4301
4052
  return na_ndloop(&ndf, 1, self);
4302
4053
  }
@@ -4330,15 +4081,10 @@ static void iter_dfloat_isneginf(na_loop_t* const lp) {
4330
4081
  }
4331
4082
  }
4332
4083
 
4333
- /*
4334
- Condition of isneginf.
4335
- @overload isneginf
4336
- @return [Numo::Bit] Condition of isneginf.
4337
- */
4338
4084
  static VALUE dfloat_isneginf(VALUE self) {
4339
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
4340
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
4341
- ndfunc_t ndf = {iter_dfloat_isneginf, FULL_LOOP, 1, 1, ain, aout};
4085
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
4086
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
4087
+ ndfunc_t ndf = { iter_dfloat_isneginf, FULL_LOOP, 1, 1, ain, aout };
4342
4088
 
4343
4089
  return na_ndloop(&ndf, 1, self);
4344
4090
  }
@@ -4372,15 +4118,10 @@ static void iter_dfloat_isfinite(na_loop_t* const lp) {
4372
4118
  }
4373
4119
  }
4374
4120
 
4375
- /*
4376
- Condition of isfinite.
4377
- @overload isfinite
4378
- @return [Numo::Bit] Condition of isfinite.
4379
- */
4380
4121
  static VALUE dfloat_isfinite(VALUE self) {
4381
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
4382
- ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
4383
- ndfunc_t ndf = {iter_dfloat_isfinite, FULL_LOOP, 1, 1, ain, aout};
4122
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
4123
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
4124
+ ndfunc_t ndf = { iter_dfloat_isfinite, FULL_LOOP, 1, 1, ain, aout };
4384
4125
 
4385
4126
  return na_ndloop(&ndf, 1, self);
4386
4127
  }
@@ -4408,19 +4149,11 @@ static void iter_dfloat_sum_nan(na_loop_t* const lp) {
4408
4149
  *(dtype*)p2 = f_sum_nan(n, p1, s1);
4409
4150
  }
4410
4151
 
4411
- /*
4412
- sum of self.
4413
- @overload sum(axis:nil, keepdims:false, nan:false)
4414
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
4415
- @param [Numeric,Array,Range] axis Performs sum along the axis.
4416
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
4417
- @return [Numo::DFloat] returns result of sum.
4418
- */
4419
4152
  static VALUE dfloat_sum(int argc, VALUE* argv, VALUE self) {
4420
4153
  VALUE v, reduce;
4421
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4422
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4423
- ndfunc_t ndf = {iter_dfloat_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
4154
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
4155
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4156
+ ndfunc_t ndf = { iter_dfloat_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
4424
4157
 
4425
4158
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_sum_nan);
4426
4159
 
@@ -4452,19 +4185,11 @@ static void iter_dfloat_prod_nan(na_loop_t* const lp) {
4452
4185
  *(dtype*)p2 = f_prod_nan(n, p1, s1);
4453
4186
  }
4454
4187
 
4455
- /*
4456
- prod of self.
4457
- @overload prod(axis:nil, keepdims:false, nan:false)
4458
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
4459
- @param [Numeric,Array,Range] axis Performs prod along the axis.
4460
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
4461
- @return [Numo::DFloat] returns result of prod.
4462
- */
4463
4188
  static VALUE dfloat_prod(int argc, VALUE* argv, VALUE self) {
4464
4189
  VALUE v, reduce;
4465
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4466
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4467
- ndfunc_t ndf = {iter_dfloat_prod, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
4190
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
4191
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4192
+ ndfunc_t ndf = { iter_dfloat_prod, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
4468
4193
 
4469
4194
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_prod_nan);
4470
4195
 
@@ -4496,19 +4221,11 @@ static void iter_dfloat_kahan_sum_nan(na_loop_t* const lp) {
4496
4221
  *(dtype*)p2 = f_kahan_sum_nan(n, p1, s1);
4497
4222
  }
4498
4223
 
4499
- /*
4500
- kahan_sum of self.
4501
- @overload kahan_sum(axis:nil, keepdims:false, nan:false)
4502
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
4503
- @param [Numeric,Array,Range] axis Performs kahan_sum along the axis.
4504
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
4505
- @return [Numo::DFloat] returns result of kahan_sum.
4506
- */
4507
4224
  static VALUE dfloat_kahan_sum(int argc, VALUE* argv, VALUE self) {
4508
4225
  VALUE v, reduce;
4509
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4510
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4511
- ndfunc_t ndf = {iter_dfloat_kahan_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
4226
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
4227
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4228
+ ndfunc_t ndf = { iter_dfloat_kahan_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
4512
4229
 
4513
4230
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_kahan_sum_nan);
4514
4231
 
@@ -4517,182 +4234,6 @@ static VALUE dfloat_kahan_sum(int argc, VALUE* argv, VALUE self) {
4517
4234
  return dfloat_extract(v);
4518
4235
  }
4519
4236
 
4520
- static void iter_dfloat_mean(na_loop_t* const lp) {
4521
- size_t n;
4522
- char *p1, *p2;
4523
- ssize_t s1;
4524
-
4525
- INIT_COUNTER(lp, n);
4526
- INIT_PTR(lp, 0, p1, s1);
4527
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
4528
-
4529
- *(dtype*)p2 = f_mean(n, p1, s1);
4530
- }
4531
- static void iter_dfloat_mean_nan(na_loop_t* const lp) {
4532
- size_t n;
4533
- char *p1, *p2;
4534
- ssize_t s1;
4535
-
4536
- INIT_COUNTER(lp, n);
4537
- INIT_PTR(lp, 0, p1, s1);
4538
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
4539
-
4540
- *(dtype*)p2 = f_mean_nan(n, p1, s1);
4541
- }
4542
-
4543
- /*
4544
- mean of self.
4545
- @overload mean(axis:nil, keepdims:false, nan:false)
4546
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
4547
- @param [Numeric,Array,Range] axis Performs mean along the axis.
4548
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
4549
- @return [Numo::DFloat] returns result of mean.
4550
- */
4551
- static VALUE dfloat_mean(int argc, VALUE* argv, VALUE self) {
4552
- VALUE v, reduce;
4553
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4554
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4555
- ndfunc_t ndf = {iter_dfloat_mean, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
4556
-
4557
- reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_mean_nan);
4558
-
4559
- v = na_ndloop(&ndf, 2, self, reduce);
4560
-
4561
- return dfloat_extract(v);
4562
- }
4563
-
4564
- static void iter_dfloat_stddev(na_loop_t* const lp) {
4565
- size_t n;
4566
- char *p1, *p2;
4567
- ssize_t s1;
4568
-
4569
- INIT_COUNTER(lp, n);
4570
- INIT_PTR(lp, 0, p1, s1);
4571
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
4572
-
4573
- *(rtype*)p2 = f_stddev(n, p1, s1);
4574
- }
4575
- static void iter_dfloat_stddev_nan(na_loop_t* const lp) {
4576
- size_t n;
4577
- char *p1, *p2;
4578
- ssize_t s1;
4579
-
4580
- INIT_COUNTER(lp, n);
4581
- INIT_PTR(lp, 0, p1, s1);
4582
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
4583
-
4584
- *(rtype*)p2 = f_stddev_nan(n, p1, s1);
4585
- }
4586
-
4587
- /*
4588
- stddev of self.
4589
- @overload stddev(axis:nil, keepdims:false, nan:false)
4590
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
4591
- @param [Numeric,Array,Range] axis Performs stddev along the axis.
4592
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
4593
- @return [Numo::DFloat] returns result of stddev.
4594
- */
4595
- static VALUE dfloat_stddev(int argc, VALUE* argv, VALUE self) {
4596
- VALUE v, reduce;
4597
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4598
- ndfunc_arg_out_t aout[1] = {{cRT, 0}};
4599
- ndfunc_t ndf = {iter_dfloat_stddev, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
4600
-
4601
- reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_stddev_nan);
4602
-
4603
- v = na_ndloop(&ndf, 2, self, reduce);
4604
-
4605
- return rb_funcall(v, rb_intern("extract"), 0);
4606
- }
4607
-
4608
- static void iter_dfloat_var(na_loop_t* const lp) {
4609
- size_t n;
4610
- char *p1, *p2;
4611
- ssize_t s1;
4612
-
4613
- INIT_COUNTER(lp, n);
4614
- INIT_PTR(lp, 0, p1, s1);
4615
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
4616
-
4617
- *(rtype*)p2 = f_var(n, p1, s1);
4618
- }
4619
- static void iter_dfloat_var_nan(na_loop_t* const lp) {
4620
- size_t n;
4621
- char *p1, *p2;
4622
- ssize_t s1;
4623
-
4624
- INIT_COUNTER(lp, n);
4625
- INIT_PTR(lp, 0, p1, s1);
4626
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
4627
-
4628
- *(rtype*)p2 = f_var_nan(n, p1, s1);
4629
- }
4630
-
4631
- /*
4632
- var of self.
4633
- @overload var(axis:nil, keepdims:false, nan:false)
4634
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
4635
- @param [Numeric,Array,Range] axis Performs var along the axis.
4636
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
4637
- @return [Numo::DFloat] returns result of var.
4638
- */
4639
- static VALUE dfloat_var(int argc, VALUE* argv, VALUE self) {
4640
- VALUE v, reduce;
4641
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4642
- ndfunc_arg_out_t aout[1] = {{cRT, 0}};
4643
- ndfunc_t ndf = {iter_dfloat_var, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
4644
-
4645
- reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_var_nan);
4646
-
4647
- v = na_ndloop(&ndf, 2, self, reduce);
4648
-
4649
- return rb_funcall(v, rb_intern("extract"), 0);
4650
- }
4651
-
4652
- static void iter_dfloat_rms(na_loop_t* const lp) {
4653
- size_t n;
4654
- char *p1, *p2;
4655
- ssize_t s1;
4656
-
4657
- INIT_COUNTER(lp, n);
4658
- INIT_PTR(lp, 0, p1, s1);
4659
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
4660
-
4661
- *(rtype*)p2 = f_rms(n, p1, s1);
4662
- }
4663
- static void iter_dfloat_rms_nan(na_loop_t* const lp) {
4664
- size_t n;
4665
- char *p1, *p2;
4666
- ssize_t s1;
4667
-
4668
- INIT_COUNTER(lp, n);
4669
- INIT_PTR(lp, 0, p1, s1);
4670
- p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
4671
-
4672
- *(rtype*)p2 = f_rms_nan(n, p1, s1);
4673
- }
4674
-
4675
- /*
4676
- rms of self.
4677
- @overload rms(axis:nil, keepdims:false, nan:false)
4678
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
4679
- @param [Numeric,Array,Range] axis Performs rms along the axis.
4680
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
4681
- @return [Numo::DFloat] returns result of rms.
4682
- */
4683
- static VALUE dfloat_rms(int argc, VALUE* argv, VALUE self) {
4684
- VALUE v, reduce;
4685
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4686
- ndfunc_arg_out_t aout[1] = {{cRT, 0}};
4687
- ndfunc_t ndf = {iter_dfloat_rms, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
4688
-
4689
- reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_rms_nan);
4690
-
4691
- v = na_ndloop(&ndf, 2, self, reduce);
4692
-
4693
- return rb_funcall(v, rb_intern("extract"), 0);
4694
- }
4695
-
4696
4237
  static void iter_dfloat_min(na_loop_t* const lp) {
4697
4238
  size_t n;
4698
4239
  char *p1, *p2;
@@ -4716,19 +4257,11 @@ static void iter_dfloat_min_nan(na_loop_t* const lp) {
4716
4257
  *(dtype*)p2 = f_min_nan(n, p1, s1);
4717
4258
  }
4718
4259
 
4719
- /*
4720
- min of self.
4721
- @overload min(axis:nil, keepdims:false, nan:false)
4722
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
4723
- @param [Numeric,Array,Range] axis Performs min along the axis.
4724
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
4725
- @return [Numo::DFloat] returns result of min.
4726
- */
4727
4260
  static VALUE dfloat_min(int argc, VALUE* argv, VALUE self) {
4728
4261
  VALUE v, reduce;
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 = {iter_dfloat_min, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
4262
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
4263
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4264
+ ndfunc_t ndf = { iter_dfloat_min, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
4732
4265
 
4733
4266
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_min_nan);
4734
4267
 
@@ -4760,19 +4293,11 @@ static void iter_dfloat_max_nan(na_loop_t* const lp) {
4760
4293
  *(dtype*)p2 = f_max_nan(n, p1, s1);
4761
4294
  }
4762
4295
 
4763
- /*
4764
- max of self.
4765
- @overload max(axis:nil, keepdims:false, nan:false)
4766
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
4767
- @param [Numeric,Array,Range] axis Performs max along the axis.
4768
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
4769
- @return [Numo::DFloat] returns result of max.
4770
- */
4771
4296
  static VALUE dfloat_max(int argc, VALUE* argv, VALUE self) {
4772
4297
  VALUE v, reduce;
4773
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4774
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4775
- ndfunc_t ndf = {iter_dfloat_max, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
4298
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
4299
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4300
+ ndfunc_t ndf = { iter_dfloat_max, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
4776
4301
 
4777
4302
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_max_nan);
4778
4303
 
@@ -4804,19 +4329,11 @@ static void iter_dfloat_ptp_nan(na_loop_t* const lp) {
4804
4329
  *(dtype*)p2 = f_ptp_nan(n, p1, s1);
4805
4330
  }
4806
4331
 
4807
- /*
4808
- ptp of self.
4809
- @overload ptp(axis:nil, keepdims:false, nan:false)
4810
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
4811
- @param [Numeric,Array,Range] axis Performs ptp along the axis.
4812
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
4813
- @return [Numo::DFloat] returns result of ptp.
4814
- */
4815
4332
  static VALUE dfloat_ptp(int argc, VALUE* argv, VALUE self) {
4816
4333
  VALUE v, reduce;
4817
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
4818
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
4819
- ndfunc_t ndf = {iter_dfloat_ptp, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
4334
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
4335
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4336
+ ndfunc_t ndf = { iter_dfloat_ptp, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
4820
4337
 
4821
4338
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_ptp_nan);
4822
4339
 
@@ -4893,31 +4410,12 @@ static void iter_dfloat_max_index_index32_nan(na_loop_t* const lp) {
4893
4410
  }
4894
4411
  #undef idx_t
4895
4412
 
4896
- /*
4897
- Index of the maximum value.
4898
- @overload max_index(axis:nil, nan:false)
4899
- @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
4900
- @param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat 1-d indices**.
4901
- @return [Integer,Numo::Int] returns result indices.
4902
- @see #argmax
4903
- @see #max
4904
-
4905
- @example
4906
- a = Numo::NArray[3,4,1,2]
4907
- a.max_index #=> 1
4908
-
4909
- b = Numo::NArray[[3,4,1],[2,0,5]]
4910
- b.max_index #=> 5
4911
- b.max_index(axis:1) #=> [1, 5]
4912
- b.max_index(axis:0) #=> [0, 1, 5]
4913
- b[b.max_index(axis:0)] #=> [3, 4, 5]
4914
- */
4915
4413
  static VALUE dfloat_max_index(int argc, VALUE* argv, VALUE self) {
4916
4414
  narray_t* na;
4917
4415
  VALUE idx, reduce;
4918
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {Qnil, 0}, {sym_reduce, 0}};
4919
- ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
4920
- ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout};
4416
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { Qnil, 0 }, { sym_reduce, 0 } };
4417
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
4418
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout };
4921
4419
 
4922
4420
  GetNArray(self, na);
4923
4421
  if (na->ndim == 0) {
@@ -5010,31 +4508,12 @@ static void iter_dfloat_min_index_index32_nan(na_loop_t* const lp) {
5010
4508
  }
5011
4509
  #undef idx_t
5012
4510
 
5013
- /*
5014
- Index of the minimum value.
5015
- @overload min_index(axis:nil, nan:false)
5016
- @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
5017
- @param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat 1-d indices**.
5018
- @return [Integer,Numo::Int] returns result indices.
5019
- @see #argmin
5020
- @see #min
5021
-
5022
- @example
5023
- a = Numo::NArray[3,4,1,2]
5024
- a.min_index #=> 2
5025
-
5026
- b = Numo::NArray[[3,4,1],[2,0,5]]
5027
- b.min_index #=> 4
5028
- b.min_index(axis:1) #=> [2, 4]
5029
- b.min_index(axis:0) #=> [3, 4, 2]
5030
- b[b.min_index(axis:0)] #=> [2, 0, 1]
5031
- */
5032
4511
  static VALUE dfloat_min_index(int argc, VALUE* argv, VALUE self) {
5033
4512
  narray_t* na;
5034
4513
  VALUE idx, reduce;
5035
- ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {Qnil, 0}, {sym_reduce, 0}};
5036
- ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
5037
- ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout};
4514
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { Qnil, 0 }, { sym_reduce, 0 } };
4515
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
4516
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout };
5038
4517
 
5039
4518
  GetNArray(self, na);
5040
4519
  if (na->ndim == 0) {
@@ -5123,31 +4602,12 @@ static void iter_dfloat_argmax_arg32_nan(na_loop_t* const lp) {
5123
4602
  }
5124
4603
  #undef idx_t
5125
4604
 
5126
- /*
5127
- Index of the maximum value.
5128
- @overload argmax(axis:nil, nan:false)
5129
- @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
5130
- @param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices along the axis**.
5131
- @return [Integer,Numo::Int] returns the result indices.
5132
- @see #max_index
5133
- @see #max
5134
-
5135
- @example
5136
- a = Numo::NArray[3,4,1,2]
5137
- a.argmax #=> 1
5138
-
5139
- b = Numo::NArray[[3,4,1],[2,0,5]]
5140
- b.argmax #=> 5
5141
- b.argmax(axis:1) #=> [1, 2]
5142
- b.argmax(axis:0) #=> [0, 0, 1]
5143
- b.at(b.argmax(axis:0), 0..-1) #=> [3, 4, 5]
5144
- */
5145
4605
  static VALUE dfloat_argmax(int argc, VALUE* argv, VALUE self) {
5146
4606
  narray_t* na;
5147
4607
  VALUE reduce;
5148
- ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_reduce, 0}};
5149
- ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
5150
- ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout};
4608
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } };
4609
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
4610
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout };
5151
4611
 
5152
4612
  GetNArray(self, na);
5153
4613
  if (na->ndim == 0) {
@@ -5233,31 +4693,12 @@ static void iter_dfloat_argmin_arg32_nan(na_loop_t* const lp) {
5233
4693
  }
5234
4694
  #undef idx_t
5235
4695
 
5236
- /*
5237
- Index of the minimum value.
5238
- @overload argmin(axis:nil, nan:false)
5239
- @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
5240
- @param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices along the axis**.
5241
- @return [Integer,Numo::Int] returns the result indices.
5242
- @see #min_index
5243
- @see #min
5244
-
5245
- @example
5246
- a = Numo::NArray[3,4,1,2]
5247
- a.argmin #=> 2
5248
-
5249
- b = Numo::NArray[[3,4,1],[2,0,5]]
5250
- b.argmin #=> 4
5251
- b.argmin(axis:1) #=> [2, 1]
5252
- b.argmin(axis:0) #=> [1, 1, 0]
5253
- b.at(b.argmin(axis:0), 0..-1) #=> [2, 0, 1]
5254
- */
5255
4696
  static VALUE dfloat_argmin(int argc, VALUE* argv, VALUE self) {
5256
4697
  narray_t* na;
5257
4698
  VALUE reduce;
5258
- ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_reduce, 0}};
5259
- ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
5260
- ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout};
4699
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } };
4700
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
4701
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout };
5261
4702
 
5262
4703
  GetNArray(self, na);
5263
4704
  if (na->ndim == 0) {
@@ -5308,35 +4749,19 @@ static void iter_dfloat_minmax_nan(na_loop_t* const lp) {
5308
4749
  *(dtype*)(lp->args[2].ptr + lp->args[2].iter[0].pos) = xmax;
5309
4750
  }
5310
4751
 
5311
- /*
5312
- minmax of self.
5313
- @overload minmax(axis:nil, keepdims:false, nan:false)
5314
- @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
5315
- @param [Numeric,Array,Range] axis Finds min-max along the axis.
5316
- @param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
5317
- @return [Numo::DFloat,Numo::DFloat] min and max of self.
5318
- */
5319
4752
  static VALUE dfloat_minmax(int argc, VALUE* argv, VALUE self) {
5320
4753
  VALUE reduce;
5321
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
5322
- ndfunc_arg_out_t aout[2] = {{cT, 0}, {cT, 0}};
5323
- ndfunc_t ndf = {iter_dfloat_minmax, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 2, ain, aout};
4754
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
4755
+ ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
4756
+ ndfunc_t ndf = {
4757
+ iter_dfloat_minmax, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 2, ain, aout
4758
+ };
5324
4759
 
5325
4760
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_minmax_nan);
5326
4761
 
5327
4762
  return na_ndloop(&ndf, 2, self, reduce);
5328
4763
  }
5329
4764
 
5330
- /*
5331
- Element-wise maximum of two arrays.
5332
-
5333
- @overload maximum(a1, a2, nan:false)
5334
- @param [Numo::NArray,Numeric] a1 The array to be compared.
5335
- @param [Numo::NArray,Numeric] a2 The array to be compared.
5336
- @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
5337
- @return [Numo::DFloat]
5338
- */
5339
-
5340
4765
  static void iter_dfloat_s_maximum(na_loop_t* const lp) {
5341
4766
  size_t i, n;
5342
4767
  char *p1, *p2, *p3;
@@ -5379,13 +4804,13 @@ static void iter_dfloat_s_maximum_nan(na_loop_t* const lp) {
5379
4804
  static VALUE dfloat_s_maximum(int argc, VALUE* argv, VALUE mod) {
5380
4805
  VALUE a1 = Qnil;
5381
4806
  VALUE a2 = Qnil;
5382
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
5383
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
5384
- ndfunc_t ndf = {iter_dfloat_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout};
4807
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
4808
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4809
+ ndfunc_t ndf = { iter_dfloat_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
5385
4810
 
5386
4811
  VALUE kw_hash = Qnil;
5387
- ID kw_table[1] = {id_nan};
5388
- VALUE opts[1] = {Qundef};
4812
+ ID kw_table[1] = { id_nan };
4813
+ VALUE opts[1] = { Qundef };
5389
4814
 
5390
4815
  rb_scan_args(argc, argv, "20:", &a1, &a2, &kw_hash);
5391
4816
  rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
@@ -5396,16 +4821,6 @@ static VALUE dfloat_s_maximum(int argc, VALUE* argv, VALUE mod) {
5396
4821
  return na_ndloop(&ndf, 2, a1, a2);
5397
4822
  }
5398
4823
 
5399
- /*
5400
- Element-wise minimum of two arrays.
5401
-
5402
- @overload minimum(a1, a2, nan:false)
5403
- @param [Numo::NArray,Numeric] a1 The array to be compared.
5404
- @param [Numo::NArray,Numeric] a2 The array to be compared.
5405
- @param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
5406
- @return [Numo::DFloat]
5407
- */
5408
-
5409
4824
  static void iter_dfloat_s_minimum(na_loop_t* const lp) {
5410
4825
  size_t i, n;
5411
4826
  char *p1, *p2, *p3;
@@ -5448,13 +4863,13 @@ static void iter_dfloat_s_minimum_nan(na_loop_t* const lp) {
5448
4863
  static VALUE dfloat_s_minimum(int argc, VALUE* argv, VALUE mod) {
5449
4864
  VALUE a1 = Qnil;
5450
4865
  VALUE a2 = Qnil;
5451
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
5452
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
5453
- ndfunc_t ndf = {iter_dfloat_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout};
4866
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
4867
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4868
+ ndfunc_t ndf = { iter_dfloat_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
5454
4869
 
5455
4870
  VALUE kw_hash = Qnil;
5456
- ID kw_table[1] = {id_nan};
5457
- VALUE opts[1] = {Qundef};
4871
+ ID kw_table[1] = { id_nan };
4872
+ VALUE opts[1] = { Qundef };
5458
4873
 
5459
4874
  rb_scan_args(argc, argv, "20:", &a1, &a2, &kw_hash);
5460
4875
  rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
@@ -5474,16 +4889,13 @@ static void iter_dfloat_cumsum(na_loop_t* const lp) {
5474
4889
  INIT_COUNTER(lp, i);
5475
4890
  INIT_PTR(lp, 0, p1, s1);
5476
4891
  INIT_PTR(lp, 1, p2, s2);
5477
- // printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
5478
4892
 
5479
4893
  GET_DATA_STRIDE(p1, s1, dtype, x);
5480
4894
  SET_DATA_STRIDE(p2, s2, dtype, x);
5481
- // printf("i=%lu x=%f\n",i,x);
5482
4895
  for (i--; i--;) {
5483
4896
  GET_DATA_STRIDE(p1, s1, dtype, y);
5484
4897
  m_cumsum(x, y);
5485
4898
  SET_DATA_STRIDE(p2, s2, dtype, x);
5486
- // printf("i=%lu x=%f\n",i,x);
5487
4899
  }
5488
4900
  }
5489
4901
  static void iter_dfloat_cumsum_nan(na_loop_t* const lp) {
@@ -5495,31 +4907,23 @@ static void iter_dfloat_cumsum_nan(na_loop_t* const lp) {
5495
4907
  INIT_COUNTER(lp, i);
5496
4908
  INIT_PTR(lp, 0, p1, s1);
5497
4909
  INIT_PTR(lp, 1, p2, s2);
5498
- // printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
5499
4910
 
5500
4911
  GET_DATA_STRIDE(p1, s1, dtype, x);
5501
4912
  SET_DATA_STRIDE(p2, s2, dtype, x);
5502
- // printf("i=%lu x=%f\n",i,x);
5503
4913
  for (i--; i--;) {
5504
4914
  GET_DATA_STRIDE(p1, s1, dtype, y);
5505
4915
  m_cumsum_nan(x, y);
5506
4916
  SET_DATA_STRIDE(p2, s2, dtype, x);
5507
- // printf("i=%lu x=%f\n",i,x);
5508
4917
  }
5509
4918
  }
5510
4919
 
5511
- /*
5512
- cumsum of self.
5513
- @overload cumsum(axis:nil, nan:false)
5514
- @param [Numeric,Array,Range] axis Performs cumsum along the axis.
5515
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
5516
- @return [Numo::DFloat] cumsum of self.
5517
- */
5518
4920
  static VALUE dfloat_cumsum(int argc, VALUE* argv, VALUE self) {
5519
4921
  VALUE reduce;
5520
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
5521
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
5522
- ndfunc_t ndf = {iter_dfloat_cumsum, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout};
4922
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
4923
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4924
+ ndfunc_t ndf = {
4925
+ iter_dfloat_cumsum, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout
4926
+ };
5523
4927
 
5524
4928
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_cumsum_nan);
5525
4929
 
@@ -5535,16 +4939,13 @@ static void iter_dfloat_cumprod(na_loop_t* const lp) {
5535
4939
  INIT_COUNTER(lp, i);
5536
4940
  INIT_PTR(lp, 0, p1, s1);
5537
4941
  INIT_PTR(lp, 1, p2, s2);
5538
- // printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
5539
4942
 
5540
4943
  GET_DATA_STRIDE(p1, s1, dtype, x);
5541
4944
  SET_DATA_STRIDE(p2, s2, dtype, x);
5542
- // printf("i=%lu x=%f\n",i,x);
5543
4945
  for (i--; i--;) {
5544
4946
  GET_DATA_STRIDE(p1, s1, dtype, y);
5545
4947
  m_cumprod(x, y);
5546
4948
  SET_DATA_STRIDE(p2, s2, dtype, x);
5547
- // printf("i=%lu x=%f\n",i,x);
5548
4949
  }
5549
4950
  }
5550
4951
  static void iter_dfloat_cumprod_nan(na_loop_t* const lp) {
@@ -5556,31 +4957,23 @@ static void iter_dfloat_cumprod_nan(na_loop_t* const lp) {
5556
4957
  INIT_COUNTER(lp, i);
5557
4958
  INIT_PTR(lp, 0, p1, s1);
5558
4959
  INIT_PTR(lp, 1, p2, s2);
5559
- // printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
5560
4960
 
5561
4961
  GET_DATA_STRIDE(p1, s1, dtype, x);
5562
4962
  SET_DATA_STRIDE(p2, s2, dtype, x);
5563
- // printf("i=%lu x=%f\n",i,x);
5564
4963
  for (i--; i--;) {
5565
4964
  GET_DATA_STRIDE(p1, s1, dtype, y);
5566
4965
  m_cumprod_nan(x, y);
5567
4966
  SET_DATA_STRIDE(p2, s2, dtype, x);
5568
- // printf("i=%lu x=%f\n",i,x);
5569
4967
  }
5570
4968
  }
5571
4969
 
5572
- /*
5573
- cumprod of self.
5574
- @overload cumprod(axis:nil, nan:false)
5575
- @param [Numeric,Array,Range] axis Performs cumprod along the axis.
5576
- @param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
5577
- @return [Numo::DFloat] cumprod of self.
5578
- */
5579
4970
  static VALUE dfloat_cumprod(int argc, VALUE* argv, VALUE self) {
5580
4971
  VALUE reduce;
5581
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
5582
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
5583
- ndfunc_t ndf = {iter_dfloat_cumprod, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout};
4972
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
4973
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
4974
+ ndfunc_t ndf = {
4975
+ iter_dfloat_cumprod, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout
4976
+ };
5584
4977
 
5585
4978
  reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_cumprod_nan);
5586
4979
 
@@ -5660,9 +5053,9 @@ static void iter_dfloat_mulsum_nan(na_loop_t* const lp) {
5660
5053
  static VALUE dfloat_mulsum_self(int argc, VALUE* argv, VALUE self) {
5661
5054
  VALUE v, reduce;
5662
5055
  VALUE naryv[2];
5663
- ndfunc_arg_in_t ain[4] = {{cT, 0}, {cT, 0}, {sym_reduce, 0}, {sym_init, 0}};
5664
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
5665
- ndfunc_t ndf = {iter_dfloat_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout};
5056
+ ndfunc_arg_in_t ain[4] = { { cT, 0 }, { cT, 0 }, { sym_reduce, 0 }, { sym_init, 0 } };
5057
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
5058
+ ndfunc_t ndf = { iter_dfloat_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout };
5666
5059
 
5667
5060
  if (argc < 1) {
5668
5061
  rb_raise(rb_eArgError, "wrong number of arguments (%d for >=1)", argc);
@@ -5678,16 +5071,6 @@ static VALUE dfloat_mulsum_self(int argc, VALUE* argv, VALUE self) {
5678
5071
  return dfloat_extract(v);
5679
5072
  }
5680
5073
 
5681
- /*
5682
- Binary mulsum.
5683
-
5684
- @overload mulsum(other, axis:nil, keepdims:false, nan:false)
5685
- @param [Numo::NArray,Numeric] other
5686
- @param [Numeric,Array,Range] axis Performs mulsum along the axis.
5687
- @param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
5688
- @param [TrueClass] nan (keyword) If true, apply NaN-aware algorithm (avoid NaN if exists).
5689
- @return [Numo::NArray] mulsum of self and other.
5690
- */
5691
5074
  static VALUE dfloat_mulsum(int argc, VALUE* argv, VALUE self) {
5692
5075
  //
5693
5076
  VALUE klass, v;
@@ -5750,28 +5133,11 @@ static void iter_dfloat_seq(na_loop_t* const lp) {
5750
5133
  g->count = c;
5751
5134
  }
5752
5135
 
5753
- /*
5754
- Set linear sequence of numbers to self. The sequence is obtained from
5755
- beg+i*step
5756
- where i is 1-dimensional index.
5757
- @overload seq([beg,[step]])
5758
- @param [Numeric] beg beginning of sequence. (default=0)
5759
- @param [Numeric] step step of sequence. (default=1)
5760
- @return [Numo::DFloat] self.
5761
- @example
5762
- Numo::DFloat.new(6).seq(1,-0.2)
5763
- # => Numo::DFloat#shape=[6]
5764
- # [1, 0.8, 0.6, 0.4, 0.2, 0]
5765
-
5766
- Numo::DComplex.new(6).seq(1,-0.2+0.2i)
5767
- # => Numo::DComplex#shape=[6]
5768
- # [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
5769
- */
5770
5136
  static VALUE dfloat_seq(int argc, VALUE* args, VALUE self) {
5771
5137
  seq_opt_t* g;
5772
5138
  VALUE vbeg = Qnil, vstep = Qnil;
5773
- ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
5774
- ndfunc_t ndf = {iter_dfloat_seq, FULL_LOOP, 1, 0, ain, 0};
5139
+ ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
5140
+ ndfunc_t ndf = { iter_dfloat_seq, FULL_LOOP, 1, 0, ain, 0 };
5775
5141
 
5776
5142
  g = ALLOCA_N(seq_opt_t, 1);
5777
5143
  g->beg = m_zero;
@@ -5829,32 +5195,11 @@ static void iter_dfloat_logseq(na_loop_t* const lp) {
5829
5195
  g->count = c;
5830
5196
  }
5831
5197
 
5832
- /*
5833
- Set logarithmic sequence of numbers to self. The sequence is obtained from
5834
- `base**(beg+i*step)`
5835
- where i is 1-dimensional index.
5836
- Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
5837
-
5838
- @overload logseq(beg,step,[base])
5839
- @param [Numeric] beg The beginning of sequence.
5840
- @param [Numeric] step The step of sequence.
5841
- @param [Numeric] base The base of log space. (default=10)
5842
- @return [Numo::DFloat] self.
5843
-
5844
- @example
5845
- Numo::DFloat.new(5).logseq(4,-1,2)
5846
- # => Numo::DFloat#shape=[5]
5847
- # [16, 8, 4, 2, 1]
5848
-
5849
- Numo::DComplex.new(5).logseq(0,1i*Math::PI/3,Math::E)
5850
- # => Numo::DComplex#shape=[5]
5851
- # [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
5852
- */
5853
5198
  static VALUE dfloat_logseq(int argc, VALUE* args, VALUE self) {
5854
5199
  logseq_opt_t* g;
5855
5200
  VALUE vbeg, vstep, vbase;
5856
- ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
5857
- ndfunc_t ndf = {iter_dfloat_logseq, FULL_LOOP, 1, 0, ain, 0};
5201
+ ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
5202
+ ndfunc_t ndf = { iter_dfloat_logseq, FULL_LOOP, 1, 0, ain, 0 };
5858
5203
 
5859
5204
  g = ALLOCA_N(logseq_opt_t, 1);
5860
5205
  rb_scan_args(argc, args, "21", &vbeg, &vstep, &vbase);
@@ -5898,18 +5243,9 @@ static void iter_dfloat_eye(na_loop_t* const lp) {
5898
5243
  }
5899
5244
  }
5900
5245
 
5901
- /*
5902
- Eye: Set a value to diagonal components, set 0 to non-diagonal components.
5903
- @overload eye([element,offset])
5904
- @param [Numeric] element Diagonal element to be stored. Default is 1.
5905
- @param [Integer] offset Diagonal offset from the main diagonal. The
5906
- default is 0. k>0 for diagonals above the main diagonal, and k<0
5907
- for diagonals below the main diagonal.
5908
- @return [Numo::DFloat] eye of self.
5909
- */
5910
5246
  static VALUE dfloat_eye(int argc, VALUE* argv, VALUE self) {
5911
- ndfunc_arg_in_t ain[1] = {{OVERWRITE, 2}};
5912
- ndfunc_t ndf = {iter_dfloat_eye, NO_LOOP, 1, 0, ain, 0};
5247
+ ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
5248
+ ndfunc_t ndf = { iter_dfloat_eye, NO_LOOP, 1, 0, ain, 0 };
5913
5249
  ssize_t kofs;
5914
5250
  dtype data;
5915
5251
  char* g;
@@ -5939,17 +5275,21 @@ static VALUE dfloat_eye(int argc, VALUE* argv, VALUE self) {
5939
5275
  // Diagonal offset from the main diagonal.
5940
5276
  if (kofs >= 0) {
5941
5277
  if ((size_t)(kofs) >= na->shape[nd - 1]) {
5942
- rb_raise(rb_eArgError,
5943
- "invalid diagonal offset(%" SZF "d) for "
5944
- "last dimension size(%" SZF "d)",
5945
- kofs, na->shape[nd - 1]);
5278
+ rb_raise(
5279
+ rb_eArgError,
5280
+ "invalid diagonal offset(%" SZF "d) for "
5281
+ "last dimension size(%" SZF "d)",
5282
+ kofs, na->shape[nd - 1]
5283
+ );
5946
5284
  }
5947
5285
  } else {
5948
5286
  if ((size_t)(-kofs) >= na->shape[nd - 2]) {
5949
- rb_raise(rb_eArgError,
5950
- "invalid diagonal offset(%" SZF "d) for "
5951
- "last-1 dimension size(%" SZF "d)",
5952
- kofs, na->shape[nd - 2]);
5287
+ rb_raise(
5288
+ rb_eArgError,
5289
+ "invalid diagonal offset(%" SZF "d) for "
5290
+ "last-1 dimension size(%" SZF "d)",
5291
+ kofs, na->shape[nd - 2]
5292
+ );
5953
5293
  }
5954
5294
  }
5955
5295
 
@@ -5995,31 +5335,12 @@ static void iter_dfloat_rand(na_loop_t* const lp) {
5995
5335
  }
5996
5336
  }
5997
5337
 
5998
- /*
5999
- Generate uniformly distributed random numbers on self narray.
6000
- @overload rand([[low],high])
6001
- @param [Numeric] low lower inclusive boundary of random numbers. (default=0)
6002
- @param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for complex types)
6003
- @return [Numo::DFloat] self.
6004
- @example
6005
- Numo::DFloat.new(6).rand
6006
- # => Numo::DFloat#shape=[6]
6007
- # [0.0617545, 0.373067, 0.794815, 0.201042, 0.116041, 0.344032]
6008
-
6009
- Numo::DComplex.new(6).rand(5+5i)
6010
- # => Numo::DComplex#shape=[6]
6011
- # [2.69974+3.68908i, 0.825443+0.254414i, 0.540323+0.34354i, 4.52061+2.39322i, ...]
6012
-
6013
- Numo::Int32.new(6).rand(2,5)
6014
- # => Numo::Int32#shape=[6]
6015
- # [4, 3, 3, 2, 4, 2]
6016
- */
6017
5338
  static VALUE dfloat_rand(int argc, VALUE* args, VALUE self) {
6018
5339
  rand_opt_t g;
6019
5340
  VALUE v1 = Qnil, v2 = Qnil;
6020
5341
  dtype high;
6021
- ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
6022
- ndfunc_t ndf = {iter_dfloat_rand, FULL_LOOP, 1, 0, ain, 0};
5342
+ ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
5343
+ ndfunc_t ndf = { iter_dfloat_rand, FULL_LOOP, 1, 0, ain, 0 };
6023
5344
 
6024
5345
  rb_scan_args(argc, args, "02", &v1, &v2);
6025
5346
  if (v2 == Qnil) {
@@ -6093,42 +5414,12 @@ static void iter_dfloat_rand_norm(na_loop_t* const lp) {
6093
5414
  }
6094
5415
  }
6095
5416
 
6096
- /*
6097
- Generates random numbers from the normal distribution on self narray
6098
- using Box-Muller Transformation.
6099
- @overload rand_norm([mu,[sigma]])
6100
- @param [Numeric] mu mean of normal distribution. (default=0)
6101
- @param [Numeric] sigma standard deviation of normal distribution. (default=1)
6102
- @return [Numo::DFloat] self.
6103
- @example
6104
- Numo::DFloat.new(5,5).rand_norm
6105
- # => Numo::DFloat#shape=[5,5]
6106
- # [[-0.581255, -0.168354, 0.586895, -0.595142, -0.802802],
6107
- # [-0.326106, 0.282922, 1.68427, 0.918499, -0.0485384],
6108
- # [-0.464453, -0.992194, 0.413794, -0.60717, -0.699695],
6109
- # [-1.64168, 0.48676, -0.875871, -1.43275, 0.812172],
6110
- # [-0.209975, -0.103612, -0.878617, -1.42495, 1.0968]]
6111
-
6112
- Numo::DFloat.new(5,5).rand_norm(10,0.1)
6113
- # => Numo::DFloat#shape=[5,5]
6114
- # [[9.9019, 9.90339, 10.0826, 9.98384, 9.72861],
6115
- # [9.81507, 10.0272, 9.91445, 10.0568, 9.88923],
6116
- # [10.0234, 9.97874, 9.96011, 9.9006, 9.99964],
6117
- # [10.0186, 9.94598, 9.92236, 9.99811, 9.97003],
6118
- # [9.79266, 9.95044, 9.95212, 9.93692, 10.2027]]
6119
-
6120
- Numo::DComplex.new(3,3).rand_norm(5+5i)
6121
- # => Numo::DComplex#shape=[3,3]
6122
- # [[5.84303+4.40052i, 4.00984+6.08982i, 5.10979+5.13215i],
6123
- # [4.26477+3.99655i, 4.90052+5.00763i, 4.46607+2.3444i],
6124
- # [4.5528+7.11003i, 5.62117+6.69094i, 5.05443+5.35133i]]
6125
- */
6126
5417
  static VALUE dfloat_rand_norm(int argc, VALUE* args, VALUE self) {
6127
5418
  int n;
6128
5419
  randn_opt_t g;
6129
5420
  VALUE v1 = Qnil, v2 = Qnil;
6130
- ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
6131
- ndfunc_t ndf = {iter_dfloat_rand_norm, FULL_LOOP, 1, 0, ain, 0};
5421
+ ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
5422
+ ndfunc_t ndf = { iter_dfloat_rand_norm, FULL_LOOP, 1, 0, ain, 0 };
6132
5423
 
6133
5424
  n = rb_scan_args(argc, args, "02", &v1, &v2);
6134
5425
  if (n == 0) {
@@ -6161,19 +5452,12 @@ static void iter_dfloat_poly(na_loop_t* const lp) {
6161
5452
  *(dtype*)(lp->args[i].ptr + lp->args[i].iter[0].pos) = y;
6162
5453
  }
6163
5454
 
6164
- /*
6165
- Calculate polynomial.
6166
- `x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
6167
- @overload poly a0, a1, ..., an
6168
- @param [Numo::NArray,Numeric] a0,a1,...,an
6169
- @return [Numo::DFloat]
6170
- */
6171
5455
  static VALUE dfloat_poly(VALUE self, VALUE args) {
6172
5456
  int argc, i;
6173
5457
  VALUE* argv;
6174
5458
  volatile VALUE v, a;
6175
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
6176
- ndfunc_t ndf = {iter_dfloat_poly, NO_LOOP, 0, 1, 0, aout};
5459
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
5460
+ ndfunc_t ndf = { iter_dfloat_poly, NO_LOOP, 0, 1, 0, aout };
6177
5461
 
6178
5462
  argc = (int)RARRAY_LEN(args);
6179
5463
  ndf.nin = argc + 1;
@@ -6253,23 +5537,28 @@ static VALUE dfloat_poly(VALUE self, VALUE args) {
6253
5537
  * We have modified their original by adding a check for already-sorted input,
6254
5538
  * which seems to be a win per discussions on pgsql-hackers around 2006-03-21.
6255
5539
  */
6256
- #define swapcode(TYPE, parmi, parmj, n) \
6257
- do { \
6258
- size_t i = (n) / sizeof(TYPE); \
6259
- TYPE* pi = (TYPE*)(void*)(parmi); \
6260
- TYPE* pj = (TYPE*)(void*)(parmj); \
6261
- do { \
6262
- TYPE t = *pi; \
6263
- *pi++ = *pj; \
6264
- *pj++ = t; \
6265
- } while (--i > 0); \
5540
+ #define swapcode(TYPE, parmi, parmj, n) \
5541
+ do { \
5542
+ size_t i = (n) / sizeof(TYPE); \
5543
+ TYPE* pi = (TYPE*)(void*)(parmi); \
5544
+ TYPE* pj = (TYPE*)(void*)(parmj); \
5545
+ do { \
5546
+ TYPE t = *pi; \
5547
+ *pi++ = *pj; \
5548
+ *pj++ = t; \
5549
+ } while (--i > 0); \
6266
5550
  } while (0)
6267
5551
 
6268
5552
  #ifdef HAVE_STDINT_H
6269
- #define SWAPINIT(a, es) swaptype = (uintptr_t)a % sizeof(long) || (es) % sizeof(long) ? 2 : (es) == sizeof(long) ? 0 : 1;
5553
+ #define SWAPINIT(a, es) \
5554
+ swaptype = (uintptr_t)a % sizeof(long) || (es) % sizeof(long) ? 2 \
5555
+ : (es) == sizeof(long) ? 0 \
5556
+ : 1;
6270
5557
  #else
6271
- #define SWAPINIT(a, es) \
6272
- swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 : (es) == sizeof(long) ? 0 : 1;
5558
+ #define SWAPINIT(a, es) \
5559
+ swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 \
5560
+ : (es) == sizeof(long) ? 0 \
5561
+ : 1;
6273
5562
  #endif
6274
5563
 
6275
5564
  static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
@@ -6279,19 +5568,20 @@ static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
6279
5568
  swapcode(char, a, b, n);
6280
5569
  }
6281
5570
 
6282
- #define swap(a, b) \
6283
- if (swaptype == 0) { \
6284
- long t = *(long*)(void*)(a); \
6285
- *(long*)(void*)(a) = *(long*)(void*)(b); \
6286
- *(long*)(void*)(b) = t; \
6287
- } else \
5571
+ #define swap(a, b) \
5572
+ if (swaptype == 0) { \
5573
+ long t = *(long*)(void*)(a); \
5574
+ *(long*)(void*)(a) = *(long*)(void*)(b); \
5575
+ *(long*)(void*)(b) = t; \
5576
+ } else \
6288
5577
  swapfunc(a, b, es, swaptype)
6289
5578
 
6290
- #define vecswap(a, b, n) \
5579
+ #define vecswap(a, b, n) \
6291
5580
  if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
6292
5581
 
6293
- #define med3(a, b, c, _cmp) \
6294
- (cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) : (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
5582
+ #define med3(a, b, c, _cmp) \
5583
+ (cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) \
5584
+ : (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
6295
5585
  #endif
6296
5586
 
6297
5587
  #undef qsort_dtype
@@ -6520,19 +5810,10 @@ static void iter_dfloat_sort_prnan(na_loop_t* const lp) {
6520
5810
  dfloat_qsort_prnan(ptr, n, step);
6521
5811
  }
6522
5812
 
6523
- /*
6524
- sort of self.
6525
- @overload sort(axis:nil, nan:false)
6526
- @param [TrueClass] nan If true, propagete NaN. If false, ignore NaN.
6527
- @param [Numeric,Array,Range] axis Performs sort along the axis.
6528
- @return [Numo::DFloat] returns result of sort.
6529
- @example
6530
- Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
6531
- */
6532
5813
  static VALUE dfloat_sort(int argc, VALUE* argv, VALUE self) {
6533
5814
  VALUE reduce;
6534
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_reduce, 0}};
6535
- ndfunc_t ndf = {0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 0, ain, 0};
5815
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
5816
+ ndfunc_t ndf = { 0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 0, ain, 0 };
6536
5817
 
6537
5818
  if (!TEST_INPLACE(self)) {
6538
5819
  self = na_copy(self);
@@ -6637,7 +5918,8 @@ loop:
6637
5918
  pm = med3(pl, pm, pn, cmp);
6638
5919
  }
6639
5920
  swap(a, pm);
6640
- for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc; pb += es, pc -= es) {
5921
+ for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc;
5922
+ pb += es, pc -= es) {
6641
5923
  while (pb <= pc && (r = cmp(pb, a)) <= 0) {
6642
5924
  if (r == 0) {
6643
5925
  swap(pa, pb);
@@ -6762,7 +6044,8 @@ loop:
6762
6044
  pm = med3(pl, pm, pn, cmp);
6763
6045
  }
6764
6046
  swap(a, pm);
6765
- for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc; pb += es, pc -= es) {
6047
+ for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc;
6048
+ pb += es, pc -= es) {
6766
6049
  while (pb <= pc && (r = cmp(pb, a)) <= 0) {
6767
6050
  if (r == 0) {
6768
6051
  swap(pa, pb);
@@ -6809,7 +6092,6 @@ static void dfloat_index64_qsort_ignan(na_loop_t* const lp) {
6809
6092
 
6810
6093
  ptr = (char**)(lp->opt_ptr);
6811
6094
 
6812
- // printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
6813
6095
  // o_ptr=%lx,o_step=%ld)\n",(size_t)ptr,(size_t)d_ptr,(ssize_t)d_step,(size_t)i_ptr,(ssize_t)i_step,(size_t)o_ptr,(ssize_t)o_step);
6814
6096
 
6815
6097
  if (n == 1) {
@@ -6819,21 +6101,17 @@ static void dfloat_index64_qsort_ignan(na_loop_t* const lp) {
6819
6101
 
6820
6102
  for (i = 0; i < n; i++) {
6821
6103
  ptr[i] = d_ptr + d_step * i;
6822
- // printf("(%ld,%.3f)",i,*(double*)ptr[i]);
6823
6104
  }
6824
6105
 
6825
6106
  dfloat_index_qsort_ignan(ptr, n, sizeof(dtype*));
6826
6107
 
6827
6108
  // d_ptr = lp->args[0].ptr;
6828
- // printf("(d_ptr=%lx)\n",(size_t)d_ptr);
6829
6109
 
6830
6110
  for (i = 0; i < n; i++) {
6831
6111
  idx = (ptr[i] - d_ptr) / d_step;
6832
6112
  *(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
6833
- // printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
6834
6113
  o_ptr += o_step;
6835
6114
  }
6836
- // printf("\n");
6837
6115
  }
6838
6116
  #undef idx_t
6839
6117
 
@@ -6851,7 +6129,6 @@ static void dfloat_index32_qsort_ignan(na_loop_t* const lp) {
6851
6129
 
6852
6130
  ptr = (char**)(lp->opt_ptr);
6853
6131
 
6854
- // printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
6855
6132
  // o_ptr=%lx,o_step=%ld)\n",(size_t)ptr,(size_t)d_ptr,(ssize_t)d_step,(size_t)i_ptr,(ssize_t)i_step,(size_t)o_ptr,(ssize_t)o_step);
6856
6133
 
6857
6134
  if (n == 1) {
@@ -6861,21 +6138,17 @@ static void dfloat_index32_qsort_ignan(na_loop_t* const lp) {
6861
6138
 
6862
6139
  for (i = 0; i < n; i++) {
6863
6140
  ptr[i] = d_ptr + d_step * i;
6864
- // printf("(%ld,%.3f)",i,*(double*)ptr[i]);
6865
6141
  }
6866
6142
 
6867
6143
  dfloat_index_qsort_ignan(ptr, n, sizeof(dtype*));
6868
6144
 
6869
6145
  // d_ptr = lp->args[0].ptr;
6870
- // printf("(d_ptr=%lx)\n",(size_t)d_ptr);
6871
6146
 
6872
6147
  for (i = 0; i < n; i++) {
6873
6148
  idx = (ptr[i] - d_ptr) / d_step;
6874
6149
  *(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
6875
- // printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
6876
6150
  o_ptr += o_step;
6877
6151
  }
6878
- // printf("\n");
6879
6152
  }
6880
6153
  #undef idx_t
6881
6154
 
@@ -6893,7 +6166,6 @@ static void dfloat_index64_qsort_prnan(na_loop_t* const lp) {
6893
6166
 
6894
6167
  ptr = (char**)(lp->opt_ptr);
6895
6168
 
6896
- // printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
6897
6169
  // o_ptr=%lx,o_step=%ld)\n",(size_t)ptr,(size_t)d_ptr,(ssize_t)d_step,(size_t)i_ptr,(ssize_t)i_step,(size_t)o_ptr,(ssize_t)o_step);
6898
6170
 
6899
6171
  if (n == 1) {
@@ -6903,21 +6175,17 @@ static void dfloat_index64_qsort_prnan(na_loop_t* const lp) {
6903
6175
 
6904
6176
  for (i = 0; i < n; i++) {
6905
6177
  ptr[i] = d_ptr + d_step * i;
6906
- // printf("(%ld,%.3f)",i,*(double*)ptr[i]);
6907
6178
  }
6908
6179
 
6909
6180
  dfloat_index_qsort_prnan(ptr, n, sizeof(dtype*));
6910
6181
 
6911
6182
  // d_ptr = lp->args[0].ptr;
6912
- // printf("(d_ptr=%lx)\n",(size_t)d_ptr);
6913
6183
 
6914
6184
  for (i = 0; i < n; i++) {
6915
6185
  idx = (ptr[i] - d_ptr) / d_step;
6916
6186
  *(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
6917
- // printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
6918
6187
  o_ptr += o_step;
6919
6188
  }
6920
- // printf("\n");
6921
6189
  }
6922
6190
  #undef idx_t
6923
6191
 
@@ -6935,7 +6203,6 @@ static void dfloat_index32_qsort_prnan(na_loop_t* const lp) {
6935
6203
 
6936
6204
  ptr = (char**)(lp->opt_ptr);
6937
6205
 
6938
- // printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
6939
6206
  // o_ptr=%lx,o_step=%ld)\n",(size_t)ptr,(size_t)d_ptr,(ssize_t)d_step,(size_t)i_ptr,(ssize_t)i_step,(size_t)o_ptr,(ssize_t)o_step);
6940
6207
 
6941
6208
  if (n == 1) {
@@ -6945,41 +6212,28 @@ static void dfloat_index32_qsort_prnan(na_loop_t* const lp) {
6945
6212
 
6946
6213
  for (i = 0; i < n; i++) {
6947
6214
  ptr[i] = d_ptr + d_step * i;
6948
- // printf("(%ld,%.3f)",i,*(double*)ptr[i]);
6949
6215
  }
6950
6216
 
6951
6217
  dfloat_index_qsort_prnan(ptr, n, sizeof(dtype*));
6952
6218
 
6953
6219
  // d_ptr = lp->args[0].ptr;
6954
- // printf("(d_ptr=%lx)\n",(size_t)d_ptr);
6955
6220
 
6956
6221
  for (i = 0; i < n; i++) {
6957
6222
  idx = (ptr[i] - d_ptr) / d_step;
6958
6223
  *(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
6959
- // printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
6960
6224
  o_ptr += o_step;
6961
6225
  }
6962
- // printf("\n");
6963
6226
  }
6964
6227
  #undef idx_t
6965
6228
 
6966
- /*
6967
- sort_index. Returns an index array of sort result.
6968
- @overload sort_index(axis:nil, nan:false)
6969
- @param [TrueClass] nan If true, propagete NaN. If false, ignore NaN.
6970
- @param [Numeric,Array,Range] axis Performs sort_index along the axis.
6971
- @return [Integer,Numo::Int] returns result index of sort_index.
6972
- @example
6973
- Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
6974
- */
6975
6229
  static VALUE dfloat_sort_index(int argc, VALUE* argv, VALUE self) {
6976
6230
  size_t size;
6977
6231
  narray_t* na;
6978
6232
  VALUE idx, tmp, reduce, res;
6979
6233
  char* buf;
6980
- ndfunc_arg_in_t ain[3] = {{cT, 0}, {0, 0}, {sym_reduce, 0}};
6981
- ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
6982
- ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_CUM, 3, 1, ain, aout};
6234
+ ndfunc_arg_in_t ain[3] = { { cT, 0 }, { 0, 0 }, { sym_reduce, 0 } };
6235
+ ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
6236
+ ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_CUM, 3, 1, ain, aout };
6983
6237
 
6984
6238
  GetNArray(self, na);
6985
6239
  if (na->ndim == 0) {
@@ -7057,20 +6311,11 @@ static void iter_dfloat_median_prnan(na_loop_t* const lp) {
7057
6311
  }
7058
6312
  }
7059
6313
 
7060
- /*
7061
- median of self.
7062
- @overload median(axis:nil, keepdims:false, nan:false)
7063
- @param [TrueClass] nan (keyword) If true, propagete NaN. If false, ignore NaN.
7064
- @param [Numeric,Array,Range] axis Finds median along the axis.
7065
- @param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
7066
- @return [Numo::DFloat] returns median of self.
7067
- */
7068
-
7069
6314
  static VALUE dfloat_median(int argc, VALUE* argv, VALUE self) {
7070
6315
  VALUE v, reduce;
7071
- ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_reduce, 0}};
7072
- ndfunc_arg_out_t aout[1] = {{INT2FIX(0), 0}};
7073
- ndfunc_t ndf = {0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
6316
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
6317
+ ndfunc_arg_out_t aout[1] = { { INT2FIX(0), 0 } };
6318
+ ndfunc_t ndf = { 0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
7074
6319
 
7075
6320
  self = na_copy(self); // as temporary buffer
7076
6321
 
@@ -7081,10 +6326,6 @@ static VALUE dfloat_median(int argc, VALUE* argv, VALUE self) {
7081
6326
  return dfloat_extract(v);
7082
6327
  }
7083
6328
 
7084
- /*
7085
- module definition: Numo::DFloat::NMath
7086
- */
7087
-
7088
6329
  VALUE mTM;
7089
6330
 
7090
6331
  static void iter_dfloat_math_s_sqrt(na_loop_t* const lp) {
@@ -7135,9 +6376,12 @@ static void iter_dfloat_math_s_sqrt(na_loop_t* const lp) {
7135
6376
  #ifdef __SSE2__
7136
6377
  //
7137
6378
  // Check number of elements. & Check same alignment.
7138
- if ((n >= num_pack) && is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p2)[i], SIMD_ALIGNMENT_SIZE)) {
6379
+ if ((n >= num_pack) &&
6380
+ is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p2)[i], SIMD_ALIGNMENT_SIZE)) {
7139
6381
  // Calculate up to the position just before the start of SIMD computation.
7140
- cnt = get_count_of_elements_not_aligned_to_simd_size(&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype));
6382
+ cnt = get_count_of_elements_not_aligned_to_simd_size(
6383
+ &((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
6384
+ );
7141
6385
  #endif
7142
6386
  #ifdef __SSE2__
7143
6387
  for (i = 0; i < cnt; i++) {
@@ -7199,16 +6443,10 @@ static void iter_dfloat_math_s_sqrt(na_loop_t* const lp) {
7199
6443
  }
7200
6444
  }
7201
6445
 
7202
- /*
7203
- Calculate sqrt(x).
7204
- @overload sqrt(x)
7205
- @param [Numo::NArray,Numeric] x input value
7206
- @return [Numo::DFloat] result of sqrt(x).
7207
- */
7208
6446
  static VALUE dfloat_math_s_sqrt(VALUE mod, VALUE a1) {
7209
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
7210
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
7211
- ndfunc_t ndf = {iter_dfloat_math_s_sqrt, FULL_LOOP, 1, 1, ain, aout};
6447
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6448
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6449
+ ndfunc_t ndf = { iter_dfloat_math_s_sqrt, FULL_LOOP, 1, 1, ain, aout };
7212
6450
 
7213
6451
  return na_ndloop(&ndf, 1, a1);
7214
6452
  }
@@ -7277,16 +6515,10 @@ static void iter_dfloat_math_s_cbrt(na_loop_t* const lp) {
7277
6515
  }
7278
6516
  }
7279
6517
 
7280
- /*
7281
- Calculate cbrt(x).
7282
- @overload cbrt(x)
7283
- @param [Numo::NArray,Numeric] x input value
7284
- @return [Numo::DFloat] result of cbrt(x).
7285
- */
7286
6518
  static VALUE dfloat_math_s_cbrt(VALUE mod, VALUE a1) {
7287
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
7288
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
7289
- ndfunc_t ndf = {iter_dfloat_math_s_cbrt, FULL_LOOP, 1, 1, ain, aout};
6519
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6520
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6521
+ ndfunc_t ndf = { iter_dfloat_math_s_cbrt, FULL_LOOP, 1, 1, ain, aout };
7290
6522
 
7291
6523
  return na_ndloop(&ndf, 1, a1);
7292
6524
  }
@@ -7355,16 +6587,10 @@ static void iter_dfloat_math_s_log(na_loop_t* const lp) {
7355
6587
  }
7356
6588
  }
7357
6589
 
7358
- /*
7359
- Calculate log(x).
7360
- @overload log(x)
7361
- @param [Numo::NArray,Numeric] x input value
7362
- @return [Numo::DFloat] result of log(x).
7363
- */
7364
6590
  static VALUE dfloat_math_s_log(VALUE mod, VALUE a1) {
7365
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
7366
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
7367
- ndfunc_t ndf = {iter_dfloat_math_s_log, FULL_LOOP, 1, 1, ain, aout};
6591
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6592
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6593
+ ndfunc_t ndf = { iter_dfloat_math_s_log, FULL_LOOP, 1, 1, ain, aout };
7368
6594
 
7369
6595
  return na_ndloop(&ndf, 1, a1);
7370
6596
  }
@@ -7433,16 +6659,10 @@ static void iter_dfloat_math_s_log2(na_loop_t* const lp) {
7433
6659
  }
7434
6660
  }
7435
6661
 
7436
- /*
7437
- Calculate log2(x).
7438
- @overload log2(x)
7439
- @param [Numo::NArray,Numeric] x input value
7440
- @return [Numo::DFloat] result of log2(x).
7441
- */
7442
6662
  static VALUE dfloat_math_s_log2(VALUE mod, VALUE a1) {
7443
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
7444
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
7445
- ndfunc_t ndf = {iter_dfloat_math_s_log2, FULL_LOOP, 1, 1, ain, aout};
6663
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6664
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6665
+ ndfunc_t ndf = { iter_dfloat_math_s_log2, FULL_LOOP, 1, 1, ain, aout };
7446
6666
 
7447
6667
  return na_ndloop(&ndf, 1, a1);
7448
6668
  }
@@ -7511,16 +6731,10 @@ static void iter_dfloat_math_s_log10(na_loop_t* const lp) {
7511
6731
  }
7512
6732
  }
7513
6733
 
7514
- /*
7515
- Calculate log10(x).
7516
- @overload log10(x)
7517
- @param [Numo::NArray,Numeric] x input value
7518
- @return [Numo::DFloat] result of log10(x).
7519
- */
7520
6734
  static VALUE dfloat_math_s_log10(VALUE mod, VALUE a1) {
7521
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
7522
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
7523
- ndfunc_t ndf = {iter_dfloat_math_s_log10, FULL_LOOP, 1, 1, ain, aout};
6735
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6736
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6737
+ ndfunc_t ndf = { iter_dfloat_math_s_log10, FULL_LOOP, 1, 1, ain, aout };
7524
6738
 
7525
6739
  return na_ndloop(&ndf, 1, a1);
7526
6740
  }
@@ -7589,16 +6803,10 @@ static void iter_dfloat_math_s_exp(na_loop_t* const lp) {
7589
6803
  }
7590
6804
  }
7591
6805
 
7592
- /*
7593
- Calculate exp(x).
7594
- @overload exp(x)
7595
- @param [Numo::NArray,Numeric] x input value
7596
- @return [Numo::DFloat] result of exp(x).
7597
- */
7598
6806
  static VALUE dfloat_math_s_exp(VALUE mod, VALUE a1) {
7599
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
7600
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
7601
- ndfunc_t ndf = {iter_dfloat_math_s_exp, FULL_LOOP, 1, 1, ain, aout};
6807
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6808
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6809
+ ndfunc_t ndf = { iter_dfloat_math_s_exp, FULL_LOOP, 1, 1, ain, aout };
7602
6810
 
7603
6811
  return na_ndloop(&ndf, 1, a1);
7604
6812
  }
@@ -7667,16 +6875,10 @@ static void iter_dfloat_math_s_exp2(na_loop_t* const lp) {
7667
6875
  }
7668
6876
  }
7669
6877
 
7670
- /*
7671
- Calculate exp2(x).
7672
- @overload exp2(x)
7673
- @param [Numo::NArray,Numeric] x input value
7674
- @return [Numo::DFloat] result of exp2(x).
7675
- */
7676
6878
  static VALUE dfloat_math_s_exp2(VALUE mod, VALUE a1) {
7677
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
7678
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
7679
- ndfunc_t ndf = {iter_dfloat_math_s_exp2, FULL_LOOP, 1, 1, ain, aout};
6879
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6880
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6881
+ ndfunc_t ndf = { iter_dfloat_math_s_exp2, FULL_LOOP, 1, 1, ain, aout };
7680
6882
 
7681
6883
  return na_ndloop(&ndf, 1, a1);
7682
6884
  }
@@ -7745,16 +6947,10 @@ static void iter_dfloat_math_s_exp10(na_loop_t* const lp) {
7745
6947
  }
7746
6948
  }
7747
6949
 
7748
- /*
7749
- Calculate exp10(x).
7750
- @overload exp10(x)
7751
- @param [Numo::NArray,Numeric] x input value
7752
- @return [Numo::DFloat] result of exp10(x).
7753
- */
7754
6950
  static VALUE dfloat_math_s_exp10(VALUE mod, VALUE a1) {
7755
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
7756
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
7757
- ndfunc_t ndf = {iter_dfloat_math_s_exp10, FULL_LOOP, 1, 1, ain, aout};
6951
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
6952
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
6953
+ ndfunc_t ndf = { iter_dfloat_math_s_exp10, FULL_LOOP, 1, 1, ain, aout };
7758
6954
 
7759
6955
  return na_ndloop(&ndf, 1, a1);
7760
6956
  }
@@ -7823,16 +7019,10 @@ static void iter_dfloat_math_s_sin(na_loop_t* const lp) {
7823
7019
  }
7824
7020
  }
7825
7021
 
7826
- /*
7827
- Calculate sin(x).
7828
- @overload sin(x)
7829
- @param [Numo::NArray,Numeric] x input value
7830
- @return [Numo::DFloat] result of sin(x).
7831
- */
7832
7022
  static VALUE dfloat_math_s_sin(VALUE mod, VALUE a1) {
7833
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
7834
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
7835
- ndfunc_t ndf = {iter_dfloat_math_s_sin, FULL_LOOP, 1, 1, ain, aout};
7023
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7024
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7025
+ ndfunc_t ndf = { iter_dfloat_math_s_sin, FULL_LOOP, 1, 1, ain, aout };
7836
7026
 
7837
7027
  return na_ndloop(&ndf, 1, a1);
7838
7028
  }
@@ -7901,16 +7091,10 @@ static void iter_dfloat_math_s_cos(na_loop_t* const lp) {
7901
7091
  }
7902
7092
  }
7903
7093
 
7904
- /*
7905
- Calculate cos(x).
7906
- @overload cos(x)
7907
- @param [Numo::NArray,Numeric] x input value
7908
- @return [Numo::DFloat] result of cos(x).
7909
- */
7910
7094
  static VALUE dfloat_math_s_cos(VALUE mod, VALUE a1) {
7911
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
7912
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
7913
- ndfunc_t ndf = {iter_dfloat_math_s_cos, FULL_LOOP, 1, 1, ain, aout};
7095
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7096
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7097
+ ndfunc_t ndf = { iter_dfloat_math_s_cos, FULL_LOOP, 1, 1, ain, aout };
7914
7098
 
7915
7099
  return na_ndloop(&ndf, 1, a1);
7916
7100
  }
@@ -7979,16 +7163,10 @@ static void iter_dfloat_math_s_tan(na_loop_t* const lp) {
7979
7163
  }
7980
7164
  }
7981
7165
 
7982
- /*
7983
- Calculate tan(x).
7984
- @overload tan(x)
7985
- @param [Numo::NArray,Numeric] x input value
7986
- @return [Numo::DFloat] result of tan(x).
7987
- */
7988
7166
  static VALUE dfloat_math_s_tan(VALUE mod, VALUE a1) {
7989
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
7990
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
7991
- ndfunc_t ndf = {iter_dfloat_math_s_tan, FULL_LOOP, 1, 1, ain, aout};
7167
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7168
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7169
+ ndfunc_t ndf = { iter_dfloat_math_s_tan, FULL_LOOP, 1, 1, ain, aout };
7992
7170
 
7993
7171
  return na_ndloop(&ndf, 1, a1);
7994
7172
  }
@@ -8057,16 +7235,10 @@ static void iter_dfloat_math_s_asin(na_loop_t* const lp) {
8057
7235
  }
8058
7236
  }
8059
7237
 
8060
- /*
8061
- Calculate asin(x).
8062
- @overload asin(x)
8063
- @param [Numo::NArray,Numeric] x input value
8064
- @return [Numo::DFloat] result of asin(x).
8065
- */
8066
7238
  static VALUE dfloat_math_s_asin(VALUE mod, VALUE a1) {
8067
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
8068
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
8069
- ndfunc_t ndf = {iter_dfloat_math_s_asin, FULL_LOOP, 1, 1, ain, aout};
7239
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7240
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7241
+ ndfunc_t ndf = { iter_dfloat_math_s_asin, FULL_LOOP, 1, 1, ain, aout };
8070
7242
 
8071
7243
  return na_ndloop(&ndf, 1, a1);
8072
7244
  }
@@ -8135,16 +7307,10 @@ static void iter_dfloat_math_s_acos(na_loop_t* const lp) {
8135
7307
  }
8136
7308
  }
8137
7309
 
8138
- /*
8139
- Calculate acos(x).
8140
- @overload acos(x)
8141
- @param [Numo::NArray,Numeric] x input value
8142
- @return [Numo::DFloat] result of acos(x).
8143
- */
8144
7310
  static VALUE dfloat_math_s_acos(VALUE mod, VALUE a1) {
8145
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
8146
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
8147
- ndfunc_t ndf = {iter_dfloat_math_s_acos, FULL_LOOP, 1, 1, ain, aout};
7311
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7312
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7313
+ ndfunc_t ndf = { iter_dfloat_math_s_acos, FULL_LOOP, 1, 1, ain, aout };
8148
7314
 
8149
7315
  return na_ndloop(&ndf, 1, a1);
8150
7316
  }
@@ -8213,16 +7379,10 @@ static void iter_dfloat_math_s_atan(na_loop_t* const lp) {
8213
7379
  }
8214
7380
  }
8215
7381
 
8216
- /*
8217
- Calculate atan(x).
8218
- @overload atan(x)
8219
- @param [Numo::NArray,Numeric] x input value
8220
- @return [Numo::DFloat] result of atan(x).
8221
- */
8222
7382
  static VALUE dfloat_math_s_atan(VALUE mod, VALUE a1) {
8223
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
8224
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
8225
- ndfunc_t ndf = {iter_dfloat_math_s_atan, FULL_LOOP, 1, 1, ain, aout};
7383
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7384
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7385
+ ndfunc_t ndf = { iter_dfloat_math_s_atan, FULL_LOOP, 1, 1, ain, aout };
8226
7386
 
8227
7387
  return na_ndloop(&ndf, 1, a1);
8228
7388
  }
@@ -8291,16 +7451,10 @@ static void iter_dfloat_math_s_sinh(na_loop_t* const lp) {
8291
7451
  }
8292
7452
  }
8293
7453
 
8294
- /*
8295
- Calculate sinh(x).
8296
- @overload sinh(x)
8297
- @param [Numo::NArray,Numeric] x input value
8298
- @return [Numo::DFloat] result of sinh(x).
8299
- */
8300
7454
  static VALUE dfloat_math_s_sinh(VALUE mod, VALUE a1) {
8301
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
8302
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
8303
- ndfunc_t ndf = {iter_dfloat_math_s_sinh, FULL_LOOP, 1, 1, ain, aout};
7455
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7456
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7457
+ ndfunc_t ndf = { iter_dfloat_math_s_sinh, FULL_LOOP, 1, 1, ain, aout };
8304
7458
 
8305
7459
  return na_ndloop(&ndf, 1, a1);
8306
7460
  }
@@ -8369,16 +7523,10 @@ static void iter_dfloat_math_s_cosh(na_loop_t* const lp) {
8369
7523
  }
8370
7524
  }
8371
7525
 
8372
- /*
8373
- Calculate cosh(x).
8374
- @overload cosh(x)
8375
- @param [Numo::NArray,Numeric] x input value
8376
- @return [Numo::DFloat] result of cosh(x).
8377
- */
8378
7526
  static VALUE dfloat_math_s_cosh(VALUE mod, VALUE a1) {
8379
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
8380
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
8381
- ndfunc_t ndf = {iter_dfloat_math_s_cosh, FULL_LOOP, 1, 1, ain, aout};
7527
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7528
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7529
+ ndfunc_t ndf = { iter_dfloat_math_s_cosh, FULL_LOOP, 1, 1, ain, aout };
8382
7530
 
8383
7531
  return na_ndloop(&ndf, 1, a1);
8384
7532
  }
@@ -8447,16 +7595,10 @@ static void iter_dfloat_math_s_tanh(na_loop_t* const lp) {
8447
7595
  }
8448
7596
  }
8449
7597
 
8450
- /*
8451
- Calculate tanh(x).
8452
- @overload tanh(x)
8453
- @param [Numo::NArray,Numeric] x input value
8454
- @return [Numo::DFloat] result of tanh(x).
8455
- */
8456
7598
  static VALUE dfloat_math_s_tanh(VALUE mod, VALUE a1) {
8457
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
8458
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
8459
- ndfunc_t ndf = {iter_dfloat_math_s_tanh, FULL_LOOP, 1, 1, ain, aout};
7599
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7600
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7601
+ ndfunc_t ndf = { iter_dfloat_math_s_tanh, FULL_LOOP, 1, 1, ain, aout };
8460
7602
 
8461
7603
  return na_ndloop(&ndf, 1, a1);
8462
7604
  }
@@ -8525,16 +7667,10 @@ static void iter_dfloat_math_s_asinh(na_loop_t* const lp) {
8525
7667
  }
8526
7668
  }
8527
7669
 
8528
- /*
8529
- Calculate asinh(x).
8530
- @overload asinh(x)
8531
- @param [Numo::NArray,Numeric] x input value
8532
- @return [Numo::DFloat] result of asinh(x).
8533
- */
8534
7670
  static VALUE dfloat_math_s_asinh(VALUE mod, VALUE a1) {
8535
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
8536
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
8537
- ndfunc_t ndf = {iter_dfloat_math_s_asinh, FULL_LOOP, 1, 1, ain, aout};
7671
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7672
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7673
+ ndfunc_t ndf = { iter_dfloat_math_s_asinh, FULL_LOOP, 1, 1, ain, aout };
8538
7674
 
8539
7675
  return na_ndloop(&ndf, 1, a1);
8540
7676
  }
@@ -8603,16 +7739,10 @@ static void iter_dfloat_math_s_acosh(na_loop_t* const lp) {
8603
7739
  }
8604
7740
  }
8605
7741
 
8606
- /*
8607
- Calculate acosh(x).
8608
- @overload acosh(x)
8609
- @param [Numo::NArray,Numeric] x input value
8610
- @return [Numo::DFloat] result of acosh(x).
8611
- */
8612
7742
  static VALUE dfloat_math_s_acosh(VALUE mod, VALUE a1) {
8613
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
8614
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
8615
- ndfunc_t ndf = {iter_dfloat_math_s_acosh, FULL_LOOP, 1, 1, ain, aout};
7743
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7744
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7745
+ ndfunc_t ndf = { iter_dfloat_math_s_acosh, FULL_LOOP, 1, 1, ain, aout };
8616
7746
 
8617
7747
  return na_ndloop(&ndf, 1, a1);
8618
7748
  }
@@ -8681,16 +7811,10 @@ static void iter_dfloat_math_s_atanh(na_loop_t* const lp) {
8681
7811
  }
8682
7812
  }
8683
7813
 
8684
- /*
8685
- Calculate atanh(x).
8686
- @overload atanh(x)
8687
- @param [Numo::NArray,Numeric] x input value
8688
- @return [Numo::DFloat] result of atanh(x).
8689
- */
8690
7814
  static VALUE dfloat_math_s_atanh(VALUE mod, VALUE a1) {
8691
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
8692
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
8693
- ndfunc_t ndf = {iter_dfloat_math_s_atanh, FULL_LOOP, 1, 1, ain, aout};
7815
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7816
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7817
+ ndfunc_t ndf = { iter_dfloat_math_s_atanh, FULL_LOOP, 1, 1, ain, aout };
8694
7818
 
8695
7819
  return na_ndloop(&ndf, 1, a1);
8696
7820
  }
@@ -8759,16 +7883,10 @@ static void iter_dfloat_math_s_sinc(na_loop_t* const lp) {
8759
7883
  }
8760
7884
  }
8761
7885
 
8762
- /*
8763
- Calculate sinc(x).
8764
- @overload sinc(x)
8765
- @param [Numo::NArray,Numeric] x input value
8766
- @return [Numo::DFloat] result of sinc(x).
8767
- */
8768
7886
  static VALUE dfloat_math_s_sinc(VALUE mod, VALUE a1) {
8769
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
8770
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
8771
- ndfunc_t ndf = {iter_dfloat_math_s_sinc, FULL_LOOP, 1, 1, ain, aout};
7887
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
7888
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7889
+ ndfunc_t ndf = { iter_dfloat_math_s_sinc, FULL_LOOP, 1, 1, ain, aout };
8772
7890
 
8773
7891
  return na_ndloop(&ndf, 1, a1);
8774
7892
  }
@@ -8790,17 +7908,10 @@ static void iter_dfloat_math_s_atan2(na_loop_t* const lp) {
8790
7908
  }
8791
7909
  }
8792
7910
 
8793
- /*
8794
- Calculate atan2(a1,a2).
8795
- @overload atan2(a1,a2)
8796
- @param [Numo::NArray,Numeric] a1 first value
8797
- @param [Numo::NArray,Numeric] a2 second value
8798
- @return [Numo::DFloat] atan2(a1,a2).
8799
- */
8800
7911
  static VALUE dfloat_math_s_atan2(VALUE mod, VALUE a1, VALUE a2) {
8801
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
8802
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
8803
- ndfunc_t ndf = {iter_dfloat_math_s_atan2, STRIDE_LOOP, 2, 1, ain, aout};
7912
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
7913
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7914
+ ndfunc_t ndf = { iter_dfloat_math_s_atan2, STRIDE_LOOP, 2, 1, ain, aout };
8804
7915
  return na_ndloop(&ndf, 2, a1, a2);
8805
7916
  }
8806
7917
 
@@ -8821,17 +7932,10 @@ static void iter_dfloat_math_s_hypot(na_loop_t* const lp) {
8821
7932
  }
8822
7933
  }
8823
7934
 
8824
- /*
8825
- Calculate hypot(a1,a2).
8826
- @overload hypot(a1,a2)
8827
- @param [Numo::NArray,Numeric] a1 first value
8828
- @param [Numo::NArray,Numeric] a2 second value
8829
- @return [Numo::DFloat] hypot(a1,a2).
8830
- */
8831
7935
  static VALUE dfloat_math_s_hypot(VALUE mod, VALUE a1, VALUE a2) {
8832
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
8833
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
8834
- ndfunc_t ndf = {iter_dfloat_math_s_hypot, STRIDE_LOOP, 2, 1, ain, aout};
7936
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
7937
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
7938
+ ndfunc_t ndf = { iter_dfloat_math_s_hypot, STRIDE_LOOP, 2, 1, ain, aout };
8835
7939
  return na_ndloop(&ndf, 2, a1, a2);
8836
7940
  }
8837
7941
 
@@ -8899,16 +8003,10 @@ static void iter_dfloat_math_s_erf(na_loop_t* const lp) {
8899
8003
  }
8900
8004
  }
8901
8005
 
8902
- /*
8903
- Calculate erf(x).
8904
- @overload erf(x)
8905
- @param [Numo::NArray,Numeric] x input value
8906
- @return [Numo::DFloat] result of erf(x).
8907
- */
8908
8006
  static VALUE dfloat_math_s_erf(VALUE mod, VALUE a1) {
8909
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
8910
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
8911
- ndfunc_t ndf = {iter_dfloat_math_s_erf, FULL_LOOP, 1, 1, ain, aout};
8007
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
8008
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
8009
+ ndfunc_t ndf = { iter_dfloat_math_s_erf, FULL_LOOP, 1, 1, ain, aout };
8912
8010
 
8913
8011
  return na_ndloop(&ndf, 1, a1);
8914
8012
  }
@@ -8977,16 +8075,10 @@ static void iter_dfloat_math_s_erfc(na_loop_t* const lp) {
8977
8075
  }
8978
8076
  }
8979
8077
 
8980
- /*
8981
- Calculate erfc(x).
8982
- @overload erfc(x)
8983
- @param [Numo::NArray,Numeric] x input value
8984
- @return [Numo::DFloat] result of erfc(x).
8985
- */
8986
8078
  static VALUE dfloat_math_s_erfc(VALUE mod, VALUE a1) {
8987
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
8988
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
8989
- ndfunc_t ndf = {iter_dfloat_math_s_erfc, FULL_LOOP, 1, 1, ain, aout};
8079
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
8080
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
8081
+ ndfunc_t ndf = { iter_dfloat_math_s_erfc, FULL_LOOP, 1, 1, ain, aout };
8990
8082
 
8991
8083
  return na_ndloop(&ndf, 1, a1);
8992
8084
  }
@@ -9055,16 +8147,10 @@ static void iter_dfloat_math_s_log1p(na_loop_t* const lp) {
9055
8147
  }
9056
8148
  }
9057
8149
 
9058
- /*
9059
- Calculate log1p(x).
9060
- @overload log1p(x)
9061
- @param [Numo::NArray,Numeric] x input value
9062
- @return [Numo::DFloat] result of log1p(x).
9063
- */
9064
8150
  static VALUE dfloat_math_s_log1p(VALUE mod, VALUE a1) {
9065
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
9066
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
9067
- ndfunc_t ndf = {iter_dfloat_math_s_log1p, FULL_LOOP, 1, 1, ain, aout};
8151
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
8152
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
8153
+ ndfunc_t ndf = { iter_dfloat_math_s_log1p, FULL_LOOP, 1, 1, ain, aout };
9068
8154
 
9069
8155
  return na_ndloop(&ndf, 1, a1);
9070
8156
  }
@@ -9133,16 +8219,10 @@ static void iter_dfloat_math_s_expm1(na_loop_t* const lp) {
9133
8219
  }
9134
8220
  }
9135
8221
 
9136
- /*
9137
- Calculate expm1(x).
9138
- @overload expm1(x)
9139
- @param [Numo::NArray,Numeric] x input value
9140
- @return [Numo::DFloat] result of expm1(x).
9141
- */
9142
8222
  static VALUE dfloat_math_s_expm1(VALUE mod, VALUE a1) {
9143
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
9144
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
9145
- ndfunc_t ndf = {iter_dfloat_math_s_expm1, FULL_LOOP, 1, 1, ain, aout};
8223
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
8224
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
8225
+ ndfunc_t ndf = { iter_dfloat_math_s_expm1, FULL_LOOP, 1, 1, ain, aout };
9146
8226
 
9147
8227
  return na_ndloop(&ndf, 1, a1);
9148
8228
  }
@@ -9164,17 +8244,10 @@ static void iter_dfloat_math_s_ldexp(na_loop_t* const lp) {
9164
8244
  }
9165
8245
  }
9166
8246
 
9167
- /*
9168
- Calculate ldexp(a1,a2).
9169
- @overload ldexp(a1,a2)
9170
- @param [Numo::NArray,Numeric] a1 first value
9171
- @param [Numo::NArray,Numeric] a2 second value
9172
- @return [Numo::DFloat] ldexp(a1,a2).
9173
- */
9174
8247
  static VALUE dfloat_math_s_ldexp(VALUE mod, VALUE a1, VALUE a2) {
9175
- ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
9176
- ndfunc_arg_out_t aout[1] = {{cT, 0}};
9177
- ndfunc_t ndf = {iter_dfloat_math_s_ldexp, STRIDE_LOOP, 2, 1, ain, aout};
8248
+ ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
8249
+ ndfunc_arg_out_t aout[1] = { { cT, 0 } };
8250
+ ndfunc_t ndf = { iter_dfloat_math_s_ldexp, STRIDE_LOOP, 2, 1, ain, aout };
9178
8251
  return na_ndloop(&ndf, 2, a1, a2);
9179
8252
  }
9180
8253
 
@@ -9196,19 +8269,10 @@ static void iter_dfloat_math_s_frexp(na_loop_t* const lp) {
9196
8269
  }
9197
8270
  }
9198
8271
 
9199
- /*
9200
- split the number x into a normalized fraction and an exponent.
9201
- Returns [mantissa, exponent], where x = mantissa * 2**exponent.
9202
-
9203
- @overload frexp(x)
9204
- @param [Numo::NArray,Numeric] x
9205
- @return [Numo::DFloat,Numo::Int32] mantissa and exponent.
9206
-
9207
- */
9208
8272
  static VALUE dfloat_math_s_frexp(VALUE mod, VALUE a1) {
9209
- ndfunc_arg_in_t ain[1] = {{cT, 0}};
9210
- ndfunc_arg_out_t aout[2] = {{cT, 0}, {numo_cInt32, 0}};
9211
- ndfunc_t ndf = {iter_dfloat_math_s_frexp, STRIDE_LOOP, 1, 2, ain, aout};
8273
+ ndfunc_arg_in_t ain[1] = { { cT, 0 } };
8274
+ ndfunc_arg_out_t aout[2] = { { cT, 0 }, { numo_cInt32, 0 } };
8275
+ ndfunc_t ndf = { iter_dfloat_math_s_frexp, STRIDE_LOOP, 1, 2, ain, aout };
9212
8276
  return na_ndloop(&ndf, 1, a1);
9213
8277
  }
9214
8278
 
@@ -9232,16 +8296,18 @@ void Init_numo_dfloat(void) {
9232
8296
  id_nearly_eq = rb_intern("nearly_eq");
9233
8297
  id_to_a = rb_intern("to_a");
9234
8298
 
9235
- /*
9236
- Document-class: Numo::DFloat
9237
-
9238
- */
8299
+ /**
8300
+ * Document-class: Numo::DFloat
8301
+ *
8302
+ * Double precision floating point number (64-bit float) N-dimensional array class.
8303
+ */
9239
8304
  cT = rb_define_class_under(mNumo, "DFloat", cNArray);
9240
8305
 
9241
8306
  // alias of DFloat
9242
8307
  rb_define_const(mNumo, "Float64", numo_cDFloat);
9243
8308
 
9244
8309
  hCast = rb_hash_new();
8310
+ /* Upcasting rules of DFloat. */
9245
8311
  rb_define_const(cT, "UPCAST", hCast);
9246
8312
  rb_hash_aset(hCast, rb_cArray, cT);
9247
8313
 
@@ -9268,148 +8334,1002 @@ void Init_numo_dfloat(void) {
9268
8334
  rb_hash_aset(hCast, numo_cUInt8, numo_cDFloat);
9269
8335
  rb_obj_freeze(hCast);
9270
8336
 
9271
- /**/
8337
+ /* Element size of DFloat in bits. */
9272
8338
  rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
9273
- /**/
8339
+ /* Element size of DFloat in bytes. */
9274
8340
  rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
9275
- /**/
8341
+ /* Stride size of contiguous DFloat array. */
9276
8342
  rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
9277
- /**/
8343
+ /* Machine epsilon of DFloat. */
9278
8344
  rb_define_const(cT, "EPSILON", M_EPSILON);
9279
- /**/
8345
+ /* The largest representable value of DFloat. */
9280
8346
  rb_define_const(cT, "MAX", M_MAX);
9281
- /**/
8347
+ /* The smallest representable value of DFloat. */
9282
8348
  rb_define_const(cT, "MIN", M_MIN);
9283
8349
  rb_define_alloc_func(cT, dfloat_s_alloc_func);
9284
8350
  rb_define_method(cT, "allocate", dfloat_allocate, 0);
8351
+ /**
8352
+ * Extract an element only if self is a dimensionless NArray.
8353
+ * @overload extract
8354
+ * @return [Numeric,Numo::NArray] Extract element value as Ruby Object
8355
+ * if self is a dimensionless NArray, otherwise returns self.
8356
+ */
9285
8357
  rb_define_method(cT, "extract", dfloat_extract, 0);
9286
-
8358
+ /**
8359
+ * Store elements to Numo::DFloat from other.
8360
+ * @overload store(other)
8361
+ * @param [Object] other
8362
+ * @return [Numo::DFloat] self
8363
+ */
9287
8364
  rb_define_method(cT, "store", dfloat_store, 1);
9288
-
8365
+ /**
8366
+ * Cast object to Numo::DFloat.
8367
+ * @overload cast(array)
8368
+ * @param [Numeric,Array] elements
8369
+ * @param [Array] array
8370
+ * @return [Numo::DFloat]
8371
+ */
9289
8372
  rb_define_singleton_method(cT, "cast", dfloat_s_cast, 1);
8373
+ /**
8374
+ * Cast object to Numo::DFloat.
8375
+ * @overload [](elements)
8376
+ * @param [Numeric,Array] elements
8377
+ * @param [Array] array
8378
+ * @return [Numo::DFloat]
8379
+ */
8380
+ rb_define_singleton_method(cT, "[]", dfloat_s_cast, -2);
8381
+ /**
8382
+ * Multi-dimensional element reference.
8383
+ * @overload [](dim0,...,dimL)
8384
+ * @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,Boolean,Symbol]
8385
+ * dim0,...,dimL multi-dimensional indices.
8386
+ * @return [Numeric,Numo::DFloat] an element or NArray view.
8387
+ * @see Numo::NArray#[]
8388
+ * @see #[]=
8389
+ */
9290
8390
  rb_define_method(cT, "[]", dfloat_aref, -1);
8391
+ /**
8392
+ * Multi-dimensional element assignment.
8393
+ * @overload []=(dim0,...,dimL,val)
8394
+ * @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,Boolean,Symbol]
8395
+ * dim0,...,dimL multi-dimensional indices.
8396
+ * @param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
8397
+ * @return [Numeric,Numo::NArray,Array] returns `val` (last argument).
8398
+ * @see Numo::NArray#[]=
8399
+ * @see #[]
8400
+ */
9291
8401
  rb_define_method(cT, "[]=", dfloat_aset, -1);
8402
+ /**
8403
+ * Return NArray with cast to the type of self.
8404
+ * @overload coerce_cast(type)
8405
+ * @return [nil]
8406
+ */
9292
8407
  rb_define_method(cT, "coerce_cast", dfloat_coerce_cast, 1);
8408
+ /**
8409
+ * Convert self to Array.
8410
+ * @overload to_a
8411
+ * @return [Array]
8412
+ */
9293
8413
  rb_define_method(cT, "to_a", dfloat_to_a, 0);
8414
+ /**
8415
+ * Fill elements with other.
8416
+ * @overload fill other
8417
+ * @param [Numeric] other
8418
+ * @return [Numo::DFloat] self.
8419
+ */
9294
8420
  rb_define_method(cT, "fill", dfloat_fill, 1);
8421
+ /**
8422
+ * Format elements into strings.
8423
+ * @overload format format
8424
+ * @param [String] format
8425
+ * @return [Numo::RObject] array of formatted strings.
8426
+ */
9295
8427
  rb_define_method(cT, "format", dfloat_format, -1);
8428
+ /**
8429
+ * Format elements into strings.
8430
+ * @overload format_to_a format
8431
+ * @param [String] format
8432
+ * @return [Array] array of formatted strings.
8433
+ */
9296
8434
  rb_define_method(cT, "format_to_a", dfloat_format_to_a, -1);
8435
+ /**
8436
+ * Returns a string containing a human-readable representation of NArray.
8437
+ * @overload inspect
8438
+ * @return [String]
8439
+ */
9297
8440
  rb_define_method(cT, "inspect", dfloat_inspect, 0);
8441
+ /**
8442
+ * Calls the given block once for each element in self,
8443
+ * passing that element as a parameter. For a block `{|x| ... }`,
8444
+ * @overload each
8445
+ * @return [Numo::NArray] self
8446
+ * @yieldparam [Numeric] x an element of NArray.
8447
+ * @see #each_with_index
8448
+ * @see #map
8449
+ */
9298
8450
  rb_define_method(cT, "each", dfloat_each, 0);
8451
+ /**
8452
+ * Unary map.
8453
+ * @overload map
8454
+ * @return [Numo::DFloat] map of self.
8455
+ */
9299
8456
  rb_define_method(cT, "map", dfloat_map, 0);
8457
+ /**
8458
+ * Invokes the given block once for each element of self, passing that element
8459
+ * and indices along each axis as parameters. For a block `{|x,i,j,...| ... }`,
8460
+ * @overload each_with_index
8461
+ * @yieldparam [Numeric] x an element
8462
+ * @yieldparam [Integer] i,j,... multitimensional indices
8463
+ * @return [Numo::NArray] self
8464
+ * @see #each
8465
+ * @see #map_with_index
8466
+ */
9300
8467
  rb_define_method(cT, "each_with_index", dfloat_each_with_index, 0);
8468
+ /**
8469
+ * Invokes the given block once for each element of self,
8470
+ * passing that element and indices along each axis as parameters.
8471
+ * Creates a new NArray containing the values returned by the block.
8472
+ * Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
8473
+ * For a block `{|x,i,j,...| ... }`,
8474
+ * @overload map_with_index
8475
+ * @yieldparam [Numeric] x an element
8476
+ * @yieldparam [Integer] i,j,... multitimensional indices
8477
+ * @return [Numo::NArray] mapped array
8478
+ * @see #map
8479
+ * @see #each_with_index
8480
+ */
9301
8481
  rb_define_method(cT, "map_with_index", dfloat_map_with_index, 0);
8482
+ /**
8483
+ * abs of self.
8484
+ * @overload abs
8485
+ * @return [Numo::DFloat] abs of self.
8486
+ */
9302
8487
  rb_define_method(cT, "abs", dfloat_abs, 0);
8488
+ /**
8489
+ * Binary add.
8490
+ * @overload + other
8491
+ * @param [Numo::NArray,Numeric] other
8492
+ * @return [Numo::NArray] self + other
8493
+ */
9303
8494
  rb_define_method(cT, "+", dfloat_add, 1);
8495
+ /**
8496
+ * Binary sub.
8497
+ * @overload - other
8498
+ * @param [Numo::NArray,Numeric] other
8499
+ * @return [Numo::NArray] self - other
8500
+ */
9304
8501
  rb_define_method(cT, "-", dfloat_sub, 1);
8502
+ /**
8503
+ * Binary mul.
8504
+ * @overload * other
8505
+ * @param [Numo::NArray,Numeric] other
8506
+ * @return [Numo::NArray] self * other
8507
+ */
9305
8508
  rb_define_method(cT, "*", dfloat_mul, 1);
8509
+ /**
8510
+ * Binary div.
8511
+ * @overload / other
8512
+ * @param [Numo::NArray,Numeric] other
8513
+ * @return [Numo::NArray] self / other
8514
+ */
9306
8515
  rb_define_method(cT, "/", dfloat_div, 1);
8516
+ /**
8517
+ * Binary mod.
8518
+ * @overload % other
8519
+ * @param [Numo::NArray,Numeric] other
8520
+ * @return [Numo::NArray] self % other
8521
+ */
9307
8522
  rb_define_method(cT, "%", dfloat_mod, 1);
8523
+ /**
8524
+ * Binary divmod.
8525
+ * @overload divmod other
8526
+ * @param [Numo::NArray,Numeric] other
8527
+ * @return [Numo::NArray] divmod of self and other.
8528
+ */
9308
8529
  rb_define_method(cT, "divmod", dfloat_divmod, 1);
8530
+ /**
8531
+ * Binary power.
8532
+ * @overload ** other
8533
+ * @param [Numo::NArray,Numeric] other
8534
+ * @return [Numo::NArray] self to the other-th power.
8535
+ */
9309
8536
  rb_define_method(cT, "**", dfloat_pow, 1);
9310
8537
  rb_define_alias(cT, "pow", "**");
8538
+ /**
8539
+ * Unary minus.
8540
+ * @overload -@
8541
+ * @return [Numo::DFloat] minus of self.
8542
+ */
9311
8543
  rb_define_method(cT, "-@", dfloat_minus, 0);
8544
+ /**
8545
+ * Unary reciprocal.
8546
+ * @overload reciprocal
8547
+ * @return [Numo::DFloat] reciprocal of self.
8548
+ */
9312
8549
  rb_define_method(cT, "reciprocal", dfloat_reciprocal, 0);
8550
+ /**
8551
+ * Unary sign.
8552
+ * @overload sign
8553
+ * @return [Numo::DFloat] sign of self.
8554
+ */
9313
8555
  rb_define_method(cT, "sign", dfloat_sign, 0);
8556
+ /**
8557
+ * Unary square.
8558
+ * @overload square
8559
+ * @return [Numo::DFloat] square of self.
8560
+ */
9314
8561
  rb_define_method(cT, "square", dfloat_square, 0);
9315
8562
  rb_define_alias(cT, "conj", "view");
9316
8563
  rb_define_alias(cT, "im", "view");
9317
8564
  rb_define_alias(cT, "conjugate", "conj");
8565
+ /**
8566
+ * Comparison eq other.
8567
+ * @overload eq other
8568
+ * @param [Numo::NArray,Numeric] other
8569
+ * @return [Numo::Bit] result of self eq other.
8570
+ */
9318
8571
  rb_define_method(cT, "eq", dfloat_eq, 1);
8572
+ /**
8573
+ * Comparison ne other.
8574
+ * @overload ne other
8575
+ * @param [Numo::NArray,Numeric] other
8576
+ * @return [Numo::Bit] result of self ne other.
8577
+ */
9319
8578
  rb_define_method(cT, "ne", dfloat_ne, 1);
8579
+ /**
8580
+ * Comparison nearly_eq other.
8581
+ * @overload nearly_eq other
8582
+ * @param [Numo::NArray,Numeric] other
8583
+ * @return [Numo::Bit] result of self nearly_eq other.
8584
+ */
9320
8585
  rb_define_method(cT, "nearly_eq", dfloat_nearly_eq, 1);
9321
8586
  rb_define_alias(cT, "close_to", "nearly_eq");
8587
+ /**
8588
+ * Unary floor.
8589
+ * @overload floor
8590
+ * @return [Numo::DFloat] floor of self.
8591
+ */
9322
8592
  rb_define_method(cT, "floor", dfloat_floor, 0);
8593
+ /**
8594
+ * Unary round.
8595
+ * @overload round
8596
+ * @return [Numo::DFloat] round of self.
8597
+ */
9323
8598
  rb_define_method(cT, "round", dfloat_round, 0);
8599
+ /**
8600
+ * Unary ceil.
8601
+ * @overload ceil
8602
+ * @return [Numo::DFloat] ceil of self.
8603
+ */
9324
8604
  rb_define_method(cT, "ceil", dfloat_ceil, 0);
8605
+ /**
8606
+ * Unary trunc.
8607
+ * @overload trunc
8608
+ * @return [Numo::DFloat] trunc of self.
8609
+ */
9325
8610
  rb_define_method(cT, "trunc", dfloat_trunc, 0);
8611
+ /**
8612
+ * Unary rint.
8613
+ * @overload rint
8614
+ * @return [Numo::DFloat] rint of self.
8615
+ */
9326
8616
  rb_define_method(cT, "rint", dfloat_rint, 0);
8617
+ /**
8618
+ * Binary copysign.
8619
+ * @overload copysign other
8620
+ * @param [Numo::NArray,Numeric] other
8621
+ * @return [Numo::NArray] self copysign other
8622
+ */
9327
8623
  rb_define_method(cT, "copysign", dfloat_copysign, 1);
8624
+ /**
8625
+ * Condition of signbit.
8626
+ * @overload signbit
8627
+ * @return [Numo::Bit] Condition of signbit.
8628
+ */
9328
8629
  rb_define_method(cT, "signbit", dfloat_signbit, 0);
8630
+ /**
8631
+ * modf of self.
8632
+ * @overload modf
8633
+ * @return [Numo::DFloat] modf of self.
8634
+ */
9329
8635
  rb_define_method(cT, "modf", dfloat_modf, 0);
8636
+ /**
8637
+ * Comparison gt other.
8638
+ * @overload gt other
8639
+ * @param [Numo::NArray,Numeric] other
8640
+ * @return [Numo::Bit] result of self gt other.
8641
+ */
9330
8642
  rb_define_method(cT, "gt", dfloat_gt, 1);
8643
+ /**
8644
+ * Comparison ge other.
8645
+ * @overload ge other
8646
+ * @param [Numo::NArray,Numeric] other
8647
+ * @return [Numo::Bit] result of self ge other.
8648
+ */
9331
8649
  rb_define_method(cT, "ge", dfloat_ge, 1);
8650
+ /**
8651
+ * Comparison lt other.
8652
+ * @overload lt other
8653
+ * @param [Numo::NArray,Numeric] other
8654
+ * @return [Numo::Bit] result of self lt other.
8655
+ */
9332
8656
  rb_define_method(cT, "lt", dfloat_lt, 1);
8657
+ /**
8658
+ * Comparison le other.
8659
+ * @overload le other
8660
+ * @param [Numo::NArray,Numeric] other
8661
+ * @return [Numo::Bit] result of self le other.
8662
+ */
9333
8663
  rb_define_method(cT, "le", dfloat_le, 1);
9334
8664
  rb_define_alias(cT, ">", "gt");
9335
8665
  rb_define_alias(cT, ">=", "ge");
9336
8666
  rb_define_alias(cT, "<", "lt");
9337
8667
  rb_define_alias(cT, "<=", "le");
8668
+ /**
8669
+ * Clip array elements by [min,max].
8670
+ * If either of min or max is nil, one side is clipped.
8671
+ * @overload clip(min,max)
8672
+ * @param [Numo::NArray,Numeric] min
8673
+ * @param [Numo::NArray,Numeric] max
8674
+ * @return [Numo::NArray] result of clip.
8675
+ *
8676
+ * @example
8677
+ * a = Numo::Int32.new(10).seq
8678
+ * # => Numo::Int32#shape=[10]
8679
+ * # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
8680
+ *
8681
+ * a.clip(1,8)
8682
+ * # => Numo::Int32#shape=[10]
8683
+ * # [1, 1, 2, 3, 4, 5, 6, 7, 8, 8]
8684
+ *
8685
+ * a.inplace.clip(3,6)
8686
+ * a
8687
+ * # => Numo::Int32#shape=[10]
8688
+ * # [3, 3, 3, 3, 4, 5, 6, 6, 6, 6]
8689
+ *
8690
+ * b = Numo::Int32.new(10).seq
8691
+ * # => Numo::Int32#shape=[10]
8692
+ * # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
8693
+ *
8694
+ * b.clip([3,4,1,1,1,4,4,4,4,4], 8)
8695
+ * # => Numo::Int32#shape=[10]
8696
+ * # [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]
8697
+ */
9338
8698
  rb_define_method(cT, "clip", dfloat_clip, 2);
8699
+ /**
8700
+ * Condition of isnan.
8701
+ * @overload isnan
8702
+ * @return [Numo::Bit] Condition of isnan.
8703
+ */
9339
8704
  rb_define_method(cT, "isnan", dfloat_isnan, 0);
8705
+ /**
8706
+ * Condition of isinf.
8707
+ * @overload isinf
8708
+ * @return [Numo::Bit] Condition of isinf.
8709
+ */
9340
8710
  rb_define_method(cT, "isinf", dfloat_isinf, 0);
8711
+ /**
8712
+ * Condition of isposinf.
8713
+ * @overload isposinf
8714
+ * @return [Numo::Bit] Condition of isposinf.
8715
+ */
9341
8716
  rb_define_method(cT, "isposinf", dfloat_isposinf, 0);
8717
+ /**
8718
+ * Condition of isneginf.
8719
+ * @overload isneginf
8720
+ * @return [Numo::Bit] Condition of isneginf.
8721
+ */
9342
8722
  rb_define_method(cT, "isneginf", dfloat_isneginf, 0);
8723
+ /**
8724
+ * Condition of isfinite.
8725
+ * @overload isfinite
8726
+ * @return [Numo::Bit] Condition of isfinite.
8727
+ */
9343
8728
  rb_define_method(cT, "isfinite", dfloat_isfinite, 0);
8729
+ /**
8730
+ * sum of self.
8731
+ * @overload sum(axis:nil, keepdims:false, nan:false)
8732
+ * @param [Boolean] nan If true, apply NaN-aware algorithm
8733
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
8734
+ * @param [Numeric,Array,Range] axis Performs sum along the axis.
8735
+ * @param [Boolean] keepdims If true, the reduced axes are left in the result array as
8736
+ * dimensions with size one.
8737
+ * @return [Numo::DFloat] returns result of sum.
8738
+ */
9344
8739
  rb_define_method(cT, "sum", dfloat_sum, -1);
8740
+ /**
8741
+ * prod of self.
8742
+ * @overload prod(axis:nil, keepdims:false, nan:false)
8743
+ * @param [Boolean] nan If true, apply NaN-aware algorithm
8744
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
8745
+ * @param [Numeric,Array,Range] axis Performs prod along the axis.
8746
+ * @param [Boolean] keepdims If true, the reduced axes are left in the result array as
8747
+ * dimensions with size one.
8748
+ * @return [Numo::DFloat] returns result of prod.
8749
+ */
9345
8750
  rb_define_method(cT, "prod", dfloat_prod, -1);
8751
+ /**
8752
+ * kahan_sum of self.
8753
+ * @overload kahan_sum(axis:nil, keepdims:false, nan:false)
8754
+ * @param [Boolean] nan If true, apply NaN-aware algorithm
8755
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
8756
+ * @param [Numeric,Array,Range] axis Performs kahan_sum along the axis.
8757
+ * @param [Boolean] keepdims If true, the reduced axes are left in the result array as
8758
+ * dimensions with size one.
8759
+ * @return [Numo::DFloat] returns result of kahan_sum.
8760
+ */
9346
8761
  rb_define_method(cT, "kahan_sum", dfloat_kahan_sum, -1);
8762
+ /**
8763
+ * mean of self.
8764
+ * @overload mean(axis: nil, keepdims: false, nan: false)
8765
+ * @param axis [Numeric, Array, Range] Performs mean along the axis.
8766
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
8767
+ * dimensions with size one.
8768
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
8769
+ * (avoid NaN for sum/mean etc, or return NaN for min/max etc).
8770
+ * @return [Numo::DFloat] returns result of mean.
8771
+ */
9347
8772
  rb_define_method(cT, "mean", dfloat_mean, -1);
9348
- rb_define_method(cT, "stddev", dfloat_stddev, -1);
8773
+ /**
8774
+ * var of self.
8775
+ * @overload var(axis: nil, keepdims: false, nan: false)
8776
+ * @param axis [Numeric, Array, Range] Performs var along the axis.
8777
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
8778
+ * dimensions with size one.
8779
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
8780
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
8781
+ * @return [Numo::DFloat] returns result of var.
8782
+ */
9349
8783
  rb_define_method(cT, "var", dfloat_var, -1);
8784
+ /**
8785
+ * stddev of self.
8786
+ * @overload stddev(axis: nil, keepdims: false, nan: false)
8787
+ * @param axis [Numeric, Array, Range] Performs stddev along the axis.
8788
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
8789
+ * dimensions with size one.
8790
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
8791
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
8792
+ * @return [Numo::DFloat] returns result of stddev.
8793
+ */
8794
+ rb_define_method(cT, "stddev", dfloat_stddev, -1);
8795
+ /**
8796
+ * rms of self.
8797
+ * @overload rms(axis: nil, keepdims: false, nan: false)
8798
+ * @param axis [Numeric, Array, Range] Performs rms along the axis.
8799
+ * @param keepdims [Boolean] If true, the reduced axes are left in the result array as
8800
+ * dimensions with size one.
8801
+ * @param nan [Boolean] If true, apply NaN-aware algorithm
8802
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
8803
+ * @return [Numo::DFloat] returns result of rms.
8804
+ */
9350
8805
  rb_define_method(cT, "rms", dfloat_rms, -1);
8806
+ /**
8807
+ * min of self.
8808
+ * @overload min(axis:nil, keepdims:false, nan:false)
8809
+ * @param [Boolean] nan If true, apply NaN-aware algorithm
8810
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
8811
+ * @param [Numeric,Array,Range] axis Performs min along the axis.
8812
+ * @param [Boolean] keepdims If true, the reduced axes are left in the result array as
8813
+ * dimensions with size one.
8814
+ * @return [Numo::DFloat] returns result of min.
8815
+ */
9351
8816
  rb_define_method(cT, "min", dfloat_min, -1);
8817
+ /**
8818
+ * max of self.
8819
+ * @overload max(axis:nil, keepdims:false, nan:false)
8820
+ * @param [Boolean] nan If true, apply NaN-aware algorithm
8821
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
8822
+ * @param [Numeric,Array,Range] axis Performs max along the axis.
8823
+ * @param [Boolean] keepdims If true, the reduced axes are left in the result array as
8824
+ * dimensions with size one.
8825
+ * @return [Numo::DFloat] returns result of max.
8826
+ */
9352
8827
  rb_define_method(cT, "max", dfloat_max, -1);
8828
+ /**
8829
+ * ptp of self.
8830
+ * @overload ptp(axis:nil, keepdims:false, nan:false)
8831
+ * @param [Boolean] nan If true, apply NaN-aware algorithm
8832
+ * (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
8833
+ * @param [Numeric,Array,Range] axis Performs ptp along the axis.
8834
+ * @param [Boolean] keepdims If true, the reduced axes are left in the result array as
8835
+ * dimensions with size one.
8836
+ * @return [Numo::DFloat] returns result of ptp.
8837
+ */
9353
8838
  rb_define_method(cT, "ptp", dfloat_ptp, -1);
8839
+ /**
8840
+ * Index of the maximum value.
8841
+ * @overload max_index(axis:nil, nan:false)
8842
+ * @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
8843
+ * @param [Numeric,Array,Range] axis Finds maximum values along the axis
8844
+ * and returns **flat 1-d indices**.
8845
+ * @return [Integer,Numo::Int] returns result indices.
8846
+ * @see #argmax
8847
+ * @see #max
8848
+ *
8849
+ * @example
8850
+ * a = Numo::NArray[3,4,1,2]
8851
+ * a.max_index #=> 1
8852
+ *
8853
+ * b = Numo::NArray[[3,4,1],[2,0,5]]
8854
+ * b.max_index #=> 5
8855
+ * b.max_index(axis:1) #=> [1, 5]
8856
+ * b.max_index(axis:0) #=> [0, 1, 5]
8857
+ * b[b.max_index(axis:0)] #=> [3, 4, 5]
8858
+ */
9354
8859
  rb_define_method(cT, "max_index", dfloat_max_index, -1);
8860
+ /**
8861
+ * Index of the minimum value.
8862
+ * @overload min_index(axis:nil, nan:false)
8863
+ * @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
8864
+ * @param [Numeric,Array,Range] axis Finds minimum values along the axis
8865
+ * and returns **flat 1-d indices**.
8866
+ * @return [Integer,Numo::Int] returns result indices.
8867
+ * @see #argmin
8868
+ * @see #min
8869
+ *
8870
+ * @example
8871
+ * a = Numo::NArray[3,4,1,2]
8872
+ * a.min_index #=> 2
8873
+ *
8874
+ * b = Numo::NArray[[3,4,1],[2,0,5]]
8875
+ * b.min_index #=> 4
8876
+ * b.min_index(axis:1) #=> [2, 4]
8877
+ * b.min_index(axis:0) #=> [3, 4, 2]
8878
+ * b[b.min_index(axis:0)] #=> [2, 0, 1]
8879
+ */
9355
8880
  rb_define_method(cT, "min_index", dfloat_min_index, -1);
8881
+ /**
8882
+ * Index of the maximum value.
8883
+ * @overload argmax(axis:nil, nan:false)
8884
+ * @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
8885
+ * @param [Numeric,Array,Range] axis Finds maximum values along the axis
8886
+ * and returns **indices along the axis**.
8887
+ * @return [Integer,Numo::Int] returns the result indices.
8888
+ * @see #max_index
8889
+ * @see #max
8890
+ *
8891
+ * @example
8892
+ * a = Numo::NArray[3,4,1,2]
8893
+ * a.argmax #=> 1
8894
+ *
8895
+ * b = Numo::NArray[[3,4,1],[2,0,5]]
8896
+ * b.argmax #=> 5
8897
+ * b.argmax(axis:1) #=> [1, 2]
8898
+ * b.argmax(axis:0) #=> [0, 0, 1]
8899
+ * b.at(b.argmax(axis:0), 0..-1) #=> [3, 4, 5]
8900
+ */
9356
8901
  rb_define_method(cT, "argmax", dfloat_argmax, -1);
8902
+ /**
8903
+ * Index of the minimum value.
8904
+ * @overload argmin(axis:nil, nan:false)
8905
+ * @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
8906
+ * @param [Numeric,Array,Range] axis Finds minimum values along the axis
8907
+ * and returns **indices along the axis**.
8908
+ * @return [Integer,Numo::Int] returns the result indices.
8909
+ * @see #min_index
8910
+ * @see #min
8911
+ *
8912
+ * @example
8913
+ * a = Numo::NArray[3,4,1,2]
8914
+ * a.argmin #=> 2
8915
+ *
8916
+ * b = Numo::NArray[[3,4,1],[2,0,5]]
8917
+ * b.argmin #=> 4
8918
+ * b.argmin(axis:1) #=> [2, 1]
8919
+ * b.argmin(axis:0) #=> [1, 1, 0]
8920
+ * b.at(b.argmin(axis:0), 0..-1) #=> [2, 0, 1]
8921
+ */
9357
8922
  rb_define_method(cT, "argmin", dfloat_argmin, -1);
8923
+ /**
8924
+ * minmax of self.
8925
+ * @overload minmax(axis:nil, keepdims:false, nan:false)
8926
+ * @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
8927
+ * @param [Numeric,Array,Range] axis Finds min-max along the axis.
8928
+ * @param [Boolean] keepdims (keyword) If true, the reduced axes are left
8929
+ * in the result array as dimensions with size one.
8930
+ * @return [Numo::DFloat,Numo::DFloat] min and max of self.
8931
+ */
9358
8932
  rb_define_method(cT, "minmax", dfloat_minmax, -1);
8933
+ /**
8934
+ * Element-wise maximum of two arrays.
8935
+ * @overload maximum(a1, a2, nan:false)
8936
+ * @param [Numo::NArray,Numeric] a1 The array to be compared.
8937
+ * @param [Numo::NArray,Numeric] a2 The array to be compared.
8938
+ * @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
8939
+ * @return [Numo::DFloat]
8940
+ */
9359
8941
  rb_define_module_function(cT, "maximum", dfloat_s_maximum, -1);
8942
+ /**
8943
+ * Element-wise minimum of two arrays.
8944
+ * @overload minimum(a1, a2, nan:false)
8945
+ * @param [Numo::NArray,Numeric] a1 The array to be compared.
8946
+ * @param [Numo::NArray,Numeric] a2 The array to be compared.
8947
+ * @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
8948
+ * @return [Numo::DFloat]
8949
+ */
9360
8950
  rb_define_module_function(cT, "minimum", dfloat_s_minimum, -1);
8951
+ /**
8952
+ * cumsum of self.
8953
+ * @overload cumsum(axis:nil, nan:false)
8954
+ * @param [Numeric,Array,Range] axis Performs cumsum along the axis.
8955
+ * @param [Boolean] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
8956
+ * @return [Numo::DFloat] cumsum of self.
8957
+ */
9361
8958
  rb_define_method(cT, "cumsum", dfloat_cumsum, -1);
8959
+ /**
8960
+ * cumprod of self.
8961
+ * @overload cumprod(axis:nil, nan:false)
8962
+ * @param [Numeric,Array,Range] axis Performs cumprod along the axis.
8963
+ * @param [Boolean] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
8964
+ * @return [Numo::DFloat] cumprod of self.
8965
+ */
9362
8966
  rb_define_method(cT, "cumprod", dfloat_cumprod, -1);
8967
+ /**
8968
+ * Binary mulsum.
8969
+ * @overload mulsum(other, axis:nil, keepdims:false, nan:false)
8970
+ * @param [Numo::NArray,Numeric] other
8971
+ * @param [Numeric,Array,Range] axis Performs mulsum along the axis.
8972
+ * @param [Boolean] keepdims (keyword) If true, the reduced axes are left
8973
+ * in the result array as dimensions with size one.
8974
+ * @param [Boolean] nan (keyword) If true, apply NaN-aware algorithm (avoid NaN if exists).
8975
+ * @return [Numo::NArray] mulsum of self and other.
8976
+ */
9363
8977
  rb_define_method(cT, "mulsum", dfloat_mulsum, -1);
8978
+ /**
8979
+ * Set linear sequence of numbers to self. The sequence is obtained from
8980
+ * beg+i*step
8981
+ * where i is 1-dimensional index.
8982
+ * @overload seq([beg,[step]])
8983
+ * @param [Numeric] beg beginning of sequence. (default=0)
8984
+ * @param [Numeric] step step of sequence. (default=1)
8985
+ * @return [Numo::DFloat] self.
8986
+ * @example
8987
+ * Numo::DFloat.new(6).seq(1,-0.2)
8988
+ * # => Numo::DFloat#shape=[6]
8989
+ * # [1, 0.8, 0.6, 0.4, 0.2, 0]
8990
+ *
8991
+ * Numo::DComplex.new(6).seq(1,-0.2+0.2i)
8992
+ * # => Numo::DComplex#shape=[6]
8993
+ * # [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
8994
+ */
9364
8995
  rb_define_method(cT, "seq", dfloat_seq, -1);
8996
+ /**
8997
+ * Set logarithmic sequence of numbers to self. The sequence is obtained from
8998
+ * `base**(beg+i*step)`
8999
+ * where i is 1-dimensional index.
9000
+ * Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
9001
+ *
9002
+ * @overload logseq(beg,step,[base])
9003
+ * @param [Numeric] beg The beginning of sequence.
9004
+ * @param [Numeric] step The step of sequence.
9005
+ * @param [Numeric] base The base of log space. (default=10)
9006
+ * @return [Numo::DFloat] self.
9007
+ *
9008
+ * @example
9009
+ * Numo::DFloat.new(5).logseq(4,-1,2)
9010
+ * # => Numo::DFloat#shape=[5]
9011
+ * # [16, 8, 4, 2, 1]
9012
+ *
9013
+ * Numo::DComplex.new(5).logseq(0,1i*Math::PI/3,Math::E)
9014
+ * # => Numo::DComplex#shape=[5]
9015
+ * # [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
9016
+ */
9365
9017
  rb_define_method(cT, "logseq", dfloat_logseq, -1);
9018
+ /**
9019
+ * Eye: Set a value to diagonal components, set 0 to non-diagonal components.
9020
+ * @overload eye([element,offset])
9021
+ * @param [Numeric] element Diagonal element to be stored. Default is 1.
9022
+ * @param [Integer] offset Diagonal offset from the main diagonal.
9023
+ * The default is 0. k>0 for diagonals above the main diagonal,
9024
+ * and k<0 for diagonals below the main diagonal.
9025
+ * @return [Numo::DFloat] eye of self.
9026
+ */
9366
9027
  rb_define_method(cT, "eye", dfloat_eye, -1);
9367
9028
  rb_define_alias(cT, "indgen", "seq");
9029
+ /**
9030
+ * Generate uniformly distributed random numbers on self narray.
9031
+ * @overload rand([[low],high])
9032
+ * @param [Numeric] low lower inclusive boundary of random numbers. (default=0)
9033
+ * @param [Numeric] high upper exclusive boundary of random numbers.
9034
+ * (default=1 or 1+1i for complex types)
9035
+ * @return [Numo::DFloat] self.
9036
+ * @example
9037
+ * Numo::DFloat.new(6).rand
9038
+ * # => Numo::DFloat#shape=[6]
9039
+ * # [0.0617545, 0.373067, 0.794815, 0.201042, 0.116041, 0.344032]
9040
+ *
9041
+ * Numo::DComplex.new(6).rand(5+5i)
9042
+ * # => Numo::DComplex#shape=[6]
9043
+ * # [2.69974+3.68908i, 0.825443+0.254414i, 0.540323+0.34354i, 4.52061+2.39322i, ...]
9044
+ *
9045
+ * Numo::Int32.new(6).rand(2,5)
9046
+ * # => Numo::Int32#shape=[6]
9047
+ * # [4, 3, 3, 2, 4, 2]
9048
+ */
9368
9049
  rb_define_method(cT, "rand", dfloat_rand, -1);
9050
+ /**
9051
+ * Generates random numbers from the normal distribution on self narray
9052
+ * using Box-Muller Transformation.
9053
+ * @overload rand_norm([mu,[sigma]])
9054
+ * @param [Numeric] mu mean of normal distribution. (default=0)
9055
+ * @param [Numeric] sigma standard deviation of normal distribution. (default=1)
9056
+ * @return [Numo::DFloat] self.
9057
+ * @example
9058
+ * Numo::DFloat.new(5,5).rand_norm
9059
+ * # => Numo::DFloat#shape=[5,5]
9060
+ * # [[-0.581255, -0.168354, 0.586895, -0.595142, -0.802802],
9061
+ * # [-0.326106, 0.282922, 1.68427, 0.918499, -0.0485384],
9062
+ * # [-0.464453, -0.992194, 0.413794, -0.60717, -0.699695],
9063
+ * # [-1.64168, 0.48676, -0.875871, -1.43275, 0.812172],
9064
+ * # [-0.209975, -0.103612, -0.878617, -1.42495, 1.0968]]
9065
+ *
9066
+ * Numo::DFloat.new(5,5).rand_norm(10,0.1)
9067
+ * # => Numo::DFloat#shape=[5,5]
9068
+ * # [[9.9019, 9.90339, 10.0826, 9.98384, 9.72861],
9069
+ * # [9.81507, 10.0272, 9.91445, 10.0568, 9.88923],
9070
+ * # [10.0234, 9.97874, 9.96011, 9.9006, 9.99964],
9071
+ * # [10.0186, 9.94598, 9.92236, 9.99811, 9.97003],
9072
+ * # [9.79266, 9.95044, 9.95212, 9.93692, 10.2027]]
9073
+ *
9074
+ * Numo::DComplex.new(3,3).rand_norm(5+5i)
9075
+ * # => Numo::DComplex#shape=[3,3]
9076
+ * # [[5.84303+4.40052i, 4.00984+6.08982i, 5.10979+5.13215i],
9077
+ * # [4.26477+3.99655i, 4.90052+5.00763i, 4.46607+2.3444i],
9078
+ * # [4.5528+7.11003i, 5.62117+6.69094i, 5.05443+5.35133i]]
9079
+ */
9369
9080
  rb_define_method(cT, "rand_norm", dfloat_rand_norm, -1);
9081
+ /**
9082
+ * Calculate polynomial.
9083
+ * `x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
9084
+ * @overload poly a0, a1, ..., an
9085
+ * @param [Numo::NArray,Numeric] a0,a1,...,an
9086
+ * @return [Numo::DFloat]
9087
+ */
9370
9088
  rb_define_method(cT, "poly", dfloat_poly, -2);
9371
-
9089
+ /**
9090
+ * sort of self.
9091
+ * @overload sort(axis:nil, nan:false)
9092
+ * @param [Boolean] nan If true, propagete NaN. If false, ignore NaN.
9093
+ * @param [Numeric,Array,Range] axis Performs sort along the axis.
9094
+ * @return [Numo::DFloat] returns result of sort.
9095
+ * @example
9096
+ * Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
9097
+ */
9372
9098
  rb_define_method(cT, "sort", dfloat_sort, -1);
9373
-
9099
+ /**
9100
+ * sort_index. Returns an index array of sort result.
9101
+ * @overload sort_index(axis:nil, nan:false)
9102
+ * @param [Boolean] nan If true, propagete NaN. If false, ignore NaN.
9103
+ * @param [Numeric,Array,Range] axis Performs sort_index along the axis.
9104
+ * @return [Integer,Numo::Int] returns result index of sort_index.
9105
+ * @example
9106
+ * Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
9107
+ */
9374
9108
  rb_define_method(cT, "sort_index", dfloat_sort_index, -1);
9109
+ /**
9110
+ * median of self.
9111
+ * @overload median(axis:nil, keepdims:false, nan:false)
9112
+ * @param [Boolean] nan (keyword) If true, propagete NaN. If false, ignore NaN.
9113
+ * @param [Numeric,Array,Range] axis Finds median along the axis.
9114
+ * @param [Boolean] keepdims If true, the reduced axes are left
9115
+ * in the result array as dimensions with size one.
9116
+ * @return [Numo::DFloat] returns median of self.
9117
+ */
9375
9118
  rb_define_method(cT, "median", dfloat_median, -1);
9376
- rb_define_singleton_method(cT, "[]", dfloat_s_cast, -2);
9377
-
9378
- /*
9379
- Document-module: Numo::DFloat::NMath
9380
-
9381
- */
9382
9119
 
9120
+ /**
9121
+ * Document-module: Numo::DFloat::Math
9122
+ *
9123
+ * This module contains mathematical functions for Numo::DFloat.
9124
+ */
9383
9125
  mTM = rb_define_module_under(cT, "Math");
9384
-
9126
+ /**
9127
+ * Calculate sqrt(x).
9128
+ * @overload sqrt(x)
9129
+ * @param [Numo::NArray,Numeric] x input value
9130
+ * @return [Numo::DFloat] result of sqrt(x).
9131
+ */
9385
9132
  rb_define_module_function(mTM, "sqrt", dfloat_math_s_sqrt, 1);
9133
+ /**
9134
+ * Calculate cbrt(x).
9135
+ * @overload cbrt(x)
9136
+ * @param [Numo::NArray,Numeric] x input value
9137
+ * @return [Numo::DFloat] result of cbrt(x).
9138
+ */
9386
9139
  rb_define_module_function(mTM, "cbrt", dfloat_math_s_cbrt, 1);
9140
+ /**
9141
+ * Calculate log(x).
9142
+ * @overload log(x)
9143
+ * @param [Numo::NArray,Numeric] x input value
9144
+ * @return [Numo::DFloat] result of log(x).
9145
+ */
9387
9146
  rb_define_module_function(mTM, "log", dfloat_math_s_log, 1);
9147
+ /**
9148
+ * Calculate log2(x).
9149
+ * @overload log2(x)
9150
+ * @param [Numo::NArray,Numeric] x input value
9151
+ * @return [Numo::DFloat] result of log2(x).
9152
+ */
9388
9153
  rb_define_module_function(mTM, "log2", dfloat_math_s_log2, 1);
9154
+ /**
9155
+ * Calculate log10(x).
9156
+ * @overload log10(x)
9157
+ * @param [Numo::NArray,Numeric] x input value
9158
+ * @return [Numo::DFloat] result of log10(x).
9159
+ */
9389
9160
  rb_define_module_function(mTM, "log10", dfloat_math_s_log10, 1);
9161
+ /**
9162
+ * Calculate exp(x).
9163
+ * @overload exp(x)
9164
+ * @param [Numo::NArray,Numeric] x input value
9165
+ * @return [Numo::DFloat] result of exp(x).
9166
+ */
9390
9167
  rb_define_module_function(mTM, "exp", dfloat_math_s_exp, 1);
9168
+ /**
9169
+ * Calculate exp2(x).
9170
+ * @overload exp2(x)
9171
+ * @param [Numo::NArray,Numeric] x input value
9172
+ * @return [Numo::DFloat] result of exp2(x).
9173
+ */
9391
9174
  rb_define_module_function(mTM, "exp2", dfloat_math_s_exp2, 1);
9175
+ /**
9176
+ * Calculate exp10(x).
9177
+ * @overload exp10(x)
9178
+ * @param [Numo::NArray,Numeric] x input value
9179
+ * @return [Numo::DFloat] result of exp10(x).
9180
+ */
9392
9181
  rb_define_module_function(mTM, "exp10", dfloat_math_s_exp10, 1);
9182
+ /**
9183
+ * Calculate sin(x).
9184
+ * @overload sin(x)
9185
+ * @param [Numo::NArray,Numeric] x input value
9186
+ * @return [Numo::DFloat] result of sin(x).
9187
+ */
9393
9188
  rb_define_module_function(mTM, "sin", dfloat_math_s_sin, 1);
9189
+ /**
9190
+ * Calculate cos(x).
9191
+ * @overload cos(x)
9192
+ * @param [Numo::NArray,Numeric] x input value
9193
+ * @return [Numo::DFloat] result of cos(x).
9194
+ */
9394
9195
  rb_define_module_function(mTM, "cos", dfloat_math_s_cos, 1);
9196
+ /**
9197
+ * Calculate tan(x).
9198
+ * @overload tan(x)
9199
+ * @param [Numo::NArray,Numeric] x input value
9200
+ * @return [Numo::DFloat] result of tan(x).
9201
+ */
9395
9202
  rb_define_module_function(mTM, "tan", dfloat_math_s_tan, 1);
9203
+ /**
9204
+ * Calculate asin(x).
9205
+ * @overload asin(x)
9206
+ * @param [Numo::NArray,Numeric] x input value
9207
+ * @return [Numo::DFloat] result of asin(x).
9208
+ */
9396
9209
  rb_define_module_function(mTM, "asin", dfloat_math_s_asin, 1);
9210
+ /**
9211
+ * Calculate acos(x).
9212
+ * @overload acos(x)
9213
+ * @param [Numo::NArray,Numeric] x input value
9214
+ * @return [Numo::DFloat] result of acos(x).
9215
+ */
9397
9216
  rb_define_module_function(mTM, "acos", dfloat_math_s_acos, 1);
9217
+ /**
9218
+ * Calculate atan(x).
9219
+ * @overload atan(x)
9220
+ * @param [Numo::NArray,Numeric] x input value
9221
+ * @return [Numo::DFloat] result of atan(x).
9222
+ */
9398
9223
  rb_define_module_function(mTM, "atan", dfloat_math_s_atan, 1);
9224
+ /**
9225
+ * Calculate sinh(x).
9226
+ * @overload sinh(x)
9227
+ * @param [Numo::NArray,Numeric] x input value
9228
+ * @return [Numo::DFloat] result of sinh(x).
9229
+ */
9399
9230
  rb_define_module_function(mTM, "sinh", dfloat_math_s_sinh, 1);
9231
+ /**
9232
+ * Calculate cosh(x).
9233
+ * @overload cosh(x)
9234
+ * @param [Numo::NArray,Numeric] x input value
9235
+ * @return [Numo::DFloat] result of cosh(x).
9236
+ */
9400
9237
  rb_define_module_function(mTM, "cosh", dfloat_math_s_cosh, 1);
9238
+ /**
9239
+ * Calculate tanh(x).
9240
+ * @overload tanh(x)
9241
+ * @param [Numo::NArray,Numeric] x input value
9242
+ * @return [Numo::DFloat] result of tanh(x).
9243
+ */
9401
9244
  rb_define_module_function(mTM, "tanh", dfloat_math_s_tanh, 1);
9245
+ /**
9246
+ * Calculate asinh(x).
9247
+ * @overload asinh(x)
9248
+ * @param [Numo::NArray,Numeric] x input value
9249
+ * @return [Numo::DFloat] result of asinh(x).
9250
+ */
9402
9251
  rb_define_module_function(mTM, "asinh", dfloat_math_s_asinh, 1);
9252
+ /**
9253
+ * Calculate acosh(x).
9254
+ * @overload acosh(x)
9255
+ * @param [Numo::NArray,Numeric] x input value
9256
+ * @return [Numo::DFloat] result of acosh(x).
9257
+ */
9403
9258
  rb_define_module_function(mTM, "acosh", dfloat_math_s_acosh, 1);
9259
+ /**
9260
+ * Calculate atanh(x).
9261
+ * @overload atanh(x)
9262
+ * @param [Numo::NArray,Numeric] x input value
9263
+ * @return [Numo::DFloat] result of atanh(x).
9264
+ */
9404
9265
  rb_define_module_function(mTM, "atanh", dfloat_math_s_atanh, 1);
9266
+ /**
9267
+ * Calculate sinc(x).
9268
+ * @overload sinc(x)
9269
+ * @param [Numo::NArray,Numeric] x input value
9270
+ * @return [Numo::DFloat] result of sinc(x).
9271
+ */
9405
9272
  rb_define_module_function(mTM, "sinc", dfloat_math_s_sinc, 1);
9273
+ /**
9274
+ * Calculate atan2(a1,a2).
9275
+ * @overload atan2(a1,a2)
9276
+ * @param [Numo::NArray,Numeric] a1 first value
9277
+ * @param [Numo::NArray,Numeric] a2 second value
9278
+ * @return [Numo::DFloat] atan2(a1,a2).
9279
+ */
9406
9280
  rb_define_module_function(mTM, "atan2", dfloat_math_s_atan2, 2);
9281
+ /**
9282
+ * Calculate hypot(a1,a2).
9283
+ * @overload hypot(a1,a2)
9284
+ * @param [Numo::NArray,Numeric] a1 first value
9285
+ * @param [Numo::NArray,Numeric] a2 second value
9286
+ * @return [Numo::DFloat] hypot(a1,a2).
9287
+ */
9407
9288
  rb_define_module_function(mTM, "hypot", dfloat_math_s_hypot, 2);
9289
+ /**
9290
+ * Calculate erf(x).
9291
+ * @overload erf(x)
9292
+ * @param [Numo::NArray,Numeric] x input value
9293
+ * @return [Numo::DFloat] result of erf(x).
9294
+ */
9408
9295
  rb_define_module_function(mTM, "erf", dfloat_math_s_erf, 1);
9296
+ /**
9297
+ * Calculate erfc(x).
9298
+ * @overload erfc(x)
9299
+ * @param [Numo::NArray,Numeric] x input value
9300
+ * @return [Numo::DFloat] result of erfc(x).
9301
+ */
9409
9302
  rb_define_module_function(mTM, "erfc", dfloat_math_s_erfc, 1);
9303
+ /**
9304
+ * Calculate log1p(x).
9305
+ * @overload log1p(x)
9306
+ * @param [Numo::NArray,Numeric] x input value
9307
+ * @return [Numo::DFloat] result of log1p(x).
9308
+ */
9410
9309
  rb_define_module_function(mTM, "log1p", dfloat_math_s_log1p, 1);
9310
+ /**
9311
+ * Calculate expm1(x).
9312
+ * @overload expm1(x)
9313
+ * @param [Numo::NArray,Numeric] x input value
9314
+ * @return [Numo::DFloat] result of expm1(x).
9315
+ */
9411
9316
  rb_define_module_function(mTM, "expm1", dfloat_math_s_expm1, 1);
9317
+ /**
9318
+ * Calculate ldexp(a1,a2).
9319
+ * @overload ldexp(a1,a2)
9320
+ * @param [Numo::NArray,Numeric] a1 first value
9321
+ * @param [Numo::NArray,Numeric] a2 second value
9322
+ * @return [Numo::DFloat] ldexp(a1,a2).
9323
+ */
9412
9324
  rb_define_module_function(mTM, "ldexp", dfloat_math_s_ldexp, 2);
9325
+ /**
9326
+ * split the number x into a normalized fraction and an exponent.
9327
+ * Returns [mantissa, exponent], where x = mantissa * 2**exponent.
9328
+ *
9329
+ * @overload frexp(x)
9330
+ * @param [Numo::NArray,Numeric] x
9331
+ * @return [Numo::DFloat,Numo::Int32] mantissa and exponent.
9332
+ */
9413
9333
  rb_define_module_function(mTM, "frexp", dfloat_math_s_frexp, 1);
9414
9334
 
9415
9335
  // how to do this?