numo-narray-alt 0.9.4 → 0.9.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/README.md +22 -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 +51 -21
- data/ext/numo/narray/data.c +88 -86
- data/ext/numo/narray/index.c +51 -28
- data/ext/numo/narray/kwargs.c +11 -9
- data/ext/numo/narray/math.c +14 -6
- data/ext/numo/narray/narray.c +93 -58
- 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/bit.h +76 -0
- data/ext/numo/narray/numo/types/complex.h +7 -3
- data/ext/numo/narray/numo/types/complex_macro.h +28 -25
- data/ext/numo/narray/numo/types/float_macro.h +21 -17
- data/ext/numo/narray/numo/types/real_accum.h +22 -22
- data/ext/numo/narray/numo/types/robj_macro.h +20 -12
- data/ext/numo/narray/numo/types/xint_macro.h +51 -8
- data/ext/numo/narray/rand.c +7 -0
- data/ext/numo/narray/src/mh/mean.h +102 -0
- data/ext/numo/narray/src/mh/rms.h +102 -0
- data/ext/numo/narray/src/mh/stddev.h +103 -0
- data/ext/numo/narray/src/mh/var.h +102 -0
- data/ext/numo/narray/src/t_bit.c +206 -147
- data/ext/numo/narray/src/t_dcomplex.c +531 -641
- data/ext/numo/narray/src/t_dfloat.c +1341 -1421
- data/ext/numo/narray/src/t_int16.c +562 -468
- data/ext/numo/narray/src/t_int32.c +562 -468
- data/ext/numo/narray/src/t_int64.c +561 -467
- data/ext/numo/narray/src/t_int8.c +520 -448
- data/ext/numo/narray/src/t_robject.c +519 -619
- data/ext/numo/narray/src/t_scomplex.c +524 -659
- data/ext/numo/narray/src/t_sfloat.c +1332 -1410
- data/ext/numo/narray/src/t_uint16.c +562 -468
- data/ext/numo/narray/src/t_uint32.c +562 -468
- data/ext/numo/narray/src/t_uint64.c +562 -468
- data/ext/numo/narray/src/t_uint8.c +522 -448
- data/ext/numo/narray/step.c +7 -2
- data/ext/numo/narray/struct.c +31 -24
- data/lib/numo/narray/extra.rb +74 -30
- data/numo-narray-alt.gemspec +38 -0
- metadata +10 -1
@@ -37,14 +37,23 @@ static ID id_to_a;
|
|
37
37
|
|
38
38
|
#include <numo/types/uint8.h>
|
39
39
|
|
40
|
-
VALUE cT;
|
41
|
-
extern VALUE cRT;
|
42
|
-
|
43
40
|
/*
|
44
41
|
class definition: Numo::UInt8
|
45
42
|
*/
|
46
|
-
|
47
43
|
VALUE cT;
|
44
|
+
extern VALUE cRT;
|
45
|
+
|
46
|
+
#include "mh/mean.h"
|
47
|
+
#include "mh/var.h"
|
48
|
+
#include "mh/stddev.h"
|
49
|
+
#include "mh/rms.h"
|
50
|
+
|
51
|
+
typedef u_int8_t uint8; // Type aliases for shorter notation
|
52
|
+
// following the codebase naming convention.
|
53
|
+
DEF_NARRAY_INT_MEAN_METHOD_FUNC(uint8, numo_cUInt8)
|
54
|
+
DEF_NARRAY_INT_VAR_METHOD_FUNC(uint8, numo_cUInt8)
|
55
|
+
DEF_NARRAY_INT_STDDEV_METHOD_FUNC(uint8, numo_cUInt8)
|
56
|
+
DEF_NARRAY_INT_RMS_METHOD_FUNC(uint8, numo_cUInt8)
|
48
57
|
|
49
58
|
static VALUE uint8_store(VALUE, VALUE);
|
50
59
|
|
@@ -152,9 +161,9 @@ static VALUE uint8_allocate(VALUE self) {
|
|
152
161
|
/*
|
153
162
|
Extract an element only if self is a dimensionless NArray.
|
154
163
|
@overload extract
|
155
|
-
|
156
|
-
|
157
|
-
|
164
|
+
@return [Numeric,Numo::NArray]
|
165
|
+
--- Extract element value as Ruby Object if self is a dimensionless NArray,
|
166
|
+
otherwise returns self.
|
158
167
|
*/
|
159
168
|
static VALUE uint8_extract(VALUE self) {
|
160
169
|
volatile VALUE v;
|
@@ -238,8 +247,8 @@ static void iter_uint8_store_bit(na_loop_t* const lp) {
|
|
238
247
|
}
|
239
248
|
|
240
249
|
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};
|
250
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
251
|
+
ndfunc_t ndf = { iter_uint8_store_bit, FULL_LOOP, 2, 0, ain, 0 };
|
243
252
|
|
244
253
|
na_ndloop(&ndf, 2, self, obj);
|
245
254
|
return self;
|
@@ -287,8 +296,8 @@ static void iter_uint8_store_dfloat(na_loop_t* const lp) {
|
|
287
296
|
}
|
288
297
|
|
289
298
|
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};
|
299
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
300
|
+
ndfunc_t ndf = { iter_uint8_store_dfloat, FULL_LOOP, 2, 0, ain, 0 };
|
292
301
|
|
293
302
|
na_ndloop(&ndf, 2, self, obj);
|
294
303
|
return self;
|
@@ -336,8 +345,8 @@ static void iter_uint8_store_sfloat(na_loop_t* const lp) {
|
|
336
345
|
}
|
337
346
|
|
338
347
|
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};
|
348
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
349
|
+
ndfunc_t ndf = { iter_uint8_store_sfloat, FULL_LOOP, 2, 0, ain, 0 };
|
341
350
|
|
342
351
|
na_ndloop(&ndf, 2, self, obj);
|
343
352
|
return self;
|
@@ -385,8 +394,8 @@ static void iter_uint8_store_int64(na_loop_t* const lp) {
|
|
385
394
|
}
|
386
395
|
|
387
396
|
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};
|
397
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
398
|
+
ndfunc_t ndf = { iter_uint8_store_int64, FULL_LOOP, 2, 0, ain, 0 };
|
390
399
|
|
391
400
|
na_ndloop(&ndf, 2, self, obj);
|
392
401
|
return self;
|
@@ -434,8 +443,8 @@ static void iter_uint8_store_int32(na_loop_t* const lp) {
|
|
434
443
|
}
|
435
444
|
|
436
445
|
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};
|
446
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
447
|
+
ndfunc_t ndf = { iter_uint8_store_int32, FULL_LOOP, 2, 0, ain, 0 };
|
439
448
|
|
440
449
|
na_ndloop(&ndf, 2, self, obj);
|
441
450
|
return self;
|
@@ -483,8 +492,8 @@ static void iter_uint8_store_int16(na_loop_t* const lp) {
|
|
483
492
|
}
|
484
493
|
|
485
494
|
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};
|
495
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
496
|
+
ndfunc_t ndf = { iter_uint8_store_int16, FULL_LOOP, 2, 0, ain, 0 };
|
488
497
|
|
489
498
|
na_ndloop(&ndf, 2, self, obj);
|
490
499
|
return self;
|
@@ -532,8 +541,8 @@ static void iter_uint8_store_int8(na_loop_t* const lp) {
|
|
532
541
|
}
|
533
542
|
|
534
543
|
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};
|
544
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
545
|
+
ndfunc_t ndf = { iter_uint8_store_int8, FULL_LOOP, 2, 0, ain, 0 };
|
537
546
|
|
538
547
|
na_ndloop(&ndf, 2, self, obj);
|
539
548
|
return self;
|
@@ -581,8 +590,8 @@ static void iter_uint8_store_uint64(na_loop_t* const lp) {
|
|
581
590
|
}
|
582
591
|
|
583
592
|
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};
|
593
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
594
|
+
ndfunc_t ndf = { iter_uint8_store_uint64, FULL_LOOP, 2, 0, ain, 0 };
|
586
595
|
|
587
596
|
na_ndloop(&ndf, 2, self, obj);
|
588
597
|
return self;
|
@@ -630,8 +639,8 @@ static void iter_uint8_store_uint32(na_loop_t* const lp) {
|
|
630
639
|
}
|
631
640
|
|
632
641
|
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};
|
642
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
643
|
+
ndfunc_t ndf = { iter_uint8_store_uint32, FULL_LOOP, 2, 0, ain, 0 };
|
635
644
|
|
636
645
|
na_ndloop(&ndf, 2, self, obj);
|
637
646
|
return self;
|
@@ -679,8 +688,8 @@ static void iter_uint8_store_uint16(na_loop_t* const lp) {
|
|
679
688
|
}
|
680
689
|
|
681
690
|
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};
|
691
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
692
|
+
ndfunc_t ndf = { iter_uint8_store_uint16, FULL_LOOP, 2, 0, ain, 0 };
|
684
693
|
|
685
694
|
na_ndloop(&ndf, 2, self, obj);
|
686
695
|
return self;
|
@@ -728,8 +737,8 @@ static void iter_uint8_store_uint8(na_loop_t* const lp) {
|
|
728
737
|
}
|
729
738
|
|
730
739
|
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};
|
740
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
741
|
+
ndfunc_t ndf = { iter_uint8_store_uint8, FULL_LOOP, 2, 0, ain, 0 };
|
733
742
|
|
734
743
|
na_ndloop(&ndf, 2, self, obj);
|
735
744
|
return self;
|
@@ -777,8 +786,8 @@ static void iter_uint8_store_robject(na_loop_t* const lp) {
|
|
777
786
|
}
|
778
787
|
|
779
788
|
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};
|
789
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
790
|
+
ndfunc_t ndf = { iter_uint8_store_robject, FULL_LOOP, 2, 0, ain, 0 };
|
782
791
|
|
783
792
|
na_ndloop(&ndf, 2, self, obj);
|
784
793
|
return self;
|
@@ -886,8 +895,8 @@ loop_end:
|
|
886
895
|
}
|
887
896
|
|
888
897
|
static VALUE 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};
|
898
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { rb_cArray, 0 } };
|
899
|
+
ndfunc_t ndf = { iter_uint8_store_array, FULL_LOOP, 2, 0, ain, 0 };
|
891
900
|
|
892
901
|
na_ndloop_store_rarray(&ndf, self, rary);
|
893
902
|
return self;
|
@@ -896,8 +905,8 @@ static VALUE uint8_store_array(VALUE self, VALUE rary) {
|
|
896
905
|
/*
|
897
906
|
Store elements to Numo::UInt8 from other.
|
898
907
|
@overload store(other)
|
899
|
-
|
900
|
-
|
908
|
+
@param [Object] other
|
909
|
+
@return [Numo::UInt8] self
|
901
910
|
*/
|
902
911
|
static VALUE uint8_store(VALUE self, VALUE obj) {
|
903
912
|
VALUE r, klass;
|
@@ -982,8 +991,10 @@ static VALUE uint8_store(VALUE self, VALUE obj) {
|
|
982
991
|
}
|
983
992
|
}
|
984
993
|
|
985
|
-
rb_raise(
|
986
|
-
|
994
|
+
rb_raise(
|
995
|
+
nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
|
996
|
+
rb_class2name(rb_obj_class(self))
|
997
|
+
);
|
987
998
|
|
988
999
|
return self;
|
989
1000
|
}
|
@@ -1077,7 +1088,10 @@ static dtype uint8_extract_data(VALUE obj) {
|
|
1077
1088
|
return uint8_extract_data(r);
|
1078
1089
|
}
|
1079
1090
|
|
1080
|
-
rb_raise(
|
1091
|
+
rb_raise(
|
1092
|
+
nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
|
1093
|
+
rb_class2name(cT)
|
1094
|
+
);
|
1081
1095
|
}
|
1082
1096
|
if (TYPE(obj) == T_ARRAY) {
|
1083
1097
|
if (RARRAY_LEN(obj) != 1) {
|
@@ -1104,9 +1118,9 @@ static VALUE uint8_cast_array(VALUE rary) {
|
|
1104
1118
|
Cast object to Numo::UInt8.
|
1105
1119
|
@overload [](elements)
|
1106
1120
|
@overload cast(array)
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1121
|
+
@param [Numeric,Array] elements
|
1122
|
+
@param [Array] array
|
1123
|
+
@return [Numo::UInt8]
|
1110
1124
|
*/
|
1111
1125
|
static VALUE uint8_s_cast(VALUE type, VALUE obj) {
|
1112
1126
|
VALUE v;
|
@@ -1146,9 +1160,9 @@ static VALUE uint8_s_cast(VALUE type, VALUE obj) {
|
|
1146
1160
|
/*
|
1147
1161
|
Multi-dimensional element reference.
|
1148
1162
|
@overload [](dim0,...,dimL)
|
1149
|
-
|
1150
|
-
indices.
|
1151
|
-
|
1163
|
+
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
|
1164
|
+
dim0,...,dimL multi-dimensional indices.
|
1165
|
+
@return [Numeric,Numo::UInt8] an element or NArray view.
|
1152
1166
|
@see Numo::NArray#[]
|
1153
1167
|
@see #[]=
|
1154
1168
|
*/
|
@@ -1169,10 +1183,10 @@ static VALUE uint8_aref(int argc, VALUE* argv, VALUE self) {
|
|
1169
1183
|
/*
|
1170
1184
|
Multi-dimensional element assignment.
|
1171
1185
|
@overload []=(dim0,...,dimL,val)
|
1172
|
-
|
1173
|
-
indices.
|
1174
|
-
|
1175
|
-
|
1186
|
+
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
|
1187
|
+
dim0,...,dimL multi-dimensional indices.
|
1188
|
+
@param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
|
1189
|
+
@return [Numeric,Numo::NArray,Array] returns `val` (last argument).
|
1176
1190
|
@see Numo::NArray#[]=
|
1177
1191
|
@see #[]
|
1178
1192
|
*/
|
@@ -1203,7 +1217,7 @@ static VALUE uint8_aset(int argc, VALUE* argv, VALUE self) {
|
|
1203
1217
|
/*
|
1204
1218
|
return NArray with cast to the type of self.
|
1205
1219
|
@overload coerce_cast(type)
|
1206
|
-
|
1220
|
+
@return [nil]
|
1207
1221
|
*/
|
1208
1222
|
static VALUE uint8_coerce_cast(VALUE self, VALUE type) {
|
1209
1223
|
return Qnil;
|
@@ -1238,12 +1252,12 @@ static void iter_uint8_to_a(na_loop_t* const lp) {
|
|
1238
1252
|
/*
|
1239
1253
|
Convert self to Array.
|
1240
1254
|
@overload to_a
|
1241
|
-
|
1255
|
+
@return [Array]
|
1242
1256
|
*/
|
1243
1257
|
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};
|
1258
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
|
1259
|
+
ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
|
1260
|
+
ndfunc_t ndf = { iter_uint8_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
|
1247
1261
|
return na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
|
1248
1262
|
}
|
1249
1263
|
|
@@ -1271,12 +1285,12 @@ static void iter_uint8_fill(na_loop_t* const lp) {
|
|
1271
1285
|
/*
|
1272
1286
|
Fill elements with other.
|
1273
1287
|
@overload fill other
|
1274
|
-
|
1275
|
-
|
1288
|
+
@param [Numeric] other
|
1289
|
+
@return [Numo::UInt8] self.
|
1276
1290
|
*/
|
1277
1291
|
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};
|
1292
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
|
1293
|
+
ndfunc_t ndf = { iter_uint8_fill, FULL_LOOP, 2, 0, ain, 0 };
|
1280
1294
|
|
1281
1295
|
na_ndloop(&ndf, 2, self, val);
|
1282
1296
|
return self;
|
@@ -1325,15 +1339,15 @@ static void iter_uint8_format(na_loop_t* const lp) {
|
|
1325
1339
|
/*
|
1326
1340
|
Format elements into strings.
|
1327
1341
|
@overload format format
|
1328
|
-
|
1329
|
-
|
1342
|
+
@param [String] format
|
1343
|
+
@return [Numo::RObject] array of formatted strings.
|
1330
1344
|
*/
|
1331
1345
|
static VALUE uint8_format(int argc, VALUE* argv, VALUE self) {
|
1332
1346
|
VALUE fmt = Qnil;
|
1333
1347
|
|
1334
|
-
ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_option}};
|
1335
|
-
ndfunc_arg_out_t aout[1] = {{numo_cRObject, 0}};
|
1336
|
-
ndfunc_t ndf = {iter_uint8_format, FULL_LOOP_NIP, 2, 1, ain, aout};
|
1348
|
+
ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_option } };
|
1349
|
+
ndfunc_arg_out_t aout[1] = { { numo_cRObject, 0 } };
|
1350
|
+
ndfunc_t ndf = { iter_uint8_format, FULL_LOOP_NIP, 2, 1, ain, aout };
|
1337
1351
|
|
1338
1352
|
rb_scan_args(argc, argv, "01", &fmt);
|
1339
1353
|
return na_ndloop(&ndf, 2, self, fmt);
|
@@ -1372,14 +1386,14 @@ static void iter_uint8_format_to_a(na_loop_t* const lp) {
|
|
1372
1386
|
/*
|
1373
1387
|
Format elements into strings.
|
1374
1388
|
@overload format_to_a format
|
1375
|
-
|
1376
|
-
|
1389
|
+
@param [String] format
|
1390
|
+
@return [Array] array of formatted strings.
|
1377
1391
|
*/
|
1378
1392
|
static VALUE uint8_format_to_a(int argc, VALUE* argv, VALUE self) {
|
1379
1393
|
VALUE fmt = Qnil;
|
1380
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
|
1381
|
-
ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
|
1382
|
-
ndfunc_t ndf = {iter_uint8_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
|
1394
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
|
1395
|
+
ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
|
1396
|
+
ndfunc_t ndf = { iter_uint8_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
|
1383
1397
|
|
1384
1398
|
rb_scan_args(argc, argv, "01", &fmt);
|
1385
1399
|
return na_ndloop_cast_narray_to_rarray(&ndf, self, fmt);
|
@@ -1392,7 +1406,7 @@ static VALUE iter_uint8_inspect(char* ptr, size_t pos, VALUE fmt) {
|
|
1392
1406
|
/*
|
1393
1407
|
Returns a string containing a human-readable representation of NArray.
|
1394
1408
|
@overload inspect
|
1395
|
-
|
1409
|
+
@return [String]
|
1396
1410
|
*/
|
1397
1411
|
static VALUE uint8_inspect(VALUE ary) {
|
1398
1412
|
return na_ndloop_inspect(ary, iter_uint8_inspect, Qnil);
|
@@ -1426,15 +1440,15 @@ static void iter_uint8_each(na_loop_t* const lp) {
|
|
1426
1440
|
Calls the given block once for each element in self,
|
1427
1441
|
passing that element as a parameter.
|
1428
1442
|
@overload each
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1443
|
+
@return [Numo::NArray] self
|
1444
|
+
For a block `{|x| ... }`,
|
1445
|
+
@yieldparam [Numeric] x an element of NArray.
|
1432
1446
|
@see #each_with_index
|
1433
1447
|
@see #map
|
1434
1448
|
*/
|
1435
1449
|
static VALUE 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};
|
1450
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1451
|
+
ndfunc_t ndf = { iter_uint8_each, FULL_LOOP_NIP, 1, 0, ain, 0 };
|
1438
1452
|
|
1439
1453
|
na_ndloop(&ndf, 1, self);
|
1440
1454
|
return self;
|
@@ -1488,12 +1502,12 @@ static void iter_uint8_map(na_loop_t* const lp) {
|
|
1488
1502
|
/*
|
1489
1503
|
Unary map.
|
1490
1504
|
@overload map
|
1491
|
-
|
1505
|
+
@return [Numo::UInt8] map of self.
|
1492
1506
|
*/
|
1493
1507
|
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};
|
1508
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
1509
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1510
|
+
ndfunc_t ndf = { iter_uint8_map, FULL_LOOP, 1, 1, ain, aout };
|
1497
1511
|
|
1498
1512
|
return na_ndloop(&ndf, 1, self);
|
1499
1513
|
}
|
@@ -1547,16 +1561,16 @@ static void iter_uint8_each_with_index(na_loop_t* const lp) {
|
|
1547
1561
|
Invokes the given block once for each element of self,
|
1548
1562
|
passing that element and indices along each axis as parameters.
|
1549
1563
|
@overload each_with_index
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1564
|
+
For a block `{|x,i,j,...| ... }`,
|
1565
|
+
@yieldparam [Numeric] x an element
|
1566
|
+
@yieldparam [Integer] i,j,... multitimensional indices
|
1567
|
+
@return [Numo::NArray] self
|
1554
1568
|
@see #each
|
1555
1569
|
@see #map_with_index
|
1556
1570
|
*/
|
1557
1571
|
static VALUE 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};
|
1572
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1573
|
+
ndfunc_t ndf = { iter_uint8_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0 };
|
1560
1574
|
|
1561
1575
|
na_ndloop_with_index(&ndf, 1, self);
|
1562
1576
|
return self;
|
@@ -1638,17 +1652,17 @@ static void iter_uint8_map_with_index(na_loop_t* const lp) {
|
|
1638
1652
|
Creates a new NArray containing the values returned by the block.
|
1639
1653
|
Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
|
1640
1654
|
@overload map_with_index
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1655
|
+
For a block `{|x,i,j,...| ... }`,
|
1656
|
+
@yieldparam [Numeric] x an element
|
1657
|
+
@yieldparam [Integer] i,j,... multitimensional indices
|
1658
|
+
@return [Numo::NArray] mapped array
|
1645
1659
|
@see #map
|
1646
1660
|
@see #each_with_index
|
1647
1661
|
*/
|
1648
1662
|
static VALUE 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};
|
1663
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1664
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1665
|
+
ndfunc_t ndf = { iter_uint8_map_with_index, FULL_LOOP, 1, 1, ain, aout };
|
1652
1666
|
|
1653
1667
|
return na_ndloop_with_index(&ndf, 1, self);
|
1654
1668
|
}
|
@@ -1697,17 +1711,17 @@ static void iter_uint8_abs(na_loop_t* const lp) {
|
|
1697
1711
|
/*
|
1698
1712
|
abs of self.
|
1699
1713
|
@overload abs
|
1700
|
-
|
1714
|
+
@return [Numo::UInt8] abs of self.
|
1701
1715
|
*/
|
1702
1716
|
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};
|
1717
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
1718
|
+
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
1719
|
+
ndfunc_t ndf = { iter_uint8_abs, FULL_LOOP, 1, 1, ain, aout };
|
1706
1720
|
|
1707
1721
|
return na_ndloop(&ndf, 1, self);
|
1708
1722
|
}
|
1709
1723
|
|
1710
|
-
#define check_intdivzero(y)
|
1724
|
+
#define check_intdivzero(y) \
|
1711
1725
|
{}
|
1712
1726
|
|
1713
1727
|
static void iter_uint8_add(na_loop_t* const lp) {
|
@@ -1767,9 +1781,9 @@ static void iter_uint8_add(na_loop_t* const lp) {
|
|
1767
1781
|
#undef check_intdivzero
|
1768
1782
|
|
1769
1783
|
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};
|
1784
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
1785
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1786
|
+
ndfunc_t ndf = { iter_uint8_add, STRIDE_LOOP, 2, 1, ain, aout };
|
1773
1787
|
|
1774
1788
|
return na_ndloop(&ndf, 2, self, other);
|
1775
1789
|
}
|
@@ -1777,8 +1791,8 @@ static VALUE uint8_add_self(VALUE self, VALUE other) {
|
|
1777
1791
|
/*
|
1778
1792
|
Binary add.
|
1779
1793
|
@overload + other
|
1780
|
-
|
1781
|
-
|
1794
|
+
@param [Numo::NArray,Numeric] other
|
1795
|
+
@return [Numo::NArray] self + other
|
1782
1796
|
*/
|
1783
1797
|
static VALUE uint8_add(VALUE self, VALUE other) {
|
1784
1798
|
|
@@ -1793,7 +1807,7 @@ static VALUE uint8_add(VALUE self, VALUE other) {
|
|
1793
1807
|
}
|
1794
1808
|
}
|
1795
1809
|
|
1796
|
-
#define check_intdivzero(y)
|
1810
|
+
#define check_intdivzero(y) \
|
1797
1811
|
{}
|
1798
1812
|
|
1799
1813
|
static void iter_uint8_sub(na_loop_t* const lp) {
|
@@ -1853,9 +1867,9 @@ static void iter_uint8_sub(na_loop_t* const lp) {
|
|
1853
1867
|
#undef check_intdivzero
|
1854
1868
|
|
1855
1869
|
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};
|
1870
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
1871
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1872
|
+
ndfunc_t ndf = { iter_uint8_sub, STRIDE_LOOP, 2, 1, ain, aout };
|
1859
1873
|
|
1860
1874
|
return na_ndloop(&ndf, 2, self, other);
|
1861
1875
|
}
|
@@ -1863,8 +1877,8 @@ static VALUE uint8_sub_self(VALUE self, VALUE other) {
|
|
1863
1877
|
/*
|
1864
1878
|
Binary sub.
|
1865
1879
|
@overload - other
|
1866
|
-
|
1867
|
-
|
1880
|
+
@param [Numo::NArray,Numeric] other
|
1881
|
+
@return [Numo::NArray] self - other
|
1868
1882
|
*/
|
1869
1883
|
static VALUE uint8_sub(VALUE self, VALUE other) {
|
1870
1884
|
|
@@ -1879,7 +1893,7 @@ static VALUE uint8_sub(VALUE self, VALUE other) {
|
|
1879
1893
|
}
|
1880
1894
|
}
|
1881
1895
|
|
1882
|
-
#define check_intdivzero(y)
|
1896
|
+
#define check_intdivzero(y) \
|
1883
1897
|
{}
|
1884
1898
|
|
1885
1899
|
static void iter_uint8_mul(na_loop_t* const lp) {
|
@@ -1939,9 +1953,9 @@ static void iter_uint8_mul(na_loop_t* const lp) {
|
|
1939
1953
|
#undef check_intdivzero
|
1940
1954
|
|
1941
1955
|
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};
|
1956
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
1957
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1958
|
+
ndfunc_t ndf = { iter_uint8_mul, STRIDE_LOOP, 2, 1, ain, aout };
|
1945
1959
|
|
1946
1960
|
return na_ndloop(&ndf, 2, self, other);
|
1947
1961
|
}
|
@@ -1949,8 +1963,8 @@ static VALUE uint8_mul_self(VALUE self, VALUE other) {
|
|
1949
1963
|
/*
|
1950
1964
|
Binary mul.
|
1951
1965
|
@overload * other
|
1952
|
-
|
1953
|
-
|
1966
|
+
@param [Numo::NArray,Numeric] other
|
1967
|
+
@return [Numo::NArray] self * other
|
1954
1968
|
*/
|
1955
1969
|
static VALUE uint8_mul(VALUE self, VALUE other) {
|
1956
1970
|
|
@@ -1965,10 +1979,10 @@ static VALUE uint8_mul(VALUE self, VALUE other) {
|
|
1965
1979
|
}
|
1966
1980
|
}
|
1967
1981
|
|
1968
|
-
#define check_intdivzero(y)
|
1969
|
-
if ((y) == 0) {
|
1970
|
-
lp->err_type = rb_eZeroDivError;
|
1971
|
-
return;
|
1982
|
+
#define check_intdivzero(y) \
|
1983
|
+
if ((y) == 0) { \
|
1984
|
+
lp->err_type = rb_eZeroDivError; \
|
1985
|
+
return; \
|
1972
1986
|
}
|
1973
1987
|
|
1974
1988
|
static void iter_uint8_div(na_loop_t* const lp) {
|
@@ -2028,9 +2042,9 @@ static void iter_uint8_div(na_loop_t* const lp) {
|
|
2028
2042
|
#undef check_intdivzero
|
2029
2043
|
|
2030
2044
|
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};
|
2045
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2046
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2047
|
+
ndfunc_t ndf = { iter_uint8_div, STRIDE_LOOP, 2, 1, ain, aout };
|
2034
2048
|
|
2035
2049
|
return na_ndloop(&ndf, 2, self, other);
|
2036
2050
|
}
|
@@ -2038,8 +2052,8 @@ static VALUE uint8_div_self(VALUE self, VALUE other) {
|
|
2038
2052
|
/*
|
2039
2053
|
Binary div.
|
2040
2054
|
@overload / other
|
2041
|
-
|
2042
|
-
|
2055
|
+
@param [Numo::NArray,Numeric] other
|
2056
|
+
@return [Numo::NArray] self / other
|
2043
2057
|
*/
|
2044
2058
|
static VALUE uint8_div(VALUE self, VALUE other) {
|
2045
2059
|
|
@@ -2054,10 +2068,10 @@ static VALUE uint8_div(VALUE self, VALUE other) {
|
|
2054
2068
|
}
|
2055
2069
|
}
|
2056
2070
|
|
2057
|
-
#define check_intdivzero(y)
|
2058
|
-
if ((y) == 0) {
|
2059
|
-
lp->err_type = rb_eZeroDivError;
|
2060
|
-
return;
|
2071
|
+
#define check_intdivzero(y) \
|
2072
|
+
if ((y) == 0) { \
|
2073
|
+
lp->err_type = rb_eZeroDivError; \
|
2074
|
+
return; \
|
2061
2075
|
}
|
2062
2076
|
|
2063
2077
|
static void iter_uint8_mod(na_loop_t* const lp) {
|
@@ -2117,9 +2131,9 @@ static void iter_uint8_mod(na_loop_t* const lp) {
|
|
2117
2131
|
#undef check_intdivzero
|
2118
2132
|
|
2119
2133
|
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};
|
2134
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2135
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2136
|
+
ndfunc_t ndf = { iter_uint8_mod, STRIDE_LOOP, 2, 1, ain, aout };
|
2123
2137
|
|
2124
2138
|
return na_ndloop(&ndf, 2, self, other);
|
2125
2139
|
}
|
@@ -2127,8 +2141,8 @@ static VALUE uint8_mod_self(VALUE self, VALUE other) {
|
|
2127
2141
|
/*
|
2128
2142
|
Binary mod.
|
2129
2143
|
@overload % other
|
2130
|
-
|
2131
|
-
|
2144
|
+
@param [Numo::NArray,Numeric] other
|
2145
|
+
@return [Numo::NArray] self % other
|
2132
2146
|
*/
|
2133
2147
|
static VALUE uint8_mod(VALUE self, VALUE other) {
|
2134
2148
|
|
@@ -2167,9 +2181,9 @@ static void iter_uint8_divmod(na_loop_t* const lp) {
|
|
2167
2181
|
}
|
2168
2182
|
|
2169
2183
|
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};
|
2184
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2185
|
+
ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
|
2186
|
+
ndfunc_t ndf = { iter_uint8_divmod, STRIDE_LOOP, 2, 2, ain, aout };
|
2173
2187
|
|
2174
2188
|
return na_ndloop(&ndf, 2, self, other);
|
2175
2189
|
}
|
@@ -2177,8 +2191,8 @@ static VALUE uint8_divmod_self(VALUE self, VALUE other) {
|
|
2177
2191
|
/*
|
2178
2192
|
Binary divmod.
|
2179
2193
|
@overload divmod other
|
2180
|
-
|
2181
|
-
|
2194
|
+
@param [Numo::NArray,Numeric] other
|
2195
|
+
@return [Numo::NArray] divmod of self and other.
|
2182
2196
|
*/
|
2183
2197
|
static VALUE uint8_divmod(VALUE self, VALUE other) {
|
2184
2198
|
|
@@ -2228,11 +2242,11 @@ static void iter_uint8_pow_int32(na_loop_t* const lp) {
|
|
2228
2242
|
}
|
2229
2243
|
|
2230
2244
|
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};
|
2245
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2246
|
+
ndfunc_arg_in_t ain_i[2] = { { cT, 0 }, { numo_cInt32, 0 } };
|
2247
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2248
|
+
ndfunc_t ndf = { iter_uint8_pow, STRIDE_LOOP, 2, 1, ain, aout };
|
2249
|
+
ndfunc_t ndf_i = { iter_uint8_pow_int32, STRIDE_LOOP, 2, 1, ain_i, aout };
|
2236
2250
|
|
2237
2251
|
// fixme : use na.integer?
|
2238
2252
|
if (FIXNUM_P(other) || rb_obj_is_kind_of(other, numo_cInt32)) {
|
@@ -2245,8 +2259,8 @@ static VALUE uint8_pow_self(VALUE self, VALUE other) {
|
|
2245
2259
|
/*
|
2246
2260
|
Binary power.
|
2247
2261
|
@overload ** other
|
2248
|
-
|
2249
|
-
|
2262
|
+
@param [Numo::NArray,Numeric] other
|
2263
|
+
@return [Numo::NArray] self to the other-th power.
|
2250
2264
|
*/
|
2251
2265
|
static VALUE uint8_pow(VALUE self, VALUE other) {
|
2252
2266
|
|
@@ -2308,12 +2322,12 @@ static void iter_uint8_minus(na_loop_t* const lp) {
|
|
2308
2322
|
/*
|
2309
2323
|
Unary minus.
|
2310
2324
|
@overload -@
|
2311
|
-
|
2325
|
+
@return [Numo::UInt8] minus of self.
|
2312
2326
|
*/
|
2313
2327
|
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};
|
2328
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2329
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2330
|
+
ndfunc_t ndf = { iter_uint8_minus, FULL_LOOP, 1, 1, ain, aout };
|
2317
2331
|
|
2318
2332
|
return na_ndloop(&ndf, 1, self);
|
2319
2333
|
}
|
@@ -2366,12 +2380,12 @@ static void iter_uint8_reciprocal(na_loop_t* const lp) {
|
|
2366
2380
|
/*
|
2367
2381
|
Unary reciprocal.
|
2368
2382
|
@overload reciprocal
|
2369
|
-
|
2383
|
+
@return [Numo::UInt8] reciprocal of self.
|
2370
2384
|
*/
|
2371
2385
|
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};
|
2386
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2387
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2388
|
+
ndfunc_t ndf = { iter_uint8_reciprocal, FULL_LOOP, 1, 1, ain, aout };
|
2375
2389
|
|
2376
2390
|
return na_ndloop(&ndf, 1, self);
|
2377
2391
|
}
|
@@ -2424,12 +2438,12 @@ static void iter_uint8_sign(na_loop_t* const lp) {
|
|
2424
2438
|
/*
|
2425
2439
|
Unary sign.
|
2426
2440
|
@overload sign
|
2427
|
-
|
2441
|
+
@return [Numo::UInt8] sign of self.
|
2428
2442
|
*/
|
2429
2443
|
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};
|
2444
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2445
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2446
|
+
ndfunc_t ndf = { iter_uint8_sign, FULL_LOOP, 1, 1, ain, aout };
|
2433
2447
|
|
2434
2448
|
return na_ndloop(&ndf, 1, self);
|
2435
2449
|
}
|
@@ -2482,12 +2496,12 @@ static void iter_uint8_square(na_loop_t* const lp) {
|
|
2482
2496
|
/*
|
2483
2497
|
Unary square.
|
2484
2498
|
@overload square
|
2485
|
-
|
2499
|
+
@return [Numo::UInt8] square of self.
|
2486
2500
|
*/
|
2487
2501
|
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};
|
2502
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2503
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2504
|
+
ndfunc_t ndf = { iter_uint8_square, FULL_LOOP, 1, 1, ain, aout };
|
2491
2505
|
|
2492
2506
|
return na_ndloop(&ndf, 1, self);
|
2493
2507
|
}
|
@@ -2514,9 +2528,9 @@ static void iter_uint8_eq(na_loop_t* const lp) {
|
|
2514
2528
|
}
|
2515
2529
|
|
2516
2530
|
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};
|
2531
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2532
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
2533
|
+
ndfunc_t ndf = { iter_uint8_eq, STRIDE_LOOP, 2, 1, ain, aout };
|
2520
2534
|
|
2521
2535
|
return na_ndloop(&ndf, 2, self, other);
|
2522
2536
|
}
|
@@ -2524,8 +2538,8 @@ static VALUE uint8_eq_self(VALUE self, VALUE other) {
|
|
2524
2538
|
/*
|
2525
2539
|
Comparison eq other.
|
2526
2540
|
@overload eq other
|
2527
|
-
|
2528
|
-
|
2541
|
+
@param [Numo::NArray,Numeric] other
|
2542
|
+
@return [Numo::Bit] result of self eq other.
|
2529
2543
|
*/
|
2530
2544
|
static VALUE uint8_eq(VALUE self, VALUE other) {
|
2531
2545
|
|
@@ -2561,9 +2575,9 @@ static void iter_uint8_ne(na_loop_t* const lp) {
|
|
2561
2575
|
}
|
2562
2576
|
|
2563
2577
|
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};
|
2578
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2579
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
2580
|
+
ndfunc_t ndf = { iter_uint8_ne, STRIDE_LOOP, 2, 1, ain, aout };
|
2567
2581
|
|
2568
2582
|
return na_ndloop(&ndf, 2, self, other);
|
2569
2583
|
}
|
@@ -2571,8 +2585,8 @@ static VALUE uint8_ne_self(VALUE self, VALUE other) {
|
|
2571
2585
|
/*
|
2572
2586
|
Comparison ne other.
|
2573
2587
|
@overload ne other
|
2574
|
-
|
2575
|
-
|
2588
|
+
@param [Numo::NArray,Numeric] other
|
2589
|
+
@return [Numo::Bit] result of self ne other.
|
2576
2590
|
*/
|
2577
2591
|
static VALUE uint8_ne(VALUE self, VALUE other) {
|
2578
2592
|
|
@@ -2586,7 +2600,7 @@ static VALUE uint8_ne(VALUE self, VALUE other) {
|
|
2586
2600
|
}
|
2587
2601
|
}
|
2588
2602
|
|
2589
|
-
#define check_intdivzero(y)
|
2603
|
+
#define check_intdivzero(y) \
|
2590
2604
|
{}
|
2591
2605
|
|
2592
2606
|
static void iter_uint8_bit_and(na_loop_t* const lp) {
|
@@ -2646,9 +2660,9 @@ static void iter_uint8_bit_and(na_loop_t* const lp) {
|
|
2646
2660
|
#undef check_intdivzero
|
2647
2661
|
|
2648
2662
|
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};
|
2663
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2664
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2665
|
+
ndfunc_t ndf = { iter_uint8_bit_and, STRIDE_LOOP, 2, 1, ain, aout };
|
2652
2666
|
|
2653
2667
|
return na_ndloop(&ndf, 2, self, other);
|
2654
2668
|
}
|
@@ -2656,8 +2670,8 @@ static VALUE uint8_bit_and_self(VALUE self, VALUE other) {
|
|
2656
2670
|
/*
|
2657
2671
|
Binary bit_and.
|
2658
2672
|
@overload & other
|
2659
|
-
|
2660
|
-
|
2673
|
+
@param [Numo::NArray,Numeric] other
|
2674
|
+
@return [Numo::NArray] self & other
|
2661
2675
|
*/
|
2662
2676
|
static VALUE uint8_bit_and(VALUE self, VALUE other) {
|
2663
2677
|
|
@@ -2672,7 +2686,7 @@ static VALUE uint8_bit_and(VALUE self, VALUE other) {
|
|
2672
2686
|
}
|
2673
2687
|
}
|
2674
2688
|
|
2675
|
-
#define check_intdivzero(y)
|
2689
|
+
#define check_intdivzero(y) \
|
2676
2690
|
{}
|
2677
2691
|
|
2678
2692
|
static void iter_uint8_bit_or(na_loop_t* const lp) {
|
@@ -2732,9 +2746,9 @@ static void iter_uint8_bit_or(na_loop_t* const lp) {
|
|
2732
2746
|
#undef check_intdivzero
|
2733
2747
|
|
2734
2748
|
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};
|
2749
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2750
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2751
|
+
ndfunc_t ndf = { iter_uint8_bit_or, STRIDE_LOOP, 2, 1, ain, aout };
|
2738
2752
|
|
2739
2753
|
return na_ndloop(&ndf, 2, self, other);
|
2740
2754
|
}
|
@@ -2742,8 +2756,8 @@ static VALUE uint8_bit_or_self(VALUE self, VALUE other) {
|
|
2742
2756
|
/*
|
2743
2757
|
Binary bit_or.
|
2744
2758
|
@overload | other
|
2745
|
-
|
2746
|
-
|
2759
|
+
@param [Numo::NArray,Numeric] other
|
2760
|
+
@return [Numo::NArray] self | other
|
2747
2761
|
*/
|
2748
2762
|
static VALUE uint8_bit_or(VALUE self, VALUE other) {
|
2749
2763
|
|
@@ -2758,7 +2772,7 @@ static VALUE uint8_bit_or(VALUE self, VALUE other) {
|
|
2758
2772
|
}
|
2759
2773
|
}
|
2760
2774
|
|
2761
|
-
#define check_intdivzero(y)
|
2775
|
+
#define check_intdivzero(y) \
|
2762
2776
|
{}
|
2763
2777
|
|
2764
2778
|
static void iter_uint8_bit_xor(na_loop_t* const lp) {
|
@@ -2818,9 +2832,9 @@ static void iter_uint8_bit_xor(na_loop_t* const lp) {
|
|
2818
2832
|
#undef check_intdivzero
|
2819
2833
|
|
2820
2834
|
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};
|
2835
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2836
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2837
|
+
ndfunc_t ndf = { iter_uint8_bit_xor, STRIDE_LOOP, 2, 1, ain, aout };
|
2824
2838
|
|
2825
2839
|
return na_ndloop(&ndf, 2, self, other);
|
2826
2840
|
}
|
@@ -2828,8 +2842,8 @@ static VALUE uint8_bit_xor_self(VALUE self, VALUE other) {
|
|
2828
2842
|
/*
|
2829
2843
|
Binary bit_xor.
|
2830
2844
|
@overload ^ other
|
2831
|
-
|
2832
|
-
|
2845
|
+
@param [Numo::NArray,Numeric] other
|
2846
|
+
@return [Numo::NArray] self ^ other
|
2833
2847
|
*/
|
2834
2848
|
static VALUE uint8_bit_xor(VALUE self, VALUE other) {
|
2835
2849
|
|
@@ -2892,17 +2906,17 @@ static void iter_uint8_bit_not(na_loop_t* const lp) {
|
|
2892
2906
|
/*
|
2893
2907
|
Unary bit_not.
|
2894
2908
|
@overload ~
|
2895
|
-
|
2909
|
+
@return [Numo::UInt8] bit_not of self.
|
2896
2910
|
*/
|
2897
2911
|
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};
|
2912
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2913
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2914
|
+
ndfunc_t ndf = { iter_uint8_bit_not, FULL_LOOP, 1, 1, ain, aout };
|
2901
2915
|
|
2902
2916
|
return na_ndloop(&ndf, 1, self);
|
2903
2917
|
}
|
2904
2918
|
|
2905
|
-
#define check_intdivzero(y)
|
2919
|
+
#define check_intdivzero(y) \
|
2906
2920
|
{}
|
2907
2921
|
|
2908
2922
|
static void iter_uint8_left_shift(na_loop_t* const lp) {
|
@@ -2962,9 +2976,9 @@ static void iter_uint8_left_shift(na_loop_t* const lp) {
|
|
2962
2976
|
#undef check_intdivzero
|
2963
2977
|
|
2964
2978
|
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};
|
2979
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2980
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2981
|
+
ndfunc_t ndf = { iter_uint8_left_shift, STRIDE_LOOP, 2, 1, ain, aout };
|
2968
2982
|
|
2969
2983
|
return na_ndloop(&ndf, 2, self, other);
|
2970
2984
|
}
|
@@ -2972,8 +2986,8 @@ static VALUE uint8_left_shift_self(VALUE self, VALUE other) {
|
|
2972
2986
|
/*
|
2973
2987
|
Binary left_shift.
|
2974
2988
|
@overload << other
|
2975
|
-
|
2976
|
-
|
2989
|
+
@param [Numo::NArray,Numeric] other
|
2990
|
+
@return [Numo::NArray] self << other
|
2977
2991
|
*/
|
2978
2992
|
static VALUE uint8_left_shift(VALUE self, VALUE other) {
|
2979
2993
|
|
@@ -2988,7 +3002,7 @@ static VALUE uint8_left_shift(VALUE self, VALUE other) {
|
|
2988
3002
|
}
|
2989
3003
|
}
|
2990
3004
|
|
2991
|
-
#define check_intdivzero(y)
|
3005
|
+
#define check_intdivzero(y) \
|
2992
3006
|
{}
|
2993
3007
|
|
2994
3008
|
static void iter_uint8_right_shift(na_loop_t* const lp) {
|
@@ -3048,9 +3062,9 @@ static void iter_uint8_right_shift(na_loop_t* const lp) {
|
|
3048
3062
|
#undef check_intdivzero
|
3049
3063
|
|
3050
3064
|
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};
|
3065
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3066
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3067
|
+
ndfunc_t ndf = { iter_uint8_right_shift, STRIDE_LOOP, 2, 1, ain, aout };
|
3054
3068
|
|
3055
3069
|
return na_ndloop(&ndf, 2, self, other);
|
3056
3070
|
}
|
@@ -3058,8 +3072,8 @@ static VALUE uint8_right_shift_self(VALUE self, VALUE other) {
|
|
3058
3072
|
/*
|
3059
3073
|
Binary right_shift.
|
3060
3074
|
@overload >> other
|
3061
|
-
|
3062
|
-
|
3075
|
+
@param [Numo::NArray,Numeric] other
|
3076
|
+
@return [Numo::NArray] self >> other
|
3063
3077
|
*/
|
3064
3078
|
static VALUE uint8_right_shift(VALUE self, VALUE other) {
|
3065
3079
|
|
@@ -3096,9 +3110,9 @@ static void iter_uint8_gt(na_loop_t* const lp) {
|
|
3096
3110
|
}
|
3097
3111
|
|
3098
3112
|
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};
|
3113
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3114
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3115
|
+
ndfunc_t ndf = { iter_uint8_gt, STRIDE_LOOP, 2, 1, ain, aout };
|
3102
3116
|
|
3103
3117
|
return na_ndloop(&ndf, 2, self, other);
|
3104
3118
|
}
|
@@ -3106,8 +3120,8 @@ static VALUE uint8_gt_self(VALUE self, VALUE other) {
|
|
3106
3120
|
/*
|
3107
3121
|
Comparison gt other.
|
3108
3122
|
@overload gt other
|
3109
|
-
|
3110
|
-
|
3123
|
+
@param [Numo::NArray,Numeric] other
|
3124
|
+
@return [Numo::Bit] result of self gt other.
|
3111
3125
|
*/
|
3112
3126
|
static VALUE uint8_gt(VALUE self, VALUE other) {
|
3113
3127
|
|
@@ -3143,9 +3157,9 @@ static void iter_uint8_ge(na_loop_t* const lp) {
|
|
3143
3157
|
}
|
3144
3158
|
|
3145
3159
|
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};
|
3160
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3161
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3162
|
+
ndfunc_t ndf = { iter_uint8_ge, STRIDE_LOOP, 2, 1, ain, aout };
|
3149
3163
|
|
3150
3164
|
return na_ndloop(&ndf, 2, self, other);
|
3151
3165
|
}
|
@@ -3153,8 +3167,8 @@ static VALUE uint8_ge_self(VALUE self, VALUE other) {
|
|
3153
3167
|
/*
|
3154
3168
|
Comparison ge other.
|
3155
3169
|
@overload ge other
|
3156
|
-
|
3157
|
-
|
3170
|
+
@param [Numo::NArray,Numeric] other
|
3171
|
+
@return [Numo::Bit] result of self ge other.
|
3158
3172
|
*/
|
3159
3173
|
static VALUE uint8_ge(VALUE self, VALUE other) {
|
3160
3174
|
|
@@ -3190,9 +3204,9 @@ static void iter_uint8_lt(na_loop_t* const lp) {
|
|
3190
3204
|
}
|
3191
3205
|
|
3192
3206
|
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};
|
3207
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3208
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3209
|
+
ndfunc_t ndf = { iter_uint8_lt, STRIDE_LOOP, 2, 1, ain, aout };
|
3196
3210
|
|
3197
3211
|
return na_ndloop(&ndf, 2, self, other);
|
3198
3212
|
}
|
@@ -3200,8 +3214,8 @@ static VALUE uint8_lt_self(VALUE self, VALUE other) {
|
|
3200
3214
|
/*
|
3201
3215
|
Comparison lt other.
|
3202
3216
|
@overload lt other
|
3203
|
-
|
3204
|
-
|
3217
|
+
@param [Numo::NArray,Numeric] other
|
3218
|
+
@return [Numo::Bit] result of self lt other.
|
3205
3219
|
*/
|
3206
3220
|
static VALUE uint8_lt(VALUE self, VALUE other) {
|
3207
3221
|
|
@@ -3237,9 +3251,9 @@ static void iter_uint8_le(na_loop_t* const lp) {
|
|
3237
3251
|
}
|
3238
3252
|
|
3239
3253
|
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};
|
3254
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3255
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3256
|
+
ndfunc_t ndf = { iter_uint8_le, STRIDE_LOOP, 2, 1, ain, aout };
|
3243
3257
|
|
3244
3258
|
return na_ndloop(&ndf, 2, self, other);
|
3245
3259
|
}
|
@@ -3247,8 +3261,8 @@ static VALUE uint8_le_self(VALUE self, VALUE other) {
|
|
3247
3261
|
/*
|
3248
3262
|
Comparison le other.
|
3249
3263
|
@overload le other
|
3250
|
-
|
3251
|
-
|
3264
|
+
@param [Numo::NArray,Numeric] other
|
3265
|
+
@return [Numo::Bit] result of self le other.
|
3252
3266
|
*/
|
3253
3267
|
static VALUE uint8_le(VALUE self, VALUE other) {
|
3254
3268
|
|
@@ -3331,9 +3345,9 @@ static void iter_uint8_clip_max(na_loop_t* const lp) {
|
|
3331
3345
|
Clip array elements by [min,max].
|
3332
3346
|
If either of min or max is nil, one side is clipped.
|
3333
3347
|
@overload clip(min,max)
|
3334
|
-
|
3335
|
-
|
3336
|
-
|
3348
|
+
@param [Numo::NArray,Numeric] min
|
3349
|
+
@param [Numo::NArray,Numeric] max
|
3350
|
+
@return [Numo::NArray] result of clip.
|
3337
3351
|
|
3338
3352
|
@example
|
3339
3353
|
a = Numo::Int32.new(10).seq
|
@@ -3358,11 +3372,11 @@ static void iter_uint8_clip_max(na_loop_t* const lp) {
|
|
3358
3372
|
# [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]
|
3359
3373
|
*/
|
3360
3374
|
static VALUE 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};
|
3375
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { cT, 0 }, { cT, 0 } };
|
3376
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3377
|
+
ndfunc_t ndf_min = { iter_uint8_clip_min, STRIDE_LOOP, 2, 1, ain, aout };
|
3378
|
+
ndfunc_t ndf_max = { iter_uint8_clip_max, STRIDE_LOOP, 2, 1, ain, aout };
|
3379
|
+
ndfunc_t ndf_both = { iter_uint8_clip, STRIDE_LOOP, 3, 1, ain, aout };
|
3366
3380
|
|
3367
3381
|
if (RTEST(min)) {
|
3368
3382
|
if (RTEST(max)) {
|
@@ -3394,15 +3408,16 @@ static void iter_uint8_sum(na_loop_t* const lp) {
|
|
3394
3408
|
/*
|
3395
3409
|
sum of self.
|
3396
3410
|
@overload sum(axis:nil, keepdims:false)
|
3397
|
-
|
3398
|
-
|
3399
|
-
|
3411
|
+
@param [Numeric,Array,Range] axis Performs sum along the axis.
|
3412
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3413
|
+
dimensions with size one.
|
3414
|
+
@return [Numo::UInt8] returns result of sum.
|
3400
3415
|
*/
|
3401
3416
|
static VALUE uint8_sum(int argc, VALUE* argv, VALUE self) {
|
3402
3417
|
VALUE v, reduce;
|
3403
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
3404
|
-
ndfunc_arg_out_t aout[1] = {{numo_cUInt64, 0}};
|
3405
|
-
ndfunc_t ndf = {iter_uint8_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
3418
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3419
|
+
ndfunc_arg_out_t aout[1] = { { numo_cUInt64, 0 } };
|
3420
|
+
ndfunc_t ndf = { iter_uint8_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
3406
3421
|
|
3407
3422
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
3408
3423
|
|
@@ -3426,15 +3441,16 @@ static void iter_uint8_prod(na_loop_t* const lp) {
|
|
3426
3441
|
/*
|
3427
3442
|
prod of self.
|
3428
3443
|
@overload prod(axis:nil, keepdims:false)
|
3429
|
-
|
3430
|
-
|
3431
|
-
|
3444
|
+
@param [Numeric,Array,Range] axis Performs prod along the axis.
|
3445
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3446
|
+
dimensions with size one.
|
3447
|
+
@return [Numo::UInt8] returns result of prod.
|
3432
3448
|
*/
|
3433
3449
|
static VALUE uint8_prod(int argc, VALUE* argv, VALUE self) {
|
3434
3450
|
VALUE v, reduce;
|
3435
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
3436
|
-
ndfunc_arg_out_t aout[1] = {{numo_cUInt64, 0}};
|
3437
|
-
ndfunc_t ndf = {iter_uint8_prod, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
3451
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3452
|
+
ndfunc_arg_out_t aout[1] = { { numo_cUInt64, 0 } };
|
3453
|
+
ndfunc_t ndf = { iter_uint8_prod, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
3438
3454
|
|
3439
3455
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
3440
3456
|
|
@@ -3458,15 +3474,16 @@ static void iter_uint8_min(na_loop_t* const lp) {
|
|
3458
3474
|
/*
|
3459
3475
|
min of self.
|
3460
3476
|
@overload min(axis:nil, keepdims:false)
|
3461
|
-
|
3462
|
-
|
3463
|
-
|
3477
|
+
@param [Numeric,Array,Range] axis Performs min along the axis.
|
3478
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3479
|
+
dimensions with size one.
|
3480
|
+
@return [Numo::UInt8] returns result of min.
|
3464
3481
|
*/
|
3465
3482
|
static VALUE uint8_min(int argc, VALUE* argv, VALUE self) {
|
3466
3483
|
VALUE v, reduce;
|
3467
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
3468
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3469
|
-
ndfunc_t ndf = {iter_uint8_min, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
3484
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3485
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3486
|
+
ndfunc_t ndf = { iter_uint8_min, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
3470
3487
|
|
3471
3488
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
3472
3489
|
|
@@ -3490,15 +3507,16 @@ static void iter_uint8_max(na_loop_t* const lp) {
|
|
3490
3507
|
/*
|
3491
3508
|
max of self.
|
3492
3509
|
@overload max(axis:nil, keepdims:false)
|
3493
|
-
|
3494
|
-
|
3495
|
-
|
3510
|
+
@param [Numeric,Array,Range] axis Performs max along the axis.
|
3511
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3512
|
+
dimensions with size one.
|
3513
|
+
@return [Numo::UInt8] returns result of max.
|
3496
3514
|
*/
|
3497
3515
|
static VALUE uint8_max(int argc, VALUE* argv, VALUE self) {
|
3498
3516
|
VALUE v, reduce;
|
3499
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
3500
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3501
|
-
ndfunc_t ndf = {iter_uint8_max, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
3517
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3518
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3519
|
+
ndfunc_t ndf = { iter_uint8_max, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
3502
3520
|
|
3503
3521
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
3504
3522
|
|
@@ -3522,15 +3540,16 @@ static void iter_uint8_ptp(na_loop_t* const lp) {
|
|
3522
3540
|
/*
|
3523
3541
|
ptp of self.
|
3524
3542
|
@overload ptp(axis:nil, keepdims:false)
|
3525
|
-
|
3526
|
-
|
3527
|
-
|
3543
|
+
@param [Numeric,Array,Range] axis Performs ptp along the axis.
|
3544
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3545
|
+
dimensions with size one.
|
3546
|
+
@return [Numo::UInt8] returns result of ptp.
|
3528
3547
|
*/
|
3529
3548
|
static VALUE uint8_ptp(int argc, VALUE* argv, VALUE self) {
|
3530
3549
|
VALUE v, reduce;
|
3531
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
3532
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3533
|
-
ndfunc_t ndf = {iter_uint8_ptp, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
3550
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3551
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3552
|
+
ndfunc_t ndf = { iter_uint8_ptp, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
3534
3553
|
|
3535
3554
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
3536
3555
|
|
@@ -3576,8 +3595,9 @@ static void iter_uint8_max_index_index32(na_loop_t* const lp) {
|
|
3576
3595
|
/*
|
3577
3596
|
Index of the maximum value.
|
3578
3597
|
@overload max_index(axis:nil)
|
3579
|
-
|
3580
|
-
|
3598
|
+
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat
|
3599
|
+
1-d indices**.
|
3600
|
+
@return [Integer,Numo::Int] returns result indices.
|
3581
3601
|
@see #argmax
|
3582
3602
|
@see #max
|
3583
3603
|
|
@@ -3594,9 +3614,9 @@ static void iter_uint8_max_index_index32(na_loop_t* const lp) {
|
|
3594
3614
|
static VALUE uint8_max_index(int argc, VALUE* argv, VALUE self) {
|
3595
3615
|
narray_t* na;
|
3596
3616
|
VALUE idx, reduce;
|
3597
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {Qnil, 0}, {sym_reduce, 0}};
|
3598
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
3599
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout};
|
3617
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { Qnil, 0 }, { sym_reduce, 0 } };
|
3618
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
3619
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout };
|
3600
3620
|
|
3601
3621
|
GetNArray(self, na);
|
3602
3622
|
if (na->ndim == 0) {
|
@@ -3658,8 +3678,9 @@ static void iter_uint8_min_index_index32(na_loop_t* const lp) {
|
|
3658
3678
|
/*
|
3659
3679
|
Index of the minimum value.
|
3660
3680
|
@overload min_index(axis:nil)
|
3661
|
-
|
3662
|
-
|
3681
|
+
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat
|
3682
|
+
1-d indices**.
|
3683
|
+
@return [Integer,Numo::Int] returns result indices.
|
3663
3684
|
@see #argmin
|
3664
3685
|
@see #min
|
3665
3686
|
|
@@ -3676,9 +3697,9 @@ static void iter_uint8_min_index_index32(na_loop_t* const lp) {
|
|
3676
3697
|
static VALUE uint8_min_index(int argc, VALUE* argv, VALUE self) {
|
3677
3698
|
narray_t* na;
|
3678
3699
|
VALUE idx, reduce;
|
3679
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {Qnil, 0}, {sym_reduce, 0}};
|
3680
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
3681
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout};
|
3700
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { Qnil, 0 }, { sym_reduce, 0 } };
|
3701
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
3702
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout };
|
3682
3703
|
|
3683
3704
|
GetNArray(self, na);
|
3684
3705
|
if (na->ndim == 0) {
|
@@ -3738,8 +3759,9 @@ static void iter_uint8_argmax_arg32(na_loop_t* const lp) {
|
|
3738
3759
|
/*
|
3739
3760
|
Index of the maximum value.
|
3740
3761
|
@overload argmax(axis:nil)
|
3741
|
-
|
3742
|
-
|
3762
|
+
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices
|
3763
|
+
along the axis**.
|
3764
|
+
@return [Integer,Numo::Int] returns the result indices.
|
3743
3765
|
@see #max_index
|
3744
3766
|
@see #max
|
3745
3767
|
|
@@ -3756,9 +3778,9 @@ static void iter_uint8_argmax_arg32(na_loop_t* const lp) {
|
|
3756
3778
|
static VALUE uint8_argmax(int argc, VALUE* argv, VALUE self) {
|
3757
3779
|
narray_t* na;
|
3758
3780
|
VALUE reduce;
|
3759
|
-
ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_reduce, 0}};
|
3760
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
3761
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout};
|
3781
|
+
ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } };
|
3782
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
3783
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout };
|
3762
3784
|
|
3763
3785
|
GetNArray(self, na);
|
3764
3786
|
if (na->ndim == 0) {
|
@@ -3815,8 +3837,9 @@ static void iter_uint8_argmin_arg32(na_loop_t* const lp) {
|
|
3815
3837
|
/*
|
3816
3838
|
Index of the minimum value.
|
3817
3839
|
@overload argmin(axis:nil)
|
3818
|
-
|
3819
|
-
|
3840
|
+
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices
|
3841
|
+
along the axis**.
|
3842
|
+
@return [Integer,Numo::Int] returns the result indices.
|
3820
3843
|
@see #min_index
|
3821
3844
|
@see #min
|
3822
3845
|
|
@@ -3833,9 +3856,9 @@ static void iter_uint8_argmin_arg32(na_loop_t* const lp) {
|
|
3833
3856
|
static VALUE uint8_argmin(int argc, VALUE* argv, VALUE self) {
|
3834
3857
|
narray_t* na;
|
3835
3858
|
VALUE reduce;
|
3836
|
-
ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_reduce, 0}};
|
3837
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
3838
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout};
|
3859
|
+
ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } };
|
3860
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
3861
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout };
|
3839
3862
|
|
3840
3863
|
GetNArray(self, na);
|
3841
3864
|
if (na->ndim == 0) {
|
@@ -3875,29 +3898,24 @@ static void iter_uint8_minmax(na_loop_t* const lp) {
|
|
3875
3898
|
/*
|
3876
3899
|
minmax of self.
|
3877
3900
|
@overload minmax(axis:nil, keepdims:false)
|
3878
|
-
|
3879
|
-
|
3880
|
-
|
3901
|
+
@param [Numeric,Array,Range] axis Finds min-max along the axis.
|
3902
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
3903
|
+
as dimensions with size one.
|
3904
|
+
@return [Numo::UInt8,Numo::UInt8] min and max of self.
|
3881
3905
|
*/
|
3882
3906
|
static VALUE uint8_minmax(int argc, VALUE* argv, VALUE self) {
|
3883
3907
|
VALUE reduce;
|
3884
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
3885
|
-
ndfunc_arg_out_t aout[2] = {{cT, 0}, {cT, 0}};
|
3886
|
-
ndfunc_t ndf = {
|
3908
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3909
|
+
ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
|
3910
|
+
ndfunc_t ndf = {
|
3911
|
+
iter_uint8_minmax, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 2, ain, aout
|
3912
|
+
};
|
3887
3913
|
|
3888
3914
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
3889
3915
|
|
3890
3916
|
return na_ndloop(&ndf, 2, self, reduce);
|
3891
3917
|
}
|
3892
3918
|
|
3893
|
-
/*
|
3894
|
-
Element-wise maximum of two arrays.
|
3895
|
-
|
3896
|
-
@overload maximum(a1, a2)
|
3897
|
-
@param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
|
3898
|
-
@return [Numo::UInt8]
|
3899
|
-
*/
|
3900
|
-
|
3901
3919
|
static void iter_uint8_s_maximum(na_loop_t* const lp) {
|
3902
3920
|
size_t i, n;
|
3903
3921
|
char *p1, *p2, *p3;
|
@@ -3921,23 +3939,15 @@ static void iter_uint8_s_maximum(na_loop_t* const lp) {
|
|
3921
3939
|
static VALUE uint8_s_maximum(int argc, VALUE* argv, VALUE mod) {
|
3922
3940
|
VALUE a1 = Qnil;
|
3923
3941
|
VALUE a2 = Qnil;
|
3924
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3925
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3926
|
-
ndfunc_t ndf = {iter_uint8_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout};
|
3942
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3943
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3944
|
+
ndfunc_t ndf = { iter_uint8_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
|
3927
3945
|
|
3928
3946
|
rb_scan_args(argc, argv, "20", &a1, &a2);
|
3929
3947
|
|
3930
3948
|
return na_ndloop(&ndf, 2, a1, a2);
|
3931
3949
|
}
|
3932
3950
|
|
3933
|
-
/*
|
3934
|
-
Element-wise minimum of two arrays.
|
3935
|
-
|
3936
|
-
@overload minimum(a1, a2)
|
3937
|
-
@param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
|
3938
|
-
@return [Numo::UInt8]
|
3939
|
-
*/
|
3940
|
-
|
3941
3951
|
static void iter_uint8_s_minimum(na_loop_t* const lp) {
|
3942
3952
|
size_t i, n;
|
3943
3953
|
char *p1, *p2, *p3;
|
@@ -3961,9 +3971,9 @@ static void iter_uint8_s_minimum(na_loop_t* const lp) {
|
|
3961
3971
|
static VALUE uint8_s_minimum(int argc, VALUE* argv, VALUE mod) {
|
3962
3972
|
VALUE a1 = Qnil;
|
3963
3973
|
VALUE a2 = Qnil;
|
3964
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3965
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3966
|
-
ndfunc_t ndf = {iter_uint8_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout};
|
3974
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3975
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3976
|
+
ndfunc_t ndf = { iter_uint8_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
|
3967
3977
|
|
3968
3978
|
rb_scan_args(argc, argv, "20", &a1, &a2);
|
3969
3979
|
|
@@ -4002,10 +4012,12 @@ static void iter_uint8_bincount_32(na_loop_t* const lp) {
|
|
4002
4012
|
}
|
4003
4013
|
|
4004
4014
|
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 = {
|
4015
|
+
size_t shape_out[1] = { length };
|
4016
|
+
ndfunc_arg_in_t ain[1] = { { cT, 1 } };
|
4017
|
+
ndfunc_arg_out_t aout[1] = { { numo_cUInt32, 1, shape_out } };
|
4018
|
+
ndfunc_t ndf = {
|
4019
|
+
iter_uint8_bincount_32, NO_LOOP | NDF_STRIDE_LOOP | NDF_INDEX_LOOP, 1, 1, ain, aout
|
4020
|
+
};
|
4009
4021
|
|
4010
4022
|
return na_ndloop(&ndf, 1, self);
|
4011
4023
|
}
|
@@ -4040,10 +4052,12 @@ static void iter_uint8_bincount_64(na_loop_t* const lp) {
|
|
4040
4052
|
}
|
4041
4053
|
|
4042
4054
|
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 = {
|
4055
|
+
size_t shape_out[1] = { length };
|
4056
|
+
ndfunc_arg_in_t ain[1] = { { cT, 1 } };
|
4057
|
+
ndfunc_arg_out_t aout[1] = { { numo_cUInt64, 1, shape_out } };
|
4058
|
+
ndfunc_t ndf = {
|
4059
|
+
iter_uint8_bincount_64, NO_LOOP | NDF_STRIDE_LOOP | NDF_INDEX_LOOP, 1, 1, ain, aout
|
4060
|
+
};
|
4047
4061
|
|
4048
4062
|
return na_ndloop(&ndf, 1, self);
|
4049
4063
|
}
|
@@ -4080,10 +4094,10 @@ static void iter_uint8_bincount_sf(na_loop_t* const lp) {
|
|
4080
4094
|
}
|
4081
4095
|
|
4082
4096
|
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};
|
4097
|
+
size_t shape_out[1] = { length };
|
4098
|
+
ndfunc_arg_in_t ain[2] = { { cT, 1 }, { numo_cSFloat, 1 } };
|
4099
|
+
ndfunc_arg_out_t aout[1] = { { numo_cSFloat, 1, shape_out } };
|
4100
|
+
ndfunc_t ndf = { iter_uint8_bincount_sf, NO_LOOP | NDF_STRIDE_LOOP, 2, 1, ain, aout };
|
4087
4101
|
|
4088
4102
|
return na_ndloop(&ndf, 2, self, weight);
|
4089
4103
|
}
|
@@ -4117,10 +4131,10 @@ static void iter_uint8_bincount_df(na_loop_t* const lp) {
|
|
4117
4131
|
}
|
4118
4132
|
|
4119
4133
|
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};
|
4134
|
+
size_t shape_out[1] = { length };
|
4135
|
+
ndfunc_arg_in_t ain[2] = { { cT, 1 }, { numo_cDFloat, 1 } };
|
4136
|
+
ndfunc_arg_out_t aout[1] = { { numo_cDFloat, 1, shape_out } };
|
4137
|
+
ndfunc_t ndf = { iter_uint8_bincount_df, NO_LOOP | NDF_STRIDE_LOOP, 2, 1, ain, aout };
|
4124
4138
|
|
4125
4139
|
return na_ndloop(&ndf, 2, self, weight);
|
4126
4140
|
}
|
@@ -4131,13 +4145,13 @@ static VALUE uint8_bincount_df(VALUE self, VALUE weight, size_t length) {
|
|
4131
4145
|
Only Integer-types has this method.
|
4132
4146
|
|
4133
4147
|
@overload bincount([weight], minlength:nil)
|
4134
|
-
|
4135
|
-
|
4136
|
-
|
4137
|
-
|
4138
|
-
|
4139
|
-
|
4140
|
-
|
4148
|
+
@param [SFloat or DFloat or Array] weight (optional) Array of
|
4149
|
+
float values. Its size along last axis should be same as that of self.
|
4150
|
+
@param [Integer] minlength (keyword, optional) Minimum size along
|
4151
|
+
last axis for the output array.
|
4152
|
+
@return [UInt32 or UInt64 or SFloat or DFloat]
|
4153
|
+
Returns Float NArray if weight array is supplied,
|
4154
|
+
otherwise returns UInt32 or UInt64 depending on the size along last axis.
|
4141
4155
|
@example
|
4142
4156
|
Numo::Int32[0..4].bincount
|
4143
4157
|
# => Numo::UInt32#shape=[5]
|
@@ -4160,9 +4174,9 @@ static VALUE uint8_bincount_df(VALUE self, VALUE weight, size_t length) {
|
|
4160
4174
|
*/
|
4161
4175
|
static VALUE uint8_bincount(int argc, VALUE* argv, VALUE self) {
|
4162
4176
|
VALUE weight = Qnil, kw = Qnil;
|
4163
|
-
VALUE opts[1] = {Qundef};
|
4177
|
+
VALUE opts[1] = { Qundef };
|
4164
4178
|
VALUE v, wclass;
|
4165
|
-
ID table[1] = {id_minlength};
|
4179
|
+
ID table[1] = { id_minlength };
|
4166
4180
|
size_t length, minlength;
|
4167
4181
|
|
4168
4182
|
rb_scan_args(argc, argv, "01:", &weight, &kw);
|
@@ -4204,31 +4218,30 @@ static void iter_uint8_cumsum(na_loop_t* const lp) {
|
|
4204
4218
|
INIT_COUNTER(lp, i);
|
4205
4219
|
INIT_PTR(lp, 0, p1, s1);
|
4206
4220
|
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
4221
|
|
4209
4222
|
GET_DATA_STRIDE(p1, s1, dtype, x);
|
4210
4223
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4211
|
-
// printf("i=%lu x=%f\n",i,x);
|
4212
4224
|
for (i--; i--;) {
|
4213
4225
|
GET_DATA_STRIDE(p1, s1, dtype, y);
|
4214
4226
|
m_cumsum(x, y);
|
4215
4227
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4216
|
-
// printf("i=%lu x=%f\n",i,x);
|
4217
4228
|
}
|
4218
4229
|
}
|
4219
4230
|
|
4220
4231
|
/*
|
4221
4232
|
cumsum of self.
|
4222
4233
|
@overload cumsum(axis:nil, nan:false)
|
4223
|
-
|
4224
|
-
|
4225
|
-
|
4234
|
+
@param [Numeric,Array,Range] axis Performs cumsum along the axis.
|
4235
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
4236
|
+
@return [Numo::UInt8] cumsum of self.
|
4226
4237
|
*/
|
4227
4238
|
static VALUE uint8_cumsum(int argc, VALUE* argv, VALUE self) {
|
4228
4239
|
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 = {
|
4240
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4241
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4242
|
+
ndfunc_t ndf = {
|
4243
|
+
iter_uint8_cumsum, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout
|
4244
|
+
};
|
4232
4245
|
|
4233
4246
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
4234
4247
|
|
@@ -4244,31 +4257,30 @@ static void iter_uint8_cumprod(na_loop_t* const lp) {
|
|
4244
4257
|
INIT_COUNTER(lp, i);
|
4245
4258
|
INIT_PTR(lp, 0, p1, s1);
|
4246
4259
|
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
4260
|
|
4249
4261
|
GET_DATA_STRIDE(p1, s1, dtype, x);
|
4250
4262
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4251
|
-
// printf("i=%lu x=%f\n",i,x);
|
4252
4263
|
for (i--; i--;) {
|
4253
4264
|
GET_DATA_STRIDE(p1, s1, dtype, y);
|
4254
4265
|
m_cumprod(x, y);
|
4255
4266
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4256
|
-
// printf("i=%lu x=%f\n",i,x);
|
4257
4267
|
}
|
4258
4268
|
}
|
4259
4269
|
|
4260
4270
|
/*
|
4261
4271
|
cumprod of self.
|
4262
4272
|
@overload cumprod(axis:nil, nan:false)
|
4263
|
-
|
4264
|
-
|
4265
|
-
|
4273
|
+
@param [Numeric,Array,Range] axis Performs cumprod along the axis.
|
4274
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
4275
|
+
@return [Numo::UInt8] cumprod of self.
|
4266
4276
|
*/
|
4267
4277
|
static VALUE uint8_cumprod(int argc, VALUE* argv, VALUE self) {
|
4268
4278
|
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 = {
|
4279
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4280
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4281
|
+
ndfunc_t ndf = {
|
4282
|
+
iter_uint8_cumprod, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout
|
4283
|
+
};
|
4272
4284
|
|
4273
4285
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, 0);
|
4274
4286
|
|
@@ -4314,9 +4326,9 @@ static void iter_uint8_mulsum(na_loop_t* const lp) {
|
|
4314
4326
|
static VALUE uint8_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
4315
4327
|
VALUE v, reduce;
|
4316
4328
|
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};
|
4329
|
+
ndfunc_arg_in_t ain[4] = { { cT, 0 }, { cT, 0 }, { sym_reduce, 0 }, { sym_init, 0 } };
|
4330
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4331
|
+
ndfunc_t ndf = { iter_uint8_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout };
|
4320
4332
|
|
4321
4333
|
if (argc < 1) {
|
4322
4334
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for >=1)", argc);
|
@@ -4336,10 +4348,11 @@ static VALUE uint8_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
|
4336
4348
|
Binary mulsum.
|
4337
4349
|
|
4338
4350
|
@overload mulsum(other, axis:nil, keepdims:false)
|
4339
|
-
|
4340
|
-
|
4341
|
-
|
4342
|
-
|
4351
|
+
@param [Numo::NArray,Numeric] other
|
4352
|
+
@param [Numeric,Array,Range] axis Performs mulsum along the axis.
|
4353
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
4354
|
+
as dimensions with size one.
|
4355
|
+
@return [Numo::NArray] mulsum of self and other.
|
4343
4356
|
*/
|
4344
4357
|
static VALUE uint8_mulsum(int argc, VALUE* argv, VALUE self) {
|
4345
4358
|
//
|
@@ -4408,9 +4421,9 @@ static void iter_uint8_seq(na_loop_t* const lp) {
|
|
4408
4421
|
beg+i*step
|
4409
4422
|
where i is 1-dimensional index.
|
4410
4423
|
@overload seq([beg,[step]])
|
4411
|
-
|
4412
|
-
|
4413
|
-
|
4424
|
+
@param [Numeric] beg beginning of sequence. (default=0)
|
4425
|
+
@param [Numeric] step step of sequence. (default=1)
|
4426
|
+
@return [Numo::UInt8] self.
|
4414
4427
|
@example
|
4415
4428
|
Numo::DFloat.new(6).seq(1,-0.2)
|
4416
4429
|
# => Numo::DFloat#shape=[6]
|
@@ -4420,17 +4433,17 @@ static void iter_uint8_seq(na_loop_t* const lp) {
|
|
4420
4433
|
# => Numo::DComplex#shape=[6]
|
4421
4434
|
# [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
4422
4435
|
*/
|
4423
|
-
static VALUE uint8_seq(int argc, VALUE*
|
4436
|
+
static VALUE uint8_seq(int argc, VALUE* argv, VALUE self) {
|
4424
4437
|
seq_opt_t* g;
|
4425
4438
|
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};
|
4439
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
4440
|
+
ndfunc_t ndf = { iter_uint8_seq, FULL_LOOP, 1, 0, ain, 0 };
|
4428
4441
|
|
4429
4442
|
g = ALLOCA_N(seq_opt_t, 1);
|
4430
4443
|
g->beg = m_zero;
|
4431
4444
|
g->step = m_one;
|
4432
4445
|
g->count = 0;
|
4433
|
-
rb_scan_args(argc,
|
4446
|
+
rb_scan_args(argc, argv, "02", &vbeg, &vstep);
|
4434
4447
|
if (vbeg != Qnil) {
|
4435
4448
|
g->beg = NUM2DBL(vbeg);
|
4436
4449
|
}
|
@@ -4474,15 +4487,15 @@ static void iter_uint8_eye(na_loop_t* const lp) {
|
|
4474
4487
|
/*
|
4475
4488
|
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
|
4476
4489
|
@overload eye([element,offset])
|
4477
|
-
|
4478
|
-
|
4479
|
-
|
4480
|
-
|
4481
|
-
|
4490
|
+
@param [Numeric] element Diagonal element to be stored. Default is 1.
|
4491
|
+
@param [Integer] offset Diagonal offset from the main diagonal. The
|
4492
|
+
default is 0. k>0 for diagonals above the main diagonal, and k<0
|
4493
|
+
for diagonals below the main diagonal.
|
4494
|
+
@return [Numo::UInt8] eye of self.
|
4482
4495
|
*/
|
4483
4496
|
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};
|
4497
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
|
4498
|
+
ndfunc_t ndf = { iter_uint8_eye, NO_LOOP, 1, 0, ain, 0 };
|
4486
4499
|
ssize_t kofs;
|
4487
4500
|
dtype data;
|
4488
4501
|
char* g;
|
@@ -4512,17 +4525,21 @@ static VALUE uint8_eye(int argc, VALUE* argv, VALUE self) {
|
|
4512
4525
|
// Diagonal offset from the main diagonal.
|
4513
4526
|
if (kofs >= 0) {
|
4514
4527
|
if ((size_t)(kofs) >= na->shape[nd - 1]) {
|
4515
|
-
rb_raise(
|
4516
|
-
|
4517
|
-
|
4518
|
-
|
4528
|
+
rb_raise(
|
4529
|
+
rb_eArgError,
|
4530
|
+
"invalid diagonal offset(%" SZF "d) for "
|
4531
|
+
"last dimension size(%" SZF "d)",
|
4532
|
+
kofs, na->shape[nd - 1]
|
4533
|
+
);
|
4519
4534
|
}
|
4520
4535
|
} else {
|
4521
4536
|
if ((size_t)(-kofs) >= na->shape[nd - 2]) {
|
4522
|
-
rb_raise(
|
4523
|
-
|
4524
|
-
|
4525
|
-
|
4537
|
+
rb_raise(
|
4538
|
+
rb_eArgError,
|
4539
|
+
"invalid diagonal offset(%" SZF "d) for "
|
4540
|
+
"last-1 dimension size(%" SZF "d)",
|
4541
|
+
kofs, na->shape[nd - 2]
|
4542
|
+
);
|
4526
4543
|
}
|
4527
4544
|
}
|
4528
4545
|
|
@@ -4606,9 +4623,10 @@ static void iter_uint8_rand(na_loop_t* const lp) {
|
|
4606
4623
|
/*
|
4607
4624
|
Generate uniformly distributed random numbers on self narray.
|
4608
4625
|
@overload rand([[low],high])
|
4609
|
-
|
4610
|
-
|
4611
|
-
|
4626
|
+
@param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
4627
|
+
@param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
|
4628
|
+
complex types)
|
4629
|
+
@return [Numo::UInt8] self.
|
4612
4630
|
@example
|
4613
4631
|
Numo::DFloat.new(6).rand
|
4614
4632
|
# => Numo::DFloat#shape=[6]
|
@@ -4622,14 +4640,14 @@ static void iter_uint8_rand(na_loop_t* const lp) {
|
|
4622
4640
|
# => Numo::Int32#shape=[6]
|
4623
4641
|
# [4, 3, 3, 2, 4, 2]
|
4624
4642
|
*/
|
4625
|
-
static VALUE uint8_rand(int argc, VALUE*
|
4643
|
+
static VALUE uint8_rand(int argc, VALUE* argv, VALUE self) {
|
4626
4644
|
rand_opt_t g;
|
4627
4645
|
VALUE v1 = Qnil, v2 = Qnil;
|
4628
4646
|
dtype high;
|
4629
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
|
4630
|
-
ndfunc_t ndf = {iter_uint8_rand, FULL_LOOP, 1, 0, ain, 0};
|
4647
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
4648
|
+
ndfunc_t ndf = { iter_uint8_rand, FULL_LOOP, 1, 0, ain, 0 };
|
4631
4649
|
|
4632
|
-
rb_scan_args(argc,
|
4650
|
+
rb_scan_args(argc, argv, "11", &v1, &v2);
|
4633
4651
|
if (v2 == Qnil) {
|
4634
4652
|
g.low = m_zero;
|
4635
4653
|
g.max = high = m_num_to_data(v1);
|
@@ -4668,15 +4686,15 @@ static void iter_uint8_poly(na_loop_t* const lp) {
|
|
4668
4686
|
Calculate polynomial.
|
4669
4687
|
`x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
|
4670
4688
|
@overload poly a0, a1, ..., an
|
4671
|
-
|
4672
|
-
|
4689
|
+
@param [Numo::NArray,Numeric] a0,a1,...,an
|
4690
|
+
@return [Numo::UInt8]
|
4673
4691
|
*/
|
4674
4692
|
static VALUE uint8_poly(VALUE self, VALUE args) {
|
4675
4693
|
int argc, i;
|
4676
4694
|
VALUE* argv;
|
4677
4695
|
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};
|
4696
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4697
|
+
ndfunc_t ndf = { iter_uint8_poly, NO_LOOP, 0, 1, 0, aout };
|
4680
4698
|
|
4681
4699
|
argc = (int)RARRAY_LEN(args);
|
4682
4700
|
ndf.nin = argc + 1;
|
@@ -4756,23 +4774,28 @@ static VALUE uint8_poly(VALUE self, VALUE args) {
|
|
4756
4774
|
* We have modified their original by adding a check for already-sorted input,
|
4757
4775
|
* which seems to be a win per discussions on pgsql-hackers around 2006-03-21.
|
4758
4776
|
*/
|
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);
|
4777
|
+
#define swapcode(TYPE, parmi, parmj, n) \
|
4778
|
+
do { \
|
4779
|
+
size_t i = (n) / sizeof(TYPE); \
|
4780
|
+
TYPE* pi = (TYPE*)(void*)(parmi); \
|
4781
|
+
TYPE* pj = (TYPE*)(void*)(parmj); \
|
4782
|
+
do { \
|
4783
|
+
TYPE t = *pi; \
|
4784
|
+
*pi++ = *pj; \
|
4785
|
+
*pj++ = t; \
|
4786
|
+
} while (--i > 0); \
|
4769
4787
|
} while (0)
|
4770
4788
|
|
4771
4789
|
#ifdef HAVE_STDINT_H
|
4772
|
-
#define SWAPINIT(a, es)
|
4790
|
+
#define SWAPINIT(a, es) \
|
4791
|
+
swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
4792
|
+
: (es) == sizeof(long) ? 0 \
|
4793
|
+
: 1;
|
4773
4794
|
#else
|
4774
|
-
#define SWAPINIT(a, es)
|
4775
|
-
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2
|
4795
|
+
#define SWAPINIT(a, es) \
|
4796
|
+
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
4797
|
+
: (es) == sizeof(long) ? 0 \
|
4798
|
+
: 1;
|
4776
4799
|
#endif
|
4777
4800
|
|
4778
4801
|
static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
|
@@ -4782,19 +4805,20 @@ static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
|
|
4782
4805
|
swapcode(char, a, b, n);
|
4783
4806
|
}
|
4784
4807
|
|
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
|
4808
|
+
#define swap(a, b) \
|
4809
|
+
if (swaptype == 0) { \
|
4810
|
+
long t = *(long*)(void*)(a); \
|
4811
|
+
*(long*)(void*)(a) = *(long*)(void*)(b); \
|
4812
|
+
*(long*)(void*)(b) = t; \
|
4813
|
+
} else \
|
4791
4814
|
swapfunc(a, b, es, swaptype)
|
4792
4815
|
|
4793
|
-
#define vecswap(a, b, n)
|
4816
|
+
#define vecswap(a, b, n) \
|
4794
4817
|
if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
|
4795
4818
|
|
4796
|
-
#define med3(a, b, c, _cmp)
|
4797
|
-
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a))
|
4819
|
+
#define med3(a, b, c, _cmp) \
|
4820
|
+
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) \
|
4821
|
+
: (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
|
4798
4822
|
#endif
|
4799
4823
|
|
4800
4824
|
#undef qsort_dtype
|
@@ -4884,15 +4908,15 @@ static void iter_uint8_sort(na_loop_t* const lp) {
|
|
4884
4908
|
/*
|
4885
4909
|
sort of self.
|
4886
4910
|
@overload sort(axis:nil)
|
4887
|
-
|
4888
|
-
|
4911
|
+
@param [Numeric,Array,Range] axis Performs sort along the axis.
|
4912
|
+
@return [Numo::UInt8] returns result of sort.
|
4889
4913
|
@example
|
4890
4914
|
Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
|
4891
4915
|
*/
|
4892
4916
|
static VALUE uint8_sort(int argc, VALUE* argv, VALUE self) {
|
4893
4917
|
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};
|
4918
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
|
4919
|
+
ndfunc_t ndf = { 0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 0, ain, 0 };
|
4896
4920
|
|
4897
4921
|
if (!TEST_INPLACE(self)) {
|
4898
4922
|
self = na_copy(self);
|
@@ -4993,7 +5017,8 @@ loop:
|
|
4993
5017
|
pm = med3(pl, pm, pn, cmp);
|
4994
5018
|
}
|
4995
5019
|
swap(a, pm);
|
4996
|
-
for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc;
|
5020
|
+
for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc;
|
5021
|
+
pb += es, pc -= es) {
|
4997
5022
|
while (pb <= pc && (r = cmp(pb, a)) <= 0) {
|
4998
5023
|
if (r == 0) {
|
4999
5024
|
swap(pa, pb);
|
@@ -5040,7 +5065,6 @@ static void uint8_index64_qsort(na_loop_t* const lp) {
|
|
5040
5065
|
|
5041
5066
|
ptr = (char**)(lp->opt_ptr);
|
5042
5067
|
|
5043
|
-
// printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
|
5044
5068
|
// 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
5069
|
|
5046
5070
|
if (n == 1) {
|
@@ -5050,21 +5074,17 @@ static void uint8_index64_qsort(na_loop_t* const lp) {
|
|
5050
5074
|
|
5051
5075
|
for (i = 0; i < n; i++) {
|
5052
5076
|
ptr[i] = d_ptr + d_step * i;
|
5053
|
-
// printf("(%ld,%.3f)",i,*(double*)ptr[i]);
|
5054
5077
|
}
|
5055
5078
|
|
5056
5079
|
uint8_index_qsort(ptr, n, sizeof(dtype*));
|
5057
5080
|
|
5058
5081
|
// d_ptr = lp->args[0].ptr;
|
5059
|
-
// printf("(d_ptr=%lx)\n",(size_t)d_ptr);
|
5060
5082
|
|
5061
5083
|
for (i = 0; i < n; i++) {
|
5062
5084
|
idx = (ptr[i] - d_ptr) / d_step;
|
5063
5085
|
*(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
|
5064
|
-
// printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
|
5065
5086
|
o_ptr += o_step;
|
5066
5087
|
}
|
5067
|
-
// printf("\n");
|
5068
5088
|
}
|
5069
5089
|
#undef idx_t
|
5070
5090
|
|
@@ -5082,7 +5102,6 @@ static void uint8_index32_qsort(na_loop_t* const lp) {
|
|
5082
5102
|
|
5083
5103
|
ptr = (char**)(lp->opt_ptr);
|
5084
5104
|
|
5085
|
-
// printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
|
5086
5105
|
// 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
5106
|
|
5088
5107
|
if (n == 1) {
|
@@ -5092,29 +5111,25 @@ static void uint8_index32_qsort(na_loop_t* const lp) {
|
|
5092
5111
|
|
5093
5112
|
for (i = 0; i < n; i++) {
|
5094
5113
|
ptr[i] = d_ptr + d_step * i;
|
5095
|
-
// printf("(%ld,%.3f)",i,*(double*)ptr[i]);
|
5096
5114
|
}
|
5097
5115
|
|
5098
5116
|
uint8_index_qsort(ptr, n, sizeof(dtype*));
|
5099
5117
|
|
5100
5118
|
// d_ptr = lp->args[0].ptr;
|
5101
|
-
// printf("(d_ptr=%lx)\n",(size_t)d_ptr);
|
5102
5119
|
|
5103
5120
|
for (i = 0; i < n; i++) {
|
5104
5121
|
idx = (ptr[i] - d_ptr) / d_step;
|
5105
5122
|
*(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
|
5106
|
-
// printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
|
5107
5123
|
o_ptr += o_step;
|
5108
5124
|
}
|
5109
|
-
// printf("\n");
|
5110
5125
|
}
|
5111
5126
|
#undef idx_t
|
5112
5127
|
|
5113
5128
|
/*
|
5114
5129
|
sort_index. Returns an index array of sort result.
|
5115
5130
|
@overload sort_index(axis:nil)
|
5116
|
-
|
5117
|
-
|
5131
|
+
@param [Numeric,Array,Range] axis Performs sort_index along the axis.
|
5132
|
+
@return [Integer,Numo::Int] returns result index of sort_index.
|
5118
5133
|
@example
|
5119
5134
|
Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
|
5120
5135
|
*/
|
@@ -5123,9 +5138,9 @@ static VALUE uint8_sort_index(int argc, VALUE* argv, VALUE self) {
|
|
5123
5138
|
narray_t* na;
|
5124
5139
|
VALUE idx, tmp, reduce, res;
|
5125
5140
|
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};
|
5141
|
+
ndfunc_arg_in_t ain[3] = { { cT, 0 }, { 0, 0 }, { sym_reduce, 0 } };
|
5142
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
5143
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_CUM, 3, 1, ain, aout };
|
5129
5144
|
|
5130
5145
|
GetNArray(self, na);
|
5131
5146
|
if (na->ndim == 0) {
|
@@ -5178,16 +5193,17 @@ static void iter_uint8_median(na_loop_t* const lp) {
|
|
5178
5193
|
/*
|
5179
5194
|
median of self.
|
5180
5195
|
@overload median(axis:nil, keepdims:false)
|
5181
|
-
|
5182
|
-
|
5183
|
-
|
5196
|
+
@param [Numeric,Array,Range] axis Finds median along the axis.
|
5197
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
5198
|
+
dimensions with size one.
|
5199
|
+
@return [Numo::UInt8] returns median of self.
|
5184
5200
|
*/
|
5185
5201
|
|
5186
5202
|
static VALUE uint8_median(int argc, VALUE* argv, VALUE self) {
|
5187
5203
|
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};
|
5204
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
|
5205
|
+
ndfunc_arg_out_t aout[1] = { { INT2FIX(0), 0 } };
|
5206
|
+
ndfunc_t ndf = { 0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
5191
5207
|
|
5192
5208
|
self = na_copy(self); // as temporary buffer
|
5193
5209
|
|
@@ -5219,13 +5235,15 @@ void Init_numo_uint8(void) {
|
|
5219
5235
|
id_ne = rb_intern("ne");
|
5220
5236
|
id_to_a = rb_intern("to_a");
|
5221
5237
|
|
5222
|
-
|
5223
|
-
|
5224
|
-
|
5225
|
-
|
5238
|
+
/**
|
5239
|
+
* Document-class: Numo::UInt8
|
5240
|
+
*
|
5241
|
+
* 8-bit unsigned integer N-dimensional array class.
|
5242
|
+
*/
|
5226
5243
|
cT = rb_define_class_under(mNumo, "UInt8", cNArray);
|
5227
5244
|
|
5228
5245
|
hCast = rb_hash_new();
|
5246
|
+
/* Upcasting rules of UInt8. */
|
5229
5247
|
rb_define_const(cT, "UPCAST", hCast);
|
5230
5248
|
rb_hash_aset(hCast, rb_cArray, cT);
|
5231
5249
|
|
@@ -5252,15 +5270,15 @@ void Init_numo_uint8(void) {
|
|
5252
5270
|
rb_hash_aset(hCast, numo_cUInt8, cT);
|
5253
5271
|
rb_obj_freeze(hCast);
|
5254
5272
|
|
5255
|
-
|
5273
|
+
/* Element size of UInt8 in bits. */
|
5256
5274
|
rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
|
5257
|
-
|
5275
|
+
/* Element size of UInt8 in bytes. */
|
5258
5276
|
rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
|
5259
|
-
|
5277
|
+
/* Stride size of contiguous UInt8 array. */
|
5260
5278
|
rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
|
5261
|
-
|
5279
|
+
/* The largest representable value of UInt8. */
|
5262
5280
|
rb_define_const(cT, "MAX", M_MAX);
|
5263
|
-
|
5281
|
+
/* The smallest representable value of UInt8. */
|
5264
5282
|
rb_define_const(cT, "MIN", M_MIN);
|
5265
5283
|
rb_define_alloc_func(cT, uint8_s_alloc_func);
|
5266
5284
|
rb_define_method(cT, "allocate", uint8_allocate, 0);
|
@@ -5331,7 +5349,19 @@ void Init_numo_uint8(void) {
|
|
5331
5349
|
rb_define_method(cT, "argmax", uint8_argmax, -1);
|
5332
5350
|
rb_define_method(cT, "argmin", uint8_argmin, -1);
|
5333
5351
|
rb_define_method(cT, "minmax", uint8_minmax, -1);
|
5352
|
+
/**
|
5353
|
+
* Element-wise maximum of two arrays.
|
5354
|
+
* @overload maximum(a1, a2)
|
5355
|
+
* @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
|
5356
|
+
* @return [Numo::UInt8]
|
5357
|
+
*/
|
5334
5358
|
rb_define_module_function(cT, "maximum", uint8_s_maximum, -1);
|
5359
|
+
/**
|
5360
|
+
* Element-wise minimum of two arrays.
|
5361
|
+
* @overload minimum(a1, a2)
|
5362
|
+
* @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
|
5363
|
+
* @return [Numo::UInt8]
|
5364
|
+
*/
|
5335
5365
|
rb_define_module_function(cT, "minimum", uint8_s_minimum, -1);
|
5336
5366
|
rb_define_method(cT, "bincount", uint8_bincount, -1);
|
5337
5367
|
rb_define_method(cT, "cumsum", uint8_cumsum, -1);
|
@@ -5348,4 +5378,48 @@ void Init_numo_uint8(void) {
|
|
5348
5378
|
rb_define_method(cT, "sort_index", uint8_sort_index, -1);
|
5349
5379
|
rb_define_method(cT, "median", uint8_median, -1);
|
5350
5380
|
rb_define_singleton_method(cT, "[]", uint8_s_cast, -2);
|
5381
|
+
/**
|
5382
|
+
* mean of self.
|
5383
|
+
* @overload mean(axis: nil, keepdims: false, nan: false)
|
5384
|
+
* @param axis [Numeric, Array, Range] Performs mean along the axis.
|
5385
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5386
|
+
* dimensions with size one.
|
5387
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5388
|
+
* (avoid NaN for sum/mean etc, or return NaN for min/max etc).
|
5389
|
+
* @return [Numo::DFloat] returns result of mean.
|
5390
|
+
*/
|
5391
|
+
rb_define_method(cT, "mean", uint8_mean, -1);
|
5392
|
+
/**
|
5393
|
+
* var of self.
|
5394
|
+
* @overload var(axis: nil, keepdims: false, nan: false)
|
5395
|
+
* @param axis [Numeric, Array, Range] Performs var along the axis.
|
5396
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5397
|
+
* dimensions with size one.
|
5398
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5399
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5400
|
+
* @return [Numo::DFloat] returns result of var.
|
5401
|
+
*/
|
5402
|
+
rb_define_method(cT, "var", uint8_var, -1);
|
5403
|
+
/**
|
5404
|
+
* stddev of self.
|
5405
|
+
* @overload stddev(axis: nil, keepdims: false, nan: false)
|
5406
|
+
* @param axis [Numeric, Array, Range] Performs stddev along the axis.
|
5407
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5408
|
+
* dimensions with size one.
|
5409
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5410
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5411
|
+
* @return [Numo::DFloat] returns result of stddev.
|
5412
|
+
*/
|
5413
|
+
rb_define_method(cT, "stddev", uint8_stddev, -1);
|
5414
|
+
/**
|
5415
|
+
* rms of self.
|
5416
|
+
* @overload rms(axis: nil, keepdims: false, nan: false)
|
5417
|
+
* @param axis [Numeric, Array, Range] Performs rms along the axis.
|
5418
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5419
|
+
* dimensions with size one.
|
5420
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5421
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5422
|
+
* @return [Numo::DFloat] returns result of rms.
|
5423
|
+
*/
|
5424
|
+
rb_define_method(cT, "rms", uint8_rms, -1);
|
5351
5425
|
}
|