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/int64.h>
|
39
39
|
|
40
|
-
VALUE cT;
|
41
|
-
extern VALUE cRT;
|
42
|
-
|
43
40
|
/*
|
44
41
|
class definition: Numo::Int64
|
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 int64_t int64; // Type aliases for shorter notation
|
52
|
+
// following the codebase naming convention.
|
53
|
+
DEF_NARRAY_INT_MEAN_METHOD_FUNC(int64, numo_cInt64)
|
54
|
+
DEF_NARRAY_INT_VAR_METHOD_FUNC(int64, numo_cInt64)
|
55
|
+
DEF_NARRAY_INT_STDDEV_METHOD_FUNC(int64, numo_cInt64)
|
56
|
+
DEF_NARRAY_INT_RMS_METHOD_FUNC(int64, numo_cInt64)
|
48
57
|
|
49
58
|
static VALUE int64_store(VALUE, VALUE);
|
50
59
|
|
@@ -152,9 +161,9 @@ static VALUE int64_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 int64_extract(VALUE self) {
|
160
169
|
volatile VALUE v;
|
@@ -896,8 +905,8 @@ static VALUE int64_store_array(VALUE self, VALUE rary) {
|
|
896
905
|
/*
|
897
906
|
Store elements to Numo::Int64 from other.
|
898
907
|
@overload store(other)
|
899
|
-
|
900
|
-
|
908
|
+
@param [Object] other
|
909
|
+
@return [Numo::Int64] self
|
901
910
|
*/
|
902
911
|
static VALUE int64_store(VALUE self, VALUE obj) {
|
903
912
|
VALUE r, klass;
|
@@ -1109,9 +1118,9 @@ static VALUE int64_cast_array(VALUE rary) {
|
|
1109
1118
|
Cast object to Numo::Int64.
|
1110
1119
|
@overload [](elements)
|
1111
1120
|
@overload cast(array)
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1121
|
+
@param [Numeric,Array] elements
|
1122
|
+
@param [Array] array
|
1123
|
+
@return [Numo::Int64]
|
1115
1124
|
*/
|
1116
1125
|
static VALUE int64_s_cast(VALUE type, VALUE obj) {
|
1117
1126
|
VALUE v;
|
@@ -1151,9 +1160,9 @@ static VALUE int64_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::Int64] an element or NArray view.
|
1157
1166
|
@see Numo::NArray#[]
|
1158
1167
|
@see #[]=
|
1159
1168
|
*/
|
@@ -1174,10 +1183,10 @@ static VALUE int64_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 int64_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 int64_coerce_cast(VALUE self, VALUE type) {
|
1214
1223
|
return Qnil;
|
@@ -1243,7 +1252,7 @@ static void iter_int64_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 int64_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_int64_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::Int64] self.
|
1281
1290
|
*/
|
1282
1291
|
static VALUE int64_fill(VALUE self, VALUE val) {
|
1283
1292
|
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
|
@@ -1330,8 +1339,8 @@ static void iter_int64_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 int64_format(int argc, VALUE* argv, VALUE self) {
|
1337
1346
|
VALUE fmt = Qnil;
|
@@ -1377,8 +1386,8 @@ static void iter_int64_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 int64_format_to_a(int argc, VALUE* argv, VALUE self) {
|
1384
1393
|
VALUE fmt = Qnil;
|
@@ -1397,7 +1406,7 @@ static VALUE iter_int64_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 int64_inspect(VALUE ary) {
|
1403
1412
|
return na_ndloop_inspect(ary, iter_int64_inspect, Qnil);
|
@@ -1431,9 +1440,9 @@ static void iter_int64_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_int64_map(na_loop_t* const lp) {
|
|
1510
1519
|
/*
|
1511
1520
|
Unary map.
|
1512
1521
|
@overload map
|
1513
|
-
|
1522
|
+
@return [Numo::Int64] map of self.
|
1514
1523
|
*/
|
1515
1524
|
static VALUE int64_map(VALUE self) {
|
1516
1525
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -1569,10 +1578,10 @@ static void iter_int64_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_int64_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_int64_abs(na_loop_t* const lp) {
|
|
1719
1728
|
/*
|
1720
1729
|
abs of self.
|
1721
1730
|
@overload abs
|
1722
|
-
|
1731
|
+
@return [Numo::Int64] abs of self.
|
1723
1732
|
*/
|
1724
1733
|
static VALUE int64_abs(VALUE self) {
|
1725
1734
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -1729,7 +1738,7 @@ static VALUE int64_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_int64_add(na_loop_t* const lp) {
|
@@ -1831,8 +1840,8 @@ static VALUE int64_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 int64_add(VALUE self, VALUE other) {
|
1838
1847
|
|
@@ -1847,7 +1856,7 @@ static VALUE int64_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_int64_sub(na_loop_t* const lp) {
|
@@ -1949,8 +1958,8 @@ static VALUE int64_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 int64_sub(VALUE self, VALUE other) {
|
1956
1965
|
|
@@ -1965,7 +1974,7 @@ static VALUE int64_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_int64_mul(na_loop_t* const lp) {
|
@@ -2067,8 +2076,8 @@ static VALUE int64_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 int64_mul(VALUE self, VALUE other) {
|
2074
2083
|
|
@@ -2083,10 +2092,10 @@ static VALUE int64_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_int64_div(na_loop_t* const lp) {
|
@@ -2188,8 +2197,8 @@ static VALUE int64_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 int64_div(VALUE self, VALUE other) {
|
2195
2204
|
|
@@ -2204,10 +2213,10 @@ static VALUE int64_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_int64_mod(na_loop_t* const lp) {
|
@@ -2309,8 +2318,8 @@ static VALUE int64_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 int64_mod(VALUE self, VALUE other) {
|
2316
2325
|
|
@@ -2359,8 +2368,8 @@ static VALUE int64_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 int64_divmod(VALUE self, VALUE other) {
|
2366
2375
|
|
@@ -2427,8 +2436,8 @@ static VALUE int64_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 int64_pow(VALUE self, VALUE other) {
|
2434
2443
|
|
@@ -2507,7 +2516,7 @@ static void iter_int64_minus(na_loop_t* const lp) {
|
|
2507
2516
|
/*
|
2508
2517
|
Unary minus.
|
2509
2518
|
@overload -@
|
2510
|
-
|
2519
|
+
@return [Numo::Int64] minus of self.
|
2511
2520
|
*/
|
2512
2521
|
static VALUE int64_minus(VALUE self) {
|
2513
2522
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2582,7 +2591,7 @@ static void iter_int64_reciprocal(na_loop_t* const lp) {
|
|
2582
2591
|
/*
|
2583
2592
|
Unary reciprocal.
|
2584
2593
|
@overload reciprocal
|
2585
|
-
|
2594
|
+
@return [Numo::Int64] reciprocal of self.
|
2586
2595
|
*/
|
2587
2596
|
static VALUE int64_reciprocal(VALUE self) {
|
2588
2597
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2657,7 +2666,7 @@ static void iter_int64_sign(na_loop_t* const lp) {
|
|
2657
2666
|
/*
|
2658
2667
|
Unary sign.
|
2659
2668
|
@overload sign
|
2660
|
-
|
2669
|
+
@return [Numo::Int64] sign of self.
|
2661
2670
|
*/
|
2662
2671
|
static VALUE int64_sign(VALUE self) {
|
2663
2672
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2732,7 +2741,7 @@ static void iter_int64_square(na_loop_t* const lp) {
|
|
2732
2741
|
/*
|
2733
2742
|
Unary square.
|
2734
2743
|
@overload square
|
2735
|
-
|
2744
|
+
@return [Numo::Int64] square of self.
|
2736
2745
|
*/
|
2737
2746
|
static VALUE int64_square(VALUE self) {
|
2738
2747
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2774,8 +2783,8 @@ static VALUE int64_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 int64_eq(VALUE self, VALUE other) {
|
2781
2790
|
|
@@ -2821,8 +2830,8 @@ static VALUE int64_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 int64_ne(VALUE self, VALUE other) {
|
2828
2837
|
|
@@ -2836,7 +2845,7 @@ static VALUE int64_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_int64_bit_and(na_loop_t* const lp) {
|
@@ -2938,8 +2947,8 @@ static VALUE int64_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 int64_bit_and(VALUE self, VALUE other) {
|
2945
2954
|
|
@@ -2954,7 +2963,7 @@ static VALUE int64_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_int64_bit_or(na_loop_t* const lp) {
|
@@ -3056,8 +3065,8 @@ static VALUE int64_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 int64_bit_or(VALUE self, VALUE other) {
|
3063
3072
|
|
@@ -3072,7 +3081,7 @@ static VALUE int64_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_int64_bit_xor(na_loop_t* const lp) {
|
@@ -3174,8 +3183,8 @@ static VALUE int64_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 int64_bit_xor(VALUE self, VALUE other) {
|
3181
3190
|
|
@@ -3255,7 +3264,7 @@ static void iter_int64_bit_not(na_loop_t* const lp) {
|
|
3255
3264
|
/*
|
3256
3265
|
Unary bit_not.
|
3257
3266
|
@overload ~
|
3258
|
-
|
3267
|
+
@return [Numo::Int64] bit_not of self.
|
3259
3268
|
*/
|
3260
3269
|
static VALUE int64_bit_not(VALUE self) {
|
3261
3270
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -3265,7 +3274,7 @@ static VALUE int64_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_int64_left_shift(na_loop_t* const lp) {
|
@@ -3367,8 +3376,8 @@ static VALUE int64_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 int64_left_shift(VALUE self, VALUE other) {
|
3374
3383
|
|
@@ -3383,7 +3392,7 @@ static VALUE int64_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_int64_right_shift(na_loop_t* const lp) {
|
@@ -3485,8 +3494,8 @@ static VALUE int64_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 int64_right_shift(VALUE self, VALUE other) {
|
3492
3501
|
|
@@ -3533,8 +3542,8 @@ static VALUE int64_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 int64_gt(VALUE self, VALUE other) {
|
3540
3549
|
|
@@ -3580,8 +3589,8 @@ static VALUE int64_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 int64_ge(VALUE self, VALUE other) {
|
3587
3596
|
|
@@ -3627,8 +3636,8 @@ static VALUE int64_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 int64_lt(VALUE self, VALUE other) {
|
3634
3643
|
|
@@ -3674,8 +3683,8 @@ static VALUE int64_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 int64_le(VALUE self, VALUE other) {
|
3681
3690
|
|
@@ -3758,9 +3767,9 @@ static void iter_int64_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_int64_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::Int64] returns result of sum.
|
3828
3837
|
*/
|
3829
3838
|
static VALUE int64_sum(int argc, VALUE* argv, VALUE self) {
|
3830
3839
|
VALUE v, reduce;
|
@@ -3854,10 +3863,10 @@ static void iter_int64_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::Int64] returns result of prod.
|
3861
3870
|
*/
|
3862
3871
|
static VALUE int64_prod(int argc, VALUE* argv, VALUE self) {
|
3863
3872
|
VALUE v, reduce;
|
@@ -3887,10 +3896,10 @@ static void iter_int64_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::Int64] returns result of min.
|
3894
3903
|
*/
|
3895
3904
|
static VALUE int64_min(int argc, VALUE* argv, VALUE self) {
|
3896
3905
|
VALUE v, reduce;
|
@@ -3920,10 +3929,10 @@ static void iter_int64_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::Int64] returns result of max.
|
3927
3936
|
*/
|
3928
3937
|
static VALUE int64_max(int argc, VALUE* argv, VALUE self) {
|
3929
3938
|
VALUE v, reduce;
|
@@ -3953,10 +3962,10 @@ static void iter_int64_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::Int64] returns result of ptp.
|
3960
3969
|
*/
|
3961
3970
|
static VALUE int64_ptp(int argc, VALUE* argv, VALUE self) {
|
3962
3971
|
VALUE v, reduce;
|
@@ -4008,9 +4017,9 @@ static void iter_int64_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_int64_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_int64_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_int64_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_int64_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::Int64,Numo::Int64] min and max of self.
|
4318
4327
|
*/
|
4319
4328
|
static VALUE int64_minmax(int argc, VALUE* argv, VALUE self) {
|
4320
4329
|
VALUE reduce;
|
@@ -4329,14 +4338,6 @@ static VALUE int64_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::Int64]
|
4338
|
-
*/
|
4339
|
-
|
4340
4341
|
static void iter_int64_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 int64_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::Int64]
|
4378
|
-
*/
|
4379
|
-
|
4380
4373
|
static void iter_int64_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 int64_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]
|
@@ -4664,9 +4657,9 @@ static void iter_int64_cumsum(na_loop_t* const lp) {
|
|
4664
4657
|
/*
|
4665
4658
|
cumsum of self.
|
4666
4659
|
@overload cumsum(axis:nil, nan:false)
|
4667
|
-
|
4668
|
-
|
4669
|
-
|
4660
|
+
@param [Numeric,Array,Range] axis Performs cumsum along the axis.
|
4661
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
4662
|
+
@return [Numo::Int64] cumsum of self.
|
4670
4663
|
*/
|
4671
4664
|
static VALUE int64_cumsum(int argc, VALUE* argv, VALUE self) {
|
4672
4665
|
VALUE reduce;
|
@@ -4703,9 +4696,9 @@ static void iter_int64_cumprod(na_loop_t* const lp) {
|
|
4703
4696
|
/*
|
4704
4697
|
cumprod of self.
|
4705
4698
|
@overload cumprod(axis:nil, nan:false)
|
4706
|
-
|
4707
|
-
|
4708
|
-
|
4699
|
+
@param [Numeric,Array,Range] axis Performs cumprod along the axis.
|
4700
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
4701
|
+
@return [Numo::Int64] cumprod of self.
|
4709
4702
|
*/
|
4710
4703
|
static VALUE int64_cumprod(int argc, VALUE* argv, VALUE self) {
|
4711
4704
|
VALUE reduce;
|
@@ -4781,11 +4774,11 @@ static VALUE int64_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
|
4781
4774
|
Binary mulsum.
|
4782
4775
|
|
4783
4776
|
@overload mulsum(other, axis:nil, keepdims:false)
|
4784
|
-
|
4785
|
-
|
4786
|
-
|
4787
|
-
|
4788
|
-
|
4777
|
+
@param [Numo::NArray,Numeric] other
|
4778
|
+
@param [Numeric,Array,Range] axis Performs mulsum along the axis.
|
4779
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
4780
|
+
as dimensions with size one.
|
4781
|
+
@return [Numo::NArray] mulsum of self and other.
|
4789
4782
|
*/
|
4790
4783
|
static VALUE int64_mulsum(int argc, VALUE* argv, VALUE self) {
|
4791
4784
|
//
|
@@ -4854,9 +4847,9 @@ static void iter_int64_seq(na_loop_t* const lp) {
|
|
4854
4847
|
beg+i*step
|
4855
4848
|
where i is 1-dimensional index.
|
4856
4849
|
@overload seq([beg,[step]])
|
4857
|
-
|
4858
|
-
|
4859
|
-
|
4850
|
+
@param [Numeric] beg beginning of sequence. (default=0)
|
4851
|
+
@param [Numeric] step step of sequence. (default=1)
|
4852
|
+
@return [Numo::Int64] self.
|
4860
4853
|
@example
|
4861
4854
|
Numo::DFloat.new(6).seq(1,-0.2)
|
4862
4855
|
# => Numo::DFloat#shape=[6]
|
@@ -4866,7 +4859,7 @@ static void iter_int64_seq(na_loop_t* const lp) {
|
|
4866
4859
|
# => Numo::DComplex#shape=[6]
|
4867
4860
|
# [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
4868
4861
|
*/
|
4869
|
-
static VALUE int64_seq(int argc, VALUE*
|
4862
|
+
static VALUE int64_seq(int argc, VALUE* argv, VALUE self) {
|
4870
4863
|
seq_opt_t* g;
|
4871
4864
|
VALUE vbeg = Qnil, vstep = Qnil;
|
4872
4865
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
@@ -4876,7 +4869,7 @@ static VALUE int64_seq(int argc, VALUE* args, VALUE self) {
|
|
4876
4869
|
g->beg = m_zero;
|
4877
4870
|
g->step = m_one;
|
4878
4871
|
g->count = 0;
|
4879
|
-
rb_scan_args(argc,
|
4872
|
+
rb_scan_args(argc, argv, "02", &vbeg, &vstep);
|
4880
4873
|
if (vbeg != Qnil) {
|
4881
4874
|
g->beg = NUM2DBL(vbeg);
|
4882
4875
|
}
|
@@ -4920,11 +4913,11 @@ static void iter_int64_eye(na_loop_t* const lp) {
|
|
4920
4913
|
/*
|
4921
4914
|
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
|
4922
4915
|
@overload eye([element,offset])
|
4923
|
-
|
4924
|
-
|
4925
|
-
|
4926
|
-
|
4927
|
-
|
4916
|
+
@param [Numeric] element Diagonal element to be stored. Default is 1.
|
4917
|
+
@param [Integer] offset Diagonal offset from the main diagonal. The
|
4918
|
+
default is 0. k>0 for diagonals above the main diagonal, and k<0
|
4919
|
+
for diagonals below the main diagonal.
|
4920
|
+
@return [Numo::Int64] eye of self.
|
4928
4921
|
*/
|
4929
4922
|
static VALUE int64_eye(int argc, VALUE* argv, VALUE self) {
|
4930
4923
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
|
@@ -5058,10 +5051,10 @@ static void iter_int64_rand(na_loop_t* const lp) {
|
|
5058
5051
|
/*
|
5059
5052
|
Generate uniformly distributed random numbers on self narray.
|
5060
5053
|
@overload rand([[low],high])
|
5061
|
-
|
5062
|
-
|
5063
|
-
|
5064
|
-
|
5054
|
+
@param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
5055
|
+
@param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
|
5056
|
+
complex types)
|
5057
|
+
@return [Numo::Int64] self.
|
5065
5058
|
@example
|
5066
5059
|
Numo::DFloat.new(6).rand
|
5067
5060
|
# => Numo::DFloat#shape=[6]
|
@@ -5075,14 +5068,14 @@ static void iter_int64_rand(na_loop_t* const lp) {
|
|
5075
5068
|
# => Numo::Int32#shape=[6]
|
5076
5069
|
# [4, 3, 3, 2, 4, 2]
|
5077
5070
|
*/
|
5078
|
-
static VALUE int64_rand(int argc, VALUE*
|
5071
|
+
static VALUE int64_rand(int argc, VALUE* argv, VALUE self) {
|
5079
5072
|
rand_opt_t g;
|
5080
5073
|
VALUE v1 = Qnil, v2 = Qnil;
|
5081
5074
|
dtype high;
|
5082
5075
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
5083
5076
|
ndfunc_t ndf = { iter_int64_rand, FULL_LOOP, 1, 0, ain, 0 };
|
5084
5077
|
|
5085
|
-
rb_scan_args(argc,
|
5078
|
+
rb_scan_args(argc, argv, "11", &v1, &v2);
|
5086
5079
|
if (v2 == Qnil) {
|
5087
5080
|
g.low = m_zero;
|
5088
5081
|
g.max = high = m_num_to_data(v1);
|
@@ -5121,8 +5114,8 @@ static void iter_int64_poly(na_loop_t* const lp) {
|
|
5121
5114
|
Calculate polynomial.
|
5122
5115
|
`x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
|
5123
5116
|
@overload poly a0, a1, ..., an
|
5124
|
-
|
5125
|
-
|
5117
|
+
@param [Numo::NArray,Numeric] a0,a1,...,an
|
5118
|
+
@return [Numo::Int64]
|
5126
5119
|
*/
|
5127
5120
|
static VALUE int64_poly(VALUE self, VALUE args) {
|
5128
5121
|
int argc, i;
|
@@ -5209,27 +5202,27 @@ static VALUE int64_poly(VALUE self, VALUE args) {
|
|
5209
5202
|
* We have modified their original by adding a check for already-sorted input,
|
5210
5203
|
* which seems to be a win per discussions on pgsql-hackers around 2006-03-21.
|
5211
5204
|
*/
|
5212
|
-
#define swapcode(TYPE, parmi, parmj, n)
|
5213
|
-
do {
|
5214
|
-
size_t i = (n) / sizeof(TYPE);
|
5215
|
-
TYPE* pi = (TYPE*)(void*)(parmi);
|
5216
|
-
TYPE* pj = (TYPE*)(void*)(parmj);
|
5217
|
-
do {
|
5218
|
-
TYPE t = *pi;
|
5219
|
-
*pi++ = *pj;
|
5220
|
-
*pj++ = t;
|
5221
|
-
} while (--i > 0);
|
5205
|
+
#define swapcode(TYPE, parmi, parmj, n) \
|
5206
|
+
do { \
|
5207
|
+
size_t i = (n) / sizeof(TYPE); \
|
5208
|
+
TYPE* pi = (TYPE*)(void*)(parmi); \
|
5209
|
+
TYPE* pj = (TYPE*)(void*)(parmj); \
|
5210
|
+
do { \
|
5211
|
+
TYPE t = *pi; \
|
5212
|
+
*pi++ = *pj; \
|
5213
|
+
*pj++ = t; \
|
5214
|
+
} while (--i > 0); \
|
5222
5215
|
} while (0)
|
5223
5216
|
|
5224
5217
|
#ifdef HAVE_STDINT_H
|
5225
|
-
#define SWAPINIT(a, es)
|
5226
|
-
swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2
|
5227
|
-
: (es) == sizeof(long) ? 0
|
5218
|
+
#define SWAPINIT(a, es) \
|
5219
|
+
swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
5220
|
+
: (es) == sizeof(long) ? 0 \
|
5228
5221
|
: 1;
|
5229
5222
|
#else
|
5230
|
-
#define SWAPINIT(a, es)
|
5231
|
-
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2
|
5232
|
-
: (es) == sizeof(long) ? 0
|
5223
|
+
#define SWAPINIT(a, es) \
|
5224
|
+
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
5225
|
+
: (es) == sizeof(long) ? 0 \
|
5233
5226
|
: 1;
|
5234
5227
|
#endif
|
5235
5228
|
|
@@ -5240,19 +5233,19 @@ static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
|
|
5240
5233
|
swapcode(char, a, b, n);
|
5241
5234
|
}
|
5242
5235
|
|
5243
|
-
#define swap(a, b)
|
5244
|
-
if (swaptype == 0) {
|
5245
|
-
long t = *(long*)(void*)(a);
|
5246
|
-
*(long*)(void*)(a) = *(long*)(void*)(b);
|
5247
|
-
*(long*)(void*)(b) = t;
|
5248
|
-
} else
|
5236
|
+
#define swap(a, b) \
|
5237
|
+
if (swaptype == 0) { \
|
5238
|
+
long t = *(long*)(void*)(a); \
|
5239
|
+
*(long*)(void*)(a) = *(long*)(void*)(b); \
|
5240
|
+
*(long*)(void*)(b) = t; \
|
5241
|
+
} else \
|
5249
5242
|
swapfunc(a, b, es, swaptype)
|
5250
5243
|
|
5251
|
-
#define vecswap(a, b, n)
|
5244
|
+
#define vecswap(a, b, n) \
|
5252
5245
|
if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
|
5253
5246
|
|
5254
|
-
#define med3(a, b, c, _cmp)
|
5255
|
-
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a))
|
5247
|
+
#define med3(a, b, c, _cmp) \
|
5248
|
+
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) \
|
5256
5249
|
: (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
|
5257
5250
|
#endif
|
5258
5251
|
|
@@ -5343,8 +5336,8 @@ static void iter_int64_sort(na_loop_t* const lp) {
|
|
5343
5336
|
/*
|
5344
5337
|
sort of self.
|
5345
5338
|
@overload sort(axis:nil)
|
5346
|
-
|
5347
|
-
|
5339
|
+
@param [Numeric,Array,Range] axis Performs sort along the axis.
|
5340
|
+
@return [Numo::Int64] returns result of sort.
|
5348
5341
|
@example
|
5349
5342
|
Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
|
5350
5343
|
*/
|
@@ -5563,8 +5556,8 @@ static void int64_index32_qsort(na_loop_t* const lp) {
|
|
5563
5556
|
/*
|
5564
5557
|
sort_index. Returns an index array of sort result.
|
5565
5558
|
@overload sort_index(axis:nil)
|
5566
|
-
|
5567
|
-
|
5559
|
+
@param [Numeric,Array,Range] axis Performs sort_index along the axis.
|
5560
|
+
@return [Integer,Numo::Int] returns result index of sort_index.
|
5568
5561
|
@example
|
5569
5562
|
Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
|
5570
5563
|
*/
|
@@ -5628,9 +5621,9 @@ static void iter_int64_median(na_loop_t* const lp) {
|
|
5628
5621
|
/*
|
5629
5622
|
median of self.
|
5630
5623
|
@overload median(axis:nil, keepdims:false)
|
5631
|
-
|
5632
|
-
|
5633
|
-
|
5624
|
+
@param [Numeric,Array,Range] axis Finds median along the axis.
|
5625
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
5626
|
+
dimensions with size one.
|
5634
5627
|
@return [Numo::Int64] returns median of self.
|
5635
5628
|
*/
|
5636
5629
|
|
@@ -5670,13 +5663,15 @@ void Init_numo_int64(void) {
|
|
5670
5663
|
id_ne = rb_intern("ne");
|
5671
5664
|
id_to_a = rb_intern("to_a");
|
5672
5665
|
|
5673
|
-
|
5674
|
-
|
5675
|
-
|
5676
|
-
|
5666
|
+
/**
|
5667
|
+
* Document-class: Numo::Int64
|
5668
|
+
*
|
5669
|
+
* 64-bit signed integer N-dimensional array class.
|
5670
|
+
*/
|
5677
5671
|
cT = rb_define_class_under(mNumo, "Int64", cNArray);
|
5678
5672
|
|
5679
5673
|
hCast = rb_hash_new();
|
5674
|
+
/* Upcasting rules of Int64. */
|
5680
5675
|
rb_define_const(cT, "UPCAST", hCast);
|
5681
5676
|
rb_hash_aset(hCast, rb_cArray, cT);
|
5682
5677
|
|
@@ -5703,15 +5698,15 @@ void Init_numo_int64(void) {
|
|
5703
5698
|
rb_hash_aset(hCast, numo_cUInt8, cT);
|
5704
5699
|
rb_obj_freeze(hCast);
|
5705
5700
|
|
5706
|
-
|
5701
|
+
/* Element size of Int64 in bits. */
|
5707
5702
|
rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
|
5708
|
-
|
5703
|
+
/* Element size of Int64 in bytes. */
|
5709
5704
|
rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
|
5710
|
-
|
5705
|
+
/* Stride size of contiguous Int64 array. */
|
5711
5706
|
rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
|
5712
|
-
|
5707
|
+
/* The largest representable value of Int64. */
|
5713
5708
|
rb_define_const(cT, "MAX", M_MAX);
|
5714
|
-
|
5709
|
+
/* The smallest representable value of Int64. */
|
5715
5710
|
rb_define_const(cT, "MIN", M_MIN);
|
5716
5711
|
rb_define_alloc_func(cT, int64_s_alloc_func);
|
5717
5712
|
rb_define_method(cT, "allocate", int64_allocate, 0);
|
@@ -5782,7 +5777,19 @@ void Init_numo_int64(void) {
|
|
5782
5777
|
rb_define_method(cT, "argmax", int64_argmax, -1);
|
5783
5778
|
rb_define_method(cT, "argmin", int64_argmin, -1);
|
5784
5779
|
rb_define_method(cT, "minmax", int64_minmax, -1);
|
5780
|
+
/**
|
5781
|
+
* Element-wise maximum of two arrays.
|
5782
|
+
* @overload maximum(a1, a2)
|
5783
|
+
* @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
|
5784
|
+
* @return [Numo::Int64]
|
5785
|
+
*/
|
5785
5786
|
rb_define_module_function(cT, "maximum", int64_s_maximum, -1);
|
5787
|
+
/**
|
5788
|
+
* Element-wise minimum of two arrays.
|
5789
|
+
* @overload minimum(a1, a2)
|
5790
|
+
* @param [Numo::NArray,Numeric] a1,a2 The arrays holding the elements to be compared.
|
5791
|
+
* @return [Numo::Int64]
|
5792
|
+
*/
|
5786
5793
|
rb_define_module_function(cT, "minimum", int64_s_minimum, -1);
|
5787
5794
|
rb_define_method(cT, "bincount", int64_bincount, -1);
|
5788
5795
|
rb_define_method(cT, "cumsum", int64_cumsum, -1);
|
@@ -5799,4 +5806,48 @@ void Init_numo_int64(void) {
|
|
5799
5806
|
rb_define_method(cT, "sort_index", int64_sort_index, -1);
|
5800
5807
|
rb_define_method(cT, "median", int64_median, -1);
|
5801
5808
|
rb_define_singleton_method(cT, "[]", int64_s_cast, -2);
|
5809
|
+
/**
|
5810
|
+
* mean of self.
|
5811
|
+
* @overload mean(axis: nil, keepdims: false, nan: false)
|
5812
|
+
* @param axis [Numeric, Array, Range] Performs mean along the axis.
|
5813
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5814
|
+
* dimensions with size one.
|
5815
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5816
|
+
* (avoid NaN for sum/mean etc, or return NaN for min/max etc).
|
5817
|
+
* @return [Numo::DFloat]
|
5818
|
+
*/
|
5819
|
+
rb_define_method(cT, "mean", int64_mean, -1);
|
5820
|
+
/**
|
5821
|
+
* var of self.
|
5822
|
+
* @overload var(axis: nil, keepdims: false, nan: false)
|
5823
|
+
* @param axis [Numeric, Array, Range] Performs var along the axis.
|
5824
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5825
|
+
* dimensions with size one.
|
5826
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5827
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5828
|
+
* @return [Numo::DFloat] returns result of var.
|
5829
|
+
*/
|
5830
|
+
rb_define_method(cT, "var", int64_var, -1);
|
5831
|
+
/**
|
5832
|
+
* stddev of self.
|
5833
|
+
* @overload stddev(axis: nil, keepdims: false, nan: false)
|
5834
|
+
* @param axis [Numeric, Array, Range] Performs stddev along the axis.
|
5835
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5836
|
+
* dimensions with size one.
|
5837
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5838
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5839
|
+
* @return [Numo::DFloat] returns result of stddev.
|
5840
|
+
*/
|
5841
|
+
rb_define_method(cT, "stddev", int64_stddev, -1);
|
5842
|
+
/**
|
5843
|
+
* rms of self.
|
5844
|
+
* @overload rms(axis: nil, keepdims: false, nan: false)
|
5845
|
+
* @param axis [Numeric, Array, Range] Performs rms along the axis.
|
5846
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5847
|
+
* dimensions with size one.
|
5848
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5849
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5850
|
+
* @return [Numo::DFloat] returns result of rms.
|
5851
|
+
*/
|
5852
|
+
rb_define_method(cT, "rms", int64_rms, -1);
|
5802
5853
|
}
|