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_int8_store_bit(na_loop_t* const lp) {
|
|
238
238
|
}
|
239
239
|
|
240
240
|
static VALUE int8_store_bit(VALUE self, VALUE obj) {
|
241
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
242
|
-
ndfunc_t ndf = {iter_int8_store_bit, FULL_LOOP, 2, 0, ain, 0};
|
241
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
242
|
+
ndfunc_t ndf = { iter_int8_store_bit, FULL_LOOP, 2, 0, ain, 0 };
|
243
243
|
|
244
244
|
na_ndloop(&ndf, 2, self, obj);
|
245
245
|
return self;
|
@@ -287,8 +287,8 @@ static void iter_int8_store_dfloat(na_loop_t* const lp) {
|
|
287
287
|
}
|
288
288
|
|
289
289
|
static VALUE int8_store_dfloat(VALUE self, VALUE obj) {
|
290
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
291
|
-
ndfunc_t ndf = {iter_int8_store_dfloat, FULL_LOOP, 2, 0, ain, 0};
|
290
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
291
|
+
ndfunc_t ndf = { iter_int8_store_dfloat, FULL_LOOP, 2, 0, ain, 0 };
|
292
292
|
|
293
293
|
na_ndloop(&ndf, 2, self, obj);
|
294
294
|
return self;
|
@@ -336,8 +336,8 @@ static void iter_int8_store_sfloat(na_loop_t* const lp) {
|
|
336
336
|
}
|
337
337
|
|
338
338
|
static VALUE int8_store_sfloat(VALUE self, VALUE obj) {
|
339
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
340
|
-
ndfunc_t ndf = {iter_int8_store_sfloat, FULL_LOOP, 2, 0, ain, 0};
|
339
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
340
|
+
ndfunc_t ndf = { iter_int8_store_sfloat, FULL_LOOP, 2, 0, ain, 0 };
|
341
341
|
|
342
342
|
na_ndloop(&ndf, 2, self, obj);
|
343
343
|
return self;
|
@@ -385,8 +385,8 @@ static void iter_int8_store_int64(na_loop_t* const lp) {
|
|
385
385
|
}
|
386
386
|
|
387
387
|
static VALUE int8_store_int64(VALUE self, VALUE obj) {
|
388
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
389
|
-
ndfunc_t ndf = {iter_int8_store_int64, FULL_LOOP, 2, 0, ain, 0};
|
388
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
389
|
+
ndfunc_t ndf = { iter_int8_store_int64, FULL_LOOP, 2, 0, ain, 0 };
|
390
390
|
|
391
391
|
na_ndloop(&ndf, 2, self, obj);
|
392
392
|
return self;
|
@@ -434,8 +434,8 @@ static void iter_int8_store_int32(na_loop_t* const lp) {
|
|
434
434
|
}
|
435
435
|
|
436
436
|
static VALUE int8_store_int32(VALUE self, VALUE obj) {
|
437
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
438
|
-
ndfunc_t ndf = {iter_int8_store_int32, FULL_LOOP, 2, 0, ain, 0};
|
437
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
438
|
+
ndfunc_t ndf = { iter_int8_store_int32, FULL_LOOP, 2, 0, ain, 0 };
|
439
439
|
|
440
440
|
na_ndloop(&ndf, 2, self, obj);
|
441
441
|
return self;
|
@@ -483,8 +483,8 @@ static void iter_int8_store_int16(na_loop_t* const lp) {
|
|
483
483
|
}
|
484
484
|
|
485
485
|
static VALUE int8_store_int16(VALUE self, VALUE obj) {
|
486
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
487
|
-
ndfunc_t ndf = {iter_int8_store_int16, FULL_LOOP, 2, 0, ain, 0};
|
486
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
487
|
+
ndfunc_t ndf = { iter_int8_store_int16, FULL_LOOP, 2, 0, ain, 0 };
|
488
488
|
|
489
489
|
na_ndloop(&ndf, 2, self, obj);
|
490
490
|
return self;
|
@@ -532,8 +532,8 @@ static void iter_int8_store_int8(na_loop_t* const lp) {
|
|
532
532
|
}
|
533
533
|
|
534
534
|
static VALUE int8_store_int8(VALUE self, VALUE obj) {
|
535
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
536
|
-
ndfunc_t ndf = {iter_int8_store_int8, FULL_LOOP, 2, 0, ain, 0};
|
535
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
536
|
+
ndfunc_t ndf = { iter_int8_store_int8, FULL_LOOP, 2, 0, ain, 0 };
|
537
537
|
|
538
538
|
na_ndloop(&ndf, 2, self, obj);
|
539
539
|
return self;
|
@@ -581,8 +581,8 @@ static void iter_int8_store_uint64(na_loop_t* const lp) {
|
|
581
581
|
}
|
582
582
|
|
583
583
|
static VALUE int8_store_uint64(VALUE self, VALUE obj) {
|
584
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
585
|
-
ndfunc_t ndf = {iter_int8_store_uint64, FULL_LOOP, 2, 0, ain, 0};
|
584
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
585
|
+
ndfunc_t ndf = { iter_int8_store_uint64, FULL_LOOP, 2, 0, ain, 0 };
|
586
586
|
|
587
587
|
na_ndloop(&ndf, 2, self, obj);
|
588
588
|
return self;
|
@@ -630,8 +630,8 @@ static void iter_int8_store_uint32(na_loop_t* const lp) {
|
|
630
630
|
}
|
631
631
|
|
632
632
|
static VALUE int8_store_uint32(VALUE self, VALUE obj) {
|
633
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
634
|
-
ndfunc_t ndf = {iter_int8_store_uint32, FULL_LOOP, 2, 0, ain, 0};
|
633
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
634
|
+
ndfunc_t ndf = { iter_int8_store_uint32, FULL_LOOP, 2, 0, ain, 0 };
|
635
635
|
|
636
636
|
na_ndloop(&ndf, 2, self, obj);
|
637
637
|
return self;
|
@@ -679,8 +679,8 @@ static void iter_int8_store_uint16(na_loop_t* const lp) {
|
|
679
679
|
}
|
680
680
|
|
681
681
|
static VALUE int8_store_uint16(VALUE self, VALUE obj) {
|
682
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
683
|
-
ndfunc_t ndf = {iter_int8_store_uint16, FULL_LOOP, 2, 0, ain, 0};
|
682
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
683
|
+
ndfunc_t ndf = { iter_int8_store_uint16, FULL_LOOP, 2, 0, ain, 0 };
|
684
684
|
|
685
685
|
na_ndloop(&ndf, 2, self, obj);
|
686
686
|
return self;
|
@@ -728,8 +728,8 @@ static void iter_int8_store_uint8(na_loop_t* const lp) {
|
|
728
728
|
}
|
729
729
|
|
730
730
|
static VALUE int8_store_uint8(VALUE self, VALUE obj) {
|
731
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
732
|
-
ndfunc_t ndf = {iter_int8_store_uint8, FULL_LOOP, 2, 0, ain, 0};
|
731
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
732
|
+
ndfunc_t ndf = { iter_int8_store_uint8, FULL_LOOP, 2, 0, ain, 0 };
|
733
733
|
|
734
734
|
na_ndloop(&ndf, 2, self, obj);
|
735
735
|
return self;
|
@@ -777,8 +777,8 @@ static void iter_int8_store_robject(na_loop_t* const lp) {
|
|
777
777
|
}
|
778
778
|
|
779
779
|
static VALUE int8_store_robject(VALUE self, VALUE obj) {
|
780
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
781
|
-
ndfunc_t ndf = {iter_int8_store_robject, FULL_LOOP, 2, 0, ain, 0};
|
780
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
781
|
+
ndfunc_t ndf = { iter_int8_store_robject, FULL_LOOP, 2, 0, ain, 0 };
|
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 int8_store_array(VALUE self, VALUE rary) {
|
889
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {rb_cArray, 0}};
|
890
|
-
ndfunc_t ndf = {iter_int8_store_array, FULL_LOOP, 2, 0, ain, 0};
|
889
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { rb_cArray, 0 } };
|
890
|
+
ndfunc_t ndf = { iter_int8_store_array, FULL_LOOP, 2, 0, ain, 0 };
|
891
891
|
|
892
892
|
na_ndloop_store_rarray(&ndf, self, rary);
|
893
893
|
return self;
|
@@ -982,8 +982,10 @@ static VALUE int8_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 int8_extract_data(VALUE obj) {
|
|
1077
1079
|
return int8_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 int8_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::Int8] an element or NArray view.
|
1152
1157
|
@see Numo::NArray#[]
|
1153
1158
|
@see #[]=
|
@@ -1169,8 +1174,8 @@ static VALUE int8_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_int8_to_a(na_loop_t* const lp) {
|
|
1241
1246
|
@return [Array]
|
1242
1247
|
*/
|
1243
1248
|
static VALUE int8_to_a(VALUE self) {
|
1244
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
|
1245
|
-
ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
|
1246
|
-
ndfunc_t ndf = {iter_int8_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
|
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_int8_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_int8_fill(na_loop_t* const lp) {
|
|
1275
1280
|
@return [Numo::Int8] self.
|
1276
1281
|
*/
|
1277
1282
|
static VALUE int8_fill(VALUE self, VALUE val) {
|
1278
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_option}};
|
1279
|
-
ndfunc_t ndf = {iter_int8_fill, FULL_LOOP, 2, 0, ain, 0};
|
1283
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
|
1284
|
+
ndfunc_t ndf = { iter_int8_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_int8_format(na_loop_t* const lp) {
|
|
1331
1336
|
static VALUE int8_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_int8_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_int8_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_int8_format_to_a(na_loop_t* const lp) {
|
|
1377
1382
|
*/
|
1378
1383
|
static VALUE int8_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_int8_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_int8_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_int8_each(na_loop_t* const lp) {
|
|
1433
1438
|
@see #map
|
1434
1439
|
*/
|
1435
1440
|
static VALUE int8_each(VALUE self) {
|
1436
|
-
ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
|
1437
|
-
ndfunc_t ndf = {iter_int8_each, FULL_LOOP_NIP, 1, 0, ain, 0};
|
1441
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1442
|
+
ndfunc_t ndf = { iter_int8_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_int8_map(na_loop_t* const lp) {
|
|
1491
1496
|
@return [Numo::Int8] map of self.
|
1492
1497
|
*/
|
1493
1498
|
static VALUE int8_map(VALUE self) {
|
1494
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
1495
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1496
|
-
ndfunc_t ndf = {iter_int8_map, FULL_LOOP, 1, 1, ain, aout};
|
1499
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
1500
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1501
|
+
ndfunc_t ndf = { iter_int8_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_int8_each_with_index(na_loop_t* const lp) {
|
|
1555
1560
|
@see #map_with_index
|
1556
1561
|
*/
|
1557
1562
|
static VALUE int8_each_with_index(VALUE self) {
|
1558
|
-
ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
|
1559
|
-
ndfunc_t ndf = {iter_int8_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0};
|
1563
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1564
|
+
ndfunc_t ndf = { iter_int8_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_int8_map_with_index(na_loop_t* const lp) {
|
|
1646
1651
|
@see #each_with_index
|
1647
1652
|
*/
|
1648
1653
|
static VALUE int8_map_with_index(VALUE self) {
|
1649
|
-
ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
|
1650
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1651
|
-
ndfunc_t ndf = {iter_int8_map_with_index, FULL_LOOP, 1, 1, ain, aout};
|
1654
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1655
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1656
|
+
ndfunc_t ndf = { iter_int8_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_int8_abs(na_loop_t* const lp) {
|
|
1700
1705
|
@return [Numo::Int8] abs of self.
|
1701
1706
|
*/
|
1702
1707
|
static VALUE int8_abs(VALUE self) {
|
1703
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
1704
|
-
ndfunc_arg_out_t aout[1] = {{cRT, 0}};
|
1705
|
-
ndfunc_t ndf = {iter_int8_abs, FULL_LOOP, 1, 1, ain, aout};
|
1708
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
1709
|
+
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
1710
|
+
ndfunc_t ndf = { iter_int8_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_int8_add(na_loop_t* const lp) {
|
@@ -1767,9 +1772,9 @@ static void iter_int8_add(na_loop_t* const lp) {
|
|
1767
1772
|
#undef check_intdivzero
|
1768
1773
|
|
1769
1774
|
static VALUE int8_add_self(VALUE self, VALUE other) {
|
1770
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
1771
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1772
|
-
ndfunc_t ndf = {iter_int8_add, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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 int8_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_int8_sub(na_loop_t* const lp) {
|
@@ -1853,9 +1858,9 @@ static void iter_int8_sub(na_loop_t* const lp) {
|
|
1853
1858
|
#undef check_intdivzero
|
1854
1859
|
|
1855
1860
|
static VALUE int8_sub_self(VALUE self, VALUE other) {
|
1856
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
1857
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1858
|
-
ndfunc_t ndf = {iter_int8_sub, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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 int8_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_int8_mul(na_loop_t* const lp) {
|
@@ -1939,9 +1944,9 @@ static void iter_int8_mul(na_loop_t* const lp) {
|
|
1939
1944
|
#undef check_intdivzero
|
1940
1945
|
|
1941
1946
|
static VALUE int8_mul_self(VALUE self, VALUE other) {
|
1942
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
1943
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1944
|
-
ndfunc_t ndf = {iter_int8_mul, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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 int8_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_int8_div(na_loop_t* const lp) {
|
@@ -2028,9 +2033,9 @@ static void iter_int8_div(na_loop_t* const lp) {
|
|
2028
2033
|
#undef check_intdivzero
|
2029
2034
|
|
2030
2035
|
static VALUE int8_div_self(VALUE self, VALUE other) {
|
2031
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2032
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2033
|
-
ndfunc_t ndf = {iter_int8_div, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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 int8_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_int8_mod(na_loop_t* const lp) {
|
@@ -2117,9 +2122,9 @@ static void iter_int8_mod(na_loop_t* const lp) {
|
|
2117
2122
|
#undef check_intdivzero
|
2118
2123
|
|
2119
2124
|
static VALUE int8_mod_self(VALUE self, VALUE other) {
|
2120
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2121
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2122
|
-
ndfunc_t ndf = {iter_int8_mod, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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_int8_divmod(na_loop_t* const lp) {
|
|
2167
2172
|
}
|
2168
2173
|
|
2169
2174
|
static VALUE int8_divmod_self(VALUE self, VALUE other) {
|
2170
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2171
|
-
ndfunc_arg_out_t aout[2] = {{cT, 0}, {cT, 0}};
|
2172
|
-
ndfunc_t ndf = {iter_int8_divmod, STRIDE_LOOP, 2, 2, ain, aout};
|
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_int8_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_int8_pow_int32(na_loop_t* const lp) {
|
|
2228
2233
|
}
|
2229
2234
|
|
2230
2235
|
static VALUE int8_pow_self(VALUE self, VALUE other) {
|
2231
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2232
|
-
ndfunc_arg_in_t ain_i[2] = {{cT, 0}, {numo_cInt32, 0}};
|
2233
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2234
|
-
ndfunc_t ndf = {iter_int8_pow, STRIDE_LOOP, 2, 1, ain, aout};
|
2235
|
-
ndfunc_t ndf_i = {iter_int8_pow_int32, STRIDE_LOOP, 2, 1, ain_i, aout};
|
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_int8_pow, STRIDE_LOOP, 2, 1, ain, aout };
|
2240
|
+
ndfunc_t ndf_i = { iter_int8_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_int8_minus(na_loop_t* const lp) {
|
|
2311
2316
|
@return [Numo::Int8] minus of self.
|
2312
2317
|
*/
|
2313
2318
|
static VALUE int8_minus(VALUE self) {
|
2314
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2315
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2316
|
-
ndfunc_t ndf = {iter_int8_minus, FULL_LOOP, 1, 1, ain, aout};
|
2319
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2320
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2321
|
+
ndfunc_t ndf = { iter_int8_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_int8_reciprocal(na_loop_t* const lp) {
|
|
2369
2374
|
@return [Numo::Int8] reciprocal of self.
|
2370
2375
|
*/
|
2371
2376
|
static VALUE int8_reciprocal(VALUE self) {
|
2372
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2373
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2374
|
-
ndfunc_t ndf = {iter_int8_reciprocal, FULL_LOOP, 1, 1, ain, aout};
|
2377
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2378
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2379
|
+
ndfunc_t ndf = { iter_int8_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_int8_sign(na_loop_t* const lp) {
|
|
2427
2432
|
@return [Numo::Int8] sign of self.
|
2428
2433
|
*/
|
2429
2434
|
static VALUE int8_sign(VALUE self) {
|
2430
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2431
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2432
|
-
ndfunc_t ndf = {iter_int8_sign, FULL_LOOP, 1, 1, ain, aout};
|
2435
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2436
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2437
|
+
ndfunc_t ndf = { iter_int8_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_int8_square(na_loop_t* const lp) {
|
|
2485
2490
|
@return [Numo::Int8] square of self.
|
2486
2491
|
*/
|
2487
2492
|
static VALUE int8_square(VALUE self) {
|
2488
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2489
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2490
|
-
ndfunc_t ndf = {iter_int8_square, FULL_LOOP, 1, 1, ain, aout};
|
2493
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2494
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2495
|
+
ndfunc_t ndf = { iter_int8_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_int8_eq(na_loop_t* const lp) {
|
|
2514
2519
|
}
|
2515
2520
|
|
2516
2521
|
static VALUE int8_eq_self(VALUE self, VALUE other) {
|
2517
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2518
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
2519
|
-
ndfunc_t ndf = {iter_int8_eq, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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_int8_ne(na_loop_t* const lp) {
|
|
2561
2566
|
}
|
2562
2567
|
|
2563
2568
|
static VALUE int8_ne_self(VALUE self, VALUE other) {
|
2564
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2565
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
2566
|
-
ndfunc_t ndf = {iter_int8_ne, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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 int8_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_int8_bit_and(na_loop_t* const lp) {
|
@@ -2646,9 +2651,9 @@ static void iter_int8_bit_and(na_loop_t* const lp) {
|
|
2646
2651
|
#undef check_intdivzero
|
2647
2652
|
|
2648
2653
|
static VALUE int8_bit_and_self(VALUE self, VALUE other) {
|
2649
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2650
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2651
|
-
ndfunc_t ndf = {iter_int8_bit_and, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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 int8_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_int8_bit_or(na_loop_t* const lp) {
|
@@ -2732,9 +2737,9 @@ static void iter_int8_bit_or(na_loop_t* const lp) {
|
|
2732
2737
|
#undef check_intdivzero
|
2733
2738
|
|
2734
2739
|
static VALUE int8_bit_or_self(VALUE self, VALUE other) {
|
2735
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2736
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2737
|
-
ndfunc_t ndf = {iter_int8_bit_or, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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 int8_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_int8_bit_xor(na_loop_t* const lp) {
|
@@ -2818,9 +2823,9 @@ static void iter_int8_bit_xor(na_loop_t* const lp) {
|
|
2818
2823
|
#undef check_intdivzero
|
2819
2824
|
|
2820
2825
|
static VALUE int8_bit_xor_self(VALUE self, VALUE other) {
|
2821
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2822
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2823
|
-
ndfunc_t ndf = {iter_int8_bit_xor, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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_int8_bit_not(na_loop_t* const lp) {
|
|
2895
2900
|
@return [Numo::Int8] bit_not of self.
|
2896
2901
|
*/
|
2897
2902
|
static VALUE int8_bit_not(VALUE self) {
|
2898
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2899
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2900
|
-
ndfunc_t ndf = {iter_int8_bit_not, FULL_LOOP, 1, 1, ain, aout};
|
2903
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2904
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2905
|
+
ndfunc_t ndf = { iter_int8_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_int8_left_shift(na_loop_t* const lp) {
|
@@ -2962,9 +2967,9 @@ static void iter_int8_left_shift(na_loop_t* const lp) {
|
|
2962
2967
|
#undef check_intdivzero
|
2963
2968
|
|
2964
2969
|
static VALUE int8_left_shift_self(VALUE self, VALUE other) {
|
2965
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2966
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2967
|
-
ndfunc_t ndf = {iter_int8_left_shift, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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 int8_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_int8_right_shift(na_loop_t* const lp) {
|
@@ -3048,9 +3053,9 @@ static void iter_int8_right_shift(na_loop_t* const lp) {
|
|
3048
3053
|
#undef check_intdivzero
|
3049
3054
|
|
3050
3055
|
static VALUE int8_right_shift_self(VALUE self, VALUE other) {
|
3051
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3052
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3053
|
-
ndfunc_t ndf = {iter_int8_right_shift, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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_int8_gt(na_loop_t* const lp) {
|
|
3096
3101
|
}
|
3097
3102
|
|
3098
3103
|
static VALUE int8_gt_self(VALUE self, VALUE other) {
|
3099
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3100
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3101
|
-
ndfunc_t ndf = {iter_int8_gt, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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_int8_ge(na_loop_t* const lp) {
|
|
3143
3148
|
}
|
3144
3149
|
|
3145
3150
|
static VALUE int8_ge_self(VALUE self, VALUE other) {
|
3146
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3147
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3148
|
-
ndfunc_t ndf = {iter_int8_ge, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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_int8_lt(na_loop_t* const lp) {
|
|
3190
3195
|
}
|
3191
3196
|
|
3192
3197
|
static VALUE int8_lt_self(VALUE self, VALUE other) {
|
3193
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3194
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3195
|
-
ndfunc_t ndf = {iter_int8_lt, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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_int8_le(na_loop_t* const lp) {
|
|
3237
3242
|
}
|
3238
3243
|
|
3239
3244
|
static VALUE int8_le_self(VALUE self, VALUE other) {
|
3240
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3241
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3242
|
-
ndfunc_t ndf = {iter_int8_le, STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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_int8_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 int8_clip(VALUE self, VALUE min, VALUE max) {
|
3361
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {cT, 0}, {cT, 0}};
|
3362
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3363
|
-
ndfunc_t ndf_min = {iter_int8_clip_min, STRIDE_LOOP, 2, 1, ain, aout};
|
3364
|
-
ndfunc_t ndf_max = {iter_int8_clip_max, STRIDE_LOOP, 2, 1, ain, aout};
|
3365
|
-
ndfunc_t ndf_both = {iter_int8_clip, STRIDE_LOOP, 3, 1, ain, aout};
|
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_int8_clip_min, STRIDE_LOOP, 2, 1, ain, aout };
|
3369
|
+
ndfunc_t ndf_max = { iter_int8_clip_max, STRIDE_LOOP, 2, 1, ain, aout };
|
3370
|
+
ndfunc_t ndf_both = { iter_int8_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_int8_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::Int8] returns result of sum.
|
3400
3406
|
*/
|
3401
3407
|
static VALUE int8_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_cInt64, 0}};
|
3405
|
-
ndfunc_t ndf = {iter_int8_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_cInt64, 0 } };
|
3411
|
+
ndfunc_t ndf = { iter_int8_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_int8_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::Int8] returns result of prod.
|
3432
3439
|
*/
|
3433
3440
|
static VALUE int8_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_cInt64, 0}};
|
3437
|
-
ndfunc_t ndf = {iter_int8_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_cInt64, 0 } };
|
3444
|
+
ndfunc_t ndf = { iter_int8_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_int8_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::Int8] returns result of min.
|
3464
3472
|
*/
|
3465
3473
|
static VALUE int8_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_int8_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_int8_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_int8_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::Int8] returns result of max.
|
3496
3505
|
*/
|
3497
3506
|
static VALUE int8_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_int8_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_int8_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_int8_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::Int8] returns result of ptp.
|
3528
3538
|
*/
|
3529
3539
|
static VALUE int8_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_int8_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_int8_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_int8_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_int8_max_index_index32(na_loop_t* const lp) {
|
|
3594
3605
|
static VALUE int8_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_int8_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_int8_min_index_index32(na_loop_t* const lp) {
|
|
3676
3688
|
static VALUE int8_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_int8_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_int8_argmax_arg32(na_loop_t* const lp) {
|
|
3756
3769
|
static VALUE int8_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_int8_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_int8_argmin_arg32(na_loop_t* const lp) {
|
|
3833
3847
|
static VALUE int8_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_int8_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::Int8,Numo::Int8] min and max of self.
|
3881
3896
|
*/
|
3882
3897
|
static VALUE int8_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_int8_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_int8_s_maximum(na_loop_t* const lp) {
|
|
3921
3938
|
static VALUE int8_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_int8_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_int8_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_int8_s_minimum(na_loop_t* const lp) {
|
|
3961
3978
|
static VALUE int8_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_int8_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_int8_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_int8_bincount_32(na_loop_t* const lp) {
|
|
4002
4019
|
}
|
4003
4020
|
|
4004
4021
|
static VALUE int8_bincount_32(VALUE self, size_t length) {
|
4005
|
-
size_t shape_out[1] = {length};
|
4006
|
-
ndfunc_arg_in_t ain[1] = {{cT, 1}};
|
4007
|
-
ndfunc_arg_out_t aout[1] = {{numo_cUInt32, 1, shape_out}};
|
4008
|
-
ndfunc_t ndf = {
|
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_int8_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_int8_bincount_64(na_loop_t* const lp) {
|
|
4040
4059
|
}
|
4041
4060
|
|
4042
4061
|
static VALUE int8_bincount_64(VALUE self, size_t length) {
|
4043
|
-
size_t shape_out[1] = {length};
|
4044
|
-
ndfunc_arg_in_t ain[1] = {{cT, 1}};
|
4045
|
-
ndfunc_arg_out_t aout[1] = {{numo_cUInt64, 1, shape_out}};
|
4046
|
-
ndfunc_t ndf = {
|
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_int8_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_int8_bincount_sf(na_loop_t* const lp) {
|
|
4080
4101
|
}
|
4081
4102
|
|
4082
4103
|
static VALUE int8_bincount_sf(VALUE self, VALUE weight, size_t length) {
|
4083
|
-
size_t shape_out[1] = {length};
|
4084
|
-
ndfunc_arg_in_t ain[2] = {{cT, 1}, {numo_cSFloat, 1}};
|
4085
|
-
ndfunc_arg_out_t aout[1] = {{numo_cSFloat, 1, shape_out}};
|
4086
|
-
ndfunc_t ndf = {iter_int8_bincount_sf, NO_LOOP | NDF_STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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_int8_bincount_df(na_loop_t* const lp) {
|
|
4117
4138
|
}
|
4118
4139
|
|
4119
4140
|
static VALUE int8_bincount_df(VALUE self, VALUE weight, size_t length) {
|
4120
|
-
size_t shape_out[1] = {length};
|
4121
|
-
ndfunc_arg_in_t ain[2] = {{cT, 1}, {numo_cDFloat, 1}};
|
4122
|
-
ndfunc_arg_out_t aout[1] = {{numo_cDFloat, 1, shape_out}};
|
4123
|
-
ndfunc_t ndf = {iter_int8_bincount_df, NO_LOOP | NDF_STRIDE_LOOP, 2, 1, ain, aout};
|
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_int8_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 int8_bincount_df(VALUE self, VALUE weight, size_t length) {
|
|
4160
4181
|
*/
|
4161
4182
|
static VALUE int8_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);
|
@@ -4208,16 +4229,13 @@ static void iter_int8_cumsum(na_loop_t* const lp) {
|
|
4208
4229
|
INIT_COUNTER(lp, i);
|
4209
4230
|
INIT_PTR(lp, 0, p1, s1);
|
4210
4231
|
INIT_PTR(lp, 1, p2, s2);
|
4211
|
-
// printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
|
4212
4232
|
|
4213
4233
|
GET_DATA_STRIDE(p1, s1, dtype, x);
|
4214
4234
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4215
|
-
// printf("i=%lu x=%f\n",i,x);
|
4216
4235
|
for (i--; i--;) {
|
4217
4236
|
GET_DATA_STRIDE(p1, s1, dtype, y);
|
4218
4237
|
m_cumsum(x, y);
|
4219
4238
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4220
|
-
// printf("i=%lu x=%f\n",i,x);
|
4221
4239
|
}
|
4222
4240
|
}
|
4223
4241
|
|
@@ -4230,9 +4248,9 @@ static void iter_int8_cumsum(na_loop_t* const lp) {
|
|
4230
4248
|
*/
|
4231
4249
|
static VALUE int8_cumsum(int argc, VALUE* argv, VALUE self) {
|
4232
4250
|
VALUE reduce;
|
4233
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4234
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4235
|
-
ndfunc_t ndf = {iter_int8_cumsum, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout};
|
4251
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4252
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4253
|
+
ndfunc_t ndf = { iter_int8_cumsum, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout };
|
4236
4254
|
|
4237
4255
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
4238
4256
|
|
@@ -4248,16 +4266,13 @@ static void iter_int8_cumprod(na_loop_t* const lp) {
|
|
4248
4266
|
INIT_COUNTER(lp, i);
|
4249
4267
|
INIT_PTR(lp, 0, p1, s1);
|
4250
4268
|
INIT_PTR(lp, 1, p2, s2);
|
4251
|
-
// printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
|
4252
4269
|
|
4253
4270
|
GET_DATA_STRIDE(p1, s1, dtype, x);
|
4254
4271
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4255
|
-
// printf("i=%lu x=%f\n",i,x);
|
4256
4272
|
for (i--; i--;) {
|
4257
4273
|
GET_DATA_STRIDE(p1, s1, dtype, y);
|
4258
4274
|
m_cumprod(x, y);
|
4259
4275
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4260
|
-
// printf("i=%lu x=%f\n",i,x);
|
4261
4276
|
}
|
4262
4277
|
}
|
4263
4278
|
|
@@ -4270,9 +4285,11 @@ static void iter_int8_cumprod(na_loop_t* const lp) {
|
|
4270
4285
|
*/
|
4271
4286
|
static VALUE int8_cumprod(int argc, VALUE* argv, VALUE self) {
|
4272
4287
|
VALUE reduce;
|
4273
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4274
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4275
|
-
ndfunc_t ndf = {
|
4288
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4289
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4290
|
+
ndfunc_t ndf = {
|
4291
|
+
iter_int8_cumprod, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout
|
4292
|
+
};
|
4276
4293
|
|
4277
4294
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
4278
4295
|
|
@@ -4318,9 +4335,9 @@ static void iter_int8_mulsum(na_loop_t* const lp) {
|
|
4318
4335
|
static VALUE int8_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
4319
4336
|
VALUE v, reduce;
|
4320
4337
|
VALUE naryv[2];
|
4321
|
-
ndfunc_arg_in_t ain[4] = {{cT, 0}, {cT, 0}, {sym_reduce, 0}, {sym_init, 0}};
|
4322
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4323
|
-
ndfunc_t ndf = {iter_int8_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout};
|
4338
|
+
ndfunc_arg_in_t ain[4] = { { cT, 0 }, { cT, 0 }, { sym_reduce, 0 }, { sym_init, 0 } };
|
4339
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4340
|
+
ndfunc_t ndf = { iter_int8_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout };
|
4324
4341
|
|
4325
4342
|
if (argc < 1) {
|
4326
4343
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for >=1)", argc);
|
@@ -4342,7 +4359,8 @@ static VALUE int8_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
|
4342
4359
|
@overload mulsum(other, axis:nil, keepdims:false)
|
4343
4360
|
@param [Numo::NArray,Numeric] other
|
4344
4361
|
@param [Numeric,Array,Range] axis Performs mulsum along the axis.
|
4345
|
-
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
4362
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
4363
|
+
as dimensions with size one.
|
4346
4364
|
@return [Numo::NArray] mulsum of self and other.
|
4347
4365
|
*/
|
4348
4366
|
static VALUE int8_mulsum(int argc, VALUE* argv, VALUE self) {
|
@@ -4427,8 +4445,8 @@ static void iter_int8_seq(na_loop_t* const lp) {
|
|
4427
4445
|
static VALUE int8_seq(int argc, VALUE* args, VALUE self) {
|
4428
4446
|
seq_opt_t* g;
|
4429
4447
|
VALUE vbeg = Qnil, vstep = Qnil;
|
4430
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
|
4431
|
-
ndfunc_t ndf = {iter_int8_seq, FULL_LOOP, 1, 0, ain, 0};
|
4448
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
4449
|
+
ndfunc_t ndf = { iter_int8_seq, FULL_LOOP, 1, 0, ain, 0 };
|
4432
4450
|
|
4433
4451
|
g = ALLOCA_N(seq_opt_t, 1);
|
4434
4452
|
g->beg = m_zero;
|
@@ -4485,8 +4503,8 @@ static void iter_int8_eye(na_loop_t* const lp) {
|
|
4485
4503
|
@return [Numo::Int8] eye of self.
|
4486
4504
|
*/
|
4487
4505
|
static VALUE int8_eye(int argc, VALUE* argv, VALUE self) {
|
4488
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 2}};
|
4489
|
-
ndfunc_t ndf = {iter_int8_eye, NO_LOOP, 1, 0, ain, 0};
|
4506
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
|
4507
|
+
ndfunc_t ndf = { iter_int8_eye, NO_LOOP, 1, 0, ain, 0 };
|
4490
4508
|
ssize_t kofs;
|
4491
4509
|
dtype data;
|
4492
4510
|
char* g;
|
@@ -4516,17 +4534,21 @@ static VALUE int8_eye(int argc, VALUE* argv, VALUE self) {
|
|
4516
4534
|
// Diagonal offset from the main diagonal.
|
4517
4535
|
if (kofs >= 0) {
|
4518
4536
|
if ((size_t)(kofs) >= na->shape[nd - 1]) {
|
4519
|
-
rb_raise(
|
4520
|
-
|
4521
|
-
|
4522
|
-
|
4537
|
+
rb_raise(
|
4538
|
+
rb_eArgError,
|
4539
|
+
"invalid diagonal offset(%" SZF "d) for "
|
4540
|
+
"last dimension size(%" SZF "d)",
|
4541
|
+
kofs, na->shape[nd - 1]
|
4542
|
+
);
|
4523
4543
|
}
|
4524
4544
|
} else {
|
4525
4545
|
if ((size_t)(-kofs) >= na->shape[nd - 2]) {
|
4526
|
-
rb_raise(
|
4527
|
-
|
4528
|
-
|
4529
|
-
|
4546
|
+
rb_raise(
|
4547
|
+
rb_eArgError,
|
4548
|
+
"invalid diagonal offset(%" SZF "d) for "
|
4549
|
+
"last-1 dimension size(%" SZF "d)",
|
4550
|
+
kofs, na->shape[nd - 2]
|
4551
|
+
);
|
4530
4552
|
}
|
4531
4553
|
}
|
4532
4554
|
|
@@ -4611,7 +4633,8 @@ static void iter_int8_rand(na_loop_t* const lp) {
|
|
4611
4633
|
Generate uniformly distributed random numbers on self narray.
|
4612
4634
|
@overload rand([[low],high])
|
4613
4635
|
@param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
4614
|
-
@param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
|
4636
|
+
@param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
|
4637
|
+
complex types)
|
4615
4638
|
@return [Numo::Int8] self.
|
4616
4639
|
@example
|
4617
4640
|
Numo::DFloat.new(6).rand
|
@@ -4630,8 +4653,8 @@ static VALUE int8_rand(int argc, VALUE* args, VALUE self) {
|
|
4630
4653
|
rand_opt_t g;
|
4631
4654
|
VALUE v1 = Qnil, v2 = Qnil;
|
4632
4655
|
dtype high;
|
4633
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
|
4634
|
-
ndfunc_t ndf = {iter_int8_rand, FULL_LOOP, 1, 0, ain, 0};
|
4656
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
4657
|
+
ndfunc_t ndf = { iter_int8_rand, FULL_LOOP, 1, 0, ain, 0 };
|
4635
4658
|
|
4636
4659
|
rb_scan_args(argc, args, "11", &v1, &v2);
|
4637
4660
|
if (v2 == Qnil) {
|
@@ -4679,8 +4702,8 @@ static VALUE int8_poly(VALUE self, VALUE args) {
|
|
4679
4702
|
int argc, i;
|
4680
4703
|
VALUE* argv;
|
4681
4704
|
volatile VALUE v, a;
|
4682
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4683
|
-
ndfunc_t ndf = {iter_int8_poly, NO_LOOP, 0, 1, 0, aout};
|
4705
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4706
|
+
ndfunc_t ndf = { iter_int8_poly, NO_LOOP, 0, 1, 0, aout };
|
4684
4707
|
|
4685
4708
|
argc = (int)RARRAY_LEN(args);
|
4686
4709
|
ndf.nin = argc + 1;
|
@@ -4760,23 +4783,28 @@ static VALUE int8_poly(VALUE self, VALUE args) {
|
|
4760
4783
|
* We have modified their original by adding a check for already-sorted input,
|
4761
4784
|
* which seems to be a win per discussions on pgsql-hackers around 2006-03-21.
|
4762
4785
|
*/
|
4763
|
-
#define swapcode(TYPE, parmi, parmj, n)
|
4764
|
-
do {
|
4765
|
-
size_t i = (n) / sizeof(TYPE);
|
4766
|
-
TYPE* pi = (TYPE*)(void*)(parmi);
|
4767
|
-
TYPE* pj = (TYPE*)(void*)(parmj);
|
4768
|
-
do {
|
4769
|
-
TYPE t = *pi;
|
4770
|
-
*pi++ = *pj;
|
4771
|
-
*pj++ = t;
|
4772
|
-
} while (--i > 0);
|
4786
|
+
#define swapcode(TYPE, parmi, parmj, n) \
|
4787
|
+
do { \
|
4788
|
+
size_t i = (n) / sizeof(TYPE); \
|
4789
|
+
TYPE* pi = (TYPE*)(void*)(parmi); \
|
4790
|
+
TYPE* pj = (TYPE*)(void*)(parmj); \
|
4791
|
+
do { \
|
4792
|
+
TYPE t = *pi; \
|
4793
|
+
*pi++ = *pj; \
|
4794
|
+
*pj++ = t; \
|
4795
|
+
} while (--i > 0); \
|
4773
4796
|
} while (0)
|
4774
4797
|
|
4775
4798
|
#ifdef HAVE_STDINT_H
|
4776
|
-
#define SWAPINIT(a, es)
|
4799
|
+
#define SWAPINIT(a, es) \
|
4800
|
+
swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
4801
|
+
: (es) == sizeof(long) ? 0 \
|
4802
|
+
: 1;
|
4777
4803
|
#else
|
4778
|
-
#define SWAPINIT(a, es)
|
4779
|
-
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2
|
4804
|
+
#define SWAPINIT(a, es) \
|
4805
|
+
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
4806
|
+
: (es) == sizeof(long) ? 0 \
|
4807
|
+
: 1;
|
4780
4808
|
#endif
|
4781
4809
|
|
4782
4810
|
static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
|
@@ -4786,19 +4814,20 @@ static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
|
|
4786
4814
|
swapcode(char, a, b, n);
|
4787
4815
|
}
|
4788
4816
|
|
4789
|
-
#define swap(a, b)
|
4790
|
-
if (swaptype == 0) {
|
4791
|
-
long t = *(long*)(void*)(a);
|
4792
|
-
*(long*)(void*)(a) = *(long*)(void*)(b);
|
4793
|
-
*(long*)(void*)(b) = t;
|
4794
|
-
} else
|
4817
|
+
#define swap(a, b) \
|
4818
|
+
if (swaptype == 0) { \
|
4819
|
+
long t = *(long*)(void*)(a); \
|
4820
|
+
*(long*)(void*)(a) = *(long*)(void*)(b); \
|
4821
|
+
*(long*)(void*)(b) = t; \
|
4822
|
+
} else \
|
4795
4823
|
swapfunc(a, b, es, swaptype)
|
4796
4824
|
|
4797
|
-
#define vecswap(a, b, n)
|
4825
|
+
#define vecswap(a, b, n) \
|
4798
4826
|
if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
|
4799
4827
|
|
4800
|
-
#define med3(a, b, c, _cmp)
|
4801
|
-
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a))
|
4828
|
+
#define med3(a, b, c, _cmp) \
|
4829
|
+
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) \
|
4830
|
+
: (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
|
4802
4831
|
#endif
|
4803
4832
|
|
4804
4833
|
#undef qsort_dtype
|
@@ -4895,8 +4924,8 @@ static void iter_int8_sort(na_loop_t* const lp) {
|
|
4895
4924
|
*/
|
4896
4925
|
static VALUE int8_sort(int argc, VALUE* argv, VALUE self) {
|
4897
4926
|
VALUE reduce;
|
4898
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_reduce, 0}};
|
4899
|
-
ndfunc_t ndf = {0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 0, ain, 0};
|
4927
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
|
4928
|
+
ndfunc_t ndf = { 0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 0, ain, 0 };
|
4900
4929
|
|
4901
4930
|
if (!TEST_INPLACE(self)) {
|
4902
4931
|
self = na_copy(self);
|
@@ -4997,7 +5026,8 @@ loop:
|
|
4997
5026
|
pm = med3(pl, pm, pn, cmp);
|
4998
5027
|
}
|
4999
5028
|
swap(a, pm);
|
5000
|
-
for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc;
|
5029
|
+
for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc;
|
5030
|
+
pb += es, pc -= es) {
|
5001
5031
|
while (pb <= pc && (r = cmp(pb, a)) <= 0) {
|
5002
5032
|
if (r == 0) {
|
5003
5033
|
swap(pa, pb);
|
@@ -5044,7 +5074,6 @@ static void int8_index64_qsort(na_loop_t* const lp) {
|
|
5044
5074
|
|
5045
5075
|
ptr = (char**)(lp->opt_ptr);
|
5046
5076
|
|
5047
|
-
// printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
|
5048
5077
|
// o_ptr=%lx,o_step=%ld)\n",(size_t)ptr,(size_t)d_ptr,(ssize_t)d_step,(size_t)i_ptr,(ssize_t)i_step,(size_t)o_ptr,(ssize_t)o_step);
|
5049
5078
|
|
5050
5079
|
if (n == 1) {
|
@@ -5054,21 +5083,17 @@ static void int8_index64_qsort(na_loop_t* const lp) {
|
|
5054
5083
|
|
5055
5084
|
for (i = 0; i < n; i++) {
|
5056
5085
|
ptr[i] = d_ptr + d_step * i;
|
5057
|
-
// printf("(%ld,%.3f)",i,*(double*)ptr[i]);
|
5058
5086
|
}
|
5059
5087
|
|
5060
5088
|
int8_index_qsort(ptr, n, sizeof(dtype*));
|
5061
5089
|
|
5062
5090
|
// d_ptr = lp->args[0].ptr;
|
5063
|
-
// printf("(d_ptr=%lx)\n",(size_t)d_ptr);
|
5064
5091
|
|
5065
5092
|
for (i = 0; i < n; i++) {
|
5066
5093
|
idx = (ptr[i] - d_ptr) / d_step;
|
5067
5094
|
*(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
|
5068
|
-
// printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
|
5069
5095
|
o_ptr += o_step;
|
5070
5096
|
}
|
5071
|
-
// printf("\n");
|
5072
5097
|
}
|
5073
5098
|
#undef idx_t
|
5074
5099
|
|
@@ -5086,7 +5111,6 @@ static void int8_index32_qsort(na_loop_t* const lp) {
|
|
5086
5111
|
|
5087
5112
|
ptr = (char**)(lp->opt_ptr);
|
5088
5113
|
|
5089
|
-
// printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
|
5090
5114
|
// o_ptr=%lx,o_step=%ld)\n",(size_t)ptr,(size_t)d_ptr,(ssize_t)d_step,(size_t)i_ptr,(ssize_t)i_step,(size_t)o_ptr,(ssize_t)o_step);
|
5091
5115
|
|
5092
5116
|
if (n == 1) {
|
@@ -5096,21 +5120,17 @@ static void int8_index32_qsort(na_loop_t* const lp) {
|
|
5096
5120
|
|
5097
5121
|
for (i = 0; i < n; i++) {
|
5098
5122
|
ptr[i] = d_ptr + d_step * i;
|
5099
|
-
// printf("(%ld,%.3f)",i,*(double*)ptr[i]);
|
5100
5123
|
}
|
5101
5124
|
|
5102
5125
|
int8_index_qsort(ptr, n, sizeof(dtype*));
|
5103
5126
|
|
5104
5127
|
// d_ptr = lp->args[0].ptr;
|
5105
|
-
// printf("(d_ptr=%lx)\n",(size_t)d_ptr);
|
5106
5128
|
|
5107
5129
|
for (i = 0; i < n; i++) {
|
5108
5130
|
idx = (ptr[i] - d_ptr) / d_step;
|
5109
5131
|
*(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
|
5110
|
-
// printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
|
5111
5132
|
o_ptr += o_step;
|
5112
5133
|
}
|
5113
|
-
// printf("\n");
|
5114
5134
|
}
|
5115
5135
|
#undef idx_t
|
5116
5136
|
|
@@ -5127,9 +5147,9 @@ static VALUE int8_sort_index(int argc, VALUE* argv, VALUE self) {
|
|
5127
5147
|
narray_t* na;
|
5128
5148
|
VALUE idx, tmp, reduce, res;
|
5129
5149
|
char* buf;
|
5130
|
-
ndfunc_arg_in_t ain[3] = {{cT, 0}, {0, 0}, {sym_reduce, 0}};
|
5131
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
5132
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_CUM, 3, 1, ain, aout};
|
5150
|
+
ndfunc_arg_in_t ain[3] = { { cT, 0 }, { 0, 0 }, { sym_reduce, 0 } };
|
5151
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
5152
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_CUM, 3, 1, ain, aout };
|
5133
5153
|
|
5134
5154
|
GetNArray(self, na);
|
5135
5155
|
if (na->ndim == 0) {
|
@@ -5183,15 +5203,16 @@ static void iter_int8_median(na_loop_t* const lp) {
|
|
5183
5203
|
median of self.
|
5184
5204
|
@overload median(axis:nil, keepdims:false)
|
5185
5205
|
@param [Numeric,Array,Range] axis Finds median along the axis.
|
5186
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
5206
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
5207
|
+
dimensions with size one.
|
5187
5208
|
@return [Numo::Int8] returns median of self.
|
5188
5209
|
*/
|
5189
5210
|
|
5190
5211
|
static VALUE int8_median(int argc, VALUE* argv, VALUE self) {
|
5191
5212
|
VALUE v, reduce;
|
5192
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_reduce, 0}};
|
5193
|
-
ndfunc_arg_out_t aout[1] = {{INT2FIX(0), 0}};
|
5194
|
-
ndfunc_t ndf = {0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
5213
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
|
5214
|
+
ndfunc_arg_out_t aout[1] = { { INT2FIX(0), 0 } };
|
5215
|
+
ndfunc_t ndf = { 0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
5195
5216
|
|
5196
5217
|
self = na_copy(self); // as temporary buffer
|
5197
5218
|
|