numo-narray-alt 0.9.5 → 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 +13 -0
- data/ext/numo/narray/SFMT-params19937.h +12 -12
- data/ext/numo/narray/array.c +26 -2
- data/ext/numo/narray/data.c +70 -72
- data/ext/numo/narray/extconf.rb +0 -1
- data/ext/numo/narray/index.c +2 -2
- data/ext/numo/narray/kwargs.c +6 -6
- data/ext/numo/narray/math.c +10 -4
- data/ext/numo/narray/narray.c +80 -52
- 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 +80 -80
- data/ext/numo/narray/numo/types/bit.h +76 -0
- data/ext/numo/narray/numo/types/complex.h +2 -2
- data/ext/numo/narray/numo/types/complex_macro.h +27 -26
- data/ext/numo/narray/numo/types/float_macro.h +18 -17
- data/ext/numo/narray/numo/types/real_accum.h +22 -22
- data/ext/numo/narray/numo/types/robj_macro.h +15 -14
- data/ext/numo/narray/numo/types/xint_macro.h +50 -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 +121 -71
- data/ext/numo/narray/src/t_dcomplex.c +248 -387
- data/ext/numo/narray/src/t_dfloat.c +922 -1068
- data/ext/numo/narray/src/t_int16.c +282 -231
- data/ext/numo/narray/src/t_int32.c +282 -231
- data/ext/numo/narray/src/t_int64.c +281 -230
- data/ext/numo/narray/src/t_int8.c +282 -231
- data/ext/numo/narray/src/t_robject.c +278 -405
- data/ext/numo/narray/src/t_scomplex.c +246 -406
- data/ext/numo/narray/src/t_sfloat.c +916 -1058
- data/ext/numo/narray/src/t_uint16.c +282 -231
- data/ext/numo/narray/src/t_uint32.c +282 -231
- data/ext/numo/narray/src/t_uint64.c +282 -231
- data/ext/numo/narray/src/t_uint8.c +282 -231
- data/ext/numo/narray/struct.c +12 -7
- data/lib/numo/narray/extra.rb +8 -5
- metadata +6 -3
- data/ext/numo/narray/src/t_mean.c +0 -105
@@ -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;
|
@@ -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;
|
@@ -1109,9 +1118,9 @@ static VALUE uint8_cast_array(VALUE rary) {
|
|
1109
1118
|
Cast object to Numo::UInt8.
|
1110
1119
|
@overload [](elements)
|
1111
1120
|
@overload cast(array)
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1121
|
+
@param [Numeric,Array] elements
|
1122
|
+
@param [Array] array
|
1123
|
+
@return [Numo::UInt8]
|
1115
1124
|
*/
|
1116
1125
|
static VALUE uint8_s_cast(VALUE type, VALUE obj) {
|
1117
1126
|
VALUE v;
|
@@ -1151,9 +1160,9 @@ static VALUE uint8_s_cast(VALUE type, VALUE obj) {
|
|
1151
1160
|
/*
|
1152
1161
|
Multi-dimensional element reference.
|
1153
1162
|
@overload [](dim0,...,dimL)
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
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.
|
1157
1166
|
@see Numo::NArray#[]
|
1158
1167
|
@see #[]=
|
1159
1168
|
*/
|
@@ -1174,10 +1183,10 @@ static VALUE uint8_aref(int argc, VALUE* argv, VALUE self) {
|
|
1174
1183
|
/*
|
1175
1184
|
Multi-dimensional element assignment.
|
1176
1185
|
@overload []=(dim0,...,dimL,val)
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
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).
|
1181
1190
|
@see Numo::NArray#[]=
|
1182
1191
|
@see #[]
|
1183
1192
|
*/
|
@@ -1208,7 +1217,7 @@ static VALUE uint8_aset(int argc, VALUE* argv, VALUE self) {
|
|
1208
1217
|
/*
|
1209
1218
|
return NArray with cast to the type of self.
|
1210
1219
|
@overload coerce_cast(type)
|
1211
|
-
|
1220
|
+
@return [nil]
|
1212
1221
|
*/
|
1213
1222
|
static VALUE uint8_coerce_cast(VALUE self, VALUE type) {
|
1214
1223
|
return Qnil;
|
@@ -1243,7 +1252,7 @@ static void iter_uint8_to_a(na_loop_t* const lp) {
|
|
1243
1252
|
/*
|
1244
1253
|
Convert self to Array.
|
1245
1254
|
@overload to_a
|
1246
|
-
|
1255
|
+
@return [Array]
|
1247
1256
|
*/
|
1248
1257
|
static VALUE uint8_to_a(VALUE self) {
|
1249
1258
|
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
|
@@ -1276,8 +1285,8 @@ static void iter_uint8_fill(na_loop_t* const lp) {
|
|
1276
1285
|
/*
|
1277
1286
|
Fill elements with other.
|
1278
1287
|
@overload fill other
|
1279
|
-
|
1280
|
-
|
1288
|
+
@param [Numeric] other
|
1289
|
+
@return [Numo::UInt8] self.
|
1281
1290
|
*/
|
1282
1291
|
static VALUE uint8_fill(VALUE self, VALUE val) {
|
1283
1292
|
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
|
@@ -1330,8 +1339,8 @@ static void iter_uint8_format(na_loop_t* const lp) {
|
|
1330
1339
|
/*
|
1331
1340
|
Format elements into strings.
|
1332
1341
|
@overload format format
|
1333
|
-
|
1334
|
-
|
1342
|
+
@param [String] format
|
1343
|
+
@return [Numo::RObject] array of formatted strings.
|
1335
1344
|
*/
|
1336
1345
|
static VALUE uint8_format(int argc, VALUE* argv, VALUE self) {
|
1337
1346
|
VALUE fmt = Qnil;
|
@@ -1377,8 +1386,8 @@ static void iter_uint8_format_to_a(na_loop_t* const lp) {
|
|
1377
1386
|
/*
|
1378
1387
|
Format elements into strings.
|
1379
1388
|
@overload format_to_a format
|
1380
|
-
|
1381
|
-
|
1389
|
+
@param [String] format
|
1390
|
+
@return [Array] array of formatted strings.
|
1382
1391
|
*/
|
1383
1392
|
static VALUE uint8_format_to_a(int argc, VALUE* argv, VALUE self) {
|
1384
1393
|
VALUE fmt = Qnil;
|
@@ -1397,7 +1406,7 @@ static VALUE iter_uint8_inspect(char* ptr, size_t pos, VALUE fmt) {
|
|
1397
1406
|
/*
|
1398
1407
|
Returns a string containing a human-readable representation of NArray.
|
1399
1408
|
@overload inspect
|
1400
|
-
|
1409
|
+
@return [String]
|
1401
1410
|
*/
|
1402
1411
|
static VALUE uint8_inspect(VALUE ary) {
|
1403
1412
|
return na_ndloop_inspect(ary, iter_uint8_inspect, Qnil);
|
@@ -1431,9 +1440,9 @@ static void iter_uint8_each(na_loop_t* const lp) {
|
|
1431
1440
|
Calls the given block once for each element in self,
|
1432
1441
|
passing that element as a parameter.
|
1433
1442
|
@overload each
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1443
|
+
@return [Numo::NArray] self
|
1444
|
+
For a block `{|x| ... }`,
|
1445
|
+
@yieldparam [Numeric] x an element of NArray.
|
1437
1446
|
@see #each_with_index
|
1438
1447
|
@see #map
|
1439
1448
|
*/
|
@@ -1493,7 +1502,7 @@ static void iter_uint8_map(na_loop_t* const lp) {
|
|
1493
1502
|
/*
|
1494
1503
|
Unary map.
|
1495
1504
|
@overload map
|
1496
|
-
|
1505
|
+
@return [Numo::UInt8] map of self.
|
1497
1506
|
*/
|
1498
1507
|
static VALUE uint8_map(VALUE self) {
|
1499
1508
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -1552,10 +1561,10 @@ static void iter_uint8_each_with_index(na_loop_t* const lp) {
|
|
1552
1561
|
Invokes the given block once for each element of self,
|
1553
1562
|
passing that element and indices along each axis as parameters.
|
1554
1563
|
@overload each_with_index
|
1555
|
-
|
1556
|
-
|
1557
|
-
|
1558
|
-
|
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
|
1559
1568
|
@see #each
|
1560
1569
|
@see #map_with_index
|
1561
1570
|
*/
|
@@ -1643,10 +1652,10 @@ static void iter_uint8_map_with_index(na_loop_t* const lp) {
|
|
1643
1652
|
Creates a new NArray containing the values returned by the block.
|
1644
1653
|
Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
|
1645
1654
|
@overload map_with_index
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
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
|
1650
1659
|
@see #map
|
1651
1660
|
@see #each_with_index
|
1652
1661
|
*/
|
@@ -1702,7 +1711,7 @@ static void iter_uint8_abs(na_loop_t* const lp) {
|
|
1702
1711
|
/*
|
1703
1712
|
abs of self.
|
1704
1713
|
@overload abs
|
1705
|
-
|
1714
|
+
@return [Numo::UInt8] abs of self.
|
1706
1715
|
*/
|
1707
1716
|
static VALUE uint8_abs(VALUE self) {
|
1708
1717
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -1712,7 +1721,7 @@ static VALUE uint8_abs(VALUE self) {
|
|
1712
1721
|
return na_ndloop(&ndf, 1, self);
|
1713
1722
|
}
|
1714
1723
|
|
1715
|
-
#define check_intdivzero(y)
|
1724
|
+
#define check_intdivzero(y) \
|
1716
1725
|
{}
|
1717
1726
|
|
1718
1727
|
static void iter_uint8_add(na_loop_t* const lp) {
|
@@ -1782,8 +1791,8 @@ static VALUE uint8_add_self(VALUE self, VALUE other) {
|
|
1782
1791
|
/*
|
1783
1792
|
Binary add.
|
1784
1793
|
@overload + other
|
1785
|
-
|
1786
|
-
|
1794
|
+
@param [Numo::NArray,Numeric] other
|
1795
|
+
@return [Numo::NArray] self + other
|
1787
1796
|
*/
|
1788
1797
|
static VALUE uint8_add(VALUE self, VALUE other) {
|
1789
1798
|
|
@@ -1798,7 +1807,7 @@ static VALUE uint8_add(VALUE self, VALUE other) {
|
|
1798
1807
|
}
|
1799
1808
|
}
|
1800
1809
|
|
1801
|
-
#define check_intdivzero(y)
|
1810
|
+
#define check_intdivzero(y) \
|
1802
1811
|
{}
|
1803
1812
|
|
1804
1813
|
static void iter_uint8_sub(na_loop_t* const lp) {
|
@@ -1868,8 +1877,8 @@ static VALUE uint8_sub_self(VALUE self, VALUE other) {
|
|
1868
1877
|
/*
|
1869
1878
|
Binary sub.
|
1870
1879
|
@overload - other
|
1871
|
-
|
1872
|
-
|
1880
|
+
@param [Numo::NArray,Numeric] other
|
1881
|
+
@return [Numo::NArray] self - other
|
1873
1882
|
*/
|
1874
1883
|
static VALUE uint8_sub(VALUE self, VALUE other) {
|
1875
1884
|
|
@@ -1884,7 +1893,7 @@ static VALUE uint8_sub(VALUE self, VALUE other) {
|
|
1884
1893
|
}
|
1885
1894
|
}
|
1886
1895
|
|
1887
|
-
#define check_intdivzero(y)
|
1896
|
+
#define check_intdivzero(y) \
|
1888
1897
|
{}
|
1889
1898
|
|
1890
1899
|
static void iter_uint8_mul(na_loop_t* const lp) {
|
@@ -1954,8 +1963,8 @@ static VALUE uint8_mul_self(VALUE self, VALUE other) {
|
|
1954
1963
|
/*
|
1955
1964
|
Binary mul.
|
1956
1965
|
@overload * other
|
1957
|
-
|
1958
|
-
|
1966
|
+
@param [Numo::NArray,Numeric] other
|
1967
|
+
@return [Numo::NArray] self * other
|
1959
1968
|
*/
|
1960
1969
|
static VALUE uint8_mul(VALUE self, VALUE other) {
|
1961
1970
|
|
@@ -1970,10 +1979,10 @@ static VALUE uint8_mul(VALUE self, VALUE other) {
|
|
1970
1979
|
}
|
1971
1980
|
}
|
1972
1981
|
|
1973
|
-
#define check_intdivzero(y)
|
1974
|
-
if ((y) == 0) {
|
1975
|
-
lp->err_type = rb_eZeroDivError;
|
1976
|
-
return;
|
1982
|
+
#define check_intdivzero(y) \
|
1983
|
+
if ((y) == 0) { \
|
1984
|
+
lp->err_type = rb_eZeroDivError; \
|
1985
|
+
return; \
|
1977
1986
|
}
|
1978
1987
|
|
1979
1988
|
static void iter_uint8_div(na_loop_t* const lp) {
|
@@ -2043,8 +2052,8 @@ static VALUE uint8_div_self(VALUE self, VALUE other) {
|
|
2043
2052
|
/*
|
2044
2053
|
Binary div.
|
2045
2054
|
@overload / other
|
2046
|
-
|
2047
|
-
|
2055
|
+
@param [Numo::NArray,Numeric] other
|
2056
|
+
@return [Numo::NArray] self / other
|
2048
2057
|
*/
|
2049
2058
|
static VALUE uint8_div(VALUE self, VALUE other) {
|
2050
2059
|
|
@@ -2059,10 +2068,10 @@ static VALUE uint8_div(VALUE self, VALUE other) {
|
|
2059
2068
|
}
|
2060
2069
|
}
|
2061
2070
|
|
2062
|
-
#define check_intdivzero(y)
|
2063
|
-
if ((y) == 0) {
|
2064
|
-
lp->err_type = rb_eZeroDivError;
|
2065
|
-
return;
|
2071
|
+
#define check_intdivzero(y) \
|
2072
|
+
if ((y) == 0) { \
|
2073
|
+
lp->err_type = rb_eZeroDivError; \
|
2074
|
+
return; \
|
2066
2075
|
}
|
2067
2076
|
|
2068
2077
|
static void iter_uint8_mod(na_loop_t* const lp) {
|
@@ -2132,8 +2141,8 @@ static VALUE uint8_mod_self(VALUE self, VALUE other) {
|
|
2132
2141
|
/*
|
2133
2142
|
Binary mod.
|
2134
2143
|
@overload % other
|
2135
|
-
|
2136
|
-
|
2144
|
+
@param [Numo::NArray,Numeric] other
|
2145
|
+
@return [Numo::NArray] self % other
|
2137
2146
|
*/
|
2138
2147
|
static VALUE uint8_mod(VALUE self, VALUE other) {
|
2139
2148
|
|
@@ -2182,8 +2191,8 @@ static VALUE uint8_divmod_self(VALUE self, VALUE other) {
|
|
2182
2191
|
/*
|
2183
2192
|
Binary divmod.
|
2184
2193
|
@overload divmod other
|
2185
|
-
|
2186
|
-
|
2194
|
+
@param [Numo::NArray,Numeric] other
|
2195
|
+
@return [Numo::NArray] divmod of self and other.
|
2187
2196
|
*/
|
2188
2197
|
static VALUE uint8_divmod(VALUE self, VALUE other) {
|
2189
2198
|
|
@@ -2250,8 +2259,8 @@ static VALUE uint8_pow_self(VALUE self, VALUE other) {
|
|
2250
2259
|
/*
|
2251
2260
|
Binary power.
|
2252
2261
|
@overload ** other
|
2253
|
-
|
2254
|
-
|
2262
|
+
@param [Numo::NArray,Numeric] other
|
2263
|
+
@return [Numo::NArray] self to the other-th power.
|
2255
2264
|
*/
|
2256
2265
|
static VALUE uint8_pow(VALUE self, VALUE other) {
|
2257
2266
|
|
@@ -2313,7 +2322,7 @@ static void iter_uint8_minus(na_loop_t* const lp) {
|
|
2313
2322
|
/*
|
2314
2323
|
Unary minus.
|
2315
2324
|
@overload -@
|
2316
|
-
|
2325
|
+
@return [Numo::UInt8] minus of self.
|
2317
2326
|
*/
|
2318
2327
|
static VALUE uint8_minus(VALUE self) {
|
2319
2328
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2371,7 +2380,7 @@ static void iter_uint8_reciprocal(na_loop_t* const lp) {
|
|
2371
2380
|
/*
|
2372
2381
|
Unary reciprocal.
|
2373
2382
|
@overload reciprocal
|
2374
|
-
|
2383
|
+
@return [Numo::UInt8] reciprocal of self.
|
2375
2384
|
*/
|
2376
2385
|
static VALUE uint8_reciprocal(VALUE self) {
|
2377
2386
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2429,7 +2438,7 @@ static void iter_uint8_sign(na_loop_t* const lp) {
|
|
2429
2438
|
/*
|
2430
2439
|
Unary sign.
|
2431
2440
|
@overload sign
|
2432
|
-
|
2441
|
+
@return [Numo::UInt8] sign of self.
|
2433
2442
|
*/
|
2434
2443
|
static VALUE uint8_sign(VALUE self) {
|
2435
2444
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2487,7 +2496,7 @@ static void iter_uint8_square(na_loop_t* const lp) {
|
|
2487
2496
|
/*
|
2488
2497
|
Unary square.
|
2489
2498
|
@overload square
|
2490
|
-
|
2499
|
+
@return [Numo::UInt8] square of self.
|
2491
2500
|
*/
|
2492
2501
|
static VALUE uint8_square(VALUE self) {
|
2493
2502
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2529,8 +2538,8 @@ static VALUE uint8_eq_self(VALUE self, VALUE other) {
|
|
2529
2538
|
/*
|
2530
2539
|
Comparison eq other.
|
2531
2540
|
@overload eq other
|
2532
|
-
|
2533
|
-
|
2541
|
+
@param [Numo::NArray,Numeric] other
|
2542
|
+
@return [Numo::Bit] result of self eq other.
|
2534
2543
|
*/
|
2535
2544
|
static VALUE uint8_eq(VALUE self, VALUE other) {
|
2536
2545
|
|
@@ -2576,8 +2585,8 @@ static VALUE uint8_ne_self(VALUE self, VALUE other) {
|
|
2576
2585
|
/*
|
2577
2586
|
Comparison ne other.
|
2578
2587
|
@overload ne other
|
2579
|
-
|
2580
|
-
|
2588
|
+
@param [Numo::NArray,Numeric] other
|
2589
|
+
@return [Numo::Bit] result of self ne other.
|
2581
2590
|
*/
|
2582
2591
|
static VALUE uint8_ne(VALUE self, VALUE other) {
|
2583
2592
|
|
@@ -2591,7 +2600,7 @@ static VALUE uint8_ne(VALUE self, VALUE other) {
|
|
2591
2600
|
}
|
2592
2601
|
}
|
2593
2602
|
|
2594
|
-
#define check_intdivzero(y)
|
2603
|
+
#define check_intdivzero(y) \
|
2595
2604
|
{}
|
2596
2605
|
|
2597
2606
|
static void iter_uint8_bit_and(na_loop_t* const lp) {
|
@@ -2661,8 +2670,8 @@ static VALUE uint8_bit_and_self(VALUE self, VALUE other) {
|
|
2661
2670
|
/*
|
2662
2671
|
Binary bit_and.
|
2663
2672
|
@overload & other
|
2664
|
-
|
2665
|
-
|
2673
|
+
@param [Numo::NArray,Numeric] other
|
2674
|
+
@return [Numo::NArray] self & other
|
2666
2675
|
*/
|
2667
2676
|
static VALUE uint8_bit_and(VALUE self, VALUE other) {
|
2668
2677
|
|
@@ -2677,7 +2686,7 @@ static VALUE uint8_bit_and(VALUE self, VALUE other) {
|
|
2677
2686
|
}
|
2678
2687
|
}
|
2679
2688
|
|
2680
|
-
#define check_intdivzero(y)
|
2689
|
+
#define check_intdivzero(y) \
|
2681
2690
|
{}
|
2682
2691
|
|
2683
2692
|
static void iter_uint8_bit_or(na_loop_t* const lp) {
|
@@ -2747,8 +2756,8 @@ static VALUE uint8_bit_or_self(VALUE self, VALUE other) {
|
|
2747
2756
|
/*
|
2748
2757
|
Binary bit_or.
|
2749
2758
|
@overload | other
|
2750
|
-
|
2751
|
-
|
2759
|
+
@param [Numo::NArray,Numeric] other
|
2760
|
+
@return [Numo::NArray] self | other
|
2752
2761
|
*/
|
2753
2762
|
static VALUE uint8_bit_or(VALUE self, VALUE other) {
|
2754
2763
|
|
@@ -2763,7 +2772,7 @@ static VALUE uint8_bit_or(VALUE self, VALUE other) {
|
|
2763
2772
|
}
|
2764
2773
|
}
|
2765
2774
|
|
2766
|
-
#define check_intdivzero(y)
|
2775
|
+
#define check_intdivzero(y) \
|
2767
2776
|
{}
|
2768
2777
|
|
2769
2778
|
static void iter_uint8_bit_xor(na_loop_t* const lp) {
|
@@ -2833,8 +2842,8 @@ static VALUE uint8_bit_xor_self(VALUE self, VALUE other) {
|
|
2833
2842
|
/*
|
2834
2843
|
Binary bit_xor.
|
2835
2844
|
@overload ^ other
|
2836
|
-
|
2837
|
-
|
2845
|
+
@param [Numo::NArray,Numeric] other
|
2846
|
+
@return [Numo::NArray] self ^ other
|
2838
2847
|
*/
|
2839
2848
|
static VALUE uint8_bit_xor(VALUE self, VALUE other) {
|
2840
2849
|
|
@@ -2897,7 +2906,7 @@ static void iter_uint8_bit_not(na_loop_t* const lp) {
|
|
2897
2906
|
/*
|
2898
2907
|
Unary bit_not.
|
2899
2908
|
@overload ~
|
2900
|
-
|
2909
|
+
@return [Numo::UInt8] bit_not of self.
|
2901
2910
|
*/
|
2902
2911
|
static VALUE uint8_bit_not(VALUE self) {
|
2903
2912
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2907,7 +2916,7 @@ static VALUE uint8_bit_not(VALUE self) {
|
|
2907
2916
|
return na_ndloop(&ndf, 1, self);
|
2908
2917
|
}
|
2909
2918
|
|
2910
|
-
#define check_intdivzero(y)
|
2919
|
+
#define check_intdivzero(y) \
|
2911
2920
|
{}
|
2912
2921
|
|
2913
2922
|
static void iter_uint8_left_shift(na_loop_t* const lp) {
|
@@ -2977,8 +2986,8 @@ static VALUE uint8_left_shift_self(VALUE self, VALUE other) {
|
|
2977
2986
|
/*
|
2978
2987
|
Binary left_shift.
|
2979
2988
|
@overload << other
|
2980
|
-
|
2981
|
-
|
2989
|
+
@param [Numo::NArray,Numeric] other
|
2990
|
+
@return [Numo::NArray] self << other
|
2982
2991
|
*/
|
2983
2992
|
static VALUE uint8_left_shift(VALUE self, VALUE other) {
|
2984
2993
|
|
@@ -2993,7 +3002,7 @@ static VALUE uint8_left_shift(VALUE self, VALUE other) {
|
|
2993
3002
|
}
|
2994
3003
|
}
|
2995
3004
|
|
2996
|
-
#define check_intdivzero(y)
|
3005
|
+
#define check_intdivzero(y) \
|
2997
3006
|
{}
|
2998
3007
|
|
2999
3008
|
static void iter_uint8_right_shift(na_loop_t* const lp) {
|
@@ -3063,8 +3072,8 @@ static VALUE uint8_right_shift_self(VALUE self, VALUE other) {
|
|
3063
3072
|
/*
|
3064
3073
|
Binary right_shift.
|
3065
3074
|
@overload >> other
|
3066
|
-
|
3067
|
-
|
3075
|
+
@param [Numo::NArray,Numeric] other
|
3076
|
+
@return [Numo::NArray] self >> other
|
3068
3077
|
*/
|
3069
3078
|
static VALUE uint8_right_shift(VALUE self, VALUE other) {
|
3070
3079
|
|
@@ -3111,8 +3120,8 @@ static VALUE uint8_gt_self(VALUE self, VALUE other) {
|
|
3111
3120
|
/*
|
3112
3121
|
Comparison gt other.
|
3113
3122
|
@overload gt other
|
3114
|
-
|
3115
|
-
|
3123
|
+
@param [Numo::NArray,Numeric] other
|
3124
|
+
@return [Numo::Bit] result of self gt other.
|
3116
3125
|
*/
|
3117
3126
|
static VALUE uint8_gt(VALUE self, VALUE other) {
|
3118
3127
|
|
@@ -3158,8 +3167,8 @@ static VALUE uint8_ge_self(VALUE self, VALUE other) {
|
|
3158
3167
|
/*
|
3159
3168
|
Comparison ge other.
|
3160
3169
|
@overload ge other
|
3161
|
-
|
3162
|
-
|
3170
|
+
@param [Numo::NArray,Numeric] other
|
3171
|
+
@return [Numo::Bit] result of self ge other.
|
3163
3172
|
*/
|
3164
3173
|
static VALUE uint8_ge(VALUE self, VALUE other) {
|
3165
3174
|
|
@@ -3205,8 +3214,8 @@ static VALUE uint8_lt_self(VALUE self, VALUE other) {
|
|
3205
3214
|
/*
|
3206
3215
|
Comparison lt other.
|
3207
3216
|
@overload lt other
|
3208
|
-
|
3209
|
-
|
3217
|
+
@param [Numo::NArray,Numeric] other
|
3218
|
+
@return [Numo::Bit] result of self lt other.
|
3210
3219
|
*/
|
3211
3220
|
static VALUE uint8_lt(VALUE self, VALUE other) {
|
3212
3221
|
|
@@ -3252,8 +3261,8 @@ static VALUE uint8_le_self(VALUE self, VALUE other) {
|
|
3252
3261
|
/*
|
3253
3262
|
Comparison le other.
|
3254
3263
|
@overload le other
|
3255
|
-
|
3256
|
-
|
3264
|
+
@param [Numo::NArray,Numeric] other
|
3265
|
+
@return [Numo::Bit] result of self le other.
|
3257
3266
|
*/
|
3258
3267
|
static VALUE uint8_le(VALUE self, VALUE other) {
|
3259
3268
|
|
@@ -3336,9 +3345,9 @@ static void iter_uint8_clip_max(na_loop_t* const lp) {
|
|
3336
3345
|
Clip array elements by [min,max].
|
3337
3346
|
If either of min or max is nil, one side is clipped.
|
3338
3347
|
@overload clip(min,max)
|
3339
|
-
|
3340
|
-
|
3341
|
-
|
3348
|
+
@param [Numo::NArray,Numeric] min
|
3349
|
+
@param [Numo::NArray,Numeric] max
|
3350
|
+
@return [Numo::NArray] result of clip.
|
3342
3351
|
|
3343
3352
|
@example
|
3344
3353
|
a = Numo::Int32.new(10).seq
|
@@ -3399,10 +3408,10 @@ static void iter_uint8_sum(na_loop_t* const lp) {
|
|
3399
3408
|
/*
|
3400
3409
|
sum of self.
|
3401
3410
|
@overload sum(axis:nil, keepdims:false)
|
3402
|
-
|
3403
|
-
|
3404
|
-
|
3405
|
-
|
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.
|
3406
3415
|
*/
|
3407
3416
|
static VALUE uint8_sum(int argc, VALUE* argv, VALUE self) {
|
3408
3417
|
VALUE v, reduce;
|
@@ -3432,10 +3441,10 @@ static void iter_uint8_prod(na_loop_t* const lp) {
|
|
3432
3441
|
/*
|
3433
3442
|
prod of self.
|
3434
3443
|
@overload prod(axis:nil, keepdims:false)
|
3435
|
-
|
3436
|
-
|
3437
|
-
|
3438
|
-
|
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.
|
3439
3448
|
*/
|
3440
3449
|
static VALUE uint8_prod(int argc, VALUE* argv, VALUE self) {
|
3441
3450
|
VALUE v, reduce;
|
@@ -3465,10 +3474,10 @@ static void iter_uint8_min(na_loop_t* const lp) {
|
|
3465
3474
|
/*
|
3466
3475
|
min of self.
|
3467
3476
|
@overload min(axis:nil, keepdims:false)
|
3468
|
-
|
3469
|
-
|
3470
|
-
|
3471
|
-
|
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.
|
3472
3481
|
*/
|
3473
3482
|
static VALUE uint8_min(int argc, VALUE* argv, VALUE self) {
|
3474
3483
|
VALUE v, reduce;
|
@@ -3498,10 +3507,10 @@ static void iter_uint8_max(na_loop_t* const lp) {
|
|
3498
3507
|
/*
|
3499
3508
|
max of self.
|
3500
3509
|
@overload max(axis:nil, keepdims:false)
|
3501
|
-
|
3502
|
-
|
3503
|
-
|
3504
|
-
|
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.
|
3505
3514
|
*/
|
3506
3515
|
static VALUE uint8_max(int argc, VALUE* argv, VALUE self) {
|
3507
3516
|
VALUE v, reduce;
|
@@ -3531,10 +3540,10 @@ static void iter_uint8_ptp(na_loop_t* const lp) {
|
|
3531
3540
|
/*
|
3532
3541
|
ptp of self.
|
3533
3542
|
@overload ptp(axis:nil, keepdims:false)
|
3534
|
-
|
3535
|
-
|
3536
|
-
|
3537
|
-
|
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.
|
3538
3547
|
*/
|
3539
3548
|
static VALUE uint8_ptp(int argc, VALUE* argv, VALUE self) {
|
3540
3549
|
VALUE v, reduce;
|
@@ -3586,9 +3595,9 @@ static void iter_uint8_max_index_index32(na_loop_t* const lp) {
|
|
3586
3595
|
/*
|
3587
3596
|
Index of the maximum value.
|
3588
3597
|
@overload max_index(axis:nil)
|
3589
|
-
|
3590
|
-
|
3591
|
-
|
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.
|
3592
3601
|
@see #argmax
|
3593
3602
|
@see #max
|
3594
3603
|
|
@@ -3669,9 +3678,9 @@ static void iter_uint8_min_index_index32(na_loop_t* const lp) {
|
|
3669
3678
|
/*
|
3670
3679
|
Index of the minimum value.
|
3671
3680
|
@overload min_index(axis:nil)
|
3672
|
-
|
3673
|
-
|
3674
|
-
|
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.
|
3675
3684
|
@see #argmin
|
3676
3685
|
@see #min
|
3677
3686
|
|
@@ -3750,9 +3759,9 @@ static void iter_uint8_argmax_arg32(na_loop_t* const lp) {
|
|
3750
3759
|
/*
|
3751
3760
|
Index of the maximum value.
|
3752
3761
|
@overload argmax(axis:nil)
|
3753
|
-
|
3754
|
-
|
3755
|
-
|
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.
|
3756
3765
|
@see #max_index
|
3757
3766
|
@see #max
|
3758
3767
|
|
@@ -3828,9 +3837,9 @@ static void iter_uint8_argmin_arg32(na_loop_t* const lp) {
|
|
3828
3837
|
/*
|
3829
3838
|
Index of the minimum value.
|
3830
3839
|
@overload argmin(axis:nil)
|
3831
|
-
|
3832
|
-
|
3833
|
-
|
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.
|
3834
3843
|
@see #min_index
|
3835
3844
|
@see #min
|
3836
3845
|
|
@@ -3889,10 +3898,10 @@ static void iter_uint8_minmax(na_loop_t* const lp) {
|
|
3889
3898
|
/*
|
3890
3899
|
minmax of self.
|
3891
3900
|
@overload minmax(axis:nil, keepdims:false)
|
3892
|
-
|
3893
|
-
|
3894
|
-
|
3895
|
-
|
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.
|
3896
3905
|
*/
|
3897
3906
|
static VALUE uint8_minmax(int argc, VALUE* argv, VALUE self) {
|
3898
3907
|
VALUE reduce;
|
@@ -3907,14 +3916,6 @@ static VALUE uint8_minmax(int argc, VALUE* argv, VALUE self) {
|
|
3907
3916
|
return na_ndloop(&ndf, 2, self, reduce);
|
3908
3917
|
}
|
3909
3918
|
|
3910
|
-
/*
|
3911
|
-
Element-wise maximum of two arrays.
|
3912
|
-
|
3913
|
-
@overload maximum(a1, a2)
|
3914
|
-
@param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
|
3915
|
-
@return [Numo::UInt8]
|
3916
|
-
*/
|
3917
|
-
|
3918
3919
|
static void iter_uint8_s_maximum(na_loop_t* const lp) {
|
3919
3920
|
size_t i, n;
|
3920
3921
|
char *p1, *p2, *p3;
|
@@ -3947,14 +3948,6 @@ static VALUE uint8_s_maximum(int argc, VALUE* argv, VALUE mod) {
|
|
3947
3948
|
return na_ndloop(&ndf, 2, a1, a2);
|
3948
3949
|
}
|
3949
3950
|
|
3950
|
-
/*
|
3951
|
-
Element-wise minimum of two arrays.
|
3952
|
-
|
3953
|
-
@overload minimum(a1, a2)
|
3954
|
-
@param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
|
3955
|
-
@return [Numo::UInt8]
|
3956
|
-
*/
|
3957
|
-
|
3958
3951
|
static void iter_uint8_s_minimum(na_loop_t* const lp) {
|
3959
3952
|
size_t i, n;
|
3960
3953
|
char *p1, *p2, *p3;
|
@@ -4152,13 +4145,13 @@ static VALUE uint8_bincount_df(VALUE self, VALUE weight, size_t length) {
|
|
4152
4145
|
Only Integer-types has this method.
|
4153
4146
|
|
4154
4147
|
@overload bincount([weight], minlength:nil)
|
4155
|
-
|
4156
|
-
|
4157
|
-
|
4158
|
-
|
4159
|
-
|
4160
|
-
|
4161
|
-
|
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.
|
4162
4155
|
@example
|
4163
4156
|
Numo::Int32[0..4].bincount
|
4164
4157
|
# => Numo::UInt32#shape=[5]
|
@@ -4238,9 +4231,9 @@ static void iter_uint8_cumsum(na_loop_t* const lp) {
|
|
4238
4231
|
/*
|
4239
4232
|
cumsum of self.
|
4240
4233
|
@overload cumsum(axis:nil, nan:false)
|
4241
|
-
|
4242
|
-
|
4243
|
-
|
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.
|
4244
4237
|
*/
|
4245
4238
|
static VALUE uint8_cumsum(int argc, VALUE* argv, VALUE self) {
|
4246
4239
|
VALUE reduce;
|
@@ -4277,9 +4270,9 @@ static void iter_uint8_cumprod(na_loop_t* const lp) {
|
|
4277
4270
|
/*
|
4278
4271
|
cumprod of self.
|
4279
4272
|
@overload cumprod(axis:nil, nan:false)
|
4280
|
-
|
4281
|
-
|
4282
|
-
|
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.
|
4283
4276
|
*/
|
4284
4277
|
static VALUE uint8_cumprod(int argc, VALUE* argv, VALUE self) {
|
4285
4278
|
VALUE reduce;
|
@@ -4355,11 +4348,11 @@ static VALUE uint8_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
|
4355
4348
|
Binary mulsum.
|
4356
4349
|
|
4357
4350
|
@overload mulsum(other, axis:nil, keepdims:false)
|
4358
|
-
|
4359
|
-
|
4360
|
-
|
4361
|
-
|
4362
|
-
|
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.
|
4363
4356
|
*/
|
4364
4357
|
static VALUE uint8_mulsum(int argc, VALUE* argv, VALUE self) {
|
4365
4358
|
//
|
@@ -4428,9 +4421,9 @@ static void iter_uint8_seq(na_loop_t* const lp) {
|
|
4428
4421
|
beg+i*step
|
4429
4422
|
where i is 1-dimensional index.
|
4430
4423
|
@overload seq([beg,[step]])
|
4431
|
-
|
4432
|
-
|
4433
|
-
|
4424
|
+
@param [Numeric] beg beginning of sequence. (default=0)
|
4425
|
+
@param [Numeric] step step of sequence. (default=1)
|
4426
|
+
@return [Numo::UInt8] self.
|
4434
4427
|
@example
|
4435
4428
|
Numo::DFloat.new(6).seq(1,-0.2)
|
4436
4429
|
# => Numo::DFloat#shape=[6]
|
@@ -4440,7 +4433,7 @@ static void iter_uint8_seq(na_loop_t* const lp) {
|
|
4440
4433
|
# => Numo::DComplex#shape=[6]
|
4441
4434
|
# [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
4442
4435
|
*/
|
4443
|
-
static VALUE uint8_seq(int argc, VALUE*
|
4436
|
+
static VALUE uint8_seq(int argc, VALUE* argv, VALUE self) {
|
4444
4437
|
seq_opt_t* g;
|
4445
4438
|
VALUE vbeg = Qnil, vstep = Qnil;
|
4446
4439
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
@@ -4450,7 +4443,7 @@ static VALUE uint8_seq(int argc, VALUE* args, VALUE self) {
|
|
4450
4443
|
g->beg = m_zero;
|
4451
4444
|
g->step = m_one;
|
4452
4445
|
g->count = 0;
|
4453
|
-
rb_scan_args(argc,
|
4446
|
+
rb_scan_args(argc, argv, "02", &vbeg, &vstep);
|
4454
4447
|
if (vbeg != Qnil) {
|
4455
4448
|
g->beg = NUM2DBL(vbeg);
|
4456
4449
|
}
|
@@ -4494,11 +4487,11 @@ static void iter_uint8_eye(na_loop_t* const lp) {
|
|
4494
4487
|
/*
|
4495
4488
|
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
|
4496
4489
|
@overload eye([element,offset])
|
4497
|
-
|
4498
|
-
|
4499
|
-
|
4500
|
-
|
4501
|
-
|
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.
|
4502
4495
|
*/
|
4503
4496
|
static VALUE uint8_eye(int argc, VALUE* argv, VALUE self) {
|
4504
4497
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
|
@@ -4630,10 +4623,10 @@ static void iter_uint8_rand(na_loop_t* const lp) {
|
|
4630
4623
|
/*
|
4631
4624
|
Generate uniformly distributed random numbers on self narray.
|
4632
4625
|
@overload rand([[low],high])
|
4633
|
-
|
4634
|
-
|
4635
|
-
|
4636
|
-
|
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.
|
4637
4630
|
@example
|
4638
4631
|
Numo::DFloat.new(6).rand
|
4639
4632
|
# => Numo::DFloat#shape=[6]
|
@@ -4647,14 +4640,14 @@ static void iter_uint8_rand(na_loop_t* const lp) {
|
|
4647
4640
|
# => Numo::Int32#shape=[6]
|
4648
4641
|
# [4, 3, 3, 2, 4, 2]
|
4649
4642
|
*/
|
4650
|
-
static VALUE uint8_rand(int argc, VALUE*
|
4643
|
+
static VALUE uint8_rand(int argc, VALUE* argv, VALUE self) {
|
4651
4644
|
rand_opt_t g;
|
4652
4645
|
VALUE v1 = Qnil, v2 = Qnil;
|
4653
4646
|
dtype high;
|
4654
4647
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
4655
4648
|
ndfunc_t ndf = { iter_uint8_rand, FULL_LOOP, 1, 0, ain, 0 };
|
4656
4649
|
|
4657
|
-
rb_scan_args(argc,
|
4650
|
+
rb_scan_args(argc, argv, "11", &v1, &v2);
|
4658
4651
|
if (v2 == Qnil) {
|
4659
4652
|
g.low = m_zero;
|
4660
4653
|
g.max = high = m_num_to_data(v1);
|
@@ -4693,8 +4686,8 @@ static void iter_uint8_poly(na_loop_t* const lp) {
|
|
4693
4686
|
Calculate polynomial.
|
4694
4687
|
`x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
|
4695
4688
|
@overload poly a0, a1, ..., an
|
4696
|
-
|
4697
|
-
|
4689
|
+
@param [Numo::NArray,Numeric] a0,a1,...,an
|
4690
|
+
@return [Numo::UInt8]
|
4698
4691
|
*/
|
4699
4692
|
static VALUE uint8_poly(VALUE self, VALUE args) {
|
4700
4693
|
int argc, i;
|
@@ -4781,27 +4774,27 @@ static VALUE uint8_poly(VALUE self, VALUE args) {
|
|
4781
4774
|
* We have modified their original by adding a check for already-sorted input,
|
4782
4775
|
* which seems to be a win per discussions on pgsql-hackers around 2006-03-21.
|
4783
4776
|
*/
|
4784
|
-
#define swapcode(TYPE, parmi, parmj, n)
|
4785
|
-
do {
|
4786
|
-
size_t i = (n) / sizeof(TYPE);
|
4787
|
-
TYPE* pi = (TYPE*)(void*)(parmi);
|
4788
|
-
TYPE* pj = (TYPE*)(void*)(parmj);
|
4789
|
-
do {
|
4790
|
-
TYPE t = *pi;
|
4791
|
-
*pi++ = *pj;
|
4792
|
-
*pj++ = t;
|
4793
|
-
} while (--i > 0);
|
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); \
|
4794
4787
|
} while (0)
|
4795
4788
|
|
4796
4789
|
#ifdef HAVE_STDINT_H
|
4797
|
-
#define SWAPINIT(a, es)
|
4798
|
-
swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2
|
4799
|
-
: (es) == sizeof(long) ? 0
|
4790
|
+
#define SWAPINIT(a, es) \
|
4791
|
+
swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
4792
|
+
: (es) == sizeof(long) ? 0 \
|
4800
4793
|
: 1;
|
4801
4794
|
#else
|
4802
|
-
#define SWAPINIT(a, es)
|
4803
|
-
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2
|
4804
|
-
: (es) == sizeof(long) ? 0
|
4795
|
+
#define SWAPINIT(a, es) \
|
4796
|
+
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
4797
|
+
: (es) == sizeof(long) ? 0 \
|
4805
4798
|
: 1;
|
4806
4799
|
#endif
|
4807
4800
|
|
@@ -4812,19 +4805,19 @@ static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
|
|
4812
4805
|
swapcode(char, a, b, n);
|
4813
4806
|
}
|
4814
4807
|
|
4815
|
-
#define swap(a, b)
|
4816
|
-
if (swaptype == 0) {
|
4817
|
-
long t = *(long*)(void*)(a);
|
4818
|
-
*(long*)(void*)(a) = *(long*)(void*)(b);
|
4819
|
-
*(long*)(void*)(b) = t;
|
4820
|
-
} else
|
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 \
|
4821
4814
|
swapfunc(a, b, es, swaptype)
|
4822
4815
|
|
4823
|
-
#define vecswap(a, b, n)
|
4816
|
+
#define vecswap(a, b, n) \
|
4824
4817
|
if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
|
4825
4818
|
|
4826
|
-
#define med3(a, b, c, _cmp)
|
4827
|
-
(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)) \
|
4828
4821
|
: (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
|
4829
4822
|
#endif
|
4830
4823
|
|
@@ -4915,8 +4908,8 @@ static void iter_uint8_sort(na_loop_t* const lp) {
|
|
4915
4908
|
/*
|
4916
4909
|
sort of self.
|
4917
4910
|
@overload sort(axis:nil)
|
4918
|
-
|
4919
|
-
|
4911
|
+
@param [Numeric,Array,Range] axis Performs sort along the axis.
|
4912
|
+
@return [Numo::UInt8] returns result of sort.
|
4920
4913
|
@example
|
4921
4914
|
Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
|
4922
4915
|
*/
|
@@ -5135,8 +5128,8 @@ static void uint8_index32_qsort(na_loop_t* const lp) {
|
|
5135
5128
|
/*
|
5136
5129
|
sort_index. Returns an index array of sort result.
|
5137
5130
|
@overload sort_index(axis:nil)
|
5138
|
-
|
5139
|
-
|
5131
|
+
@param [Numeric,Array,Range] axis Performs sort_index along the axis.
|
5132
|
+
@return [Integer,Numo::Int] returns result index of sort_index.
|
5140
5133
|
@example
|
5141
5134
|
Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
|
5142
5135
|
*/
|
@@ -5200,10 +5193,10 @@ static void iter_uint8_median(na_loop_t* const lp) {
|
|
5200
5193
|
/*
|
5201
5194
|
median of self.
|
5202
5195
|
@overload median(axis:nil, keepdims:false)
|
5203
|
-
|
5204
|
-
|
5205
|
-
|
5206
|
-
|
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.
|
5207
5200
|
*/
|
5208
5201
|
|
5209
5202
|
static VALUE uint8_median(int argc, VALUE* argv, VALUE self) {
|
@@ -5242,13 +5235,15 @@ void Init_numo_uint8(void) {
|
|
5242
5235
|
id_ne = rb_intern("ne");
|
5243
5236
|
id_to_a = rb_intern("to_a");
|
5244
5237
|
|
5245
|
-
|
5246
|
-
|
5247
|
-
|
5248
|
-
|
5238
|
+
/**
|
5239
|
+
* Document-class: Numo::UInt8
|
5240
|
+
*
|
5241
|
+
* 8-bit unsigned integer N-dimensional array class.
|
5242
|
+
*/
|
5249
5243
|
cT = rb_define_class_under(mNumo, "UInt8", cNArray);
|
5250
5244
|
|
5251
5245
|
hCast = rb_hash_new();
|
5246
|
+
/* Upcasting rules of UInt8. */
|
5252
5247
|
rb_define_const(cT, "UPCAST", hCast);
|
5253
5248
|
rb_hash_aset(hCast, rb_cArray, cT);
|
5254
5249
|
|
@@ -5275,15 +5270,15 @@ void Init_numo_uint8(void) {
|
|
5275
5270
|
rb_hash_aset(hCast, numo_cUInt8, cT);
|
5276
5271
|
rb_obj_freeze(hCast);
|
5277
5272
|
|
5278
|
-
|
5273
|
+
/* Element size of UInt8 in bits. */
|
5279
5274
|
rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
|
5280
|
-
|
5275
|
+
/* Element size of UInt8 in bytes. */
|
5281
5276
|
rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
|
5282
|
-
|
5277
|
+
/* Stride size of contiguous UInt8 array. */
|
5283
5278
|
rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
|
5284
|
-
|
5279
|
+
/* The largest representable value of UInt8. */
|
5285
5280
|
rb_define_const(cT, "MAX", M_MAX);
|
5286
|
-
|
5281
|
+
/* The smallest representable value of UInt8. */
|
5287
5282
|
rb_define_const(cT, "MIN", M_MIN);
|
5288
5283
|
rb_define_alloc_func(cT, uint8_s_alloc_func);
|
5289
5284
|
rb_define_method(cT, "allocate", uint8_allocate, 0);
|
@@ -5354,7 +5349,19 @@ void Init_numo_uint8(void) {
|
|
5354
5349
|
rb_define_method(cT, "argmax", uint8_argmax, -1);
|
5355
5350
|
rb_define_method(cT, "argmin", uint8_argmin, -1);
|
5356
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
|
+
*/
|
5357
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
|
+
*/
|
5358
5365
|
rb_define_module_function(cT, "minimum", uint8_s_minimum, -1);
|
5359
5366
|
rb_define_method(cT, "bincount", uint8_bincount, -1);
|
5360
5367
|
rb_define_method(cT, "cumsum", uint8_cumsum, -1);
|
@@ -5371,4 +5378,48 @@ void Init_numo_uint8(void) {
|
|
5371
5378
|
rb_define_method(cT, "sort_index", uint8_sort_index, -1);
|
5372
5379
|
rb_define_method(cT, "median", uint8_median, -1);
|
5373
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);
|
5374
5425
|
}
|