numo-narray-alt 0.9.4 → 0.9.5
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.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/Rakefile +8 -0
- data/ext/numo/narray/SFMT-params19937.h +16 -12
- data/ext/numo/narray/SFMT.c +12 -5
- data/ext/numo/narray/array.c +25 -19
- data/ext/numo/narray/data.c +74 -70
- data/ext/numo/narray/extconf.rb +1 -0
- data/ext/numo/narray/index.c +49 -26
- data/ext/numo/narray/kwargs.c +11 -9
- data/ext/numo/narray/math.c +4 -2
- data/ext/numo/narray/narray.c +17 -10
- data/ext/numo/narray/ndloop.c +52 -63
- data/ext/numo/narray/numo/intern.h +9 -3
- data/ext/numo/narray/numo/narray.h +20 -20
- data/ext/numo/narray/numo/ndloop.h +1 -1
- data/ext/numo/narray/numo/template.h +85 -81
- data/ext/numo/narray/numo/types/complex.h +7 -3
- data/ext/numo/narray/numo/types/complex_macro.h +27 -25
- data/ext/numo/narray/numo/types/float_macro.h +20 -17
- data/ext/numo/narray/numo/types/real_accum.h +22 -22
- data/ext/numo/narray/numo/types/robj_macro.h +19 -12
- data/ext/numo/narray/numo/types/xint_macro.h +9 -8
- data/ext/numo/narray/src/t_bit.c +97 -88
- data/ext/numo/narray/src/t_dcomplex.c +336 -307
- data/ext/numo/narray/src/t_dfloat.c +522 -456
- data/ext/numo/narray/src/t_int16.c +351 -308
- data/ext/numo/narray/src/t_int32.c +351 -308
- data/ext/numo/narray/src/t_int64.c +351 -308
- data/ext/numo/narray/src/t_int8.c +309 -288
- data/ext/numo/narray/src/t_mean.c +105 -0
- data/ext/numo/narray/src/t_robject.c +323 -296
- data/ext/numo/narray/src/t_scomplex.c +327 -302
- data/ext/numo/narray/src/t_sfloat.c +515 -451
- data/ext/numo/narray/src/t_uint16.c +351 -308
- data/ext/numo/narray/src/t_uint32.c +351 -308
- data/ext/numo/narray/src/t_uint64.c +351 -308
- data/ext/numo/narray/src/t_uint8.c +311 -288
- data/ext/numo/narray/step.c +7 -2
- data/ext/numo/narray/struct.c +24 -22
- data/lib/numo/narray/extra.rb +66 -25
- data/numo-narray-alt.gemspec +38 -0
- metadata +7 -1
@@ -238,8 +238,8 @@ static void iter_uint8_store_bit(na_loop_t* const lp) {
|
|
238
238
|
}
|
239
239
|
|
240
240
|
static VALUE uint8_store_bit(VALUE self, VALUE obj) {
|
241
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
242
|
-
ndfunc_t ndf = {iter_uint8_store_bit, FULL_LOOP, 2, 0, ain, 0};
|
241
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
242
|
+
ndfunc_t ndf = { iter_uint8_store_bit, FULL_LOOP, 2, 0, ain, 0 };
|
243
243
|
|
244
244
|
na_ndloop(&ndf, 2, self, obj);
|
245
245
|
return self;
|
@@ -287,8 +287,8 @@ static void iter_uint8_store_dfloat(na_loop_t* const lp) {
|
|
287
287
|
}
|
288
288
|
|
289
289
|
static VALUE uint8_store_dfloat(VALUE self, VALUE obj) {
|
290
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
291
|
-
ndfunc_t ndf = {iter_uint8_store_dfloat, FULL_LOOP, 2, 0, ain, 0};
|
290
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
291
|
+
ndfunc_t ndf = { iter_uint8_store_dfloat, FULL_LOOP, 2, 0, ain, 0 };
|
292
292
|
|
293
293
|
na_ndloop(&ndf, 2, self, obj);
|
294
294
|
return self;
|
@@ -336,8 +336,8 @@ static void iter_uint8_store_sfloat(na_loop_t* const lp) {
|
|
336
336
|
}
|
337
337
|
|
338
338
|
static VALUE uint8_store_sfloat(VALUE self, VALUE obj) {
|
339
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
340
|
-
ndfunc_t ndf = {iter_uint8_store_sfloat, FULL_LOOP, 2, 0, ain, 0};
|
339
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
340
|
+
ndfunc_t ndf = { iter_uint8_store_sfloat, FULL_LOOP, 2, 0, ain, 0 };
|
341
341
|
|
342
342
|
na_ndloop(&ndf, 2, self, obj);
|
343
343
|
return self;
|
@@ -385,8 +385,8 @@ static void iter_uint8_store_int64(na_loop_t* const lp) {
|
|
385
385
|
}
|
386
386
|
|
387
387
|
static VALUE uint8_store_int64(VALUE self, VALUE obj) {
|
388
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
389
|
-
ndfunc_t ndf = {iter_uint8_store_int64, FULL_LOOP, 2, 0, ain, 0};
|
388
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
389
|
+
ndfunc_t ndf = { iter_uint8_store_int64, FULL_LOOP, 2, 0, ain, 0 };
|
390
390
|
|
391
391
|
na_ndloop(&ndf, 2, self, obj);
|
392
392
|
return self;
|
@@ -434,8 +434,8 @@ static void iter_uint8_store_int32(na_loop_t* const lp) {
|
|
434
434
|
}
|
435
435
|
|
436
436
|
static VALUE uint8_store_int32(VALUE self, VALUE obj) {
|
437
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
438
|
-
ndfunc_t ndf = {iter_uint8_store_int32, FULL_LOOP, 2, 0, ain, 0};
|
437
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
438
|
+
ndfunc_t ndf = { iter_uint8_store_int32, FULL_LOOP, 2, 0, ain, 0 };
|
439
439
|
|
440
440
|
na_ndloop(&ndf, 2, self, obj);
|
441
441
|
return self;
|
@@ -483,8 +483,8 @@ static void iter_uint8_store_int16(na_loop_t* const lp) {
|
|
483
483
|
}
|
484
484
|
|
485
485
|
static VALUE uint8_store_int16(VALUE self, VALUE obj) {
|
486
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
487
|
-
ndfunc_t ndf = {iter_uint8_store_int16, FULL_LOOP, 2, 0, ain, 0};
|
486
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
487
|
+
ndfunc_t ndf = { iter_uint8_store_int16, FULL_LOOP, 2, 0, ain, 0 };
|
488
488
|
|
489
489
|
na_ndloop(&ndf, 2, self, obj);
|
490
490
|
return self;
|
@@ -532,8 +532,8 @@ static void iter_uint8_store_int8(na_loop_t* const lp) {
|
|
532
532
|
}
|
533
533
|
|
534
534
|
static VALUE uint8_store_int8(VALUE self, VALUE obj) {
|
535
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
536
|
-
ndfunc_t ndf = {iter_uint8_store_int8, FULL_LOOP, 2, 0, ain, 0};
|
535
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
536
|
+
ndfunc_t ndf = { iter_uint8_store_int8, FULL_LOOP, 2, 0, ain, 0 };
|
537
537
|
|
538
538
|
na_ndloop(&ndf, 2, self, obj);
|
539
539
|
return self;
|
@@ -581,8 +581,8 @@ static void iter_uint8_store_uint64(na_loop_t* const lp) {
|
|
581
581
|
}
|
582
582
|
|
583
583
|
static VALUE uint8_store_uint64(VALUE self, VALUE obj) {
|
584
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
585
|
-
ndfunc_t ndf = {iter_uint8_store_uint64, FULL_LOOP, 2, 0, ain, 0};
|
584
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
585
|
+
ndfunc_t ndf = { iter_uint8_store_uint64, FULL_LOOP, 2, 0, ain, 0 };
|
586
586
|
|
587
587
|
na_ndloop(&ndf, 2, self, obj);
|
588
588
|
return self;
|
@@ -630,8 +630,8 @@ static void iter_uint8_store_uint32(na_loop_t* const lp) {
|
|
630
630
|
}
|
631
631
|
|
632
632
|
static VALUE uint8_store_uint32(VALUE self, VALUE obj) {
|
633
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
634
|
-
ndfunc_t ndf = {iter_uint8_store_uint32, FULL_LOOP, 2, 0, ain, 0};
|
633
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
634
|
+
ndfunc_t ndf = { iter_uint8_store_uint32, FULL_LOOP, 2, 0, ain, 0 };
|
635
635
|
|
636
636
|
na_ndloop(&ndf, 2, self, obj);
|
637
637
|
return self;
|
@@ -679,8 +679,8 @@ static void iter_uint8_store_uint16(na_loop_t* const lp) {
|
|
679
679
|
}
|
680
680
|
|
681
681
|
static VALUE uint8_store_uint16(VALUE self, VALUE obj) {
|
682
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
683
|
-
ndfunc_t ndf = {iter_uint8_store_uint16, FULL_LOOP, 2, 0, ain, 0};
|
682
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
683
|
+
ndfunc_t ndf = { iter_uint8_store_uint16, FULL_LOOP, 2, 0, ain, 0 };
|
684
684
|
|
685
685
|
na_ndloop(&ndf, 2, self, obj);
|
686
686
|
return self;
|
@@ -728,8 +728,8 @@ static void iter_uint8_store_uint8(na_loop_t* const lp) {
|
|
728
728
|
}
|
729
729
|
|
730
730
|
static VALUE uint8_store_uint8(VALUE self, VALUE obj) {
|
731
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
732
|
-
ndfunc_t ndf = {iter_uint8_store_uint8, FULL_LOOP, 2, 0, ain, 0};
|
731
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
732
|
+
ndfunc_t ndf = { iter_uint8_store_uint8, FULL_LOOP, 2, 0, ain, 0 };
|
733
733
|
|
734
734
|
na_ndloop(&ndf, 2, self, obj);
|
735
735
|
return self;
|
@@ -777,8 +777,8 @@ static void iter_uint8_store_robject(na_loop_t* const lp) {
|
|
777
777
|
}
|
778
778
|
|
779
779
|
static VALUE uint8_store_robject(VALUE self, VALUE obj) {
|
780
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
781
|
-
ndfunc_t ndf = {iter_uint8_store_robject, FULL_LOOP, 2, 0, ain, 0};
|
780
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
781
|
+
ndfunc_t ndf = { iter_uint8_store_robject, FULL_LOOP, 2, 0, ain, 0 };
|
782
782
|
|
783
783
|
na_ndloop(&ndf, 2, self, obj);
|
784
784
|
return self;
|
@@ -886,8 +886,8 @@ loop_end:
|
|
886
886
|
}
|
887
887
|
|
888
888
|
static VALUE uint8_store_array(VALUE self, VALUE rary) {
|
889
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {rb_cArray, 0}};
|
890
|
-
ndfunc_t ndf = {iter_uint8_store_array, FULL_LOOP, 2, 0, ain, 0};
|
889
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { rb_cArray, 0 } };
|
890
|
+
ndfunc_t ndf = { iter_uint8_store_array, FULL_LOOP, 2, 0, ain, 0 };
|
891
891
|
|
892
892
|
na_ndloop_store_rarray(&ndf, self, rary);
|
893
893
|
return self;
|
@@ -982,8 +982,10 @@ static VALUE uint8_store(VALUE self, VALUE obj) {
|
|
982
982
|
}
|
983
983
|
}
|
984
984
|
|
985
|
-
rb_raise(
|
986
|
-
|
985
|
+
rb_raise(
|
986
|
+
nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
|
987
|
+
rb_class2name(rb_obj_class(self))
|
988
|
+
);
|
987
989
|
|
988
990
|
return self;
|
989
991
|
}
|
@@ -1077,7 +1079,10 @@ static dtype uint8_extract_data(VALUE obj) {
|
|
1077
1079
|
return uint8_extract_data(r);
|
1078
1080
|
}
|
1079
1081
|
|
1080
|
-
rb_raise(
|
1082
|
+
rb_raise(
|
1083
|
+
nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
|
1084
|
+
rb_class2name(cT)
|
1085
|
+
);
|
1081
1086
|
}
|
1082
1087
|
if (TYPE(obj) == T_ARRAY) {
|
1083
1088
|
if (RARRAY_LEN(obj) != 1) {
|
@@ -1146,8 +1151,8 @@ static VALUE uint8_s_cast(VALUE type, VALUE obj) {
|
|
1146
1151
|
/*
|
1147
1152
|
Multi-dimensional element reference.
|
1148
1153
|
@overload [](dim0,...,dimL)
|
1149
|
-
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
|
1150
|
-
indices.
|
1154
|
+
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
|
1155
|
+
dim0,...,dimL multi-dimensional indices.
|
1151
1156
|
@return [Numeric,Numo::UInt8] an element or NArray view.
|
1152
1157
|
@see Numo::NArray#[]
|
1153
1158
|
@see #[]=
|
@@ -1169,8 +1174,8 @@ static VALUE uint8_aref(int argc, VALUE* argv, VALUE self) {
|
|
1169
1174
|
/*
|
1170
1175
|
Multi-dimensional element assignment.
|
1171
1176
|
@overload []=(dim0,...,dimL,val)
|
1172
|
-
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
|
1173
|
-
indices.
|
1177
|
+
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
|
1178
|
+
dim0,...,dimL multi-dimensional indices.
|
1174
1179
|
@param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
|
1175
1180
|
@return [Numeric,Numo::NArray,Array] returns `val` (last argument).
|
1176
1181
|
@see Numo::NArray#[]=
|
@@ -1241,9 +1246,9 @@ static void iter_uint8_to_a(na_loop_t* const lp) {
|
|
1241
1246
|
@return [Array]
|
1242
1247
|
*/
|
1243
1248
|
static VALUE uint8_to_a(VALUE self) {
|
1244
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
|
1245
|
-
ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
|
1246
|
-
ndfunc_t ndf = {iter_uint8_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
|
1249
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
|
1250
|
+
ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
|
1251
|
+
ndfunc_t ndf = { iter_uint8_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
|
1247
1252
|
return na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
|
1248
1253
|
}
|
1249
1254
|
|
@@ -1275,8 +1280,8 @@ static void iter_uint8_fill(na_loop_t* const lp) {
|
|
1275
1280
|
@return [Numo::UInt8] self.
|
1276
1281
|
*/
|
1277
1282
|
static VALUE uint8_fill(VALUE self, VALUE val) {
|
1278
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_option}};
|
1279
|
-
ndfunc_t ndf = {iter_uint8_fill, FULL_LOOP, 2, 0, ain, 0};
|
1283
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
|
1284
|
+
ndfunc_t ndf = { iter_uint8_fill, FULL_LOOP, 2, 0, ain, 0 };
|
1280
1285
|
|
1281
1286
|
na_ndloop(&ndf, 2, self, val);
|
1282
1287
|
return self;
|
@@ -1331,9 +1336,9 @@ static void iter_uint8_format(na_loop_t* const lp) {
|
|
1331
1336
|
static VALUE uint8_format(int argc, VALUE* argv, VALUE self) {
|
1332
1337
|
VALUE fmt = Qnil;
|
1333
1338
|
|
1334
|
-
ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_option}};
|
1335
|
-
ndfunc_arg_out_t aout[1] = {{numo_cRObject, 0}};
|
1336
|
-
ndfunc_t ndf = {iter_uint8_format, FULL_LOOP_NIP, 2, 1, ain, aout};
|
1339
|
+
ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_option } };
|
1340
|
+
ndfunc_arg_out_t aout[1] = { { numo_cRObject, 0 } };
|
1341
|
+
ndfunc_t ndf = { iter_uint8_format, FULL_LOOP_NIP, 2, 1, ain, aout };
|
1337
1342
|
|
1338
1343
|
rb_scan_args(argc, argv, "01", &fmt);
|
1339
1344
|
return na_ndloop(&ndf, 2, self, fmt);
|
@@ -1377,9 +1382,9 @@ static void iter_uint8_format_to_a(na_loop_t* const lp) {
|
|
1377
1382
|
*/
|
1378
1383
|
static VALUE uint8_format_to_a(int argc, VALUE* argv, VALUE self) {
|
1379
1384
|
VALUE fmt = Qnil;
|
1380
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
|
1381
|
-
ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
|
1382
|
-
ndfunc_t ndf = {iter_uint8_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
|
1385
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
|
1386
|
+
ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
|
1387
|
+
ndfunc_t ndf = { iter_uint8_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
|
1383
1388
|
|
1384
1389
|
rb_scan_args(argc, argv, "01", &fmt);
|
1385
1390
|
return na_ndloop_cast_narray_to_rarray(&ndf, self, fmt);
|
@@ -1433,8 +1438,8 @@ static void iter_uint8_each(na_loop_t* const lp) {
|
|
1433
1438
|
@see #map
|
1434
1439
|
*/
|
1435
1440
|
static VALUE uint8_each(VALUE self) {
|
1436
|
-
ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
|
1437
|
-
ndfunc_t ndf = {iter_uint8_each, FULL_LOOP_NIP, 1, 0, ain, 0};
|
1441
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1442
|
+
ndfunc_t ndf = { iter_uint8_each, FULL_LOOP_NIP, 1, 0, ain, 0 };
|
1438
1443
|
|
1439
1444
|
na_ndloop(&ndf, 1, self);
|
1440
1445
|
return self;
|
@@ -1491,9 +1496,9 @@ static void iter_uint8_map(na_loop_t* const lp) {
|
|
1491
1496
|
@return [Numo::UInt8] map of self.
|
1492
1497
|
*/
|
1493
1498
|
static VALUE uint8_map(VALUE self) {
|
1494
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
1495
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1496
|
-
ndfunc_t ndf = {iter_uint8_map, FULL_LOOP, 1, 1, ain, aout};
|
1499
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
1500
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1501
|
+
ndfunc_t ndf = { iter_uint8_map, FULL_LOOP, 1, 1, ain, aout };
|
1497
1502
|
|
1498
1503
|
return na_ndloop(&ndf, 1, self);
|
1499
1504
|
}
|
@@ -1555,8 +1560,8 @@ static void iter_uint8_each_with_index(na_loop_t* const lp) {
|
|
1555
1560
|
@see #map_with_index
|
1556
1561
|
*/
|
1557
1562
|
static VALUE uint8_each_with_index(VALUE self) {
|
1558
|
-
ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
|
1559
|
-
ndfunc_t ndf = {iter_uint8_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0};
|
1563
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1564
|
+
ndfunc_t ndf = { iter_uint8_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0 };
|
1560
1565
|
|
1561
1566
|
na_ndloop_with_index(&ndf, 1, self);
|
1562
1567
|
return self;
|
@@ -1646,9 +1651,9 @@ static void iter_uint8_map_with_index(na_loop_t* const lp) {
|
|
1646
1651
|
@see #each_with_index
|
1647
1652
|
*/
|
1648
1653
|
static VALUE uint8_map_with_index(VALUE self) {
|
1649
|
-
ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
|
1650
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1651
|
-
ndfunc_t ndf = {iter_uint8_map_with_index, FULL_LOOP, 1, 1, ain, aout};
|
1654
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1655
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1656
|
+
ndfunc_t ndf = { iter_uint8_map_with_index, FULL_LOOP, 1, 1, ain, aout };
|
1652
1657
|
|
1653
1658
|
return na_ndloop_with_index(&ndf, 1, self);
|
1654
1659
|
}
|
@@ -1700,14 +1705,14 @@ static void iter_uint8_abs(na_loop_t* const lp) {
|
|
1700
1705
|
@return [Numo::UInt8] abs of self.
|
1701
1706
|
*/
|
1702
1707
|
static VALUE uint8_abs(VALUE self) {
|
1703
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
1704
|
-
ndfunc_arg_out_t aout[1] = {{cRT, 0}};
|
1705
|
-
ndfunc_t ndf = {iter_uint8_abs, FULL_LOOP, 1, 1, ain, aout};
|
1708
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
1709
|
+
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
1710
|
+
ndfunc_t ndf = { iter_uint8_abs, FULL_LOOP, 1, 1, ain, aout };
|
1706
1711
|
|
1707
1712
|
return na_ndloop(&ndf, 1, self);
|
1708
1713
|
}
|
1709
1714
|
|
1710
|
-
#define check_intdivzero(y)
|
1715
|
+
#define check_intdivzero(y) \
|
1711
1716
|
{}
|
1712
1717
|
|
1713
1718
|
static void iter_uint8_add(na_loop_t* const lp) {
|
@@ -1767,9 +1772,9 @@ static void iter_uint8_add(na_loop_t* const lp) {
|
|
1767
1772
|
#undef check_intdivzero
|
1768
1773
|
|
1769
1774
|
static VALUE uint8_add_self(VALUE self, VALUE other) {
|
1770
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
1771
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1772
|
-
ndfunc_t ndf = {iter_uint8_add, STRIDE_LOOP, 2, 1, ain, aout};
|
1775
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
1776
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1777
|
+
ndfunc_t ndf = { iter_uint8_add, STRIDE_LOOP, 2, 1, ain, aout };
|
1773
1778
|
|
1774
1779
|
return na_ndloop(&ndf, 2, self, other);
|
1775
1780
|
}
|
@@ -1793,7 +1798,7 @@ static VALUE uint8_add(VALUE self, VALUE other) {
|
|
1793
1798
|
}
|
1794
1799
|
}
|
1795
1800
|
|
1796
|
-
#define check_intdivzero(y)
|
1801
|
+
#define check_intdivzero(y) \
|
1797
1802
|
{}
|
1798
1803
|
|
1799
1804
|
static void iter_uint8_sub(na_loop_t* const lp) {
|
@@ -1853,9 +1858,9 @@ static void iter_uint8_sub(na_loop_t* const lp) {
|
|
1853
1858
|
#undef check_intdivzero
|
1854
1859
|
|
1855
1860
|
static VALUE uint8_sub_self(VALUE self, VALUE other) {
|
1856
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
1857
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1858
|
-
ndfunc_t ndf = {iter_uint8_sub, STRIDE_LOOP, 2, 1, ain, aout};
|
1861
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
1862
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1863
|
+
ndfunc_t ndf = { iter_uint8_sub, STRIDE_LOOP, 2, 1, ain, aout };
|
1859
1864
|
|
1860
1865
|
return na_ndloop(&ndf, 2, self, other);
|
1861
1866
|
}
|
@@ -1879,7 +1884,7 @@ static VALUE uint8_sub(VALUE self, VALUE other) {
|
|
1879
1884
|
}
|
1880
1885
|
}
|
1881
1886
|
|
1882
|
-
#define check_intdivzero(y)
|
1887
|
+
#define check_intdivzero(y) \
|
1883
1888
|
{}
|
1884
1889
|
|
1885
1890
|
static void iter_uint8_mul(na_loop_t* const lp) {
|
@@ -1939,9 +1944,9 @@ static void iter_uint8_mul(na_loop_t* const lp) {
|
|
1939
1944
|
#undef check_intdivzero
|
1940
1945
|
|
1941
1946
|
static VALUE uint8_mul_self(VALUE self, VALUE other) {
|
1942
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
1943
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1944
|
-
ndfunc_t ndf = {iter_uint8_mul, STRIDE_LOOP, 2, 1, ain, aout};
|
1947
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
1948
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1949
|
+
ndfunc_t ndf = { iter_uint8_mul, STRIDE_LOOP, 2, 1, ain, aout };
|
1945
1950
|
|
1946
1951
|
return na_ndloop(&ndf, 2, self, other);
|
1947
1952
|
}
|
@@ -1965,10 +1970,10 @@ static VALUE uint8_mul(VALUE self, VALUE other) {
|
|
1965
1970
|
}
|
1966
1971
|
}
|
1967
1972
|
|
1968
|
-
#define check_intdivzero(y)
|
1969
|
-
if ((y) == 0) {
|
1970
|
-
lp->err_type = rb_eZeroDivError;
|
1971
|
-
return;
|
1973
|
+
#define check_intdivzero(y) \
|
1974
|
+
if ((y) == 0) { \
|
1975
|
+
lp->err_type = rb_eZeroDivError; \
|
1976
|
+
return; \
|
1972
1977
|
}
|
1973
1978
|
|
1974
1979
|
static void iter_uint8_div(na_loop_t* const lp) {
|
@@ -2028,9 +2033,9 @@ static void iter_uint8_div(na_loop_t* const lp) {
|
|
2028
2033
|
#undef check_intdivzero
|
2029
2034
|
|
2030
2035
|
static VALUE uint8_div_self(VALUE self, VALUE other) {
|
2031
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2032
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2033
|
-
ndfunc_t ndf = {iter_uint8_div, STRIDE_LOOP, 2, 1, ain, aout};
|
2036
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2037
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2038
|
+
ndfunc_t ndf = { iter_uint8_div, STRIDE_LOOP, 2, 1, ain, aout };
|
2034
2039
|
|
2035
2040
|
return na_ndloop(&ndf, 2, self, other);
|
2036
2041
|
}
|
@@ -2054,10 +2059,10 @@ static VALUE uint8_div(VALUE self, VALUE other) {
|
|
2054
2059
|
}
|
2055
2060
|
}
|
2056
2061
|
|
2057
|
-
#define check_intdivzero(y)
|
2058
|
-
if ((y) == 0) {
|
2059
|
-
lp->err_type = rb_eZeroDivError;
|
2060
|
-
return;
|
2062
|
+
#define check_intdivzero(y) \
|
2063
|
+
if ((y) == 0) { \
|
2064
|
+
lp->err_type = rb_eZeroDivError; \
|
2065
|
+
return; \
|
2061
2066
|
}
|
2062
2067
|
|
2063
2068
|
static void iter_uint8_mod(na_loop_t* const lp) {
|
@@ -2117,9 +2122,9 @@ static void iter_uint8_mod(na_loop_t* const lp) {
|
|
2117
2122
|
#undef check_intdivzero
|
2118
2123
|
|
2119
2124
|
static VALUE uint8_mod_self(VALUE self, VALUE other) {
|
2120
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2121
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2122
|
-
ndfunc_t ndf = {iter_uint8_mod, STRIDE_LOOP, 2, 1, ain, aout};
|
2125
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2126
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2127
|
+
ndfunc_t ndf = { iter_uint8_mod, STRIDE_LOOP, 2, 1, ain, aout };
|
2123
2128
|
|
2124
2129
|
return na_ndloop(&ndf, 2, self, other);
|
2125
2130
|
}
|
@@ -2167,9 +2172,9 @@ static void iter_uint8_divmod(na_loop_t* const lp) {
|
|
2167
2172
|
}
|
2168
2173
|
|
2169
2174
|
static VALUE uint8_divmod_self(VALUE self, VALUE other) {
|
2170
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2171
|
-
ndfunc_arg_out_t aout[2] = {{cT, 0}, {cT, 0}};
|
2172
|
-
ndfunc_t ndf = {iter_uint8_divmod, STRIDE_LOOP, 2, 2, ain, aout};
|
2175
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2176
|
+
ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
|
2177
|
+
ndfunc_t ndf = { iter_uint8_divmod, STRIDE_LOOP, 2, 2, ain, aout };
|
2173
2178
|
|
2174
2179
|
return na_ndloop(&ndf, 2, self, other);
|
2175
2180
|
}
|
@@ -2228,11 +2233,11 @@ static void iter_uint8_pow_int32(na_loop_t* const lp) {
|
|
2228
2233
|
}
|
2229
2234
|
|
2230
2235
|
static VALUE uint8_pow_self(VALUE self, VALUE other) {
|
2231
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2232
|
-
ndfunc_arg_in_t ain_i[2] = {{cT, 0}, {numo_cInt32, 0}};
|
2233
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2234
|
-
ndfunc_t ndf = {iter_uint8_pow, STRIDE_LOOP, 2, 1, ain, aout};
|
2235
|
-
ndfunc_t ndf_i = {iter_uint8_pow_int32, STRIDE_LOOP, 2, 1, ain_i, aout};
|
2236
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2237
|
+
ndfunc_arg_in_t ain_i[2] = { { cT, 0 }, { numo_cInt32, 0 } };
|
2238
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2239
|
+
ndfunc_t ndf = { iter_uint8_pow, STRIDE_LOOP, 2, 1, ain, aout };
|
2240
|
+
ndfunc_t ndf_i = { iter_uint8_pow_int32, STRIDE_LOOP, 2, 1, ain_i, aout };
|
2236
2241
|
|
2237
2242
|
// fixme : use na.integer?
|
2238
2243
|
if (FIXNUM_P(other) || rb_obj_is_kind_of(other, numo_cInt32)) {
|
@@ -2311,9 +2316,9 @@ static void iter_uint8_minus(na_loop_t* const lp) {
|
|
2311
2316
|
@return [Numo::UInt8] minus of self.
|
2312
2317
|
*/
|
2313
2318
|
static VALUE uint8_minus(VALUE self) {
|
2314
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2315
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2316
|
-
ndfunc_t ndf = {iter_uint8_minus, FULL_LOOP, 1, 1, ain, aout};
|
2319
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2320
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2321
|
+
ndfunc_t ndf = { iter_uint8_minus, FULL_LOOP, 1, 1, ain, aout };
|
2317
2322
|
|
2318
2323
|
return na_ndloop(&ndf, 1, self);
|
2319
2324
|
}
|
@@ -2369,9 +2374,9 @@ static void iter_uint8_reciprocal(na_loop_t* const lp) {
|
|
2369
2374
|
@return [Numo::UInt8] reciprocal of self.
|
2370
2375
|
*/
|
2371
2376
|
static VALUE uint8_reciprocal(VALUE self) {
|
2372
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2373
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2374
|
-
ndfunc_t ndf = {iter_uint8_reciprocal, FULL_LOOP, 1, 1, ain, aout};
|
2377
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2378
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2379
|
+
ndfunc_t ndf = { iter_uint8_reciprocal, FULL_LOOP, 1, 1, ain, aout };
|
2375
2380
|
|
2376
2381
|
return na_ndloop(&ndf, 1, self);
|
2377
2382
|
}
|
@@ -2427,9 +2432,9 @@ static void iter_uint8_sign(na_loop_t* const lp) {
|
|
2427
2432
|
@return [Numo::UInt8] sign of self.
|
2428
2433
|
*/
|
2429
2434
|
static VALUE uint8_sign(VALUE self) {
|
2430
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2431
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2432
|
-
ndfunc_t ndf = {iter_uint8_sign, FULL_LOOP, 1, 1, ain, aout};
|
2435
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2436
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2437
|
+
ndfunc_t ndf = { iter_uint8_sign, FULL_LOOP, 1, 1, ain, aout };
|
2433
2438
|
|
2434
2439
|
return na_ndloop(&ndf, 1, self);
|
2435
2440
|
}
|
@@ -2485,9 +2490,9 @@ static void iter_uint8_square(na_loop_t* const lp) {
|
|
2485
2490
|
@return [Numo::UInt8] square of self.
|
2486
2491
|
*/
|
2487
2492
|
static VALUE uint8_square(VALUE self) {
|
2488
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2489
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2490
|
-
ndfunc_t ndf = {iter_uint8_square, FULL_LOOP, 1, 1, ain, aout};
|
2493
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2494
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2495
|
+
ndfunc_t ndf = { iter_uint8_square, FULL_LOOP, 1, 1, ain, aout };
|
2491
2496
|
|
2492
2497
|
return na_ndloop(&ndf, 1, self);
|
2493
2498
|
}
|
@@ -2514,9 +2519,9 @@ static void iter_uint8_eq(na_loop_t* const lp) {
|
|
2514
2519
|
}
|
2515
2520
|
|
2516
2521
|
static VALUE uint8_eq_self(VALUE self, VALUE other) {
|
2517
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2518
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
2519
|
-
ndfunc_t ndf = {iter_uint8_eq, STRIDE_LOOP, 2, 1, ain, aout};
|
2522
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2523
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
2524
|
+
ndfunc_t ndf = { iter_uint8_eq, STRIDE_LOOP, 2, 1, ain, aout };
|
2520
2525
|
|
2521
2526
|
return na_ndloop(&ndf, 2, self, other);
|
2522
2527
|
}
|
@@ -2561,9 +2566,9 @@ static void iter_uint8_ne(na_loop_t* const lp) {
|
|
2561
2566
|
}
|
2562
2567
|
|
2563
2568
|
static VALUE uint8_ne_self(VALUE self, VALUE other) {
|
2564
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2565
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
2566
|
-
ndfunc_t ndf = {iter_uint8_ne, STRIDE_LOOP, 2, 1, ain, aout};
|
2569
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2570
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
2571
|
+
ndfunc_t ndf = { iter_uint8_ne, STRIDE_LOOP, 2, 1, ain, aout };
|
2567
2572
|
|
2568
2573
|
return na_ndloop(&ndf, 2, self, other);
|
2569
2574
|
}
|
@@ -2586,7 +2591,7 @@ static VALUE uint8_ne(VALUE self, VALUE other) {
|
|
2586
2591
|
}
|
2587
2592
|
}
|
2588
2593
|
|
2589
|
-
#define check_intdivzero(y)
|
2594
|
+
#define check_intdivzero(y) \
|
2590
2595
|
{}
|
2591
2596
|
|
2592
2597
|
static void iter_uint8_bit_and(na_loop_t* const lp) {
|
@@ -2646,9 +2651,9 @@ static void iter_uint8_bit_and(na_loop_t* const lp) {
|
|
2646
2651
|
#undef check_intdivzero
|
2647
2652
|
|
2648
2653
|
static VALUE uint8_bit_and_self(VALUE self, VALUE other) {
|
2649
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2650
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2651
|
-
ndfunc_t ndf = {iter_uint8_bit_and, STRIDE_LOOP, 2, 1, ain, aout};
|
2654
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2655
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2656
|
+
ndfunc_t ndf = { iter_uint8_bit_and, STRIDE_LOOP, 2, 1, ain, aout };
|
2652
2657
|
|
2653
2658
|
return na_ndloop(&ndf, 2, self, other);
|
2654
2659
|
}
|
@@ -2672,7 +2677,7 @@ static VALUE uint8_bit_and(VALUE self, VALUE other) {
|
|
2672
2677
|
}
|
2673
2678
|
}
|
2674
2679
|
|
2675
|
-
#define check_intdivzero(y)
|
2680
|
+
#define check_intdivzero(y) \
|
2676
2681
|
{}
|
2677
2682
|
|
2678
2683
|
static void iter_uint8_bit_or(na_loop_t* const lp) {
|
@@ -2732,9 +2737,9 @@ static void iter_uint8_bit_or(na_loop_t* const lp) {
|
|
2732
2737
|
#undef check_intdivzero
|
2733
2738
|
|
2734
2739
|
static VALUE uint8_bit_or_self(VALUE self, VALUE other) {
|
2735
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2736
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2737
|
-
ndfunc_t ndf = {iter_uint8_bit_or, STRIDE_LOOP, 2, 1, ain, aout};
|
2740
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2741
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2742
|
+
ndfunc_t ndf = { iter_uint8_bit_or, STRIDE_LOOP, 2, 1, ain, aout };
|
2738
2743
|
|
2739
2744
|
return na_ndloop(&ndf, 2, self, other);
|
2740
2745
|
}
|
@@ -2758,7 +2763,7 @@ static VALUE uint8_bit_or(VALUE self, VALUE other) {
|
|
2758
2763
|
}
|
2759
2764
|
}
|
2760
2765
|
|
2761
|
-
#define check_intdivzero(y)
|
2766
|
+
#define check_intdivzero(y) \
|
2762
2767
|
{}
|
2763
2768
|
|
2764
2769
|
static void iter_uint8_bit_xor(na_loop_t* const lp) {
|
@@ -2818,9 +2823,9 @@ static void iter_uint8_bit_xor(na_loop_t* const lp) {
|
|
2818
2823
|
#undef check_intdivzero
|
2819
2824
|
|
2820
2825
|
static VALUE uint8_bit_xor_self(VALUE self, VALUE other) {
|
2821
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2822
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2823
|
-
ndfunc_t ndf = {iter_uint8_bit_xor, STRIDE_LOOP, 2, 1, ain, aout};
|
2826
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2827
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2828
|
+
ndfunc_t ndf = { iter_uint8_bit_xor, STRIDE_LOOP, 2, 1, ain, aout };
|
2824
2829
|
|
2825
2830
|
return na_ndloop(&ndf, 2, self, other);
|
2826
2831
|
}
|
@@ -2895,14 +2900,14 @@ static void iter_uint8_bit_not(na_loop_t* const lp) {
|
|
2895
2900
|
@return [Numo::UInt8] bit_not of self.
|
2896
2901
|
*/
|
2897
2902
|
static VALUE uint8_bit_not(VALUE self) {
|
2898
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2899
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2900
|
-
ndfunc_t ndf = {iter_uint8_bit_not, FULL_LOOP, 1, 1, ain, aout};
|
2903
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2904
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2905
|
+
ndfunc_t ndf = { iter_uint8_bit_not, FULL_LOOP, 1, 1, ain, aout };
|
2901
2906
|
|
2902
2907
|
return na_ndloop(&ndf, 1, self);
|
2903
2908
|
}
|
2904
2909
|
|
2905
|
-
#define check_intdivzero(y)
|
2910
|
+
#define check_intdivzero(y) \
|
2906
2911
|
{}
|
2907
2912
|
|
2908
2913
|
static void iter_uint8_left_shift(na_loop_t* const lp) {
|
@@ -2962,9 +2967,9 @@ static void iter_uint8_left_shift(na_loop_t* const lp) {
|
|
2962
2967
|
#undef check_intdivzero
|
2963
2968
|
|
2964
2969
|
static VALUE uint8_left_shift_self(VALUE self, VALUE other) {
|
2965
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2966
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2967
|
-
ndfunc_t ndf = {iter_uint8_left_shift, STRIDE_LOOP, 2, 1, ain, aout};
|
2970
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2971
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2972
|
+
ndfunc_t ndf = { iter_uint8_left_shift, STRIDE_LOOP, 2, 1, ain, aout };
|
2968
2973
|
|
2969
2974
|
return na_ndloop(&ndf, 2, self, other);
|
2970
2975
|
}
|
@@ -2988,7 +2993,7 @@ static VALUE uint8_left_shift(VALUE self, VALUE other) {
|
|
2988
2993
|
}
|
2989
2994
|
}
|
2990
2995
|
|
2991
|
-
#define check_intdivzero(y)
|
2996
|
+
#define check_intdivzero(y) \
|
2992
2997
|
{}
|
2993
2998
|
|
2994
2999
|
static void iter_uint8_right_shift(na_loop_t* const lp) {
|
@@ -3048,9 +3053,9 @@ static void iter_uint8_right_shift(na_loop_t* const lp) {
|
|
3048
3053
|
#undef check_intdivzero
|
3049
3054
|
|
3050
3055
|
static VALUE uint8_right_shift_self(VALUE self, VALUE other) {
|
3051
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3052
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3053
|
-
ndfunc_t ndf = {iter_uint8_right_shift, STRIDE_LOOP, 2, 1, ain, aout};
|
3056
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3057
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3058
|
+
ndfunc_t ndf = { iter_uint8_right_shift, STRIDE_LOOP, 2, 1, ain, aout };
|
3054
3059
|
|
3055
3060
|
return na_ndloop(&ndf, 2, self, other);
|
3056
3061
|
}
|
@@ -3096,9 +3101,9 @@ static void iter_uint8_gt(na_loop_t* const lp) {
|
|
3096
3101
|
}
|
3097
3102
|
|
3098
3103
|
static VALUE uint8_gt_self(VALUE self, VALUE other) {
|
3099
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3100
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3101
|
-
ndfunc_t ndf = {iter_uint8_gt, STRIDE_LOOP, 2, 1, ain, aout};
|
3104
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3105
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3106
|
+
ndfunc_t ndf = { iter_uint8_gt, STRIDE_LOOP, 2, 1, ain, aout };
|
3102
3107
|
|
3103
3108
|
return na_ndloop(&ndf, 2, self, other);
|
3104
3109
|
}
|
@@ -3143,9 +3148,9 @@ static void iter_uint8_ge(na_loop_t* const lp) {
|
|
3143
3148
|
}
|
3144
3149
|
|
3145
3150
|
static VALUE uint8_ge_self(VALUE self, VALUE other) {
|
3146
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3147
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3148
|
-
ndfunc_t ndf = {iter_uint8_ge, STRIDE_LOOP, 2, 1, ain, aout};
|
3151
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3152
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3153
|
+
ndfunc_t ndf = { iter_uint8_ge, STRIDE_LOOP, 2, 1, ain, aout };
|
3149
3154
|
|
3150
3155
|
return na_ndloop(&ndf, 2, self, other);
|
3151
3156
|
}
|
@@ -3190,9 +3195,9 @@ static void iter_uint8_lt(na_loop_t* const lp) {
|
|
3190
3195
|
}
|
3191
3196
|
|
3192
3197
|
static VALUE uint8_lt_self(VALUE self, VALUE other) {
|
3193
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3194
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3195
|
-
ndfunc_t ndf = {iter_uint8_lt, STRIDE_LOOP, 2, 1, ain, aout};
|
3198
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3199
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3200
|
+
ndfunc_t ndf = { iter_uint8_lt, STRIDE_LOOP, 2, 1, ain, aout };
|
3196
3201
|
|
3197
3202
|
return na_ndloop(&ndf, 2, self, other);
|
3198
3203
|
}
|
@@ -3237,9 +3242,9 @@ static void iter_uint8_le(na_loop_t* const lp) {
|
|
3237
3242
|
}
|
3238
3243
|
|
3239
3244
|
static VALUE uint8_le_self(VALUE self, VALUE other) {
|
3240
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3241
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3242
|
-
ndfunc_t ndf = {iter_uint8_le, STRIDE_LOOP, 2, 1, ain, aout};
|
3245
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3246
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3247
|
+
ndfunc_t ndf = { iter_uint8_le, STRIDE_LOOP, 2, 1, ain, aout };
|
3243
3248
|
|
3244
3249
|
return na_ndloop(&ndf, 2, self, other);
|
3245
3250
|
}
|
@@ -3358,11 +3363,11 @@ static void iter_uint8_clip_max(na_loop_t* const lp) {
|
|
3358
3363
|
# [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]
|
3359
3364
|
*/
|
3360
3365
|
static VALUE uint8_clip(VALUE self, VALUE min, VALUE max) {
|
3361
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {cT, 0}, {cT, 0}};
|
3362
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3363
|
-
ndfunc_t ndf_min = {iter_uint8_clip_min, STRIDE_LOOP, 2, 1, ain, aout};
|
3364
|
-
ndfunc_t ndf_max = {iter_uint8_clip_max, STRIDE_LOOP, 2, 1, ain, aout};
|
3365
|
-
ndfunc_t ndf_both = {iter_uint8_clip, STRIDE_LOOP, 3, 1, ain, aout};
|
3366
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { cT, 0 }, { cT, 0 } };
|
3367
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3368
|
+
ndfunc_t ndf_min = { iter_uint8_clip_min, STRIDE_LOOP, 2, 1, ain, aout };
|
3369
|
+
ndfunc_t ndf_max = { iter_uint8_clip_max, STRIDE_LOOP, 2, 1, ain, aout };
|
3370
|
+
ndfunc_t ndf_both = { iter_uint8_clip, STRIDE_LOOP, 3, 1, ain, aout };
|
3366
3371
|
|
3367
3372
|
if (RTEST(min)) {
|
3368
3373
|
if (RTEST(max)) {
|
@@ -3395,14 +3400,15 @@ static void iter_uint8_sum(na_loop_t* const lp) {
|
|
3395
3400
|
sum of self.
|
3396
3401
|
@overload sum(axis:nil, keepdims:false)
|
3397
3402
|
@param [Numeric,Array,Range] axis Performs sum along the axis.
|
3398
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3403
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3404
|
+
dimensions with size one.
|
3399
3405
|
@return [Numo::UInt8] returns result of sum.
|
3400
3406
|
*/
|
3401
3407
|
static VALUE uint8_sum(int argc, VALUE* argv, VALUE self) {
|
3402
3408
|
VALUE v, reduce;
|
3403
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
3404
|
-
ndfunc_arg_out_t aout[1] = {{numo_cUInt64, 0}};
|
3405
|
-
ndfunc_t ndf = {iter_uint8_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
3409
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3410
|
+
ndfunc_arg_out_t aout[1] = { { numo_cUInt64, 0 } };
|
3411
|
+
ndfunc_t ndf = { iter_uint8_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
3406
3412
|
|
3407
3413
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
3408
3414
|
|
@@ -3427,14 +3433,15 @@ static void iter_uint8_prod(na_loop_t* const lp) {
|
|
3427
3433
|
prod of self.
|
3428
3434
|
@overload prod(axis:nil, keepdims:false)
|
3429
3435
|
@param [Numeric,Array,Range] axis Performs prod along the axis.
|
3430
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3436
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3437
|
+
dimensions with size one.
|
3431
3438
|
@return [Numo::UInt8] returns result of prod.
|
3432
3439
|
*/
|
3433
3440
|
static VALUE uint8_prod(int argc, VALUE* argv, VALUE self) {
|
3434
3441
|
VALUE v, reduce;
|
3435
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
3436
|
-
ndfunc_arg_out_t aout[1] = {{numo_cUInt64, 0}};
|
3437
|
-
ndfunc_t ndf = {iter_uint8_prod, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
3442
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3443
|
+
ndfunc_arg_out_t aout[1] = { { numo_cUInt64, 0 } };
|
3444
|
+
ndfunc_t ndf = { iter_uint8_prod, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
3438
3445
|
|
3439
3446
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
3440
3447
|
|
@@ -3459,14 +3466,15 @@ static void iter_uint8_min(na_loop_t* const lp) {
|
|
3459
3466
|
min of self.
|
3460
3467
|
@overload min(axis:nil, keepdims:false)
|
3461
3468
|
@param [Numeric,Array,Range] axis Performs min along the axis.
|
3462
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3469
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3470
|
+
dimensions with size one.
|
3463
3471
|
@return [Numo::UInt8] returns result of min.
|
3464
3472
|
*/
|
3465
3473
|
static VALUE uint8_min(int argc, VALUE* argv, VALUE self) {
|
3466
3474
|
VALUE v, reduce;
|
3467
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
3468
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3469
|
-
ndfunc_t ndf = {iter_uint8_min, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
3475
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3476
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3477
|
+
ndfunc_t ndf = { iter_uint8_min, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
3470
3478
|
|
3471
3479
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
3472
3480
|
|
@@ -3491,14 +3499,15 @@ static void iter_uint8_max(na_loop_t* const lp) {
|
|
3491
3499
|
max of self.
|
3492
3500
|
@overload max(axis:nil, keepdims:false)
|
3493
3501
|
@param [Numeric,Array,Range] axis Performs max along the axis.
|
3494
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3502
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3503
|
+
dimensions with size one.
|
3495
3504
|
@return [Numo::UInt8] returns result of max.
|
3496
3505
|
*/
|
3497
3506
|
static VALUE uint8_max(int argc, VALUE* argv, VALUE self) {
|
3498
3507
|
VALUE v, reduce;
|
3499
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
3500
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3501
|
-
ndfunc_t ndf = {iter_uint8_max, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
3508
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3509
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3510
|
+
ndfunc_t ndf = { iter_uint8_max, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
3502
3511
|
|
3503
3512
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
3504
3513
|
|
@@ -3523,14 +3532,15 @@ static void iter_uint8_ptp(na_loop_t* const lp) {
|
|
3523
3532
|
ptp of self.
|
3524
3533
|
@overload ptp(axis:nil, keepdims:false)
|
3525
3534
|
@param [Numeric,Array,Range] axis Performs ptp along the axis.
|
3526
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3535
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3536
|
+
dimensions with size one.
|
3527
3537
|
@return [Numo::UInt8] returns result of ptp.
|
3528
3538
|
*/
|
3529
3539
|
static VALUE uint8_ptp(int argc, VALUE* argv, VALUE self) {
|
3530
3540
|
VALUE v, reduce;
|
3531
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
3532
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3533
|
-
ndfunc_t ndf = {iter_uint8_ptp, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
3541
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3542
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3543
|
+
ndfunc_t ndf = { iter_uint8_ptp, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
3534
3544
|
|
3535
3545
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
3536
3546
|
|
@@ -3576,7 +3586,8 @@ static void iter_uint8_max_index_index32(na_loop_t* const lp) {
|
|
3576
3586
|
/*
|
3577
3587
|
Index of the maximum value.
|
3578
3588
|
@overload max_index(axis:nil)
|
3579
|
-
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat 1-d
|
3589
|
+
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat 1-d
|
3590
|
+
indices**.
|
3580
3591
|
@return [Integer,Numo::Int] returns result indices.
|
3581
3592
|
@see #argmax
|
3582
3593
|
@see #max
|
@@ -3594,9 +3605,9 @@ static void iter_uint8_max_index_index32(na_loop_t* const lp) {
|
|
3594
3605
|
static VALUE uint8_max_index(int argc, VALUE* argv, VALUE self) {
|
3595
3606
|
narray_t* na;
|
3596
3607
|
VALUE idx, reduce;
|
3597
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {Qnil, 0}, {sym_reduce, 0}};
|
3598
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
3599
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout};
|
3608
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { Qnil, 0 }, { sym_reduce, 0 } };
|
3609
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
3610
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout };
|
3600
3611
|
|
3601
3612
|
GetNArray(self, na);
|
3602
3613
|
if (na->ndim == 0) {
|
@@ -3658,7 +3669,8 @@ static void iter_uint8_min_index_index32(na_loop_t* const lp) {
|
|
3658
3669
|
/*
|
3659
3670
|
Index of the minimum value.
|
3660
3671
|
@overload min_index(axis:nil)
|
3661
|
-
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat 1-d
|
3672
|
+
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat 1-d
|
3673
|
+
indices**.
|
3662
3674
|
@return [Integer,Numo::Int] returns result indices.
|
3663
3675
|
@see #argmin
|
3664
3676
|
@see #min
|
@@ -3676,9 +3688,9 @@ static void iter_uint8_min_index_index32(na_loop_t* const lp) {
|
|
3676
3688
|
static VALUE uint8_min_index(int argc, VALUE* argv, VALUE self) {
|
3677
3689
|
narray_t* na;
|
3678
3690
|
VALUE idx, reduce;
|
3679
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {Qnil, 0}, {sym_reduce, 0}};
|
3680
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
3681
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout};
|
3691
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { Qnil, 0 }, { sym_reduce, 0 } };
|
3692
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
3693
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout };
|
3682
3694
|
|
3683
3695
|
GetNArray(self, na);
|
3684
3696
|
if (na->ndim == 0) {
|
@@ -3738,7 +3750,8 @@ static void iter_uint8_argmax_arg32(na_loop_t* const lp) {
|
|
3738
3750
|
/*
|
3739
3751
|
Index of the maximum value.
|
3740
3752
|
@overload argmax(axis:nil)
|
3741
|
-
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices
|
3753
|
+
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices
|
3754
|
+
along the axis**.
|
3742
3755
|
@return [Integer,Numo::Int] returns the result indices.
|
3743
3756
|
@see #max_index
|
3744
3757
|
@see #max
|
@@ -3756,9 +3769,9 @@ static void iter_uint8_argmax_arg32(na_loop_t* const lp) {
|
|
3756
3769
|
static VALUE uint8_argmax(int argc, VALUE* argv, VALUE self) {
|
3757
3770
|
narray_t* na;
|
3758
3771
|
VALUE reduce;
|
3759
|
-
ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_reduce, 0}};
|
3760
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
3761
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout};
|
3772
|
+
ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } };
|
3773
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
3774
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout };
|
3762
3775
|
|
3763
3776
|
GetNArray(self, na);
|
3764
3777
|
if (na->ndim == 0) {
|
@@ -3815,7 +3828,8 @@ static void iter_uint8_argmin_arg32(na_loop_t* const lp) {
|
|
3815
3828
|
/*
|
3816
3829
|
Index of the minimum value.
|
3817
3830
|
@overload argmin(axis:nil)
|
3818
|
-
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices
|
3831
|
+
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices
|
3832
|
+
along the axis**.
|
3819
3833
|
@return [Integer,Numo::Int] returns the result indices.
|
3820
3834
|
@see #min_index
|
3821
3835
|
@see #min
|
@@ -3833,9 +3847,9 @@ static void iter_uint8_argmin_arg32(na_loop_t* const lp) {
|
|
3833
3847
|
static VALUE uint8_argmin(int argc, VALUE* argv, VALUE self) {
|
3834
3848
|
narray_t* na;
|
3835
3849
|
VALUE reduce;
|
3836
|
-
ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_reduce, 0}};
|
3837
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
3838
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout};
|
3850
|
+
ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } };
|
3851
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
3852
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout };
|
3839
3853
|
|
3840
3854
|
GetNArray(self, na);
|
3841
3855
|
if (na->ndim == 0) {
|
@@ -3876,14 +3890,17 @@ static void iter_uint8_minmax(na_loop_t* const lp) {
|
|
3876
3890
|
minmax of self.
|
3877
3891
|
@overload minmax(axis:nil, keepdims:false)
|
3878
3892
|
@param [Numeric,Array,Range] axis Finds min-max along the axis.
|
3879
|
-
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
3893
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
3894
|
+
as dimensions with size one.
|
3880
3895
|
@return [Numo::UInt8,Numo::UInt8] min and max of self.
|
3881
3896
|
*/
|
3882
3897
|
static VALUE uint8_minmax(int argc, VALUE* argv, VALUE self) {
|
3883
3898
|
VALUE reduce;
|
3884
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
3885
|
-
ndfunc_arg_out_t aout[2] = {{cT, 0}, {cT, 0}};
|
3886
|
-
ndfunc_t ndf = {
|
3899
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3900
|
+
ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
|
3901
|
+
ndfunc_t ndf = {
|
3902
|
+
iter_uint8_minmax, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 2, ain, aout
|
3903
|
+
};
|
3887
3904
|
|
3888
3905
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
3889
3906
|
|
@@ -3921,9 +3938,9 @@ static void iter_uint8_s_maximum(na_loop_t* const lp) {
|
|
3921
3938
|
static VALUE uint8_s_maximum(int argc, VALUE* argv, VALUE mod) {
|
3922
3939
|
VALUE a1 = Qnil;
|
3923
3940
|
VALUE a2 = Qnil;
|
3924
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3925
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3926
|
-
ndfunc_t ndf = {iter_uint8_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout};
|
3941
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3942
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3943
|
+
ndfunc_t ndf = { iter_uint8_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
|
3927
3944
|
|
3928
3945
|
rb_scan_args(argc, argv, "20", &a1, &a2);
|
3929
3946
|
|
@@ -3961,9 +3978,9 @@ static void iter_uint8_s_minimum(na_loop_t* const lp) {
|
|
3961
3978
|
static VALUE uint8_s_minimum(int argc, VALUE* argv, VALUE mod) {
|
3962
3979
|
VALUE a1 = Qnil;
|
3963
3980
|
VALUE a2 = Qnil;
|
3964
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3965
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3966
|
-
ndfunc_t ndf = {iter_uint8_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout};
|
3981
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3982
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3983
|
+
ndfunc_t ndf = { iter_uint8_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
|
3967
3984
|
|
3968
3985
|
rb_scan_args(argc, argv, "20", &a1, &a2);
|
3969
3986
|
|
@@ -4002,10 +4019,12 @@ static void iter_uint8_bincount_32(na_loop_t* const lp) {
|
|
4002
4019
|
}
|
4003
4020
|
|
4004
4021
|
static VALUE uint8_bincount_32(VALUE self, size_t length) {
|
4005
|
-
size_t shape_out[1] = {length};
|
4006
|
-
ndfunc_arg_in_t ain[1] = {{cT, 1}};
|
4007
|
-
ndfunc_arg_out_t aout[1] = {{numo_cUInt32, 1, shape_out}};
|
4008
|
-
ndfunc_t ndf = {
|
4022
|
+
size_t shape_out[1] = { length };
|
4023
|
+
ndfunc_arg_in_t ain[1] = { { cT, 1 } };
|
4024
|
+
ndfunc_arg_out_t aout[1] = { { numo_cUInt32, 1, shape_out } };
|
4025
|
+
ndfunc_t ndf = {
|
4026
|
+
iter_uint8_bincount_32, NO_LOOP | NDF_STRIDE_LOOP | NDF_INDEX_LOOP, 1, 1, ain, aout
|
4027
|
+
};
|
4009
4028
|
|
4010
4029
|
return na_ndloop(&ndf, 1, self);
|
4011
4030
|
}
|
@@ -4040,10 +4059,12 @@ static void iter_uint8_bincount_64(na_loop_t* const lp) {
|
|
4040
4059
|
}
|
4041
4060
|
|
4042
4061
|
static VALUE uint8_bincount_64(VALUE self, size_t length) {
|
4043
|
-
size_t shape_out[1] = {length};
|
4044
|
-
ndfunc_arg_in_t ain[1] = {{cT, 1}};
|
4045
|
-
ndfunc_arg_out_t aout[1] = {{numo_cUInt64, 1, shape_out}};
|
4046
|
-
ndfunc_t ndf = {
|
4062
|
+
size_t shape_out[1] = { length };
|
4063
|
+
ndfunc_arg_in_t ain[1] = { { cT, 1 } };
|
4064
|
+
ndfunc_arg_out_t aout[1] = { { numo_cUInt64, 1, shape_out } };
|
4065
|
+
ndfunc_t ndf = {
|
4066
|
+
iter_uint8_bincount_64, NO_LOOP | NDF_STRIDE_LOOP | NDF_INDEX_LOOP, 1, 1, ain, aout
|
4067
|
+
};
|
4047
4068
|
|
4048
4069
|
return na_ndloop(&ndf, 1, self);
|
4049
4070
|
}
|
@@ -4080,10 +4101,10 @@ static void iter_uint8_bincount_sf(na_loop_t* const lp) {
|
|
4080
4101
|
}
|
4081
4102
|
|
4082
4103
|
static VALUE uint8_bincount_sf(VALUE self, VALUE weight, size_t length) {
|
4083
|
-
size_t shape_out[1] = {length};
|
4084
|
-
ndfunc_arg_in_t ain[2] = {{cT, 1}, {numo_cSFloat, 1}};
|
4085
|
-
ndfunc_arg_out_t aout[1] = {{numo_cSFloat, 1, shape_out}};
|
4086
|
-
ndfunc_t ndf = {iter_uint8_bincount_sf, NO_LOOP | NDF_STRIDE_LOOP, 2, 1, ain, aout};
|
4104
|
+
size_t shape_out[1] = { length };
|
4105
|
+
ndfunc_arg_in_t ain[2] = { { cT, 1 }, { numo_cSFloat, 1 } };
|
4106
|
+
ndfunc_arg_out_t aout[1] = { { numo_cSFloat, 1, shape_out } };
|
4107
|
+
ndfunc_t ndf = { iter_uint8_bincount_sf, NO_LOOP | NDF_STRIDE_LOOP, 2, 1, ain, aout };
|
4087
4108
|
|
4088
4109
|
return na_ndloop(&ndf, 2, self, weight);
|
4089
4110
|
}
|
@@ -4117,10 +4138,10 @@ static void iter_uint8_bincount_df(na_loop_t* const lp) {
|
|
4117
4138
|
}
|
4118
4139
|
|
4119
4140
|
static VALUE uint8_bincount_df(VALUE self, VALUE weight, size_t length) {
|
4120
|
-
size_t shape_out[1] = {length};
|
4121
|
-
ndfunc_arg_in_t ain[2] = {{cT, 1}, {numo_cDFloat, 1}};
|
4122
|
-
ndfunc_arg_out_t aout[1] = {{numo_cDFloat, 1, shape_out}};
|
4123
|
-
ndfunc_t ndf = {iter_uint8_bincount_df, NO_LOOP | NDF_STRIDE_LOOP, 2, 1, ain, aout};
|
4141
|
+
size_t shape_out[1] = { length };
|
4142
|
+
ndfunc_arg_in_t ain[2] = { { cT, 1 }, { numo_cDFloat, 1 } };
|
4143
|
+
ndfunc_arg_out_t aout[1] = { { numo_cDFloat, 1, shape_out } };
|
4144
|
+
ndfunc_t ndf = { iter_uint8_bincount_df, NO_LOOP | NDF_STRIDE_LOOP, 2, 1, ain, aout };
|
4124
4145
|
|
4125
4146
|
return na_ndloop(&ndf, 2, self, weight);
|
4126
4147
|
}
|
@@ -4160,9 +4181,9 @@ static VALUE uint8_bincount_df(VALUE self, VALUE weight, size_t length) {
|
|
4160
4181
|
*/
|
4161
4182
|
static VALUE uint8_bincount(int argc, VALUE* argv, VALUE self) {
|
4162
4183
|
VALUE weight = Qnil, kw = Qnil;
|
4163
|
-
VALUE opts[1] = {Qundef};
|
4184
|
+
VALUE opts[1] = { Qundef };
|
4164
4185
|
VALUE v, wclass;
|
4165
|
-
ID table[1] = {id_minlength};
|
4186
|
+
ID table[1] = { id_minlength };
|
4166
4187
|
size_t length, minlength;
|
4167
4188
|
|
4168
4189
|
rb_scan_args(argc, argv, "01:", &weight, &kw);
|
@@ -4204,16 +4225,13 @@ static void iter_uint8_cumsum(na_loop_t* const lp) {
|
|
4204
4225
|
INIT_COUNTER(lp, i);
|
4205
4226
|
INIT_PTR(lp, 0, p1, s1);
|
4206
4227
|
INIT_PTR(lp, 1, p2, s2);
|
4207
|
-
// printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
|
4208
4228
|
|
4209
4229
|
GET_DATA_STRIDE(p1, s1, dtype, x);
|
4210
4230
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4211
|
-
// printf("i=%lu x=%f\n",i,x);
|
4212
4231
|
for (i--; i--;) {
|
4213
4232
|
GET_DATA_STRIDE(p1, s1, dtype, y);
|
4214
4233
|
m_cumsum(x, y);
|
4215
4234
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4216
|
-
// printf("i=%lu x=%f\n",i,x);
|
4217
4235
|
}
|
4218
4236
|
}
|
4219
4237
|
|
@@ -4226,9 +4244,11 @@ static void iter_uint8_cumsum(na_loop_t* const lp) {
|
|
4226
4244
|
*/
|
4227
4245
|
static VALUE uint8_cumsum(int argc, VALUE* argv, VALUE self) {
|
4228
4246
|
VALUE reduce;
|
4229
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4230
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4231
|
-
ndfunc_t ndf = {
|
4247
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4248
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4249
|
+
ndfunc_t ndf = {
|
4250
|
+
iter_uint8_cumsum, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout
|
4251
|
+
};
|
4232
4252
|
|
4233
4253
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
4234
4254
|
|
@@ -4244,16 +4264,13 @@ static void iter_uint8_cumprod(na_loop_t* const lp) {
|
|
4244
4264
|
INIT_COUNTER(lp, i);
|
4245
4265
|
INIT_PTR(lp, 0, p1, s1);
|
4246
4266
|
INIT_PTR(lp, 1, p2, s2);
|
4247
|
-
// printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
|
4248
4267
|
|
4249
4268
|
GET_DATA_STRIDE(p1, s1, dtype, x);
|
4250
4269
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4251
|
-
// printf("i=%lu x=%f\n",i,x);
|
4252
4270
|
for (i--; i--;) {
|
4253
4271
|
GET_DATA_STRIDE(p1, s1, dtype, y);
|
4254
4272
|
m_cumprod(x, y);
|
4255
4273
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4256
|
-
// printf("i=%lu x=%f\n",i,x);
|
4257
4274
|
}
|
4258
4275
|
}
|
4259
4276
|
|
@@ -4266,9 +4283,11 @@ static void iter_uint8_cumprod(na_loop_t* const lp) {
|
|
4266
4283
|
*/
|
4267
4284
|
static VALUE uint8_cumprod(int argc, VALUE* argv, VALUE self) {
|
4268
4285
|
VALUE reduce;
|
4269
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4270
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4271
|
-
ndfunc_t ndf = {
|
4286
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4287
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4288
|
+
ndfunc_t ndf = {
|
4289
|
+
iter_uint8_cumprod, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout
|
4290
|
+
};
|
4272
4291
|
|
4273
4292
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
4274
4293
|
|
@@ -4314,9 +4333,9 @@ static void iter_uint8_mulsum(na_loop_t* const lp) {
|
|
4314
4333
|
static VALUE uint8_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
4315
4334
|
VALUE v, reduce;
|
4316
4335
|
VALUE naryv[2];
|
4317
|
-
ndfunc_arg_in_t ain[4] = {{cT, 0}, {cT, 0}, {sym_reduce, 0}, {sym_init, 0}};
|
4318
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4319
|
-
ndfunc_t ndf = {iter_uint8_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout};
|
4336
|
+
ndfunc_arg_in_t ain[4] = { { cT, 0 }, { cT, 0 }, { sym_reduce, 0 }, { sym_init, 0 } };
|
4337
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4338
|
+
ndfunc_t ndf = { iter_uint8_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout };
|
4320
4339
|
|
4321
4340
|
if (argc < 1) {
|
4322
4341
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for >=1)", argc);
|
@@ -4338,7 +4357,8 @@ static VALUE uint8_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
|
4338
4357
|
@overload mulsum(other, axis:nil, keepdims:false)
|
4339
4358
|
@param [Numo::NArray,Numeric] other
|
4340
4359
|
@param [Numeric,Array,Range] axis Performs mulsum along the axis.
|
4341
|
-
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
4360
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
4361
|
+
as dimensions with size one.
|
4342
4362
|
@return [Numo::NArray] mulsum of self and other.
|
4343
4363
|
*/
|
4344
4364
|
static VALUE uint8_mulsum(int argc, VALUE* argv, VALUE self) {
|
@@ -4423,8 +4443,8 @@ static void iter_uint8_seq(na_loop_t* const lp) {
|
|
4423
4443
|
static VALUE uint8_seq(int argc, VALUE* args, VALUE self) {
|
4424
4444
|
seq_opt_t* g;
|
4425
4445
|
VALUE vbeg = Qnil, vstep = Qnil;
|
4426
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
|
4427
|
-
ndfunc_t ndf = {iter_uint8_seq, FULL_LOOP, 1, 0, ain, 0};
|
4446
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
4447
|
+
ndfunc_t ndf = { iter_uint8_seq, FULL_LOOP, 1, 0, ain, 0 };
|
4428
4448
|
|
4429
4449
|
g = ALLOCA_N(seq_opt_t, 1);
|
4430
4450
|
g->beg = m_zero;
|
@@ -4481,8 +4501,8 @@ static void iter_uint8_eye(na_loop_t* const lp) {
|
|
4481
4501
|
@return [Numo::UInt8] eye of self.
|
4482
4502
|
*/
|
4483
4503
|
static VALUE uint8_eye(int argc, VALUE* argv, VALUE self) {
|
4484
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 2}};
|
4485
|
-
ndfunc_t ndf = {iter_uint8_eye, NO_LOOP, 1, 0, ain, 0};
|
4504
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
|
4505
|
+
ndfunc_t ndf = { iter_uint8_eye, NO_LOOP, 1, 0, ain, 0 };
|
4486
4506
|
ssize_t kofs;
|
4487
4507
|
dtype data;
|
4488
4508
|
char* g;
|
@@ -4512,17 +4532,21 @@ static VALUE uint8_eye(int argc, VALUE* argv, VALUE self) {
|
|
4512
4532
|
// Diagonal offset from the main diagonal.
|
4513
4533
|
if (kofs >= 0) {
|
4514
4534
|
if ((size_t)(kofs) >= na->shape[nd - 1]) {
|
4515
|
-
rb_raise(
|
4516
|
-
|
4517
|
-
|
4518
|
-
|
4535
|
+
rb_raise(
|
4536
|
+
rb_eArgError,
|
4537
|
+
"invalid diagonal offset(%" SZF "d) for "
|
4538
|
+
"last dimension size(%" SZF "d)",
|
4539
|
+
kofs, na->shape[nd - 1]
|
4540
|
+
);
|
4519
4541
|
}
|
4520
4542
|
} else {
|
4521
4543
|
if ((size_t)(-kofs) >= na->shape[nd - 2]) {
|
4522
|
-
rb_raise(
|
4523
|
-
|
4524
|
-
|
4525
|
-
|
4544
|
+
rb_raise(
|
4545
|
+
rb_eArgError,
|
4546
|
+
"invalid diagonal offset(%" SZF "d) for "
|
4547
|
+
"last-1 dimension size(%" SZF "d)",
|
4548
|
+
kofs, na->shape[nd - 2]
|
4549
|
+
);
|
4526
4550
|
}
|
4527
4551
|
}
|
4528
4552
|
|
@@ -4607,7 +4631,8 @@ static void iter_uint8_rand(na_loop_t* const lp) {
|
|
4607
4631
|
Generate uniformly distributed random numbers on self narray.
|
4608
4632
|
@overload rand([[low],high])
|
4609
4633
|
@param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
4610
|
-
@param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
|
4634
|
+
@param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
|
4635
|
+
complex types)
|
4611
4636
|
@return [Numo::UInt8] self.
|
4612
4637
|
@example
|
4613
4638
|
Numo::DFloat.new(6).rand
|
@@ -4626,8 +4651,8 @@ static VALUE uint8_rand(int argc, VALUE* args, VALUE self) {
|
|
4626
4651
|
rand_opt_t g;
|
4627
4652
|
VALUE v1 = Qnil, v2 = Qnil;
|
4628
4653
|
dtype high;
|
4629
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
|
4630
|
-
ndfunc_t ndf = {iter_uint8_rand, FULL_LOOP, 1, 0, ain, 0};
|
4654
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
4655
|
+
ndfunc_t ndf = { iter_uint8_rand, FULL_LOOP, 1, 0, ain, 0 };
|
4631
4656
|
|
4632
4657
|
rb_scan_args(argc, args, "11", &v1, &v2);
|
4633
4658
|
if (v2 == Qnil) {
|
@@ -4675,8 +4700,8 @@ static VALUE uint8_poly(VALUE self, VALUE args) {
|
|
4675
4700
|
int argc, i;
|
4676
4701
|
VALUE* argv;
|
4677
4702
|
volatile VALUE v, a;
|
4678
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4679
|
-
ndfunc_t ndf = {iter_uint8_poly, NO_LOOP, 0, 1, 0, aout};
|
4703
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4704
|
+
ndfunc_t ndf = { iter_uint8_poly, NO_LOOP, 0, 1, 0, aout };
|
4680
4705
|
|
4681
4706
|
argc = (int)RARRAY_LEN(args);
|
4682
4707
|
ndf.nin = argc + 1;
|
@@ -4756,23 +4781,28 @@ static VALUE uint8_poly(VALUE self, VALUE args) {
|
|
4756
4781
|
* We have modified their original by adding a check for already-sorted input,
|
4757
4782
|
* which seems to be a win per discussions on pgsql-hackers around 2006-03-21.
|
4758
4783
|
*/
|
4759
|
-
#define swapcode(TYPE, parmi, parmj, n)
|
4760
|
-
do {
|
4761
|
-
size_t i = (n) / sizeof(TYPE);
|
4762
|
-
TYPE* pi = (TYPE*)(void*)(parmi);
|
4763
|
-
TYPE* pj = (TYPE*)(void*)(parmj);
|
4764
|
-
do {
|
4765
|
-
TYPE t = *pi;
|
4766
|
-
*pi++ = *pj;
|
4767
|
-
*pj++ = t;
|
4768
|
-
} while (--i > 0);
|
4784
|
+
#define swapcode(TYPE, parmi, parmj, n) \
|
4785
|
+
do { \
|
4786
|
+
size_t i = (n) / sizeof(TYPE); \
|
4787
|
+
TYPE* pi = (TYPE*)(void*)(parmi); \
|
4788
|
+
TYPE* pj = (TYPE*)(void*)(parmj); \
|
4789
|
+
do { \
|
4790
|
+
TYPE t = *pi; \
|
4791
|
+
*pi++ = *pj; \
|
4792
|
+
*pj++ = t; \
|
4793
|
+
} while (--i > 0); \
|
4769
4794
|
} while (0)
|
4770
4795
|
|
4771
4796
|
#ifdef HAVE_STDINT_H
|
4772
|
-
#define SWAPINIT(a, es)
|
4797
|
+
#define SWAPINIT(a, es) \
|
4798
|
+
swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
4799
|
+
: (es) == sizeof(long) ? 0 \
|
4800
|
+
: 1;
|
4773
4801
|
#else
|
4774
|
-
#define SWAPINIT(a, es)
|
4775
|
-
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2
|
4802
|
+
#define SWAPINIT(a, es) \
|
4803
|
+
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
4804
|
+
: (es) == sizeof(long) ? 0 \
|
4805
|
+
: 1;
|
4776
4806
|
#endif
|
4777
4807
|
|
4778
4808
|
static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
|
@@ -4782,19 +4812,20 @@ static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
|
|
4782
4812
|
swapcode(char, a, b, n);
|
4783
4813
|
}
|
4784
4814
|
|
4785
|
-
#define swap(a, b)
|
4786
|
-
if (swaptype == 0) {
|
4787
|
-
long t = *(long*)(void*)(a);
|
4788
|
-
*(long*)(void*)(a) = *(long*)(void*)(b);
|
4789
|
-
*(long*)(void*)(b) = t;
|
4790
|
-
} else
|
4815
|
+
#define swap(a, b) \
|
4816
|
+
if (swaptype == 0) { \
|
4817
|
+
long t = *(long*)(void*)(a); \
|
4818
|
+
*(long*)(void*)(a) = *(long*)(void*)(b); \
|
4819
|
+
*(long*)(void*)(b) = t; \
|
4820
|
+
} else \
|
4791
4821
|
swapfunc(a, b, es, swaptype)
|
4792
4822
|
|
4793
|
-
#define vecswap(a, b, n)
|
4823
|
+
#define vecswap(a, b, n) \
|
4794
4824
|
if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
|
4795
4825
|
|
4796
|
-
#define med3(a, b, c, _cmp)
|
4797
|
-
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a))
|
4826
|
+
#define med3(a, b, c, _cmp) \
|
4827
|
+
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) \
|
4828
|
+
: (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
|
4798
4829
|
#endif
|
4799
4830
|
|
4800
4831
|
#undef qsort_dtype
|
@@ -4891,8 +4922,8 @@ static void iter_uint8_sort(na_loop_t* const lp) {
|
|
4891
4922
|
*/
|
4892
4923
|
static VALUE uint8_sort(int argc, VALUE* argv, VALUE self) {
|
4893
4924
|
VALUE reduce;
|
4894
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_reduce, 0}};
|
4895
|
-
ndfunc_t ndf = {0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 0, ain, 0};
|
4925
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
|
4926
|
+
ndfunc_t ndf = { 0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 0, ain, 0 };
|
4896
4927
|
|
4897
4928
|
if (!TEST_INPLACE(self)) {
|
4898
4929
|
self = na_copy(self);
|
@@ -4993,7 +5024,8 @@ loop:
|
|
4993
5024
|
pm = med3(pl, pm, pn, cmp);
|
4994
5025
|
}
|
4995
5026
|
swap(a, pm);
|
4996
|
-
for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc;
|
5027
|
+
for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc;
|
5028
|
+
pb += es, pc -= es) {
|
4997
5029
|
while (pb <= pc && (r = cmp(pb, a)) <= 0) {
|
4998
5030
|
if (r == 0) {
|
4999
5031
|
swap(pa, pb);
|
@@ -5040,7 +5072,6 @@ static void uint8_index64_qsort(na_loop_t* const lp) {
|
|
5040
5072
|
|
5041
5073
|
ptr = (char**)(lp->opt_ptr);
|
5042
5074
|
|
5043
|
-
// printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
|
5044
5075
|
// 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);
|
5045
5076
|
|
5046
5077
|
if (n == 1) {
|
@@ -5050,21 +5081,17 @@ static void uint8_index64_qsort(na_loop_t* const lp) {
|
|
5050
5081
|
|
5051
5082
|
for (i = 0; i < n; i++) {
|
5052
5083
|
ptr[i] = d_ptr + d_step * i;
|
5053
|
-
// printf("(%ld,%.3f)",i,*(double*)ptr[i]);
|
5054
5084
|
}
|
5055
5085
|
|
5056
5086
|
uint8_index_qsort(ptr, n, sizeof(dtype*));
|
5057
5087
|
|
5058
5088
|
// d_ptr = lp->args[0].ptr;
|
5059
|
-
// printf("(d_ptr=%lx)\n",(size_t)d_ptr);
|
5060
5089
|
|
5061
5090
|
for (i = 0; i < n; i++) {
|
5062
5091
|
idx = (ptr[i] - d_ptr) / d_step;
|
5063
5092
|
*(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
|
5064
|
-
// printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
|
5065
5093
|
o_ptr += o_step;
|
5066
5094
|
}
|
5067
|
-
// printf("\n");
|
5068
5095
|
}
|
5069
5096
|
#undef idx_t
|
5070
5097
|
|
@@ -5082,7 +5109,6 @@ static void uint8_index32_qsort(na_loop_t* const lp) {
|
|
5082
5109
|
|
5083
5110
|
ptr = (char**)(lp->opt_ptr);
|
5084
5111
|
|
5085
|
-
// printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
|
5086
5112
|
// 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);
|
5087
5113
|
|
5088
5114
|
if (n == 1) {
|
@@ -5092,21 +5118,17 @@ static void uint8_index32_qsort(na_loop_t* const lp) {
|
|
5092
5118
|
|
5093
5119
|
for (i = 0; i < n; i++) {
|
5094
5120
|
ptr[i] = d_ptr + d_step * i;
|
5095
|
-
// printf("(%ld,%.3f)",i,*(double*)ptr[i]);
|
5096
5121
|
}
|
5097
5122
|
|
5098
5123
|
uint8_index_qsort(ptr, n, sizeof(dtype*));
|
5099
5124
|
|
5100
5125
|
// d_ptr = lp->args[0].ptr;
|
5101
|
-
// printf("(d_ptr=%lx)\n",(size_t)d_ptr);
|
5102
5126
|
|
5103
5127
|
for (i = 0; i < n; i++) {
|
5104
5128
|
idx = (ptr[i] - d_ptr) / d_step;
|
5105
5129
|
*(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
|
5106
|
-
// printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
|
5107
5130
|
o_ptr += o_step;
|
5108
5131
|
}
|
5109
|
-
// printf("\n");
|
5110
5132
|
}
|
5111
5133
|
#undef idx_t
|
5112
5134
|
|
@@ -5123,9 +5145,9 @@ static VALUE uint8_sort_index(int argc, VALUE* argv, VALUE self) {
|
|
5123
5145
|
narray_t* na;
|
5124
5146
|
VALUE idx, tmp, reduce, res;
|
5125
5147
|
char* buf;
|
5126
|
-
ndfunc_arg_in_t ain[3] = {{cT, 0}, {0, 0}, {sym_reduce, 0}};
|
5127
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
5128
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_CUM, 3, 1, ain, aout};
|
5148
|
+
ndfunc_arg_in_t ain[3] = { { cT, 0 }, { 0, 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_CUM, 3, 1, ain, aout };
|
5129
5151
|
|
5130
5152
|
GetNArray(self, na);
|
5131
5153
|
if (na->ndim == 0) {
|
@@ -5179,15 +5201,16 @@ static void iter_uint8_median(na_loop_t* const lp) {
|
|
5179
5201
|
median of self.
|
5180
5202
|
@overload median(axis:nil, keepdims:false)
|
5181
5203
|
@param [Numeric,Array,Range] axis Finds median along the axis.
|
5182
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
5204
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
5205
|
+
dimensions with size one.
|
5183
5206
|
@return [Numo::UInt8] returns median of self.
|
5184
5207
|
*/
|
5185
5208
|
|
5186
5209
|
static VALUE uint8_median(int argc, VALUE* argv, VALUE self) {
|
5187
5210
|
VALUE v, reduce;
|
5188
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_reduce, 0}};
|
5189
|
-
ndfunc_arg_out_t aout[1] = {{INT2FIX(0), 0}};
|
5190
|
-
ndfunc_t ndf = {0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
5211
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
|
5212
|
+
ndfunc_arg_out_t aout[1] = { { INT2FIX(0), 0 } };
|
5213
|
+
ndfunc_t ndf = { 0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
5191
5214
|
|
5192
5215
|
self = na_copy(self); // as temporary buffer
|
5193
5216
|
|