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/uint16.h>
|
39
39
|
|
40
|
-
VALUE cT;
|
41
|
-
extern VALUE cRT;
|
42
|
-
|
43
40
|
/*
|
44
41
|
class definition: Numo::UInt16
|
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_int16_t uint16; // Type aliases for shorter notation
|
52
|
+
// following the codebase naming convention.
|
53
|
+
DEF_NARRAY_INT_MEAN_METHOD_FUNC(uint16, numo_cUInt16)
|
54
|
+
DEF_NARRAY_INT_VAR_METHOD_FUNC(uint16, numo_cUInt16)
|
55
|
+
DEF_NARRAY_INT_STDDEV_METHOD_FUNC(uint16, numo_cUInt16)
|
56
|
+
DEF_NARRAY_INT_RMS_METHOD_FUNC(uint16, numo_cUInt16)
|
48
57
|
|
49
58
|
static VALUE uint16_store(VALUE, VALUE);
|
50
59
|
|
@@ -152,9 +161,9 @@ static VALUE uint16_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 uint16_extract(VALUE self) {
|
160
169
|
volatile VALUE v;
|
@@ -896,8 +905,8 @@ static VALUE uint16_store_array(VALUE self, VALUE rary) {
|
|
896
905
|
/*
|
897
906
|
Store elements to Numo::UInt16 from other.
|
898
907
|
@overload store(other)
|
899
|
-
|
900
|
-
|
908
|
+
@param [Object] other
|
909
|
+
@return [Numo::UInt16] self
|
901
910
|
*/
|
902
911
|
static VALUE uint16_store(VALUE self, VALUE obj) {
|
903
912
|
VALUE r, klass;
|
@@ -1109,9 +1118,9 @@ static VALUE uint16_cast_array(VALUE rary) {
|
|
1109
1118
|
Cast object to Numo::UInt16.
|
1110
1119
|
@overload [](elements)
|
1111
1120
|
@overload cast(array)
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1121
|
+
@param [Numeric,Array] elements
|
1122
|
+
@param [Array] array
|
1123
|
+
@return [Numo::UInt16]
|
1115
1124
|
*/
|
1116
1125
|
static VALUE uint16_s_cast(VALUE type, VALUE obj) {
|
1117
1126
|
VALUE v;
|
@@ -1151,9 +1160,9 @@ static VALUE uint16_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::UInt16] an element or NArray view.
|
1157
1166
|
@see Numo::NArray#[]
|
1158
1167
|
@see #[]=
|
1159
1168
|
*/
|
@@ -1174,10 +1183,10 @@ static VALUE uint16_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 uint16_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 uint16_coerce_cast(VALUE self, VALUE type) {
|
1214
1223
|
return Qnil;
|
@@ -1243,7 +1252,7 @@ static void iter_uint16_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 uint16_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_uint16_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::UInt16] self.
|
1281
1290
|
*/
|
1282
1291
|
static VALUE uint16_fill(VALUE self, VALUE val) {
|
1283
1292
|
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
|
@@ -1330,8 +1339,8 @@ static void iter_uint16_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 uint16_format(int argc, VALUE* argv, VALUE self) {
|
1337
1346
|
VALUE fmt = Qnil;
|
@@ -1377,8 +1386,8 @@ static void iter_uint16_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 uint16_format_to_a(int argc, VALUE* argv, VALUE self) {
|
1384
1393
|
VALUE fmt = Qnil;
|
@@ -1397,7 +1406,7 @@ static VALUE iter_uint16_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 uint16_inspect(VALUE ary) {
|
1403
1412
|
return na_ndloop_inspect(ary, iter_uint16_inspect, Qnil);
|
@@ -1431,9 +1440,9 @@ static void iter_uint16_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
|
*/
|
@@ -1510,7 +1519,7 @@ static void iter_uint16_map(na_loop_t* const lp) {
|
|
1510
1519
|
/*
|
1511
1520
|
Unary map.
|
1512
1521
|
@overload map
|
1513
|
-
|
1522
|
+
@return [Numo::UInt16] map of self.
|
1514
1523
|
*/
|
1515
1524
|
static VALUE uint16_map(VALUE self) {
|
1516
1525
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -1569,10 +1578,10 @@ static void iter_uint16_each_with_index(na_loop_t* const lp) {
|
|
1569
1578
|
Invokes the given block once for each element of self,
|
1570
1579
|
passing that element and indices along each axis as parameters.
|
1571
1580
|
@overload each_with_index
|
1572
|
-
|
1573
|
-
|
1574
|
-
|
1575
|
-
|
1581
|
+
For a block `{|x,i,j,...| ... }`,
|
1582
|
+
@yieldparam [Numeric] x an element
|
1583
|
+
@yieldparam [Integer] i,j,... multitimensional indices
|
1584
|
+
@return [Numo::NArray] self
|
1576
1585
|
@see #each
|
1577
1586
|
@see #map_with_index
|
1578
1587
|
*/
|
@@ -1660,10 +1669,10 @@ static void iter_uint16_map_with_index(na_loop_t* const lp) {
|
|
1660
1669
|
Creates a new NArray containing the values returned by the block.
|
1661
1670
|
Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
|
1662
1671
|
@overload map_with_index
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1672
|
+
For a block `{|x,i,j,...| ... }`,
|
1673
|
+
@yieldparam [Numeric] x an element
|
1674
|
+
@yieldparam [Integer] i,j,... multitimensional indices
|
1675
|
+
@return [Numo::NArray] mapped array
|
1667
1676
|
@see #map
|
1668
1677
|
@see #each_with_index
|
1669
1678
|
*/
|
@@ -1719,7 +1728,7 @@ static void iter_uint16_abs(na_loop_t* const lp) {
|
|
1719
1728
|
/*
|
1720
1729
|
abs of self.
|
1721
1730
|
@overload abs
|
1722
|
-
|
1731
|
+
@return [Numo::UInt16] abs of self.
|
1723
1732
|
*/
|
1724
1733
|
static VALUE uint16_abs(VALUE self) {
|
1725
1734
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -1729,7 +1738,7 @@ static VALUE uint16_abs(VALUE self) {
|
|
1729
1738
|
return na_ndloop(&ndf, 1, self);
|
1730
1739
|
}
|
1731
1740
|
|
1732
|
-
#define check_intdivzero(y)
|
1741
|
+
#define check_intdivzero(y) \
|
1733
1742
|
{}
|
1734
1743
|
|
1735
1744
|
static void iter_uint16_add(na_loop_t* const lp) {
|
@@ -1831,8 +1840,8 @@ static VALUE uint16_add_self(VALUE self, VALUE other) {
|
|
1831
1840
|
/*
|
1832
1841
|
Binary add.
|
1833
1842
|
@overload + other
|
1834
|
-
|
1835
|
-
|
1843
|
+
@param [Numo::NArray,Numeric] other
|
1844
|
+
@return [Numo::NArray] self + other
|
1836
1845
|
*/
|
1837
1846
|
static VALUE uint16_add(VALUE self, VALUE other) {
|
1838
1847
|
|
@@ -1847,7 +1856,7 @@ static VALUE uint16_add(VALUE self, VALUE other) {
|
|
1847
1856
|
}
|
1848
1857
|
}
|
1849
1858
|
|
1850
|
-
#define check_intdivzero(y)
|
1859
|
+
#define check_intdivzero(y) \
|
1851
1860
|
{}
|
1852
1861
|
|
1853
1862
|
static void iter_uint16_sub(na_loop_t* const lp) {
|
@@ -1949,8 +1958,8 @@ static VALUE uint16_sub_self(VALUE self, VALUE other) {
|
|
1949
1958
|
/*
|
1950
1959
|
Binary sub.
|
1951
1960
|
@overload - other
|
1952
|
-
|
1953
|
-
|
1961
|
+
@param [Numo::NArray,Numeric] other
|
1962
|
+
@return [Numo::NArray] self - other
|
1954
1963
|
*/
|
1955
1964
|
static VALUE uint16_sub(VALUE self, VALUE other) {
|
1956
1965
|
|
@@ -1965,7 +1974,7 @@ static VALUE uint16_sub(VALUE self, VALUE other) {
|
|
1965
1974
|
}
|
1966
1975
|
}
|
1967
1976
|
|
1968
|
-
#define check_intdivzero(y)
|
1977
|
+
#define check_intdivzero(y) \
|
1969
1978
|
{}
|
1970
1979
|
|
1971
1980
|
static void iter_uint16_mul(na_loop_t* const lp) {
|
@@ -2067,8 +2076,8 @@ static VALUE uint16_mul_self(VALUE self, VALUE other) {
|
|
2067
2076
|
/*
|
2068
2077
|
Binary mul.
|
2069
2078
|
@overload * other
|
2070
|
-
|
2071
|
-
|
2079
|
+
@param [Numo::NArray,Numeric] other
|
2080
|
+
@return [Numo::NArray] self * other
|
2072
2081
|
*/
|
2073
2082
|
static VALUE uint16_mul(VALUE self, VALUE other) {
|
2074
2083
|
|
@@ -2083,10 +2092,10 @@ static VALUE uint16_mul(VALUE self, VALUE other) {
|
|
2083
2092
|
}
|
2084
2093
|
}
|
2085
2094
|
|
2086
|
-
#define check_intdivzero(y)
|
2087
|
-
if ((y) == 0) {
|
2088
|
-
lp->err_type = rb_eZeroDivError;
|
2089
|
-
return;
|
2095
|
+
#define check_intdivzero(y) \
|
2096
|
+
if ((y) == 0) { \
|
2097
|
+
lp->err_type = rb_eZeroDivError; \
|
2098
|
+
return; \
|
2090
2099
|
}
|
2091
2100
|
|
2092
2101
|
static void iter_uint16_div(na_loop_t* const lp) {
|
@@ -2188,8 +2197,8 @@ static VALUE uint16_div_self(VALUE self, VALUE other) {
|
|
2188
2197
|
/*
|
2189
2198
|
Binary div.
|
2190
2199
|
@overload / other
|
2191
|
-
|
2192
|
-
|
2200
|
+
@param [Numo::NArray,Numeric] other
|
2201
|
+
@return [Numo::NArray] self / other
|
2193
2202
|
*/
|
2194
2203
|
static VALUE uint16_div(VALUE self, VALUE other) {
|
2195
2204
|
|
@@ -2204,10 +2213,10 @@ static VALUE uint16_div(VALUE self, VALUE other) {
|
|
2204
2213
|
}
|
2205
2214
|
}
|
2206
2215
|
|
2207
|
-
#define check_intdivzero(y)
|
2208
|
-
if ((y) == 0) {
|
2209
|
-
lp->err_type = rb_eZeroDivError;
|
2210
|
-
return;
|
2216
|
+
#define check_intdivzero(y) \
|
2217
|
+
if ((y) == 0) { \
|
2218
|
+
lp->err_type = rb_eZeroDivError; \
|
2219
|
+
return; \
|
2211
2220
|
}
|
2212
2221
|
|
2213
2222
|
static void iter_uint16_mod(na_loop_t* const lp) {
|
@@ -2309,8 +2318,8 @@ static VALUE uint16_mod_self(VALUE self, VALUE other) {
|
|
2309
2318
|
/*
|
2310
2319
|
Binary mod.
|
2311
2320
|
@overload % other
|
2312
|
-
|
2313
|
-
|
2321
|
+
@param [Numo::NArray,Numeric] other
|
2322
|
+
@return [Numo::NArray] self % other
|
2314
2323
|
*/
|
2315
2324
|
static VALUE uint16_mod(VALUE self, VALUE other) {
|
2316
2325
|
|
@@ -2359,8 +2368,8 @@ static VALUE uint16_divmod_self(VALUE self, VALUE other) {
|
|
2359
2368
|
/*
|
2360
2369
|
Binary divmod.
|
2361
2370
|
@overload divmod other
|
2362
|
-
|
2363
|
-
|
2371
|
+
@param [Numo::NArray,Numeric] other
|
2372
|
+
@return [Numo::NArray] divmod of self and other.
|
2364
2373
|
*/
|
2365
2374
|
static VALUE uint16_divmod(VALUE self, VALUE other) {
|
2366
2375
|
|
@@ -2427,8 +2436,8 @@ static VALUE uint16_pow_self(VALUE self, VALUE other) {
|
|
2427
2436
|
/*
|
2428
2437
|
Binary power.
|
2429
2438
|
@overload ** other
|
2430
|
-
|
2431
|
-
|
2439
|
+
@param [Numo::NArray,Numeric] other
|
2440
|
+
@return [Numo::NArray] self to the other-th power.
|
2432
2441
|
*/
|
2433
2442
|
static VALUE uint16_pow(VALUE self, VALUE other) {
|
2434
2443
|
|
@@ -2507,7 +2516,7 @@ static void iter_uint16_minus(na_loop_t* const lp) {
|
|
2507
2516
|
/*
|
2508
2517
|
Unary minus.
|
2509
2518
|
@overload -@
|
2510
|
-
|
2519
|
+
@return [Numo::UInt16] minus of self.
|
2511
2520
|
*/
|
2512
2521
|
static VALUE uint16_minus(VALUE self) {
|
2513
2522
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2582,7 +2591,7 @@ static void iter_uint16_reciprocal(na_loop_t* const lp) {
|
|
2582
2591
|
/*
|
2583
2592
|
Unary reciprocal.
|
2584
2593
|
@overload reciprocal
|
2585
|
-
|
2594
|
+
@return [Numo::UInt16] reciprocal of self.
|
2586
2595
|
*/
|
2587
2596
|
static VALUE uint16_reciprocal(VALUE self) {
|
2588
2597
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2657,7 +2666,7 @@ static void iter_uint16_sign(na_loop_t* const lp) {
|
|
2657
2666
|
/*
|
2658
2667
|
Unary sign.
|
2659
2668
|
@overload sign
|
2660
|
-
|
2669
|
+
@return [Numo::UInt16] sign of self.
|
2661
2670
|
*/
|
2662
2671
|
static VALUE uint16_sign(VALUE self) {
|
2663
2672
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2732,7 +2741,7 @@ static void iter_uint16_square(na_loop_t* const lp) {
|
|
2732
2741
|
/*
|
2733
2742
|
Unary square.
|
2734
2743
|
@overload square
|
2735
|
-
|
2744
|
+
@return [Numo::UInt16] square of self.
|
2736
2745
|
*/
|
2737
2746
|
static VALUE uint16_square(VALUE self) {
|
2738
2747
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2774,8 +2783,8 @@ static VALUE uint16_eq_self(VALUE self, VALUE other) {
|
|
2774
2783
|
/*
|
2775
2784
|
Comparison eq other.
|
2776
2785
|
@overload eq other
|
2777
|
-
|
2778
|
-
|
2786
|
+
@param [Numo::NArray,Numeric] other
|
2787
|
+
@return [Numo::Bit] result of self eq other.
|
2779
2788
|
*/
|
2780
2789
|
static VALUE uint16_eq(VALUE self, VALUE other) {
|
2781
2790
|
|
@@ -2821,8 +2830,8 @@ static VALUE uint16_ne_self(VALUE self, VALUE other) {
|
|
2821
2830
|
/*
|
2822
2831
|
Comparison ne other.
|
2823
2832
|
@overload ne other
|
2824
|
-
|
2825
|
-
|
2833
|
+
@param [Numo::NArray,Numeric] other
|
2834
|
+
@return [Numo::Bit] result of self ne other.
|
2826
2835
|
*/
|
2827
2836
|
static VALUE uint16_ne(VALUE self, VALUE other) {
|
2828
2837
|
|
@@ -2836,7 +2845,7 @@ static VALUE uint16_ne(VALUE self, VALUE other) {
|
|
2836
2845
|
}
|
2837
2846
|
}
|
2838
2847
|
|
2839
|
-
#define check_intdivzero(y)
|
2848
|
+
#define check_intdivzero(y) \
|
2840
2849
|
{}
|
2841
2850
|
|
2842
2851
|
static void iter_uint16_bit_and(na_loop_t* const lp) {
|
@@ -2938,8 +2947,8 @@ static VALUE uint16_bit_and_self(VALUE self, VALUE other) {
|
|
2938
2947
|
/*
|
2939
2948
|
Binary bit_and.
|
2940
2949
|
@overload & other
|
2941
|
-
|
2942
|
-
|
2950
|
+
@param [Numo::NArray,Numeric] other
|
2951
|
+
@return [Numo::NArray] self & other
|
2943
2952
|
*/
|
2944
2953
|
static VALUE uint16_bit_and(VALUE self, VALUE other) {
|
2945
2954
|
|
@@ -2954,7 +2963,7 @@ static VALUE uint16_bit_and(VALUE self, VALUE other) {
|
|
2954
2963
|
}
|
2955
2964
|
}
|
2956
2965
|
|
2957
|
-
#define check_intdivzero(y)
|
2966
|
+
#define check_intdivzero(y) \
|
2958
2967
|
{}
|
2959
2968
|
|
2960
2969
|
static void iter_uint16_bit_or(na_loop_t* const lp) {
|
@@ -3056,8 +3065,8 @@ static VALUE uint16_bit_or_self(VALUE self, VALUE other) {
|
|
3056
3065
|
/*
|
3057
3066
|
Binary bit_or.
|
3058
3067
|
@overload | other
|
3059
|
-
|
3060
|
-
|
3068
|
+
@param [Numo::NArray,Numeric] other
|
3069
|
+
@return [Numo::NArray] self | other
|
3061
3070
|
*/
|
3062
3071
|
static VALUE uint16_bit_or(VALUE self, VALUE other) {
|
3063
3072
|
|
@@ -3072,7 +3081,7 @@ static VALUE uint16_bit_or(VALUE self, VALUE other) {
|
|
3072
3081
|
}
|
3073
3082
|
}
|
3074
3083
|
|
3075
|
-
#define check_intdivzero(y)
|
3084
|
+
#define check_intdivzero(y) \
|
3076
3085
|
{}
|
3077
3086
|
|
3078
3087
|
static void iter_uint16_bit_xor(na_loop_t* const lp) {
|
@@ -3174,8 +3183,8 @@ static VALUE uint16_bit_xor_self(VALUE self, VALUE other) {
|
|
3174
3183
|
/*
|
3175
3184
|
Binary bit_xor.
|
3176
3185
|
@overload ^ other
|
3177
|
-
|
3178
|
-
|
3186
|
+
@param [Numo::NArray,Numeric] other
|
3187
|
+
@return [Numo::NArray] self ^ other
|
3179
3188
|
*/
|
3180
3189
|
static VALUE uint16_bit_xor(VALUE self, VALUE other) {
|
3181
3190
|
|
@@ -3255,7 +3264,7 @@ static void iter_uint16_bit_not(na_loop_t* const lp) {
|
|
3255
3264
|
/*
|
3256
3265
|
Unary bit_not.
|
3257
3266
|
@overload ~
|
3258
|
-
|
3267
|
+
@return [Numo::UInt16] bit_not of self.
|
3259
3268
|
*/
|
3260
3269
|
static VALUE uint16_bit_not(VALUE self) {
|
3261
3270
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -3265,7 +3274,7 @@ static VALUE uint16_bit_not(VALUE self) {
|
|
3265
3274
|
return na_ndloop(&ndf, 1, self);
|
3266
3275
|
}
|
3267
3276
|
|
3268
|
-
#define check_intdivzero(y)
|
3277
|
+
#define check_intdivzero(y) \
|
3269
3278
|
{}
|
3270
3279
|
|
3271
3280
|
static void iter_uint16_left_shift(na_loop_t* const lp) {
|
@@ -3367,8 +3376,8 @@ static VALUE uint16_left_shift_self(VALUE self, VALUE other) {
|
|
3367
3376
|
/*
|
3368
3377
|
Binary left_shift.
|
3369
3378
|
@overload << other
|
3370
|
-
|
3371
|
-
|
3379
|
+
@param [Numo::NArray,Numeric] other
|
3380
|
+
@return [Numo::NArray] self << other
|
3372
3381
|
*/
|
3373
3382
|
static VALUE uint16_left_shift(VALUE self, VALUE other) {
|
3374
3383
|
|
@@ -3383,7 +3392,7 @@ static VALUE uint16_left_shift(VALUE self, VALUE other) {
|
|
3383
3392
|
}
|
3384
3393
|
}
|
3385
3394
|
|
3386
|
-
#define check_intdivzero(y)
|
3395
|
+
#define check_intdivzero(y) \
|
3387
3396
|
{}
|
3388
3397
|
|
3389
3398
|
static void iter_uint16_right_shift(na_loop_t* const lp) {
|
@@ -3485,8 +3494,8 @@ static VALUE uint16_right_shift_self(VALUE self, VALUE other) {
|
|
3485
3494
|
/*
|
3486
3495
|
Binary right_shift.
|
3487
3496
|
@overload >> other
|
3488
|
-
|
3489
|
-
|
3497
|
+
@param [Numo::NArray,Numeric] other
|
3498
|
+
@return [Numo::NArray] self >> other
|
3490
3499
|
*/
|
3491
3500
|
static VALUE uint16_right_shift(VALUE self, VALUE other) {
|
3492
3501
|
|
@@ -3533,8 +3542,8 @@ static VALUE uint16_gt_self(VALUE self, VALUE other) {
|
|
3533
3542
|
/*
|
3534
3543
|
Comparison gt other.
|
3535
3544
|
@overload gt other
|
3536
|
-
|
3537
|
-
|
3545
|
+
@param [Numo::NArray,Numeric] other
|
3546
|
+
@return [Numo::Bit] result of self gt other.
|
3538
3547
|
*/
|
3539
3548
|
static VALUE uint16_gt(VALUE self, VALUE other) {
|
3540
3549
|
|
@@ -3580,8 +3589,8 @@ static VALUE uint16_ge_self(VALUE self, VALUE other) {
|
|
3580
3589
|
/*
|
3581
3590
|
Comparison ge other.
|
3582
3591
|
@overload ge other
|
3583
|
-
|
3584
|
-
|
3592
|
+
@param [Numo::NArray,Numeric] other
|
3593
|
+
@return [Numo::Bit] result of self ge other.
|
3585
3594
|
*/
|
3586
3595
|
static VALUE uint16_ge(VALUE self, VALUE other) {
|
3587
3596
|
|
@@ -3627,8 +3636,8 @@ static VALUE uint16_lt_self(VALUE self, VALUE other) {
|
|
3627
3636
|
/*
|
3628
3637
|
Comparison lt other.
|
3629
3638
|
@overload lt other
|
3630
|
-
|
3631
|
-
|
3639
|
+
@param [Numo::NArray,Numeric] other
|
3640
|
+
@return [Numo::Bit] result of self lt other.
|
3632
3641
|
*/
|
3633
3642
|
static VALUE uint16_lt(VALUE self, VALUE other) {
|
3634
3643
|
|
@@ -3674,8 +3683,8 @@ static VALUE uint16_le_self(VALUE self, VALUE other) {
|
|
3674
3683
|
/*
|
3675
3684
|
Comparison le other.
|
3676
3685
|
@overload le other
|
3677
|
-
|
3678
|
-
|
3686
|
+
@param [Numo::NArray,Numeric] other
|
3687
|
+
@return [Numo::Bit] result of self le other.
|
3679
3688
|
*/
|
3680
3689
|
static VALUE uint16_le(VALUE self, VALUE other) {
|
3681
3690
|
|
@@ -3758,9 +3767,9 @@ static void iter_uint16_clip_max(na_loop_t* const lp) {
|
|
3758
3767
|
Clip array elements by [min,max].
|
3759
3768
|
If either of min or max is nil, one side is clipped.
|
3760
3769
|
@overload clip(min,max)
|
3761
|
-
|
3762
|
-
|
3763
|
-
|
3770
|
+
@param [Numo::NArray,Numeric] min
|
3771
|
+
@param [Numo::NArray,Numeric] max
|
3772
|
+
@return [Numo::NArray] result of clip.
|
3764
3773
|
|
3765
3774
|
@example
|
3766
3775
|
a = Numo::Int32.new(10).seq
|
@@ -3821,10 +3830,10 @@ static void iter_uint16_sum(na_loop_t* const lp) {
|
|
3821
3830
|
/*
|
3822
3831
|
sum of self.
|
3823
3832
|
@overload sum(axis:nil, keepdims:false)
|
3824
|
-
|
3825
|
-
|
3826
|
-
|
3827
|
-
|
3833
|
+
@param [Numeric,Array,Range] axis Performs sum along the axis.
|
3834
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3835
|
+
dimensions with size one.
|
3836
|
+
@return [Numo::UInt16] returns result of sum.
|
3828
3837
|
*/
|
3829
3838
|
static VALUE uint16_sum(int argc, VALUE* argv, VALUE self) {
|
3830
3839
|
VALUE v, reduce;
|
@@ -3854,10 +3863,10 @@ static void iter_uint16_prod(na_loop_t* const lp) {
|
|
3854
3863
|
/*
|
3855
3864
|
prod of self.
|
3856
3865
|
@overload prod(axis:nil, keepdims:false)
|
3857
|
-
|
3858
|
-
|
3859
|
-
|
3860
|
-
|
3866
|
+
@param [Numeric,Array,Range] axis Performs prod along the axis.
|
3867
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3868
|
+
dimensions with size one.
|
3869
|
+
@return [Numo::UInt16] returns result of prod.
|
3861
3870
|
*/
|
3862
3871
|
static VALUE uint16_prod(int argc, VALUE* argv, VALUE self) {
|
3863
3872
|
VALUE v, reduce;
|
@@ -3887,10 +3896,10 @@ static void iter_uint16_min(na_loop_t* const lp) {
|
|
3887
3896
|
/*
|
3888
3897
|
min of self.
|
3889
3898
|
@overload min(axis:nil, keepdims:false)
|
3890
|
-
|
3891
|
-
|
3892
|
-
|
3893
|
-
|
3899
|
+
@param [Numeric,Array,Range] axis Performs min along the axis.
|
3900
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3901
|
+
dimensions with size one.
|
3902
|
+
@return [Numo::UInt16] returns result of min.
|
3894
3903
|
*/
|
3895
3904
|
static VALUE uint16_min(int argc, VALUE* argv, VALUE self) {
|
3896
3905
|
VALUE v, reduce;
|
@@ -3920,10 +3929,10 @@ static void iter_uint16_max(na_loop_t* const lp) {
|
|
3920
3929
|
/*
|
3921
3930
|
max of self.
|
3922
3931
|
@overload max(axis:nil, keepdims:false)
|
3923
|
-
|
3924
|
-
|
3925
|
-
|
3926
|
-
|
3932
|
+
@param [Numeric,Array,Range] axis Performs max along the axis.
|
3933
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3934
|
+
dimensions with size one.
|
3935
|
+
@return [Numo::UInt16] returns result of max.
|
3927
3936
|
*/
|
3928
3937
|
static VALUE uint16_max(int argc, VALUE* argv, VALUE self) {
|
3929
3938
|
VALUE v, reduce;
|
@@ -3953,10 +3962,10 @@ static void iter_uint16_ptp(na_loop_t* const lp) {
|
|
3953
3962
|
/*
|
3954
3963
|
ptp of self.
|
3955
3964
|
@overload ptp(axis:nil, keepdims:false)
|
3956
|
-
|
3957
|
-
|
3958
|
-
|
3959
|
-
|
3965
|
+
@param [Numeric,Array,Range] axis Performs ptp along the axis.
|
3966
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3967
|
+
dimensions with size one.
|
3968
|
+
@return [Numo::UInt16] returns result of ptp.
|
3960
3969
|
*/
|
3961
3970
|
static VALUE uint16_ptp(int argc, VALUE* argv, VALUE self) {
|
3962
3971
|
VALUE v, reduce;
|
@@ -4008,9 +4017,9 @@ static void iter_uint16_max_index_index32(na_loop_t* const lp) {
|
|
4008
4017
|
/*
|
4009
4018
|
Index of the maximum value.
|
4010
4019
|
@overload max_index(axis:nil)
|
4011
|
-
|
4012
|
-
|
4013
|
-
|
4020
|
+
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat
|
4021
|
+
1-d indices**.
|
4022
|
+
@return [Integer,Numo::Int] returns result indices.
|
4014
4023
|
@see #argmax
|
4015
4024
|
@see #max
|
4016
4025
|
|
@@ -4091,9 +4100,9 @@ static void iter_uint16_min_index_index32(na_loop_t* const lp) {
|
|
4091
4100
|
/*
|
4092
4101
|
Index of the minimum value.
|
4093
4102
|
@overload min_index(axis:nil)
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4103
|
+
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat
|
4104
|
+
1-d indices**.
|
4105
|
+
@return [Integer,Numo::Int] returns result indices.
|
4097
4106
|
@see #argmin
|
4098
4107
|
@see #min
|
4099
4108
|
|
@@ -4172,9 +4181,9 @@ static void iter_uint16_argmax_arg32(na_loop_t* const lp) {
|
|
4172
4181
|
/*
|
4173
4182
|
Index of the maximum value.
|
4174
4183
|
@overload argmax(axis:nil)
|
4175
|
-
|
4176
|
-
|
4177
|
-
|
4184
|
+
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices
|
4185
|
+
along the axis**.
|
4186
|
+
@return [Integer,Numo::Int] returns the result indices.
|
4178
4187
|
@see #max_index
|
4179
4188
|
@see #max
|
4180
4189
|
|
@@ -4250,9 +4259,9 @@ static void iter_uint16_argmin_arg32(na_loop_t* const lp) {
|
|
4250
4259
|
/*
|
4251
4260
|
Index of the minimum value.
|
4252
4261
|
@overload argmin(axis:nil)
|
4253
|
-
|
4254
|
-
|
4255
|
-
|
4262
|
+
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices
|
4263
|
+
along the axis**.
|
4264
|
+
@return [Integer,Numo::Int] returns the result indices.
|
4256
4265
|
@see #min_index
|
4257
4266
|
@see #min
|
4258
4267
|
|
@@ -4311,10 +4320,10 @@ static void iter_uint16_minmax(na_loop_t* const lp) {
|
|
4311
4320
|
/*
|
4312
4321
|
minmax of self.
|
4313
4322
|
@overload minmax(axis:nil, keepdims:false)
|
4314
|
-
|
4315
|
-
|
4316
|
-
|
4317
|
-
|
4323
|
+
@param [Numeric,Array,Range] axis Finds min-max along the axis.
|
4324
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
4325
|
+
as dimensions with size one.
|
4326
|
+
@return [Numo::UInt16,Numo::UInt16] min and max of self.
|
4318
4327
|
*/
|
4319
4328
|
static VALUE uint16_minmax(int argc, VALUE* argv, VALUE self) {
|
4320
4329
|
VALUE reduce;
|
@@ -4329,14 +4338,6 @@ static VALUE uint16_minmax(int argc, VALUE* argv, VALUE self) {
|
|
4329
4338
|
return na_ndloop(&ndf, 2, self, reduce);
|
4330
4339
|
}
|
4331
4340
|
|
4332
|
-
/*
|
4333
|
-
Element-wise maximum of two arrays.
|
4334
|
-
|
4335
|
-
@overload maximum(a1, a2)
|
4336
|
-
@param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
|
4337
|
-
@return [Numo::UInt16]
|
4338
|
-
*/
|
4339
|
-
|
4340
4341
|
static void iter_uint16_s_maximum(na_loop_t* const lp) {
|
4341
4342
|
size_t i, n;
|
4342
4343
|
char *p1, *p2, *p3;
|
@@ -4369,14 +4370,6 @@ static VALUE uint16_s_maximum(int argc, VALUE* argv, VALUE mod) {
|
|
4369
4370
|
return na_ndloop(&ndf, 2, a1, a2);
|
4370
4371
|
}
|
4371
4372
|
|
4372
|
-
/*
|
4373
|
-
Element-wise minimum of two arrays.
|
4374
|
-
|
4375
|
-
@overload minimum(a1, a2)
|
4376
|
-
@param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
|
4377
|
-
@return [Numo::UInt16]
|
4378
|
-
*/
|
4379
|
-
|
4380
4373
|
static void iter_uint16_s_minimum(na_loop_t* const lp) {
|
4381
4374
|
size_t i, n;
|
4382
4375
|
char *p1, *p2, *p3;
|
@@ -4574,13 +4567,13 @@ static VALUE uint16_bincount_df(VALUE self, VALUE weight, size_t length) {
|
|
4574
4567
|
Only Integer-types has this method.
|
4575
4568
|
|
4576
4569
|
@overload bincount([weight], minlength:nil)
|
4577
|
-
|
4578
|
-
|
4579
|
-
|
4580
|
-
|
4581
|
-
|
4582
|
-
|
4583
|
-
|
4570
|
+
@param [SFloat or DFloat or Array] weight (optional) Array of
|
4571
|
+
float values. Its size along last axis should be same as that of self.
|
4572
|
+
@param [Integer] minlength (keyword, optional) Minimum size along
|
4573
|
+
last axis for the output array.
|
4574
|
+
@return [UInt32 or UInt64 or SFloat or DFloat]
|
4575
|
+
Returns Float NArray if weight array is supplied,
|
4576
|
+
otherwise returns UInt32 or UInt64 depending on the size along last axis.
|
4584
4577
|
@example
|
4585
4578
|
Numo::Int32[0..4].bincount
|
4586
4579
|
# => Numo::UInt32#shape=[5]
|
@@ -4660,9 +4653,9 @@ static void iter_uint16_cumsum(na_loop_t* const lp) {
|
|
4660
4653
|
/*
|
4661
4654
|
cumsum of self.
|
4662
4655
|
@overload cumsum(axis:nil, nan:false)
|
4663
|
-
|
4664
|
-
|
4665
|
-
|
4656
|
+
@param [Numeric,Array,Range] axis Performs cumsum along the axis.
|
4657
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
4658
|
+
@return [Numo::UInt16] cumsum of self.
|
4666
4659
|
*/
|
4667
4660
|
static VALUE uint16_cumsum(int argc, VALUE* argv, VALUE self) {
|
4668
4661
|
VALUE reduce;
|
@@ -4699,9 +4692,9 @@ static void iter_uint16_cumprod(na_loop_t* const lp) {
|
|
4699
4692
|
/*
|
4700
4693
|
cumprod of self.
|
4701
4694
|
@overload cumprod(axis:nil, nan:false)
|
4702
|
-
|
4703
|
-
|
4704
|
-
|
4695
|
+
@param [Numeric,Array,Range] axis Performs cumprod along the axis.
|
4696
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
4697
|
+
@return [Numo::UInt16] cumprod of self.
|
4705
4698
|
*/
|
4706
4699
|
static VALUE uint16_cumprod(int argc, VALUE* argv, VALUE self) {
|
4707
4700
|
VALUE reduce;
|
@@ -4777,11 +4770,11 @@ static VALUE uint16_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
|
4777
4770
|
Binary mulsum.
|
4778
4771
|
|
4779
4772
|
@overload mulsum(other, axis:nil, keepdims:false)
|
4780
|
-
|
4781
|
-
|
4782
|
-
|
4783
|
-
|
4784
|
-
|
4773
|
+
@param [Numo::NArray,Numeric] other
|
4774
|
+
@param [Numeric,Array,Range] axis Performs mulsum along the axis.
|
4775
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
4776
|
+
as dimensions with size one.
|
4777
|
+
@return [Numo::NArray] mulsum of self and other.
|
4785
4778
|
*/
|
4786
4779
|
static VALUE uint16_mulsum(int argc, VALUE* argv, VALUE self) {
|
4787
4780
|
//
|
@@ -4850,9 +4843,9 @@ static void iter_uint16_seq(na_loop_t* const lp) {
|
|
4850
4843
|
beg+i*step
|
4851
4844
|
where i is 1-dimensional index.
|
4852
4845
|
@overload seq([beg,[step]])
|
4853
|
-
|
4854
|
-
|
4855
|
-
|
4846
|
+
@param [Numeric] beg beginning of sequence. (default=0)
|
4847
|
+
@param [Numeric] step step of sequence. (default=1)
|
4848
|
+
@return [Numo::UInt16] self.
|
4856
4849
|
@example
|
4857
4850
|
Numo::DFloat.new(6).seq(1,-0.2)
|
4858
4851
|
# => Numo::DFloat#shape=[6]
|
@@ -4862,7 +4855,7 @@ static void iter_uint16_seq(na_loop_t* const lp) {
|
|
4862
4855
|
# => Numo::DComplex#shape=[6]
|
4863
4856
|
# [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
4864
4857
|
*/
|
4865
|
-
static VALUE uint16_seq(int argc, VALUE*
|
4858
|
+
static VALUE uint16_seq(int argc, VALUE* argv, VALUE self) {
|
4866
4859
|
seq_opt_t* g;
|
4867
4860
|
VALUE vbeg = Qnil, vstep = Qnil;
|
4868
4861
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
@@ -4872,7 +4865,7 @@ static VALUE uint16_seq(int argc, VALUE* args, VALUE self) {
|
|
4872
4865
|
g->beg = m_zero;
|
4873
4866
|
g->step = m_one;
|
4874
4867
|
g->count = 0;
|
4875
|
-
rb_scan_args(argc,
|
4868
|
+
rb_scan_args(argc, argv, "02", &vbeg, &vstep);
|
4876
4869
|
if (vbeg != Qnil) {
|
4877
4870
|
g->beg = NUM2DBL(vbeg);
|
4878
4871
|
}
|
@@ -4916,11 +4909,11 @@ static void iter_uint16_eye(na_loop_t* const lp) {
|
|
4916
4909
|
/*
|
4917
4910
|
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
|
4918
4911
|
@overload eye([element,offset])
|
4919
|
-
|
4920
|
-
|
4921
|
-
|
4922
|
-
|
4923
|
-
|
4912
|
+
@param [Numeric] element Diagonal element to be stored. Default is 1.
|
4913
|
+
@param [Integer] offset Diagonal offset from the main diagonal. The
|
4914
|
+
default is 0. k>0 for diagonals above the main diagonal, and k<0
|
4915
|
+
for diagonals below the main diagonal.
|
4916
|
+
@return [Numo::UInt16] eye of self.
|
4924
4917
|
*/
|
4925
4918
|
static VALUE uint16_eye(int argc, VALUE* argv, VALUE self) {
|
4926
4919
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
|
@@ -5052,10 +5045,10 @@ static void iter_uint16_rand(na_loop_t* const lp) {
|
|
5052
5045
|
/*
|
5053
5046
|
Generate uniformly distributed random numbers on self narray.
|
5054
5047
|
@overload rand([[low],high])
|
5055
|
-
|
5056
|
-
|
5057
|
-
|
5058
|
-
|
5048
|
+
@param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
5049
|
+
@param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
|
5050
|
+
complex types)
|
5051
|
+
@return [Numo::UInt16] self.
|
5059
5052
|
@example
|
5060
5053
|
Numo::DFloat.new(6).rand
|
5061
5054
|
# => Numo::DFloat#shape=[6]
|
@@ -5069,14 +5062,14 @@ static void iter_uint16_rand(na_loop_t* const lp) {
|
|
5069
5062
|
# => Numo::Int32#shape=[6]
|
5070
5063
|
# [4, 3, 3, 2, 4, 2]
|
5071
5064
|
*/
|
5072
|
-
static VALUE uint16_rand(int argc, VALUE*
|
5065
|
+
static VALUE uint16_rand(int argc, VALUE* argv, VALUE self) {
|
5073
5066
|
rand_opt_t g;
|
5074
5067
|
VALUE v1 = Qnil, v2 = Qnil;
|
5075
5068
|
dtype high;
|
5076
5069
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
5077
5070
|
ndfunc_t ndf = { iter_uint16_rand, FULL_LOOP, 1, 0, ain, 0 };
|
5078
5071
|
|
5079
|
-
rb_scan_args(argc,
|
5072
|
+
rb_scan_args(argc, argv, "11", &v1, &v2);
|
5080
5073
|
if (v2 == Qnil) {
|
5081
5074
|
g.low = m_zero;
|
5082
5075
|
g.max = high = m_num_to_data(v1);
|
@@ -5115,8 +5108,8 @@ static void iter_uint16_poly(na_loop_t* const lp) {
|
|
5115
5108
|
Calculate polynomial.
|
5116
5109
|
`x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
|
5117
5110
|
@overload poly a0, a1, ..., an
|
5118
|
-
|
5119
|
-
|
5111
|
+
@param [Numo::NArray,Numeric] a0,a1,...,an
|
5112
|
+
@return [Numo::UInt16]
|
5120
5113
|
*/
|
5121
5114
|
static VALUE uint16_poly(VALUE self, VALUE args) {
|
5122
5115
|
int argc, i;
|
@@ -5203,27 +5196,27 @@ static VALUE uint16_poly(VALUE self, VALUE args) {
|
|
5203
5196
|
* We have modified their original by adding a check for already-sorted input,
|
5204
5197
|
* which seems to be a win per discussions on pgsql-hackers around 2006-03-21.
|
5205
5198
|
*/
|
5206
|
-
#define swapcode(TYPE, parmi, parmj, n)
|
5207
|
-
do {
|
5208
|
-
size_t i = (n) / sizeof(TYPE);
|
5209
|
-
TYPE* pi = (TYPE*)(void*)(parmi);
|
5210
|
-
TYPE* pj = (TYPE*)(void*)(parmj);
|
5211
|
-
do {
|
5212
|
-
TYPE t = *pi;
|
5213
|
-
*pi++ = *pj;
|
5214
|
-
*pj++ = t;
|
5215
|
-
} while (--i > 0);
|
5199
|
+
#define swapcode(TYPE, parmi, parmj, n) \
|
5200
|
+
do { \
|
5201
|
+
size_t i = (n) / sizeof(TYPE); \
|
5202
|
+
TYPE* pi = (TYPE*)(void*)(parmi); \
|
5203
|
+
TYPE* pj = (TYPE*)(void*)(parmj); \
|
5204
|
+
do { \
|
5205
|
+
TYPE t = *pi; \
|
5206
|
+
*pi++ = *pj; \
|
5207
|
+
*pj++ = t; \
|
5208
|
+
} while (--i > 0); \
|
5216
5209
|
} while (0)
|
5217
5210
|
|
5218
5211
|
#ifdef HAVE_STDINT_H
|
5219
|
-
#define SWAPINIT(a, es)
|
5220
|
-
swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2
|
5221
|
-
: (es) == sizeof(long) ? 0
|
5212
|
+
#define SWAPINIT(a, es) \
|
5213
|
+
swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
5214
|
+
: (es) == sizeof(long) ? 0 \
|
5222
5215
|
: 1;
|
5223
5216
|
#else
|
5224
|
-
#define SWAPINIT(a, es)
|
5225
|
-
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2
|
5226
|
-
: (es) == sizeof(long) ? 0
|
5217
|
+
#define SWAPINIT(a, es) \
|
5218
|
+
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
5219
|
+
: (es) == sizeof(long) ? 0 \
|
5227
5220
|
: 1;
|
5228
5221
|
#endif
|
5229
5222
|
|
@@ -5234,19 +5227,19 @@ static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
|
|
5234
5227
|
swapcode(char, a, b, n);
|
5235
5228
|
}
|
5236
5229
|
|
5237
|
-
#define swap(a, b)
|
5238
|
-
if (swaptype == 0) {
|
5239
|
-
long t = *(long*)(void*)(a);
|
5240
|
-
*(long*)(void*)(a) = *(long*)(void*)(b);
|
5241
|
-
*(long*)(void*)(b) = t;
|
5242
|
-
} else
|
5230
|
+
#define swap(a, b) \
|
5231
|
+
if (swaptype == 0) { \
|
5232
|
+
long t = *(long*)(void*)(a); \
|
5233
|
+
*(long*)(void*)(a) = *(long*)(void*)(b); \
|
5234
|
+
*(long*)(void*)(b) = t; \
|
5235
|
+
} else \
|
5243
5236
|
swapfunc(a, b, es, swaptype)
|
5244
5237
|
|
5245
|
-
#define vecswap(a, b, n)
|
5238
|
+
#define vecswap(a, b, n) \
|
5246
5239
|
if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
|
5247
5240
|
|
5248
|
-
#define med3(a, b, c, _cmp)
|
5249
|
-
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a))
|
5241
|
+
#define med3(a, b, c, _cmp) \
|
5242
|
+
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) \
|
5250
5243
|
: (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
|
5251
5244
|
#endif
|
5252
5245
|
|
@@ -5337,8 +5330,8 @@ static void iter_uint16_sort(na_loop_t* const lp) {
|
|
5337
5330
|
/*
|
5338
5331
|
sort of self.
|
5339
5332
|
@overload sort(axis:nil)
|
5340
|
-
|
5341
|
-
|
5333
|
+
@param [Numeric,Array,Range] axis Performs sort along the axis.
|
5334
|
+
@return [Numo::UInt16] returns result of sort.
|
5342
5335
|
@example
|
5343
5336
|
Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
|
5344
5337
|
*/
|
@@ -5557,8 +5550,8 @@ static void uint16_index32_qsort(na_loop_t* const lp) {
|
|
5557
5550
|
/*
|
5558
5551
|
sort_index. Returns an index array of sort result.
|
5559
5552
|
@overload sort_index(axis:nil)
|
5560
|
-
|
5561
|
-
|
5553
|
+
@param [Numeric,Array,Range] axis Performs sort_index along the axis.
|
5554
|
+
@return [Integer,Numo::Int] returns result index of sort_index.
|
5562
5555
|
@example
|
5563
5556
|
Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
|
5564
5557
|
*/
|
@@ -5622,10 +5615,10 @@ static void iter_uint16_median(na_loop_t* const lp) {
|
|
5622
5615
|
/*
|
5623
5616
|
median of self.
|
5624
5617
|
@overload median(axis:nil, keepdims:false)
|
5625
|
-
|
5626
|
-
|
5627
|
-
|
5628
|
-
|
5618
|
+
@param [Numeric,Array,Range] axis Finds median along the axis.
|
5619
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
5620
|
+
dimensions with size one.
|
5621
|
+
@return [Numo::UInt16] returns median of self.
|
5629
5622
|
*/
|
5630
5623
|
|
5631
5624
|
static VALUE uint16_median(int argc, VALUE* argv, VALUE self) {
|
@@ -5664,13 +5657,15 @@ void Init_numo_uint16(void) {
|
|
5664
5657
|
id_ne = rb_intern("ne");
|
5665
5658
|
id_to_a = rb_intern("to_a");
|
5666
5659
|
|
5667
|
-
|
5668
|
-
|
5669
|
-
|
5670
|
-
|
5660
|
+
/**
|
5661
|
+
* Document-class: Numo::UInt16
|
5662
|
+
*
|
5663
|
+
* 16-bit unsigned integer N-dimensional array class.
|
5664
|
+
*/
|
5671
5665
|
cT = rb_define_class_under(mNumo, "UInt16", cNArray);
|
5672
5666
|
|
5673
5667
|
hCast = rb_hash_new();
|
5668
|
+
/* Upcasting rules of UInt16. */
|
5674
5669
|
rb_define_const(cT, "UPCAST", hCast);
|
5675
5670
|
rb_hash_aset(hCast, rb_cArray, cT);
|
5676
5671
|
|
@@ -5697,15 +5692,15 @@ void Init_numo_uint16(void) {
|
|
5697
5692
|
rb_hash_aset(hCast, numo_cUInt8, cT);
|
5698
5693
|
rb_obj_freeze(hCast);
|
5699
5694
|
|
5700
|
-
|
5695
|
+
/* Element size of UInt16 in bits. */
|
5701
5696
|
rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
|
5702
|
-
|
5697
|
+
/* Element size of UInt16 in bytes. */
|
5703
5698
|
rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
|
5704
|
-
|
5699
|
+
/* Stride size of contiguous UInt16 array. */
|
5705
5700
|
rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
|
5706
|
-
|
5701
|
+
/* The largest representable value of UInt16. */
|
5707
5702
|
rb_define_const(cT, "MAX", M_MAX);
|
5708
|
-
|
5703
|
+
/* The smallest representable value of UInt16. */
|
5709
5704
|
rb_define_const(cT, "MIN", M_MIN);
|
5710
5705
|
rb_define_alloc_func(cT, uint16_s_alloc_func);
|
5711
5706
|
rb_define_method(cT, "allocate", uint16_allocate, 0);
|
@@ -5776,7 +5771,19 @@ void Init_numo_uint16(void) {
|
|
5776
5771
|
rb_define_method(cT, "argmax", uint16_argmax, -1);
|
5777
5772
|
rb_define_method(cT, "argmin", uint16_argmin, -1);
|
5778
5773
|
rb_define_method(cT, "minmax", uint16_minmax, -1);
|
5774
|
+
/**
|
5775
|
+
* Element-wise maximum of two arrays.
|
5776
|
+
* @overload maximum(a1, a2)
|
5777
|
+
* @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
|
5778
|
+
* @return [Numo::UInt16]
|
5779
|
+
*/
|
5779
5780
|
rb_define_module_function(cT, "maximum", uint16_s_maximum, -1);
|
5781
|
+
/**
|
5782
|
+
* Element-wise minimum of two arrays.
|
5783
|
+
* @overload minimum(a1, a2)
|
5784
|
+
* @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
|
5785
|
+
* @return [Numo::UInt16]
|
5786
|
+
*/
|
5780
5787
|
rb_define_module_function(cT, "minimum", uint16_s_minimum, -1);
|
5781
5788
|
rb_define_method(cT, "bincount", uint16_bincount, -1);
|
5782
5789
|
rb_define_method(cT, "cumsum", uint16_cumsum, -1);
|
@@ -5793,4 +5800,48 @@ void Init_numo_uint16(void) {
|
|
5793
5800
|
rb_define_method(cT, "sort_index", uint16_sort_index, -1);
|
5794
5801
|
rb_define_method(cT, "median", uint16_median, -1);
|
5795
5802
|
rb_define_singleton_method(cT, "[]", uint16_s_cast, -2);
|
5803
|
+
/**
|
5804
|
+
* mean of self.
|
5805
|
+
* @overload mean(axis: nil, keepdims: false, nan: false)
|
5806
|
+
* @param axis [Numeric, Array, Range] Performs mean along the axis.
|
5807
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5808
|
+
* dimensions with size one.
|
5809
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5810
|
+
* (avoid NaN for sum/mean etc, or return NaN for min/max etc).
|
5811
|
+
* @return [Numo::DFloat] returns result of mean.
|
5812
|
+
*/
|
5813
|
+
rb_define_method(cT, "mean", uint16_mean, -1);
|
5814
|
+
/**
|
5815
|
+
* var of self.
|
5816
|
+
* @overload var(axis: nil, keepdims: false, nan: false)
|
5817
|
+
* @param axis [Numeric, Array, Range] Performs var along the axis.
|
5818
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5819
|
+
* dimensions with size one.
|
5820
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5821
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5822
|
+
* @return [Numo::DFloat] returns result of var.
|
5823
|
+
*/
|
5824
|
+
rb_define_method(cT, "var", uint16_var, -1);
|
5825
|
+
/**
|
5826
|
+
* stddev of self.
|
5827
|
+
* @overload stddev(axis: nil, keepdims: false, nan: false)
|
5828
|
+
* @param axis [Numeric, Array, Range] Performs stddev along the axis.
|
5829
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5830
|
+
* dimensions with size one.
|
5831
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5832
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5833
|
+
* @return [Numo::DFloat] returns result of stddev.
|
5834
|
+
*/
|
5835
|
+
rb_define_method(cT, "stddev", uint16_stddev, -1);
|
5836
|
+
/**
|
5837
|
+
* rms of self.
|
5838
|
+
* @overload rms(axis: nil, keepdims: false, nan: false)
|
5839
|
+
* @param axis [Numeric, Array, Range] Performs rms along the axis.
|
5840
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5841
|
+
* dimensions with size one.
|
5842
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5843
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5844
|
+
* @return [Numo::DFloat] returns result of rms.
|
5845
|
+
*/
|
5846
|
+
rb_define_method(cT, "rms", uint16_rms, -1);
|
5796
5847
|
}
|