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/int8.h>
|
39
39
|
|
40
|
-
VALUE cT;
|
41
|
-
extern VALUE cRT;
|
42
|
-
|
43
40
|
/*
|
44
41
|
class definition: Numo::Int8
|
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 int8_t int8; // Type aliases for shorter notation
|
52
|
+
// following the codebase naming convention.
|
53
|
+
DEF_NARRAY_INT_MEAN_METHOD_FUNC(int8, numo_cInt8)
|
54
|
+
DEF_NARRAY_INT_VAR_METHOD_FUNC(int8, numo_cInt8)
|
55
|
+
DEF_NARRAY_INT_STDDEV_METHOD_FUNC(int8, numo_cInt8)
|
56
|
+
DEF_NARRAY_INT_RMS_METHOD_FUNC(int8, numo_cInt8)
|
48
57
|
|
49
58
|
static VALUE int8_store(VALUE, VALUE);
|
50
59
|
|
@@ -152,9 +161,9 @@ static VALUE int8_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 int8_extract(VALUE self) {
|
160
169
|
volatile VALUE v;
|
@@ -896,8 +905,8 @@ static VALUE int8_store_array(VALUE self, VALUE rary) {
|
|
896
905
|
/*
|
897
906
|
Store elements to Numo::Int8 from other.
|
898
907
|
@overload store(other)
|
899
|
-
|
900
|
-
|
908
|
+
@param [Object] other
|
909
|
+
@return [Numo::Int8] self
|
901
910
|
*/
|
902
911
|
static VALUE int8_store(VALUE self, VALUE obj) {
|
903
912
|
VALUE r, klass;
|
@@ -1109,9 +1118,9 @@ static VALUE int8_cast_array(VALUE rary) {
|
|
1109
1118
|
Cast object to Numo::Int8.
|
1110
1119
|
@overload [](elements)
|
1111
1120
|
@overload cast(array)
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1121
|
+
@param [Numeric,Array] elements
|
1122
|
+
@param [Array] array
|
1123
|
+
@return [Numo::Int8]
|
1115
1124
|
*/
|
1116
1125
|
static VALUE int8_s_cast(VALUE type, VALUE obj) {
|
1117
1126
|
VALUE v;
|
@@ -1151,9 +1160,9 @@ static VALUE int8_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::Int8] an element or NArray view.
|
1157
1166
|
@see Numo::NArray#[]
|
1158
1167
|
@see #[]=
|
1159
1168
|
*/
|
@@ -1174,10 +1183,10 @@ static VALUE int8_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 int8_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 int8_coerce_cast(VALUE self, VALUE type) {
|
1214
1223
|
return Qnil;
|
@@ -1243,7 +1252,7 @@ static void iter_int8_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 int8_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_int8_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::Int8] self.
|
1281
1290
|
*/
|
1282
1291
|
static VALUE int8_fill(VALUE self, VALUE val) {
|
1283
1292
|
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
|
@@ -1330,8 +1339,8 @@ static void iter_int8_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 int8_format(int argc, VALUE* argv, VALUE self) {
|
1337
1346
|
VALUE fmt = Qnil;
|
@@ -1377,8 +1386,8 @@ static void iter_int8_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 int8_format_to_a(int argc, VALUE* argv, VALUE self) {
|
1384
1393
|
VALUE fmt = Qnil;
|
@@ -1397,7 +1406,7 @@ static VALUE iter_int8_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 int8_inspect(VALUE ary) {
|
1403
1412
|
return na_ndloop_inspect(ary, iter_int8_inspect, Qnil);
|
@@ -1431,9 +1440,9 @@ static void iter_int8_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_int8_map(na_loop_t* const lp) {
|
|
1493
1502
|
/*
|
1494
1503
|
Unary map.
|
1495
1504
|
@overload map
|
1496
|
-
|
1505
|
+
@return [Numo::Int8] map of self.
|
1497
1506
|
*/
|
1498
1507
|
static VALUE int8_map(VALUE self) {
|
1499
1508
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -1552,10 +1561,10 @@ static void iter_int8_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_int8_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_int8_abs(na_loop_t* const lp) {
|
|
1702
1711
|
/*
|
1703
1712
|
abs of self.
|
1704
1713
|
@overload abs
|
1705
|
-
|
1714
|
+
@return [Numo::Int8] abs of self.
|
1706
1715
|
*/
|
1707
1716
|
static VALUE int8_abs(VALUE self) {
|
1708
1717
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -1712,7 +1721,7 @@ static VALUE int8_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_int8_add(na_loop_t* const lp) {
|
@@ -1782,8 +1791,8 @@ static VALUE int8_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 int8_add(VALUE self, VALUE other) {
|
1789
1798
|
|
@@ -1798,7 +1807,7 @@ static VALUE int8_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_int8_sub(na_loop_t* const lp) {
|
@@ -1868,8 +1877,8 @@ static VALUE int8_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 int8_sub(VALUE self, VALUE other) {
|
1875
1884
|
|
@@ -1884,7 +1893,7 @@ static VALUE int8_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_int8_mul(na_loop_t* const lp) {
|
@@ -1954,8 +1963,8 @@ static VALUE int8_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 int8_mul(VALUE self, VALUE other) {
|
1961
1970
|
|
@@ -1970,10 +1979,10 @@ static VALUE int8_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_int8_div(na_loop_t* const lp) {
|
@@ -2043,8 +2052,8 @@ static VALUE int8_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 int8_div(VALUE self, VALUE other) {
|
2050
2059
|
|
@@ -2059,10 +2068,10 @@ static VALUE int8_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_int8_mod(na_loop_t* const lp) {
|
@@ -2132,8 +2141,8 @@ static VALUE int8_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 int8_mod(VALUE self, VALUE other) {
|
2139
2148
|
|
@@ -2182,8 +2191,8 @@ static VALUE int8_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 int8_divmod(VALUE self, VALUE other) {
|
2189
2198
|
|
@@ -2250,8 +2259,8 @@ static VALUE int8_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 int8_pow(VALUE self, VALUE other) {
|
2257
2266
|
|
@@ -2313,7 +2322,7 @@ static void iter_int8_minus(na_loop_t* const lp) {
|
|
2313
2322
|
/*
|
2314
2323
|
Unary minus.
|
2315
2324
|
@overload -@
|
2316
|
-
|
2325
|
+
@return [Numo::Int8] minus of self.
|
2317
2326
|
*/
|
2318
2327
|
static VALUE int8_minus(VALUE self) {
|
2319
2328
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2371,7 +2380,7 @@ static void iter_int8_reciprocal(na_loop_t* const lp) {
|
|
2371
2380
|
/*
|
2372
2381
|
Unary reciprocal.
|
2373
2382
|
@overload reciprocal
|
2374
|
-
|
2383
|
+
@return [Numo::Int8] reciprocal of self.
|
2375
2384
|
*/
|
2376
2385
|
static VALUE int8_reciprocal(VALUE self) {
|
2377
2386
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2429,7 +2438,7 @@ static void iter_int8_sign(na_loop_t* const lp) {
|
|
2429
2438
|
/*
|
2430
2439
|
Unary sign.
|
2431
2440
|
@overload sign
|
2432
|
-
|
2441
|
+
@return [Numo::Int8] sign of self.
|
2433
2442
|
*/
|
2434
2443
|
static VALUE int8_sign(VALUE self) {
|
2435
2444
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2487,7 +2496,7 @@ static void iter_int8_square(na_loop_t* const lp) {
|
|
2487
2496
|
/*
|
2488
2497
|
Unary square.
|
2489
2498
|
@overload square
|
2490
|
-
|
2499
|
+
@return [Numo::Int8] square of self.
|
2491
2500
|
*/
|
2492
2501
|
static VALUE int8_square(VALUE self) {
|
2493
2502
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2529,8 +2538,8 @@ static VALUE int8_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 int8_eq(VALUE self, VALUE other) {
|
2536
2545
|
|
@@ -2576,8 +2585,8 @@ static VALUE int8_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 int8_ne(VALUE self, VALUE other) {
|
2583
2592
|
|
@@ -2591,7 +2600,7 @@ static VALUE int8_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_int8_bit_and(na_loop_t* const lp) {
|
@@ -2661,8 +2670,8 @@ static VALUE int8_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 int8_bit_and(VALUE self, VALUE other) {
|
2668
2677
|
|
@@ -2677,7 +2686,7 @@ static VALUE int8_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_int8_bit_or(na_loop_t* const lp) {
|
@@ -2747,8 +2756,8 @@ static VALUE int8_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 int8_bit_or(VALUE self, VALUE other) {
|
2754
2763
|
|
@@ -2763,7 +2772,7 @@ static VALUE int8_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_int8_bit_xor(na_loop_t* const lp) {
|
@@ -2833,8 +2842,8 @@ static VALUE int8_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 int8_bit_xor(VALUE self, VALUE other) {
|
2840
2849
|
|
@@ -2897,7 +2906,7 @@ static void iter_int8_bit_not(na_loop_t* const lp) {
|
|
2897
2906
|
/*
|
2898
2907
|
Unary bit_not.
|
2899
2908
|
@overload ~
|
2900
|
-
|
2909
|
+
@return [Numo::Int8] bit_not of self.
|
2901
2910
|
*/
|
2902
2911
|
static VALUE int8_bit_not(VALUE self) {
|
2903
2912
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2907,7 +2916,7 @@ static VALUE int8_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_int8_left_shift(na_loop_t* const lp) {
|
@@ -2977,8 +2986,8 @@ static VALUE int8_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 int8_left_shift(VALUE self, VALUE other) {
|
2984
2993
|
|
@@ -2993,7 +3002,7 @@ static VALUE int8_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_int8_right_shift(na_loop_t* const lp) {
|
@@ -3063,8 +3072,8 @@ static VALUE int8_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 int8_right_shift(VALUE self, VALUE other) {
|
3070
3079
|
|
@@ -3111,8 +3120,8 @@ static VALUE int8_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 int8_gt(VALUE self, VALUE other) {
|
3118
3127
|
|
@@ -3158,8 +3167,8 @@ static VALUE int8_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 int8_ge(VALUE self, VALUE other) {
|
3165
3174
|
|
@@ -3205,8 +3214,8 @@ static VALUE int8_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 int8_lt(VALUE self, VALUE other) {
|
3212
3221
|
|
@@ -3252,8 +3261,8 @@ static VALUE int8_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 int8_le(VALUE self, VALUE other) {
|
3259
3268
|
|
@@ -3336,9 +3345,9 @@ static void iter_int8_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_int8_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::Int8] returns result of sum.
|
3406
3415
|
*/
|
3407
3416
|
static VALUE int8_sum(int argc, VALUE* argv, VALUE self) {
|
3408
3417
|
VALUE v, reduce;
|
@@ -3432,10 +3441,10 @@ static void iter_int8_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::Int8] returns result of prod.
|
3439
3448
|
*/
|
3440
3449
|
static VALUE int8_prod(int argc, VALUE* argv, VALUE self) {
|
3441
3450
|
VALUE v, reduce;
|
@@ -3465,10 +3474,10 @@ static void iter_int8_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::Int8] returns result of min.
|
3472
3481
|
*/
|
3473
3482
|
static VALUE int8_min(int argc, VALUE* argv, VALUE self) {
|
3474
3483
|
VALUE v, reduce;
|
@@ -3498,10 +3507,10 @@ static void iter_int8_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::Int8] returns result of max.
|
3505
3514
|
*/
|
3506
3515
|
static VALUE int8_max(int argc, VALUE* argv, VALUE self) {
|
3507
3516
|
VALUE v, reduce;
|
@@ -3531,10 +3540,10 @@ static void iter_int8_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::Int8] returns result of ptp.
|
3538
3547
|
*/
|
3539
3548
|
static VALUE int8_ptp(int argc, VALUE* argv, VALUE self) {
|
3540
3549
|
VALUE v, reduce;
|
@@ -3586,9 +3595,9 @@ static void iter_int8_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_int8_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_int8_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_int8_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_int8_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::Int8,Numo::Int8] min and max of self.
|
3896
3905
|
*/
|
3897
3906
|
static VALUE int8_minmax(int argc, VALUE* argv, VALUE self) {
|
3898
3907
|
VALUE reduce;
|
@@ -3907,14 +3916,6 @@ static VALUE int8_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::Int8]
|
3916
|
-
*/
|
3917
|
-
|
3918
3919
|
static void iter_int8_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 int8_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::Int8]
|
3956
|
-
*/
|
3957
|
-
|
3958
3951
|
static void iter_int8_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 int8_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]
|
@@ -4242,9 +4235,9 @@ static void iter_int8_cumsum(na_loop_t* const lp) {
|
|
4242
4235
|
/*
|
4243
4236
|
cumsum of self.
|
4244
4237
|
@overload cumsum(axis:nil, nan:false)
|
4245
|
-
|
4246
|
-
|
4247
|
-
|
4238
|
+
@param [Numeric,Array,Range] axis Performs cumsum along the axis.
|
4239
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
4240
|
+
@return [Numo::Int8] cumsum of self.
|
4248
4241
|
*/
|
4249
4242
|
static VALUE int8_cumsum(int argc, VALUE* argv, VALUE self) {
|
4250
4243
|
VALUE reduce;
|
@@ -4279,9 +4272,9 @@ static void iter_int8_cumprod(na_loop_t* const lp) {
|
|
4279
4272
|
/*
|
4280
4273
|
cumprod of self.
|
4281
4274
|
@overload cumprod(axis:nil, nan:false)
|
4282
|
-
|
4283
|
-
|
4284
|
-
|
4275
|
+
@param [Numeric,Array,Range] axis Performs cumprod along the axis.
|
4276
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
4277
|
+
@return [Numo::Int8] cumprod of self.
|
4285
4278
|
*/
|
4286
4279
|
static VALUE int8_cumprod(int argc, VALUE* argv, VALUE self) {
|
4287
4280
|
VALUE reduce;
|
@@ -4357,11 +4350,11 @@ static VALUE int8_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
|
4357
4350
|
Binary mulsum.
|
4358
4351
|
|
4359
4352
|
@overload mulsum(other, axis:nil, keepdims:false)
|
4360
|
-
|
4361
|
-
|
4362
|
-
|
4363
|
-
|
4364
|
-
|
4353
|
+
@param [Numo::NArray,Numeric] other
|
4354
|
+
@param [Numeric,Array,Range] axis Performs mulsum along the axis.
|
4355
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
4356
|
+
as dimensions with size one.
|
4357
|
+
@return [Numo::NArray] mulsum of self and other.
|
4365
4358
|
*/
|
4366
4359
|
static VALUE int8_mulsum(int argc, VALUE* argv, VALUE self) {
|
4367
4360
|
//
|
@@ -4430,9 +4423,9 @@ static void iter_int8_seq(na_loop_t* const lp) {
|
|
4430
4423
|
beg+i*step
|
4431
4424
|
where i is 1-dimensional index.
|
4432
4425
|
@overload seq([beg,[step]])
|
4433
|
-
|
4434
|
-
|
4435
|
-
|
4426
|
+
@param [Numeric] beg beginning of sequence. (default=0)
|
4427
|
+
@param [Numeric] step step of sequence. (default=1)
|
4428
|
+
@return [Numo::Int8] self.
|
4436
4429
|
@example
|
4437
4430
|
Numo::DFloat.new(6).seq(1,-0.2)
|
4438
4431
|
# => Numo::DFloat#shape=[6]
|
@@ -4442,7 +4435,7 @@ static void iter_int8_seq(na_loop_t* const lp) {
|
|
4442
4435
|
# => Numo::DComplex#shape=[6]
|
4443
4436
|
# [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
4444
4437
|
*/
|
4445
|
-
static VALUE int8_seq(int argc, VALUE*
|
4438
|
+
static VALUE int8_seq(int argc, VALUE* argv, VALUE self) {
|
4446
4439
|
seq_opt_t* g;
|
4447
4440
|
VALUE vbeg = Qnil, vstep = Qnil;
|
4448
4441
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
@@ -4452,7 +4445,7 @@ static VALUE int8_seq(int argc, VALUE* args, VALUE self) {
|
|
4452
4445
|
g->beg = m_zero;
|
4453
4446
|
g->step = m_one;
|
4454
4447
|
g->count = 0;
|
4455
|
-
rb_scan_args(argc,
|
4448
|
+
rb_scan_args(argc, argv, "02", &vbeg, &vstep);
|
4456
4449
|
if (vbeg != Qnil) {
|
4457
4450
|
g->beg = NUM2DBL(vbeg);
|
4458
4451
|
}
|
@@ -4496,11 +4489,11 @@ static void iter_int8_eye(na_loop_t* const lp) {
|
|
4496
4489
|
/*
|
4497
4490
|
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
|
4498
4491
|
@overload eye([element,offset])
|
4499
|
-
|
4500
|
-
|
4501
|
-
|
4502
|
-
|
4503
|
-
|
4492
|
+
@param [Numeric] element Diagonal element to be stored. Default is 1.
|
4493
|
+
@param [Integer] offset Diagonal offset from the main diagonal. The
|
4494
|
+
default is 0. k>0 for diagonals above the main diagonal, and k<0
|
4495
|
+
for diagonals below the main diagonal.
|
4496
|
+
@return [Numo::Int8] eye of self.
|
4504
4497
|
*/
|
4505
4498
|
static VALUE int8_eye(int argc, VALUE* argv, VALUE self) {
|
4506
4499
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
|
@@ -4632,10 +4625,10 @@ static void iter_int8_rand(na_loop_t* const lp) {
|
|
4632
4625
|
/*
|
4633
4626
|
Generate uniformly distributed random numbers on self narray.
|
4634
4627
|
@overload rand([[low],high])
|
4635
|
-
|
4636
|
-
|
4637
|
-
|
4638
|
-
|
4628
|
+
@param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
4629
|
+
@param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
|
4630
|
+
complex types)
|
4631
|
+
@return [Numo::Int8] self.
|
4639
4632
|
@example
|
4640
4633
|
Numo::DFloat.new(6).rand
|
4641
4634
|
# => Numo::DFloat#shape=[6]
|
@@ -4649,14 +4642,14 @@ static void iter_int8_rand(na_loop_t* const lp) {
|
|
4649
4642
|
# => Numo::Int32#shape=[6]
|
4650
4643
|
# [4, 3, 3, 2, 4, 2]
|
4651
4644
|
*/
|
4652
|
-
static VALUE int8_rand(int argc, VALUE*
|
4645
|
+
static VALUE int8_rand(int argc, VALUE* argv, VALUE self) {
|
4653
4646
|
rand_opt_t g;
|
4654
4647
|
VALUE v1 = Qnil, v2 = Qnil;
|
4655
4648
|
dtype high;
|
4656
4649
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
4657
4650
|
ndfunc_t ndf = { iter_int8_rand, FULL_LOOP, 1, 0, ain, 0 };
|
4658
4651
|
|
4659
|
-
rb_scan_args(argc,
|
4652
|
+
rb_scan_args(argc, argv, "11", &v1, &v2);
|
4660
4653
|
if (v2 == Qnil) {
|
4661
4654
|
g.low = m_zero;
|
4662
4655
|
g.max = high = m_num_to_data(v1);
|
@@ -4695,8 +4688,8 @@ static void iter_int8_poly(na_loop_t* const lp) {
|
|
4695
4688
|
Calculate polynomial.
|
4696
4689
|
`x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
|
4697
4690
|
@overload poly a0, a1, ..., an
|
4698
|
-
|
4699
|
-
|
4691
|
+
@param [Numo::NArray,Numeric] a0,a1,...,an
|
4692
|
+
@return [Numo::Int8]
|
4700
4693
|
*/
|
4701
4694
|
static VALUE int8_poly(VALUE self, VALUE args) {
|
4702
4695
|
int argc, i;
|
@@ -4783,27 +4776,27 @@ static VALUE int8_poly(VALUE self, VALUE args) {
|
|
4783
4776
|
* We have modified their original by adding a check for already-sorted input,
|
4784
4777
|
* which seems to be a win per discussions on pgsql-hackers around 2006-03-21.
|
4785
4778
|
*/
|
4786
|
-
#define swapcode(TYPE, parmi, parmj, n)
|
4787
|
-
do {
|
4788
|
-
size_t i = (n) / sizeof(TYPE);
|
4789
|
-
TYPE* pi = (TYPE*)(void*)(parmi);
|
4790
|
-
TYPE* pj = (TYPE*)(void*)(parmj);
|
4791
|
-
do {
|
4792
|
-
TYPE t = *pi;
|
4793
|
-
*pi++ = *pj;
|
4794
|
-
*pj++ = t;
|
4795
|
-
} while (--i > 0);
|
4779
|
+
#define swapcode(TYPE, parmi, parmj, n) \
|
4780
|
+
do { \
|
4781
|
+
size_t i = (n) / sizeof(TYPE); \
|
4782
|
+
TYPE* pi = (TYPE*)(void*)(parmi); \
|
4783
|
+
TYPE* pj = (TYPE*)(void*)(parmj); \
|
4784
|
+
do { \
|
4785
|
+
TYPE t = *pi; \
|
4786
|
+
*pi++ = *pj; \
|
4787
|
+
*pj++ = t; \
|
4788
|
+
} while (--i > 0); \
|
4796
4789
|
} while (0)
|
4797
4790
|
|
4798
4791
|
#ifdef HAVE_STDINT_H
|
4799
|
-
#define SWAPINIT(a, es)
|
4800
|
-
swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2
|
4801
|
-
: (es) == sizeof(long) ? 0
|
4792
|
+
#define SWAPINIT(a, es) \
|
4793
|
+
swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
4794
|
+
: (es) == sizeof(long) ? 0 \
|
4802
4795
|
: 1;
|
4803
4796
|
#else
|
4804
|
-
#define SWAPINIT(a, es)
|
4805
|
-
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2
|
4806
|
-
: (es) == sizeof(long) ? 0
|
4797
|
+
#define SWAPINIT(a, es) \
|
4798
|
+
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
4799
|
+
: (es) == sizeof(long) ? 0 \
|
4807
4800
|
: 1;
|
4808
4801
|
#endif
|
4809
4802
|
|
@@ -4814,19 +4807,19 @@ static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
|
|
4814
4807
|
swapcode(char, a, b, n);
|
4815
4808
|
}
|
4816
4809
|
|
4817
|
-
#define swap(a, b)
|
4818
|
-
if (swaptype == 0) {
|
4819
|
-
long t = *(long*)(void*)(a);
|
4820
|
-
*(long*)(void*)(a) = *(long*)(void*)(b);
|
4821
|
-
*(long*)(void*)(b) = t;
|
4822
|
-
} else
|
4810
|
+
#define swap(a, b) \
|
4811
|
+
if (swaptype == 0) { \
|
4812
|
+
long t = *(long*)(void*)(a); \
|
4813
|
+
*(long*)(void*)(a) = *(long*)(void*)(b); \
|
4814
|
+
*(long*)(void*)(b) = t; \
|
4815
|
+
} else \
|
4823
4816
|
swapfunc(a, b, es, swaptype)
|
4824
4817
|
|
4825
|
-
#define vecswap(a, b, n)
|
4818
|
+
#define vecswap(a, b, n) \
|
4826
4819
|
if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
|
4827
4820
|
|
4828
|
-
#define med3(a, b, c, _cmp)
|
4829
|
-
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a))
|
4821
|
+
#define med3(a, b, c, _cmp) \
|
4822
|
+
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) \
|
4830
4823
|
: (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
|
4831
4824
|
#endif
|
4832
4825
|
|
@@ -4917,8 +4910,8 @@ static void iter_int8_sort(na_loop_t* const lp) {
|
|
4917
4910
|
/*
|
4918
4911
|
sort of self.
|
4919
4912
|
@overload sort(axis:nil)
|
4920
|
-
|
4921
|
-
|
4913
|
+
@param [Numeric,Array,Range] axis Performs sort along the axis.
|
4914
|
+
@return [Numo::Int8] returns result of sort.
|
4922
4915
|
@example
|
4923
4916
|
Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
|
4924
4917
|
*/
|
@@ -5137,8 +5130,8 @@ static void int8_index32_qsort(na_loop_t* const lp) {
|
|
5137
5130
|
/*
|
5138
5131
|
sort_index. Returns an index array of sort result.
|
5139
5132
|
@overload sort_index(axis:nil)
|
5140
|
-
|
5141
|
-
|
5133
|
+
@param [Numeric,Array,Range] axis Performs sort_index along the axis.
|
5134
|
+
@return [Integer,Numo::Int] returns result index of sort_index.
|
5142
5135
|
@example
|
5143
5136
|
Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
|
5144
5137
|
*/
|
@@ -5202,10 +5195,10 @@ static void iter_int8_median(na_loop_t* const lp) {
|
|
5202
5195
|
/*
|
5203
5196
|
median of self.
|
5204
5197
|
@overload median(axis:nil, keepdims:false)
|
5205
|
-
|
5206
|
-
|
5207
|
-
|
5208
|
-
|
5198
|
+
@param [Numeric,Array,Range] axis Finds median along the axis.
|
5199
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
5200
|
+
dimensions with size one.
|
5201
|
+
@return [Numo::Int8] returns median of self.
|
5209
5202
|
*/
|
5210
5203
|
|
5211
5204
|
static VALUE int8_median(int argc, VALUE* argv, VALUE self) {
|
@@ -5244,13 +5237,15 @@ void Init_numo_int8(void) {
|
|
5244
5237
|
id_ne = rb_intern("ne");
|
5245
5238
|
id_to_a = rb_intern("to_a");
|
5246
5239
|
|
5247
|
-
|
5248
|
-
|
5249
|
-
|
5250
|
-
|
5240
|
+
/**
|
5241
|
+
* Document-class: Numo::Int8
|
5242
|
+
*
|
5243
|
+
* 8-bit signed integer N-dimensional array class.
|
5244
|
+
*/
|
5251
5245
|
cT = rb_define_class_under(mNumo, "Int8", cNArray);
|
5252
5246
|
|
5253
5247
|
hCast = rb_hash_new();
|
5248
|
+
/* Upcasting rules of Int8. */
|
5254
5249
|
rb_define_const(cT, "UPCAST", hCast);
|
5255
5250
|
rb_hash_aset(hCast, rb_cArray, cT);
|
5256
5251
|
|
@@ -5277,15 +5272,15 @@ void Init_numo_int8(void) {
|
|
5277
5272
|
rb_hash_aset(hCast, numo_cUInt8, numo_cInt16);
|
5278
5273
|
rb_obj_freeze(hCast);
|
5279
5274
|
|
5280
|
-
|
5275
|
+
/* Element size of Int8 in bits. */
|
5281
5276
|
rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
|
5282
|
-
|
5277
|
+
/* Element size of Int8 in bytes. */
|
5283
5278
|
rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
|
5284
|
-
|
5279
|
+
/* Stride size of contiguous Int8 array. */
|
5285
5280
|
rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
|
5286
|
-
|
5281
|
+
/* The largest representable value of Int8. */
|
5287
5282
|
rb_define_const(cT, "MAX", M_MAX);
|
5288
|
-
|
5283
|
+
/* The smallest representable value of Int8. */
|
5289
5284
|
rb_define_const(cT, "MIN", M_MIN);
|
5290
5285
|
rb_define_alloc_func(cT, int8_s_alloc_func);
|
5291
5286
|
rb_define_method(cT, "allocate", int8_allocate, 0);
|
@@ -5356,7 +5351,19 @@ void Init_numo_int8(void) {
|
|
5356
5351
|
rb_define_method(cT, "argmax", int8_argmax, -1);
|
5357
5352
|
rb_define_method(cT, "argmin", int8_argmin, -1);
|
5358
5353
|
rb_define_method(cT, "minmax", int8_minmax, -1);
|
5354
|
+
/**
|
5355
|
+
* Element-wise maximum of two arrays.
|
5356
|
+
* @overload maximum(a1, a2)
|
5357
|
+
* @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
|
5358
|
+
* @return [Numo::Int8]
|
5359
|
+
*/
|
5359
5360
|
rb_define_module_function(cT, "maximum", int8_s_maximum, -1);
|
5361
|
+
/**
|
5362
|
+
* Element-wise minimum of two arrays.
|
5363
|
+
* @overload minimum(a1, a2)
|
5364
|
+
* @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
|
5365
|
+
* @return [Numo::Int8]
|
5366
|
+
*/
|
5360
5367
|
rb_define_module_function(cT, "minimum", int8_s_minimum, -1);
|
5361
5368
|
rb_define_method(cT, "bincount", int8_bincount, -1);
|
5362
5369
|
rb_define_method(cT, "cumsum", int8_cumsum, -1);
|
@@ -5373,4 +5380,48 @@ void Init_numo_int8(void) {
|
|
5373
5380
|
rb_define_method(cT, "sort_index", int8_sort_index, -1);
|
5374
5381
|
rb_define_method(cT, "median", int8_median, -1);
|
5375
5382
|
rb_define_singleton_method(cT, "[]", int8_s_cast, -2);
|
5383
|
+
/**
|
5384
|
+
* mean of self.
|
5385
|
+
* @overload mean(axis: nil, keepdims: false, nan: false)
|
5386
|
+
* @param axis [Numeric, Array, Range] Performs mean along the axis.
|
5387
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5388
|
+
* dimensions with size one.
|
5389
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5390
|
+
* (avoid NaN for sum/mean etc, or return NaN for min/max etc).
|
5391
|
+
* @return [Numo::DFloat] returns result of mean.
|
5392
|
+
*/
|
5393
|
+
rb_define_method(cT, "mean", int8_mean, -1);
|
5394
|
+
/**
|
5395
|
+
* var of self.
|
5396
|
+
* @overload var(axis: nil, keepdims: false, nan: false)
|
5397
|
+
* @param axis [Numeric, Array, Range] Performs var along the axis.
|
5398
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5399
|
+
* dimensions with size one.
|
5400
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5401
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5402
|
+
* @return [Numo::DFloat] returns result of var.
|
5403
|
+
*/
|
5404
|
+
rb_define_method(cT, "var", int8_var, -1);
|
5405
|
+
/**
|
5406
|
+
* stddev of self.
|
5407
|
+
* @overload stddev(axis: nil, keepdims: false, nan: false)
|
5408
|
+
* @param axis [Numeric, Array, Range] Performs stddev along the axis.
|
5409
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5410
|
+
* dimensions with size one.
|
5411
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5412
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5413
|
+
* @return [Numo::DFloat] returns result of stddev.
|
5414
|
+
*/
|
5415
|
+
rb_define_method(cT, "stddev", int8_stddev, -1);
|
5416
|
+
/**
|
5417
|
+
* rms of self.
|
5418
|
+
* @overload rms(axis: nil, keepdims: false, nan: false)
|
5419
|
+
* @param axis [Numeric, Array, Range] Performs rms along the axis.
|
5420
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5421
|
+
* dimensions with size one.
|
5422
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5423
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5424
|
+
* @return [Numo::DFloat] returns result of rms.
|
5425
|
+
*/
|
5426
|
+
rb_define_method(cT, "rms", int8_rms, -1);
|
5376
5427
|
}
|