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
data/ext/numo/narray/src/t_bit.c
CHANGED
@@ -31,11 +31,15 @@ static ID id_to_a;
|
|
31
31
|
VALUE cT;
|
32
32
|
extern VALUE cRT;
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
#include "mh/mean.h"
|
35
|
+
#include "mh/var.h"
|
36
|
+
#include "mh/stddev.h"
|
37
|
+
#include "mh/rms.h"
|
37
38
|
|
38
|
-
|
39
|
+
DEF_NARRAY_BIT_MEAN_METHOD_FUNC()
|
40
|
+
DEF_NARRAY_BIT_VAR_METHOD_FUNC()
|
41
|
+
DEF_NARRAY_BIT_STDDEV_METHOD_FUNC()
|
42
|
+
DEF_NARRAY_BIT_RMS_METHOD_FUNC()
|
39
43
|
|
40
44
|
static VALUE bit_store(VALUE, VALUE);
|
41
45
|
|
@@ -139,9 +143,9 @@ static VALUE bit_allocate(VALUE self) {
|
|
139
143
|
/*
|
140
144
|
Extract an element only if self is a dimensionless NArray.
|
141
145
|
@overload extract
|
142
|
-
|
143
|
-
|
144
|
-
|
146
|
+
@return [Numeric,Numo::NArray]
|
147
|
+
--- Extract element value as Ruby Object if self is a dimensionless NArray,
|
148
|
+
otherwise returns self.
|
145
149
|
*/
|
146
150
|
|
147
151
|
static VALUE bit_extract(VALUE self) {
|
@@ -255,8 +259,8 @@ static void iter_bit_store_bit(na_loop_t* const lp) {
|
|
255
259
|
}
|
256
260
|
|
257
261
|
static VALUE bit_store_bit(VALUE self, VALUE obj) {
|
258
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
259
|
-
ndfunc_t ndf = {iter_bit_store_bit, FULL_LOOP, 2, 0, ain, 0};
|
262
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
263
|
+
ndfunc_t ndf = { iter_bit_store_bit, FULL_LOOP, 2, 0, ain, 0 };
|
260
264
|
|
261
265
|
na_ndloop(&ndf, 2, self, obj);
|
262
266
|
return self;
|
@@ -311,8 +315,8 @@ static void iter_bit_store_dfloat(na_loop_t* const lp) {
|
|
311
315
|
}
|
312
316
|
|
313
317
|
static VALUE bit_store_dfloat(VALUE self, VALUE obj) {
|
314
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
315
|
-
ndfunc_t ndf = {iter_bit_store_dfloat, FULL_LOOP, 2, 0, ain, 0};
|
318
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
319
|
+
ndfunc_t ndf = { iter_bit_store_dfloat, FULL_LOOP, 2, 0, ain, 0 };
|
316
320
|
|
317
321
|
na_ndloop(&ndf, 2, self, obj);
|
318
322
|
return self;
|
@@ -367,8 +371,8 @@ static void iter_bit_store_sfloat(na_loop_t* const lp) {
|
|
367
371
|
}
|
368
372
|
|
369
373
|
static VALUE bit_store_sfloat(VALUE self, VALUE obj) {
|
370
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
371
|
-
ndfunc_t ndf = {iter_bit_store_sfloat, FULL_LOOP, 2, 0, ain, 0};
|
374
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
375
|
+
ndfunc_t ndf = { iter_bit_store_sfloat, FULL_LOOP, 2, 0, ain, 0 };
|
372
376
|
|
373
377
|
na_ndloop(&ndf, 2, self, obj);
|
374
378
|
return self;
|
@@ -423,8 +427,8 @@ static void iter_bit_store_int64(na_loop_t* const lp) {
|
|
423
427
|
}
|
424
428
|
|
425
429
|
static VALUE bit_store_int64(VALUE self, VALUE obj) {
|
426
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
427
|
-
ndfunc_t ndf = {iter_bit_store_int64, FULL_LOOP, 2, 0, ain, 0};
|
430
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
431
|
+
ndfunc_t ndf = { iter_bit_store_int64, FULL_LOOP, 2, 0, ain, 0 };
|
428
432
|
|
429
433
|
na_ndloop(&ndf, 2, self, obj);
|
430
434
|
return self;
|
@@ -479,8 +483,8 @@ static void iter_bit_store_int32(na_loop_t* const lp) {
|
|
479
483
|
}
|
480
484
|
|
481
485
|
static VALUE bit_store_int32(VALUE self, VALUE obj) {
|
482
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
483
|
-
ndfunc_t ndf = {iter_bit_store_int32, FULL_LOOP, 2, 0, ain, 0};
|
486
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
487
|
+
ndfunc_t ndf = { iter_bit_store_int32, FULL_LOOP, 2, 0, ain, 0 };
|
484
488
|
|
485
489
|
na_ndloop(&ndf, 2, self, obj);
|
486
490
|
return self;
|
@@ -535,8 +539,8 @@ static void iter_bit_store_int16(na_loop_t* const lp) {
|
|
535
539
|
}
|
536
540
|
|
537
541
|
static VALUE bit_store_int16(VALUE self, VALUE obj) {
|
538
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
539
|
-
ndfunc_t ndf = {iter_bit_store_int16, FULL_LOOP, 2, 0, ain, 0};
|
542
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
543
|
+
ndfunc_t ndf = { iter_bit_store_int16, FULL_LOOP, 2, 0, ain, 0 };
|
540
544
|
|
541
545
|
na_ndloop(&ndf, 2, self, obj);
|
542
546
|
return self;
|
@@ -591,8 +595,8 @@ static void iter_bit_store_int8(na_loop_t* const lp) {
|
|
591
595
|
}
|
592
596
|
|
593
597
|
static VALUE bit_store_int8(VALUE self, VALUE obj) {
|
594
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
595
|
-
ndfunc_t ndf = {iter_bit_store_int8, FULL_LOOP, 2, 0, ain, 0};
|
598
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
599
|
+
ndfunc_t ndf = { iter_bit_store_int8, FULL_LOOP, 2, 0, ain, 0 };
|
596
600
|
|
597
601
|
na_ndloop(&ndf, 2, self, obj);
|
598
602
|
return self;
|
@@ -647,8 +651,8 @@ static void iter_bit_store_uint64(na_loop_t* const lp) {
|
|
647
651
|
}
|
648
652
|
|
649
653
|
static VALUE bit_store_uint64(VALUE self, VALUE obj) {
|
650
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
651
|
-
ndfunc_t ndf = {iter_bit_store_uint64, FULL_LOOP, 2, 0, ain, 0};
|
654
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
655
|
+
ndfunc_t ndf = { iter_bit_store_uint64, FULL_LOOP, 2, 0, ain, 0 };
|
652
656
|
|
653
657
|
na_ndloop(&ndf, 2, self, obj);
|
654
658
|
return self;
|
@@ -703,8 +707,8 @@ static void iter_bit_store_uint32(na_loop_t* const lp) {
|
|
703
707
|
}
|
704
708
|
|
705
709
|
static VALUE bit_store_uint32(VALUE self, VALUE obj) {
|
706
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
707
|
-
ndfunc_t ndf = {iter_bit_store_uint32, FULL_LOOP, 2, 0, ain, 0};
|
710
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
711
|
+
ndfunc_t ndf = { iter_bit_store_uint32, FULL_LOOP, 2, 0, ain, 0 };
|
708
712
|
|
709
713
|
na_ndloop(&ndf, 2, self, obj);
|
710
714
|
return self;
|
@@ -759,8 +763,8 @@ static void iter_bit_store_uint16(na_loop_t* const lp) {
|
|
759
763
|
}
|
760
764
|
|
761
765
|
static VALUE bit_store_uint16(VALUE self, VALUE obj) {
|
762
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
763
|
-
ndfunc_t ndf = {iter_bit_store_uint16, FULL_LOOP, 2, 0, ain, 0};
|
766
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
767
|
+
ndfunc_t ndf = { iter_bit_store_uint16, FULL_LOOP, 2, 0, ain, 0 };
|
764
768
|
|
765
769
|
na_ndloop(&ndf, 2, self, obj);
|
766
770
|
return self;
|
@@ -815,8 +819,8 @@ static void iter_bit_store_uint8(na_loop_t* const lp) {
|
|
815
819
|
}
|
816
820
|
|
817
821
|
static VALUE bit_store_uint8(VALUE self, VALUE obj) {
|
818
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
819
|
-
ndfunc_t ndf = {iter_bit_store_uint8, FULL_LOOP, 2, 0, ain, 0};
|
822
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
823
|
+
ndfunc_t ndf = { iter_bit_store_uint8, FULL_LOOP, 2, 0, ain, 0 };
|
820
824
|
|
821
825
|
na_ndloop(&ndf, 2, self, obj);
|
822
826
|
return self;
|
@@ -871,8 +875,8 @@ static void iter_bit_store_robject(na_loop_t* const lp) {
|
|
871
875
|
}
|
872
876
|
|
873
877
|
static VALUE bit_store_robject(VALUE self, VALUE obj) {
|
874
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
875
|
-
ndfunc_t ndf = {iter_bit_store_robject, FULL_LOOP, 2, 0, ain, 0};
|
878
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
879
|
+
ndfunc_t ndf = { iter_bit_store_robject, FULL_LOOP, 2, 0, ain, 0 };
|
876
880
|
|
877
881
|
na_ndloop(&ndf, 2, self, obj);
|
878
882
|
return self;
|
@@ -990,8 +994,8 @@ loop_end:
|
|
990
994
|
}
|
991
995
|
|
992
996
|
static VALUE bit_store_array(VALUE self, VALUE rary) {
|
993
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {rb_cArray, 0}};
|
994
|
-
ndfunc_t ndf = {iter_bit_store_array, FULL_LOOP, 2, 0, ain, 0};
|
997
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { rb_cArray, 0 } };
|
998
|
+
ndfunc_t ndf = { iter_bit_store_array, FULL_LOOP, 2, 0, ain, 0 };
|
995
999
|
|
996
1000
|
na_ndloop_store_rarray(&ndf, self, rary);
|
997
1001
|
return self;
|
@@ -1000,8 +1004,8 @@ static VALUE bit_store_array(VALUE self, VALUE rary) {
|
|
1000
1004
|
/*
|
1001
1005
|
Store elements to Numo::Bit from other.
|
1002
1006
|
@overload store(other)
|
1003
|
-
|
1004
|
-
|
1007
|
+
@param [Object] other
|
1008
|
+
@return [Numo::Bit] self
|
1005
1009
|
*/
|
1006
1010
|
static VALUE bit_store(VALUE self, VALUE obj) {
|
1007
1011
|
VALUE r, klass;
|
@@ -1086,8 +1090,10 @@ static VALUE bit_store(VALUE self, VALUE obj) {
|
|
1086
1090
|
}
|
1087
1091
|
}
|
1088
1092
|
|
1089
|
-
rb_raise(
|
1090
|
-
|
1093
|
+
rb_raise(
|
1094
|
+
nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
|
1095
|
+
rb_class2name(rb_obj_class(self))
|
1096
|
+
);
|
1091
1097
|
|
1092
1098
|
return self;
|
1093
1099
|
}
|
@@ -1181,7 +1187,10 @@ static dtype bit_extract_data(VALUE obj) {
|
|
1181
1187
|
return bit_extract_data(r);
|
1182
1188
|
}
|
1183
1189
|
|
1184
|
-
rb_raise(
|
1190
|
+
rb_raise(
|
1191
|
+
nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
|
1192
|
+
rb_class2name(cT)
|
1193
|
+
);
|
1185
1194
|
}
|
1186
1195
|
if (TYPE(obj) == T_ARRAY) {
|
1187
1196
|
if (RARRAY_LEN(obj) != 1) {
|
@@ -1208,9 +1217,9 @@ static VALUE bit_cast_array(VALUE rary) {
|
|
1208
1217
|
Cast object to Numo::Bit.
|
1209
1218
|
@overload [](elements)
|
1210
1219
|
@overload cast(array)
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1220
|
+
@param [Numeric,Array] elements
|
1221
|
+
@param [Array] array
|
1222
|
+
@return [Numo::Bit]
|
1214
1223
|
*/
|
1215
1224
|
static VALUE bit_s_cast(VALUE type, VALUE obj) {
|
1216
1225
|
VALUE v;
|
@@ -1250,9 +1259,9 @@ static VALUE bit_s_cast(VALUE type, VALUE obj) {
|
|
1250
1259
|
/*
|
1251
1260
|
Multi-dimensional element reference.
|
1252
1261
|
@overload [](dim0,...,dimL)
|
1253
|
-
|
1254
|
-
indices.
|
1255
|
-
|
1262
|
+
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
|
1263
|
+
dim0,...,dimL multi-dimensional indices.
|
1264
|
+
@return [Numeric,Numo::Bit] an element or NArray view.
|
1256
1265
|
@see Numo::NArray#[]
|
1257
1266
|
@see #[]=
|
1258
1267
|
|
@@ -1297,10 +1306,10 @@ static VALUE bit_aref(int argc, VALUE* argv, VALUE self) {
|
|
1297
1306
|
/*
|
1298
1307
|
Multi-dimensional element assignment.
|
1299
1308
|
@overload []=(dim0,...,dimL,val)
|
1300
|
-
|
1301
|
-
indices.
|
1302
|
-
|
1303
|
-
|
1309
|
+
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
|
1310
|
+
dim0,...,dimL multi-dimensional indices.
|
1311
|
+
@param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
|
1312
|
+
@return [Numeric,Numo::NArray,Array] returns `val` (last argument).
|
1304
1313
|
@see Numo::NArray#[]=
|
1305
1314
|
@see #[]
|
1306
1315
|
|
@@ -1347,7 +1356,7 @@ static VALUE bit_aset(int argc, VALUE* argv, VALUE self) {
|
|
1347
1356
|
/*
|
1348
1357
|
return NArray with cast to the type of self.
|
1349
1358
|
@overload coerce_cast(type)
|
1350
|
-
|
1359
|
+
@return [nil]
|
1351
1360
|
*/
|
1352
1361
|
static VALUE bit_coerce_cast(VALUE self, VALUE type) {
|
1353
1362
|
return Qnil;
|
@@ -1386,12 +1395,12 @@ static void iter_bit_to_a(na_loop_t* const lp) {
|
|
1386
1395
|
/*
|
1387
1396
|
Convert self to Array.
|
1388
1397
|
@overload to_a
|
1389
|
-
|
1398
|
+
@return [Array]
|
1390
1399
|
*/
|
1391
1400
|
static VALUE bit_to_a(VALUE self) {
|
1392
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
|
1393
|
-
ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
|
1394
|
-
ndfunc_t ndf = {iter_bit_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
|
1401
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
|
1402
|
+
ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
|
1403
|
+
ndfunc_t ndf = { iter_bit_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
|
1395
1404
|
return na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
|
1396
1405
|
}
|
1397
1406
|
|
@@ -1447,12 +1456,12 @@ static void iter_bit_fill(na_loop_t* const lp) {
|
|
1447
1456
|
/*
|
1448
1457
|
Fill elements with other.
|
1449
1458
|
@overload fill other
|
1450
|
-
|
1451
|
-
|
1459
|
+
@param [Numeric] other
|
1460
|
+
@return [Numo::Bit] self.
|
1452
1461
|
*/
|
1453
1462
|
static VALUE bit_fill(VALUE self, VALUE val) {
|
1454
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_option}};
|
1455
|
-
ndfunc_t ndf = {iter_bit_fill, FULL_LOOP, 2, 0, ain, 0};
|
1463
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
|
1464
|
+
ndfunc_t ndf = { iter_bit_fill, FULL_LOOP, 2, 0, ain, 0 };
|
1456
1465
|
|
1457
1466
|
na_ndloop(&ndf, 2, self, val);
|
1458
1467
|
return self;
|
@@ -1502,15 +1511,15 @@ static void iter_bit_format(na_loop_t* const lp) {
|
|
1502
1511
|
/*
|
1503
1512
|
Format elements into strings.
|
1504
1513
|
@overload format format
|
1505
|
-
|
1506
|
-
|
1514
|
+
@param [String] format
|
1515
|
+
@return [Numo::RObject] array of formatted strings.
|
1507
1516
|
*/
|
1508
1517
|
static VALUE bit_format(int argc, VALUE* argv, VALUE self) {
|
1509
1518
|
VALUE fmt = Qnil;
|
1510
1519
|
|
1511
|
-
ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_option}};
|
1512
|
-
ndfunc_arg_out_t aout[1] = {{numo_cRObject, 0}};
|
1513
|
-
ndfunc_t ndf = {iter_bit_format, FULL_LOOP_NIP, 2, 1, ain, aout};
|
1520
|
+
ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_option } };
|
1521
|
+
ndfunc_arg_out_t aout[1] = { { numo_cRObject, 0 } };
|
1522
|
+
ndfunc_t ndf = { iter_bit_format, FULL_LOOP_NIP, 2, 1, ain, aout };
|
1514
1523
|
|
1515
1524
|
rb_scan_args(argc, argv, "01", &fmt);
|
1516
1525
|
return na_ndloop(&ndf, 2, self, fmt);
|
@@ -1550,14 +1559,14 @@ static void iter_bit_format_to_a(na_loop_t* const lp) {
|
|
1550
1559
|
/*
|
1551
1560
|
Format elements into strings.
|
1552
1561
|
@overload format_to_a format
|
1553
|
-
|
1554
|
-
|
1562
|
+
@param [String] format
|
1563
|
+
@return [Array] array of formatted strings.
|
1555
1564
|
*/
|
1556
1565
|
static VALUE bit_format_to_a(int argc, VALUE* argv, VALUE self) {
|
1557
1566
|
VALUE fmt = Qnil;
|
1558
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
|
1559
|
-
ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
|
1560
|
-
ndfunc_t ndf = {iter_bit_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
|
1567
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
|
1568
|
+
ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
|
1569
|
+
ndfunc_t ndf = { iter_bit_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
|
1561
1570
|
|
1562
1571
|
rb_scan_args(argc, argv, "01", &fmt);
|
1563
1572
|
return na_ndloop_cast_narray_to_rarray(&ndf, self, fmt);
|
@@ -1572,7 +1581,7 @@ static VALUE iter_bit_inspect(char* ptr, size_t pos, VALUE fmt) {
|
|
1572
1581
|
/*
|
1573
1582
|
Returns a string containing a human-readable representation of NArray.
|
1574
1583
|
@overload inspect
|
1575
|
-
|
1584
|
+
@return [String]
|
1576
1585
|
*/
|
1577
1586
|
static VALUE bit_inspect(VALUE ary) {
|
1578
1587
|
return na_ndloop_inspect(ary, iter_bit_inspect, Qnil);
|
@@ -1609,13 +1618,13 @@ static void iter_bit_each(na_loop_t* const lp) {
|
|
1609
1618
|
Calls the given block once for each element in self,
|
1610
1619
|
passing that element as a parameter.
|
1611
1620
|
@overload each
|
1612
|
-
|
1613
|
-
|
1614
|
-
|
1621
|
+
@return [Numo::NArray] self
|
1622
|
+
For a block {|x| ... }
|
1623
|
+
@yield [x] x is element of NArray.
|
1615
1624
|
*/
|
1616
1625
|
static VALUE bit_each(VALUE self) {
|
1617
|
-
ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
|
1618
|
-
ndfunc_t ndf = {iter_bit_each, FULL_LOOP_NIP, 1, 0, ain, 0};
|
1626
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1627
|
+
ndfunc_t ndf = { iter_bit_each, FULL_LOOP_NIP, 1, 0, ain, 0 };
|
1619
1628
|
|
1620
1629
|
na_ndloop(&ndf, 1, self);
|
1621
1630
|
return self;
|
@@ -1671,13 +1680,13 @@ static void iter_bit_each_with_index(na_loop_t* const lp) {
|
|
1671
1680
|
Invokes the given block once for each element of self,
|
1672
1681
|
passing that element and indices along each axis as parameters.
|
1673
1682
|
@overload each_with_index
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1683
|
+
@return [Numo::NArray] self
|
1684
|
+
For a block {|x,i,j,...| ... }
|
1685
|
+
@yield [x,i,j,...] x is an element, i,j,... are multidimensional indices.
|
1677
1686
|
*/
|
1678
1687
|
static VALUE bit_each_with_index(VALUE self) {
|
1679
|
-
ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
|
1680
|
-
ndfunc_t ndf = {iter_bit_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0};
|
1688
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1689
|
+
ndfunc_t ndf = { iter_bit_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0 };
|
1681
1690
|
|
1682
1691
|
na_ndloop_with_index(&ndf, 1, self);
|
1683
1692
|
return self;
|
@@ -1767,12 +1776,12 @@ static void iter_bit_copy(na_loop_t* const lp) {
|
|
1767
1776
|
/*
|
1768
1777
|
Unary copy.
|
1769
1778
|
@overload copy
|
1770
|
-
|
1779
|
+
@return [Numo::Bit] copy of self.
|
1771
1780
|
*/
|
1772
1781
|
static VALUE bit_copy(VALUE self) {
|
1773
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
1774
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1775
|
-
ndfunc_t ndf = {iter_bit_copy, FULL_LOOP, 1, 1, ain, aout};
|
1782
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
1783
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1784
|
+
ndfunc_t ndf = { iter_bit_copy, FULL_LOOP, 1, 1, ain, aout };
|
1776
1785
|
|
1777
1786
|
return na_ndloop(&ndf, 1, self);
|
1778
1787
|
}
|
@@ -1861,12 +1870,12 @@ static void iter_bit_not(na_loop_t* const lp) {
|
|
1861
1870
|
/*
|
1862
1871
|
Unary not.
|
1863
1872
|
@overload not
|
1864
|
-
|
1873
|
+
@return [Numo::Bit] not of self.
|
1865
1874
|
*/
|
1866
1875
|
static VALUE bit_not(VALUE self) {
|
1867
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
1868
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1869
|
-
ndfunc_t ndf = {iter_bit_not, FULL_LOOP, 1, 1, ain, aout};
|
1876
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
1877
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1878
|
+
ndfunc_t ndf = { iter_bit_not, FULL_LOOP, 1, 1, ain, aout };
|
1870
1879
|
|
1871
1880
|
return na_ndloop(&ndf, 1, self);
|
1872
1881
|
}
|
@@ -1989,13 +1998,13 @@ static void iter_bit_and(na_loop_t* const lp) {
|
|
1989
1998
|
/*
|
1990
1999
|
Binary and.
|
1991
2000
|
@overload & other
|
1992
|
-
|
1993
|
-
|
2001
|
+
@param [Numo::NArray,Numeric] other
|
2002
|
+
@return [Numo::NArray] and of self and other.
|
1994
2003
|
*/
|
1995
2004
|
static VALUE bit_and(VALUE self, VALUE other) {
|
1996
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
1997
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1998
|
-
ndfunc_t ndf = {iter_bit_and, FULL_LOOP, 2, 1, ain, aout};
|
2005
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2006
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2007
|
+
ndfunc_t ndf = { iter_bit_and, FULL_LOOP, 2, 1, ain, aout };
|
1999
2008
|
|
2000
2009
|
return na_ndloop(&ndf, 2, self, other);
|
2001
2010
|
}
|
@@ -2118,13 +2127,13 @@ static void iter_bit_or(na_loop_t* const lp) {
|
|
2118
2127
|
/*
|
2119
2128
|
Binary or.
|
2120
2129
|
@overload | other
|
2121
|
-
|
2122
|
-
|
2130
|
+
@param [Numo::NArray,Numeric] other
|
2131
|
+
@return [Numo::NArray] or of self and other.
|
2123
2132
|
*/
|
2124
2133
|
static VALUE bit_or(VALUE self, VALUE other) {
|
2125
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2126
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2127
|
-
ndfunc_t ndf = {iter_bit_or, FULL_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_bit_or, FULL_LOOP, 2, 1, ain, aout };
|
2128
2137
|
|
2129
2138
|
return na_ndloop(&ndf, 2, self, other);
|
2130
2139
|
}
|
@@ -2247,13 +2256,13 @@ static void iter_bit_xor(na_loop_t* const lp) {
|
|
2247
2256
|
/*
|
2248
2257
|
Binary xor.
|
2249
2258
|
@overload ^ other
|
2250
|
-
|
2251
|
-
|
2259
|
+
@param [Numo::NArray,Numeric] other
|
2260
|
+
@return [Numo::NArray] xor of self and other.
|
2252
2261
|
*/
|
2253
2262
|
static VALUE bit_xor(VALUE self, VALUE other) {
|
2254
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2255
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2256
|
-
ndfunc_t ndf = {iter_bit_xor, FULL_LOOP, 2, 1, ain, aout};
|
2263
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2264
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2265
|
+
ndfunc_t ndf = { iter_bit_xor, FULL_LOOP, 2, 1, ain, aout };
|
2257
2266
|
|
2258
2267
|
return na_ndloop(&ndf, 2, self, other);
|
2259
2268
|
}
|
@@ -2376,13 +2385,13 @@ static void iter_bit_eq(na_loop_t* const lp) {
|
|
2376
2385
|
/*
|
2377
2386
|
Binary eq.
|
2378
2387
|
@overload eq other
|
2379
|
-
|
2380
|
-
|
2388
|
+
@param [Numo::NArray,Numeric] other
|
2389
|
+
@return [Numo::NArray] eq of self and other.
|
2381
2390
|
*/
|
2382
2391
|
static VALUE bit_eq(VALUE self, VALUE other) {
|
2383
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2384
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2385
|
-
ndfunc_t ndf = {iter_bit_eq, FULL_LOOP, 2, 1, ain, aout};
|
2392
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2393
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2394
|
+
ndfunc_t ndf = { iter_bit_eq, FULL_LOOP, 2, 1, ain, aout };
|
2386
2395
|
|
2387
2396
|
return na_ndloop(&ndf, 2, self, other);
|
2388
2397
|
}
|
@@ -2454,16 +2463,17 @@ static void iter_bit_count_true(na_loop_t* const lp) {
|
|
2454
2463
|
Returns the number of bits.
|
2455
2464
|
If argument is supplied, return Int-array counted along the axes.
|
2456
2465
|
@overload count_true(axis:nil, keepdims:false)
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2466
|
+
@param [Integer,Array,Range] axis (keyword) axes to be counted.
|
2467
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
2468
|
+
as dimensions with size one.
|
2469
|
+
@return [Numo::Int64]
|
2460
2470
|
*/
|
2461
2471
|
static VALUE bit_count_true(int argc, VALUE* argv, VALUE self) {
|
2462
2472
|
VALUE v, reduce;
|
2463
2473
|
narray_t* na;
|
2464
|
-
ndfunc_arg_in_t ain[3] = {{cT, 0}, {sym_reduce, 0}, {sym_init, 0}};
|
2465
|
-
ndfunc_arg_out_t aout[1] = {{numo_cInt64, 0}};
|
2466
|
-
ndfunc_t ndf = {iter_bit_count_true, FULL_LOOP_NIP, 3, 1, ain, aout};
|
2474
|
+
ndfunc_arg_in_t ain[3] = { { cT, 0 }, { sym_reduce, 0 }, { sym_init, 0 } };
|
2475
|
+
ndfunc_arg_out_t aout[1] = { { numo_cInt64, 0 } };
|
2476
|
+
ndfunc_t ndf = { iter_bit_count_true, FULL_LOOP_NIP, 3, 1, ain, aout };
|
2467
2477
|
|
2468
2478
|
GetNArray(self, na);
|
2469
2479
|
if (NA_SIZE(na) == 0) {
|
@@ -2541,16 +2551,17 @@ static void iter_bit_count_false(na_loop_t* const lp) {
|
|
2541
2551
|
Returns the number of bits.
|
2542
2552
|
If argument is supplied, return Int-array counted along the axes.
|
2543
2553
|
@overload count_false(axis:nil, keepdims:false)
|
2544
|
-
|
2545
|
-
|
2546
|
-
|
2554
|
+
@param [Integer,Array,Range] axis (keyword) axes to be counted.
|
2555
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
2556
|
+
as dimensions with size one.
|
2557
|
+
@return [Numo::Int64]
|
2547
2558
|
*/
|
2548
2559
|
static VALUE bit_count_false(int argc, VALUE* argv, VALUE self) {
|
2549
2560
|
VALUE v, reduce;
|
2550
2561
|
narray_t* na;
|
2551
|
-
ndfunc_arg_in_t ain[3] = {{cT, 0}, {sym_reduce, 0}, {sym_init, 0}};
|
2552
|
-
ndfunc_arg_out_t aout[1] = {{numo_cInt64, 0}};
|
2553
|
-
ndfunc_t ndf = {iter_bit_count_false, FULL_LOOP_NIP, 3, 1, ain, aout};
|
2562
|
+
ndfunc_arg_in_t ain[3] = { { cT, 0 }, { sym_reduce, 0 }, { sym_init, 0 } };
|
2563
|
+
ndfunc_arg_out_t aout[1] = { { numo_cInt64, 0 } };
|
2564
|
+
ndfunc_t ndf = { iter_bit_count_false, FULL_LOOP_NIP, 3, 1, ain, aout };
|
2554
2565
|
|
2555
2566
|
GetNArray(self, na);
|
2556
2567
|
if (NA_SIZE(na) == 0) {
|
@@ -2655,16 +2666,17 @@ static void iter_bit_all_p(na_loop_t* const lp) {
|
|
2655
2666
|
Return true if all of bits are one (true).
|
2656
2667
|
If argument is supplied, return Bit-array reduced along the axes.
|
2657
2668
|
@overload all?(axis:nil, keepdims:false)
|
2658
|
-
|
2659
|
-
|
2660
|
-
|
2669
|
+
@param [Integer,Array,Range] axis (keyword) axes to be reduced.
|
2670
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
2671
|
+
as dimensions with size one.
|
2672
|
+
@return [Numo::Bit] .
|
2661
2673
|
*/
|
2662
2674
|
static VALUE bit_all_p(int argc, VALUE* argv, VALUE self) {
|
2663
2675
|
VALUE v, reduce;
|
2664
2676
|
narray_t* na;
|
2665
|
-
ndfunc_arg_in_t ain[3] = {{cT, 0}, {sym_reduce, 0}, {sym_init, 0}};
|
2666
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
2667
|
-
ndfunc_t ndf = {iter_bit_all_p, FULL_LOOP_NIP, 3, 1, ain, aout};
|
2677
|
+
ndfunc_arg_in_t ain[3] = { { cT, 0 }, { sym_reduce, 0 }, { sym_init, 0 } };
|
2678
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
2679
|
+
ndfunc_t ndf = { iter_bit_all_p, FULL_LOOP_NIP, 3, 1, ain, aout };
|
2668
2680
|
|
2669
2681
|
GetNArray(self, na);
|
2670
2682
|
if (NA_SIZE(na) == 0) {
|
@@ -2782,16 +2794,17 @@ static void iter_bit_any_p(na_loop_t* const lp) {
|
|
2782
2794
|
Return true if any of bits is one (true).
|
2783
2795
|
If argument is supplied, return Bit-array reduced along the axes.
|
2784
2796
|
@overload any?(axis:nil, keepdims:false)
|
2785
|
-
|
2786
|
-
|
2787
|
-
|
2797
|
+
@param [Integer,Array,Range] axis (keyword) axes to be reduced.
|
2798
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
2799
|
+
as dimensions with size one.
|
2800
|
+
@return [Numo::Bit] .
|
2788
2801
|
*/
|
2789
2802
|
static VALUE bit_any_p(int argc, VALUE* argv, VALUE self) {
|
2790
2803
|
VALUE v, reduce;
|
2791
2804
|
narray_t* na;
|
2792
|
-
ndfunc_arg_in_t ain[3] = {{cT, 0}, {sym_reduce, 0}, {sym_init, 0}};
|
2793
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
2794
|
-
ndfunc_t ndf = {iter_bit_any_p, FULL_LOOP_NIP, 3, 1, ain, aout};
|
2805
|
+
ndfunc_arg_in_t ain[3] = { { cT, 0 }, { sym_reduce, 0 }, { sym_init, 0 } };
|
2806
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
2807
|
+
ndfunc_t ndf = { iter_bit_any_p, FULL_LOOP_NIP, 3, 1, ain, aout };
|
2795
2808
|
|
2796
2809
|
GetNArray(self, na);
|
2797
2810
|
if (NA_SIZE(na) == 0) {
|
@@ -2882,15 +2895,15 @@ static void iter_bit_where(na_loop_t* const lp) {
|
|
2882
2895
|
/*
|
2883
2896
|
Returns the array of index where the bit is one (true).
|
2884
2897
|
@overload where
|
2885
|
-
|
2898
|
+
@return [Numo::Int32,Numo::Int64]
|
2886
2899
|
*/
|
2887
2900
|
static VALUE bit_where(VALUE self) {
|
2888
2901
|
volatile VALUE idx_1;
|
2889
2902
|
size_t size, n_1;
|
2890
2903
|
where_opt_t* g;
|
2891
2904
|
|
2892
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2893
|
-
ndfunc_t ndf = {iter_bit_where, FULL_LOOP, 1, 0, ain, 0};
|
2905
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2906
|
+
ndfunc_t ndf = { iter_bit_where, FULL_LOOP, 1, 0, ain, 0 };
|
2894
2907
|
|
2895
2908
|
size = RNARRAY_SIZE(self);
|
2896
2909
|
n_1 = NUM2SIZET(bit_count_true(0, NULL, self));
|
@@ -2966,15 +2979,15 @@ static void iter_bit_where2(na_loop_t* const lp) {
|
|
2966
2979
|
The first array contains index where the bit is one (true).
|
2967
2980
|
The second array contains index where the bit is zero (false).
|
2968
2981
|
@overload where2
|
2969
|
-
|
2982
|
+
@return [Numo::Int32,Numo::Int64]*2
|
2970
2983
|
*/
|
2971
2984
|
static VALUE bit_where2(VALUE self) {
|
2972
2985
|
VALUE idx_1, idx_0;
|
2973
2986
|
size_t size, n_1, n_0;
|
2974
2987
|
where_opt_t* g;
|
2975
2988
|
|
2976
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2977
|
-
ndfunc_t ndf = {iter_bit_where2, FULL_LOOP, 1, 0, ain, 0};
|
2989
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2990
|
+
ndfunc_t ndf = { iter_bit_where2, FULL_LOOP, 1, 0, ain, 0 };
|
2978
2991
|
|
2979
2992
|
size = RNARRAY_SIZE(self);
|
2980
2993
|
n_1 = NUM2SIZET(bit_count_true(0, NULL, self));
|
@@ -3080,8 +3093,8 @@ static void shape_error(void) {
|
|
3080
3093
|
/*
|
3081
3094
|
Return subarray of argument masked with self bit array.
|
3082
3095
|
@overload mask(array)
|
3083
|
-
|
3084
|
-
|
3096
|
+
@param [Numo::NArray] array narray to be masked.
|
3097
|
+
@return [Numo::NArray] view of masked array.
|
3085
3098
|
*/
|
3086
3099
|
static VALUE bit_mask(VALUE mask, VALUE val) {
|
3087
3100
|
int i;
|
@@ -3092,8 +3105,8 @@ static VALUE bit_mask(VALUE mask, VALUE val) {
|
|
3092
3105
|
stridx_t stridx0;
|
3093
3106
|
size_t n_1;
|
3094
3107
|
where_opt_t g;
|
3095
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {Qnil, 0}};
|
3096
|
-
ndfunc_t ndf = {iter_bit_mask, FULL_LOOP, 2, 0, ain, 0};
|
3108
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { Qnil, 0 } };
|
3109
|
+
ndfunc_t ndf = { iter_bit_mask, FULL_LOOP, 2, 0, ain, 0 };
|
3097
3110
|
|
3098
3111
|
// cast val to NArray
|
3099
3112
|
if (!rb_obj_is_kind_of(val, numo_cNArray)) {
|
@@ -3159,13 +3172,15 @@ void Init_numo_bit(void) {
|
|
3159
3172
|
id_ne = rb_intern("ne");
|
3160
3173
|
id_to_a = rb_intern("to_a");
|
3161
3174
|
|
3162
|
-
|
3163
|
-
|
3164
|
-
|
3165
|
-
|
3175
|
+
/**
|
3176
|
+
* Document-class: Numo::Bit
|
3177
|
+
*
|
3178
|
+
* Binary digit (bit) N-dimensional array class.
|
3179
|
+
*/
|
3166
3180
|
cT = rb_define_class_under(mNumo, "Bit", cNArray);
|
3167
3181
|
|
3168
3182
|
hCast = rb_hash_new();
|
3183
|
+
/* Upcasting rules of Bit. */
|
3169
3184
|
rb_define_const(cT, "UPCAST", hCast);
|
3170
3185
|
rb_hash_aset(hCast, rb_cArray, cT);
|
3171
3186
|
|
@@ -3192,11 +3207,11 @@ void Init_numo_bit(void) {
|
|
3192
3207
|
rb_hash_aset(hCast, numo_cUInt8, numo_cUInt8);
|
3193
3208
|
rb_obj_freeze(hCast);
|
3194
3209
|
|
3195
|
-
|
3210
|
+
/* Element size of Bit in bits. */
|
3196
3211
|
rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(1));
|
3197
|
-
|
3212
|
+
/* Element size of Bit in bytes. */
|
3198
3213
|
rb_define_const(cT, "ELEMENT_BYTE_SIZE", rb_float_new(1.0 / 8));
|
3199
|
-
|
3214
|
+
/* Stride size of contiguous Bit array. */
|
3200
3215
|
rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(1));
|
3201
3216
|
rb_define_alloc_func(cT, bit_s_alloc_func);
|
3202
3217
|
rb_define_method(cT, "allocate", bit_allocate, 0);
|
@@ -3233,4 +3248,48 @@ void Init_numo_bit(void) {
|
|
3233
3248
|
rb_define_method(cT, "where2", bit_where2, 0);
|
3234
3249
|
rb_define_method(cT, "mask", bit_mask, 1);
|
3235
3250
|
rb_define_singleton_method(cT, "[]", bit_s_cast, -2);
|
3251
|
+
/**
|
3252
|
+
* mean of self.
|
3253
|
+
* @overload mean(axis: nil, keepdims: false, nan: false)
|
3254
|
+
* @param axis [Numeric, Array, Range] Performs mean along the axis.
|
3255
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
3256
|
+
* dimensions with size one.
|
3257
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
3258
|
+
* (avoid NaN for sum/mean etc, or return NaN for min/max etc).
|
3259
|
+
* @return [Numo::DFloat] returns result of mean.
|
3260
|
+
*/
|
3261
|
+
rb_define_method(cT, "mean", bit_mean, -1);
|
3262
|
+
/**
|
3263
|
+
* var of self.
|
3264
|
+
* @overload var(axis: nil, keepdims: false, nan: false)
|
3265
|
+
* @param axis [Numeric, Array, Range] Performs var along the axis.
|
3266
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
3267
|
+
* dimensions with size one.
|
3268
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
3269
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
3270
|
+
* @return [Numo::DFloat] returns result of var.
|
3271
|
+
*/
|
3272
|
+
rb_define_method(cT, "var", bit_var, -1);
|
3273
|
+
/**
|
3274
|
+
* stddev of self.
|
3275
|
+
* @overload stddev(axis: nil, keepdims: false, nan: false)
|
3276
|
+
* @param axis [Numeric, Array, Range] Performs stddev along the axis.
|
3277
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
3278
|
+
* dimensions with size one.
|
3279
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
3280
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
3281
|
+
* @return [Numo::DFloat] returns result of stddev.
|
3282
|
+
*/
|
3283
|
+
rb_define_method(cT, "stddev", bit_stddev, -1);
|
3284
|
+
/**
|
3285
|
+
* rms of self.
|
3286
|
+
* @overload rms(axis: nil, keepdims: false, nan: false)
|
3287
|
+
* @param axis [Numeric, Array, Range] Performs rms along the axis.
|
3288
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
3289
|
+
* dimensions with size one.
|
3290
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
3291
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
3292
|
+
* @return [Numo::DFloat] returns result of rms.
|
3293
|
+
*/
|
3294
|
+
rb_define_method(cT, "rms", bit_rms, -1);
|
3236
3295
|
}
|