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
@@ -54,14 +54,23 @@ static ID id_truncate;
|
|
54
54
|
|
55
55
|
#include <numo/types/robject.h>
|
56
56
|
|
57
|
-
VALUE cT;
|
58
|
-
extern VALUE cRT;
|
59
|
-
|
60
57
|
/*
|
61
58
|
class definition: Numo::RObject
|
62
59
|
*/
|
63
|
-
|
64
60
|
VALUE cT;
|
61
|
+
extern VALUE cRT;
|
62
|
+
|
63
|
+
#include "mh/mean.h"
|
64
|
+
#include "mh/var.h"
|
65
|
+
#include "mh/stddev.h"
|
66
|
+
#include "mh/rms.h"
|
67
|
+
|
68
|
+
typedef VALUE robject; // Type aliases for shorter notation
|
69
|
+
// following the codebase naming convention.
|
70
|
+
DEF_NARRAY_FLT_MEAN_METHOD_FUNC(robject, VALUE, numo_cRObject, numo_cRObject)
|
71
|
+
DEF_NARRAY_FLT_VAR_METHOD_FUNC(robject, VALUE, numo_cRObject, numo_cRObject)
|
72
|
+
DEF_NARRAY_FLT_STDDEV_METHOD_FUNC(robject, VALUE, numo_cRObject, numo_cRObject)
|
73
|
+
DEF_NARRAY_FLT_RMS_METHOD_FUNC(robject, VALUE, numo_cRObject, numo_cRObject)
|
65
74
|
|
66
75
|
static VALUE robject_store(VALUE, VALUE);
|
67
76
|
|
@@ -191,9 +200,9 @@ static VALUE robject_allocate(VALUE self) {
|
|
191
200
|
/*
|
192
201
|
Extract an element only if self is a dimensionless NArray.
|
193
202
|
@overload extract
|
194
|
-
|
195
|
-
|
196
|
-
|
203
|
+
@return [Numeric,Numo::NArray]
|
204
|
+
--- Extract element value as Ruby Object if self is a dimensionless NArray,
|
205
|
+
otherwise returns self.
|
197
206
|
*/
|
198
207
|
static VALUE robject_extract(VALUE self) {
|
199
208
|
volatile VALUE v;
|
@@ -935,8 +944,8 @@ static VALUE robject_store_array(VALUE self, VALUE rary) {
|
|
935
944
|
/*
|
936
945
|
Store elements to Numo::RObject from other.
|
937
946
|
@overload store(other)
|
938
|
-
|
939
|
-
|
947
|
+
@param [Object] other
|
948
|
+
@return [Numo::RObject] self
|
940
949
|
*/
|
941
950
|
static VALUE robject_store(VALUE self, VALUE obj) {
|
942
951
|
VALUE r, klass;
|
@@ -1142,9 +1151,9 @@ static VALUE robject_cast_array(VALUE rary) {
|
|
1142
1151
|
Cast object to Numo::RObject.
|
1143
1152
|
@overload [](elements)
|
1144
1153
|
@overload cast(array)
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1154
|
+
@param [Numeric,Array] elements
|
1155
|
+
@param [Array] array
|
1156
|
+
@return [Numo::RObject]
|
1148
1157
|
*/
|
1149
1158
|
static VALUE robject_s_cast(VALUE type, VALUE obj) {
|
1150
1159
|
VALUE v;
|
@@ -1183,9 +1192,9 @@ static VALUE robject_s_cast(VALUE type, VALUE obj) {
|
|
1183
1192
|
/*
|
1184
1193
|
Multi-dimensional element reference.
|
1185
1194
|
@overload [](dim0,...,dimL)
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1195
|
+
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
|
1196
|
+
dim0,...,dimL multi-dimensional indices.
|
1197
|
+
@return [Numeric,Numo::RObject] an element or NArray view.
|
1189
1198
|
@see Numo::NArray#[]
|
1190
1199
|
@see #[]=
|
1191
1200
|
*/
|
@@ -1206,10 +1215,10 @@ static VALUE robject_aref(int argc, VALUE* argv, VALUE self) {
|
|
1206
1215
|
/*
|
1207
1216
|
Multi-dimensional element assignment.
|
1208
1217
|
@overload []=(dim0,...,dimL,val)
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1218
|
+
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
|
1219
|
+
dim0,...,dimL multi-dimensional indices.
|
1220
|
+
@param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
|
1221
|
+
@return [Numeric,Numo::NArray,Array] returns `val` (last argument).
|
1213
1222
|
@see Numo::NArray#[]=
|
1214
1223
|
@see #[]
|
1215
1224
|
*/
|
@@ -1240,7 +1249,7 @@ static VALUE robject_aset(int argc, VALUE* argv, VALUE self) {
|
|
1240
1249
|
/*
|
1241
1250
|
return NArray with cast to the type of self.
|
1242
1251
|
@overload coerce_cast(type)
|
1243
|
-
|
1252
|
+
@return [nil]
|
1244
1253
|
*/
|
1245
1254
|
static VALUE robject_coerce_cast(VALUE self, VALUE type) {
|
1246
1255
|
return Qnil;
|
@@ -1275,7 +1284,7 @@ static void iter_robject_to_a(na_loop_t* const lp) {
|
|
1275
1284
|
/*
|
1276
1285
|
Convert self to Array.
|
1277
1286
|
@overload to_a
|
1278
|
-
|
1287
|
+
@return [Array]
|
1279
1288
|
*/
|
1280
1289
|
static VALUE robject_to_a(VALUE self) {
|
1281
1290
|
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
|
@@ -1308,8 +1317,8 @@ static void iter_robject_fill(na_loop_t* const lp) {
|
|
1308
1317
|
/*
|
1309
1318
|
Fill elements with other.
|
1310
1319
|
@overload fill other
|
1311
|
-
|
1312
|
-
|
1320
|
+
@param [Numeric] other
|
1321
|
+
@return [Numo::RObject] self.
|
1313
1322
|
*/
|
1314
1323
|
static VALUE robject_fill(VALUE self, VALUE val) {
|
1315
1324
|
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
|
@@ -1362,8 +1371,8 @@ static void iter_robject_format(na_loop_t* const lp) {
|
|
1362
1371
|
/*
|
1363
1372
|
Format elements into strings.
|
1364
1373
|
@overload format format
|
1365
|
-
|
1366
|
-
|
1374
|
+
@param [String] format
|
1375
|
+
@return [Numo::RObject] array of formatted strings.
|
1367
1376
|
*/
|
1368
1377
|
static VALUE robject_format(int argc, VALUE* argv, VALUE self) {
|
1369
1378
|
VALUE fmt = Qnil;
|
@@ -1409,8 +1418,8 @@ static void iter_robject_format_to_a(na_loop_t* const lp) {
|
|
1409
1418
|
/*
|
1410
1419
|
Format elements into strings.
|
1411
1420
|
@overload format_to_a format
|
1412
|
-
|
1413
|
-
|
1421
|
+
@param [String] format
|
1422
|
+
@return [Array] array of formatted strings.
|
1414
1423
|
*/
|
1415
1424
|
static VALUE robject_format_to_a(int argc, VALUE* argv, VALUE self) {
|
1416
1425
|
VALUE fmt = Qnil;
|
@@ -1429,7 +1438,7 @@ static VALUE iter_robject_inspect(char* ptr, size_t pos, VALUE fmt) {
|
|
1429
1438
|
/*
|
1430
1439
|
Returns a string containing a human-readable representation of NArray.
|
1431
1440
|
@overload inspect
|
1432
|
-
|
1441
|
+
@return [String]
|
1433
1442
|
*/
|
1434
1443
|
static VALUE robject_inspect(VALUE ary) {
|
1435
1444
|
return na_ndloop_inspect(ary, iter_robject_inspect, Qnil);
|
@@ -1463,9 +1472,9 @@ static void iter_robject_each(na_loop_t* const lp) {
|
|
1463
1472
|
Calls the given block once for each element in self,
|
1464
1473
|
passing that element as a parameter.
|
1465
1474
|
@overload each
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1475
|
+
@return [Numo::NArray] self
|
1476
|
+
For a block `{|x| ... }`,
|
1477
|
+
@yieldparam [Numeric] x an element of NArray.
|
1469
1478
|
@see #each_with_index
|
1470
1479
|
@see #map
|
1471
1480
|
*/
|
@@ -1525,7 +1534,7 @@ static void iter_robject_map(na_loop_t* const lp) {
|
|
1525
1534
|
/*
|
1526
1535
|
Unary map.
|
1527
1536
|
@overload map
|
1528
|
-
|
1537
|
+
@return [Numo::RObject] map of self.
|
1529
1538
|
*/
|
1530
1539
|
static VALUE robject_map(VALUE self) {
|
1531
1540
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -1584,10 +1593,10 @@ static void iter_robject_each_with_index(na_loop_t* const lp) {
|
|
1584
1593
|
Invokes the given block once for each element of self,
|
1585
1594
|
passing that element and indices along each axis as parameters.
|
1586
1595
|
@overload each_with_index
|
1587
|
-
|
1588
|
-
|
1589
|
-
|
1590
|
-
|
1596
|
+
For a block `{|x,i,j,...| ... }`,
|
1597
|
+
@yieldparam [Numeric] x an element
|
1598
|
+
@yieldparam [Integer] i,j,... multitimensional indices
|
1599
|
+
@return [Numo::NArray] self
|
1591
1600
|
@see #each
|
1592
1601
|
@see #map_with_index
|
1593
1602
|
*/
|
@@ -1675,10 +1684,10 @@ static void iter_robject_map_with_index(na_loop_t* const lp) {
|
|
1675
1684
|
Creates a new NArray containing the values returned by the block.
|
1676
1685
|
Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
|
1677
1686
|
@overload map_with_index
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1687
|
+
For a block `{|x,i,j,...| ... }`,
|
1688
|
+
@yieldparam [Numeric] x an element
|
1689
|
+
@yieldparam [Integer] i,j,... multitimensional indices
|
1690
|
+
@return [Numo::NArray] mapped array
|
1682
1691
|
@see #map
|
1683
1692
|
@see #each_with_index
|
1684
1693
|
*/
|
@@ -1734,7 +1743,7 @@ static void iter_robject_abs(na_loop_t* const lp) {
|
|
1734
1743
|
/*
|
1735
1744
|
abs of self.
|
1736
1745
|
@overload abs
|
1737
|
-
|
1746
|
+
@return [Numo::RObject] abs of self.
|
1738
1747
|
*/
|
1739
1748
|
static VALUE robject_abs(VALUE self) {
|
1740
1749
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -1744,7 +1753,7 @@ static VALUE robject_abs(VALUE self) {
|
|
1744
1753
|
return na_ndloop(&ndf, 1, self);
|
1745
1754
|
}
|
1746
1755
|
|
1747
|
-
#define check_intdivzero(y)
|
1756
|
+
#define check_intdivzero(y) \
|
1748
1757
|
{}
|
1749
1758
|
|
1750
1759
|
static void iter_robject_add(na_loop_t* const lp) {
|
@@ -1814,14 +1823,14 @@ static VALUE robject_add_self(VALUE self, VALUE other) {
|
|
1814
1823
|
/*
|
1815
1824
|
Binary add.
|
1816
1825
|
@overload + other
|
1817
|
-
|
1818
|
-
|
1826
|
+
@param [Numo::NArray,Numeric] other
|
1827
|
+
@return [Numo::NArray] self + other
|
1819
1828
|
*/
|
1820
1829
|
static VALUE robject_add(VALUE self, VALUE other) {
|
1821
1830
|
return robject_add_self(self, other);
|
1822
1831
|
}
|
1823
1832
|
|
1824
|
-
#define check_intdivzero(y)
|
1833
|
+
#define check_intdivzero(y) \
|
1825
1834
|
{}
|
1826
1835
|
|
1827
1836
|
static void iter_robject_sub(na_loop_t* const lp) {
|
@@ -1891,14 +1900,14 @@ static VALUE robject_sub_self(VALUE self, VALUE other) {
|
|
1891
1900
|
/*
|
1892
1901
|
Binary sub.
|
1893
1902
|
@overload - other
|
1894
|
-
|
1895
|
-
|
1903
|
+
@param [Numo::NArray,Numeric] other
|
1904
|
+
@return [Numo::NArray] self - other
|
1896
1905
|
*/
|
1897
1906
|
static VALUE robject_sub(VALUE self, VALUE other) {
|
1898
1907
|
return robject_sub_self(self, other);
|
1899
1908
|
}
|
1900
1909
|
|
1901
|
-
#define check_intdivzero(y)
|
1910
|
+
#define check_intdivzero(y) \
|
1902
1911
|
{}
|
1903
1912
|
|
1904
1913
|
static void iter_robject_mul(na_loop_t* const lp) {
|
@@ -1968,17 +1977,17 @@ static VALUE robject_mul_self(VALUE self, VALUE other) {
|
|
1968
1977
|
/*
|
1969
1978
|
Binary mul.
|
1970
1979
|
@overload * other
|
1971
|
-
|
1972
|
-
|
1980
|
+
@param [Numo::NArray,Numeric] other
|
1981
|
+
@return [Numo::NArray] self * other
|
1973
1982
|
*/
|
1974
1983
|
static VALUE robject_mul(VALUE self, VALUE other) {
|
1975
1984
|
return robject_mul_self(self, other);
|
1976
1985
|
}
|
1977
1986
|
|
1978
|
-
#define check_intdivzero(y)
|
1979
|
-
if ((y) == 0) {
|
1980
|
-
lp->err_type = rb_eZeroDivError;
|
1981
|
-
return;
|
1987
|
+
#define check_intdivzero(y) \
|
1988
|
+
if ((y) == 0) { \
|
1989
|
+
lp->err_type = rb_eZeroDivError; \
|
1990
|
+
return; \
|
1982
1991
|
}
|
1983
1992
|
|
1984
1993
|
static void iter_robject_div(na_loop_t* const lp) {
|
@@ -2048,17 +2057,17 @@ static VALUE robject_div_self(VALUE self, VALUE other) {
|
|
2048
2057
|
/*
|
2049
2058
|
Binary div.
|
2050
2059
|
@overload / other
|
2051
|
-
|
2052
|
-
|
2060
|
+
@param [Numo::NArray,Numeric] other
|
2061
|
+
@return [Numo::NArray] self / other
|
2053
2062
|
*/
|
2054
2063
|
static VALUE robject_div(VALUE self, VALUE other) {
|
2055
2064
|
return robject_div_self(self, other);
|
2056
2065
|
}
|
2057
2066
|
|
2058
|
-
#define check_intdivzero(y)
|
2059
|
-
if ((y) == 0) {
|
2060
|
-
lp->err_type = rb_eZeroDivError;
|
2061
|
-
return;
|
2067
|
+
#define check_intdivzero(y) \
|
2068
|
+
if ((y) == 0) { \
|
2069
|
+
lp->err_type = rb_eZeroDivError; \
|
2070
|
+
return; \
|
2062
2071
|
}
|
2063
2072
|
|
2064
2073
|
static void iter_robject_mod(na_loop_t* const lp) {
|
@@ -2128,8 +2137,8 @@ static VALUE robject_mod_self(VALUE self, VALUE other) {
|
|
2128
2137
|
/*
|
2129
2138
|
Binary mod.
|
2130
2139
|
@overload % other
|
2131
|
-
|
2132
|
-
|
2140
|
+
@param [Numo::NArray,Numeric] other
|
2141
|
+
@return [Numo::NArray] self % other
|
2133
2142
|
*/
|
2134
2143
|
static VALUE robject_mod(VALUE self, VALUE other) {
|
2135
2144
|
return robject_mod_self(self, other);
|
@@ -2169,8 +2178,8 @@ static VALUE robject_divmod_self(VALUE self, VALUE other) {
|
|
2169
2178
|
/*
|
2170
2179
|
Binary divmod.
|
2171
2180
|
@overload divmod other
|
2172
|
-
|
2173
|
-
|
2181
|
+
@param [Numo::NArray,Numeric] other
|
2182
|
+
@return [Numo::NArray] divmod of self and other.
|
2174
2183
|
*/
|
2175
2184
|
static VALUE robject_divmod(VALUE self, VALUE other) {
|
2176
2185
|
return robject_divmod_self(self, other);
|
@@ -2229,8 +2238,8 @@ static VALUE robject_pow_self(VALUE self, VALUE other) {
|
|
2229
2238
|
/*
|
2230
2239
|
Binary power.
|
2231
2240
|
@overload ** other
|
2232
|
-
|
2233
|
-
|
2241
|
+
@param [Numo::NArray,Numeric] other
|
2242
|
+
@return [Numo::NArray] self to the other-th power.
|
2234
2243
|
*/
|
2235
2244
|
static VALUE robject_pow(VALUE self, VALUE other) {
|
2236
2245
|
return robject_pow_self(self, other);
|
@@ -2284,7 +2293,7 @@ static void iter_robject_minus(na_loop_t* const lp) {
|
|
2284
2293
|
/*
|
2285
2294
|
Unary minus.
|
2286
2295
|
@overload -@
|
2287
|
-
|
2296
|
+
@return [Numo::RObject] minus of self.
|
2288
2297
|
*/
|
2289
2298
|
static VALUE robject_minus(VALUE self) {
|
2290
2299
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2342,7 +2351,7 @@ static void iter_robject_reciprocal(na_loop_t* const lp) {
|
|
2342
2351
|
/*
|
2343
2352
|
Unary reciprocal.
|
2344
2353
|
@overload reciprocal
|
2345
|
-
|
2354
|
+
@return [Numo::RObject] reciprocal of self.
|
2346
2355
|
*/
|
2347
2356
|
static VALUE robject_reciprocal(VALUE self) {
|
2348
2357
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2400,7 +2409,7 @@ static void iter_robject_sign(na_loop_t* const lp) {
|
|
2400
2409
|
/*
|
2401
2410
|
Unary sign.
|
2402
2411
|
@overload sign
|
2403
|
-
|
2412
|
+
@return [Numo::RObject] sign of self.
|
2404
2413
|
*/
|
2405
2414
|
static VALUE robject_sign(VALUE self) {
|
2406
2415
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2458,7 +2467,7 @@ static void iter_robject_square(na_loop_t* const lp) {
|
|
2458
2467
|
/*
|
2459
2468
|
Unary square.
|
2460
2469
|
@overload square
|
2461
|
-
|
2470
|
+
@return [Numo::RObject] square of self.
|
2462
2471
|
*/
|
2463
2472
|
static VALUE robject_square(VALUE self) {
|
2464
2473
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2500,8 +2509,8 @@ static VALUE robject_eq_self(VALUE self, VALUE other) {
|
|
2500
2509
|
/*
|
2501
2510
|
Comparison eq other.
|
2502
2511
|
@overload eq other
|
2503
|
-
|
2504
|
-
|
2512
|
+
@param [Numo::NArray,Numeric] other
|
2513
|
+
@return [Numo::Bit] result of self eq other.
|
2505
2514
|
*/
|
2506
2515
|
static VALUE robject_eq(VALUE self, VALUE other) {
|
2507
2516
|
return robject_eq_self(self, other);
|
@@ -2539,8 +2548,8 @@ static VALUE robject_ne_self(VALUE self, VALUE other) {
|
|
2539
2548
|
/*
|
2540
2549
|
Comparison ne other.
|
2541
2550
|
@overload ne other
|
2542
|
-
|
2543
|
-
|
2551
|
+
@param [Numo::NArray,Numeric] other
|
2552
|
+
@return [Numo::Bit] result of self ne other.
|
2544
2553
|
*/
|
2545
2554
|
static VALUE robject_ne(VALUE self, VALUE other) {
|
2546
2555
|
return robject_ne_self(self, other);
|
@@ -2578,14 +2587,14 @@ static VALUE robject_nearly_eq_self(VALUE self, VALUE other) {
|
|
2578
2587
|
/*
|
2579
2588
|
Comparison nearly_eq other.
|
2580
2589
|
@overload nearly_eq other
|
2581
|
-
|
2582
|
-
|
2590
|
+
@param [Numo::NArray,Numeric] other
|
2591
|
+
@return [Numo::Bit] result of self nearly_eq other.
|
2583
2592
|
*/
|
2584
2593
|
static VALUE robject_nearly_eq(VALUE self, VALUE other) {
|
2585
2594
|
return robject_nearly_eq_self(self, other);
|
2586
2595
|
}
|
2587
2596
|
|
2588
|
-
#define check_intdivzero(y)
|
2597
|
+
#define check_intdivzero(y) \
|
2589
2598
|
{}
|
2590
2599
|
|
2591
2600
|
static void iter_robject_bit_and(na_loop_t* const lp) {
|
@@ -2655,14 +2664,14 @@ static VALUE robject_bit_and_self(VALUE self, VALUE other) {
|
|
2655
2664
|
/*
|
2656
2665
|
Binary bit_and.
|
2657
2666
|
@overload & other
|
2658
|
-
|
2659
|
-
|
2667
|
+
@param [Numo::NArray,Numeric] other
|
2668
|
+
@return [Numo::NArray] self & other
|
2660
2669
|
*/
|
2661
2670
|
static VALUE robject_bit_and(VALUE self, VALUE other) {
|
2662
2671
|
return robject_bit_and_self(self, other);
|
2663
2672
|
}
|
2664
2673
|
|
2665
|
-
#define check_intdivzero(y)
|
2674
|
+
#define check_intdivzero(y) \
|
2666
2675
|
{}
|
2667
2676
|
|
2668
2677
|
static void iter_robject_bit_or(na_loop_t* const lp) {
|
@@ -2732,14 +2741,14 @@ static VALUE robject_bit_or_self(VALUE self, VALUE other) {
|
|
2732
2741
|
/*
|
2733
2742
|
Binary bit_or.
|
2734
2743
|
@overload | other
|
2735
|
-
|
2736
|
-
|
2744
|
+
@param [Numo::NArray,Numeric] other
|
2745
|
+
@return [Numo::NArray] self | other
|
2737
2746
|
*/
|
2738
2747
|
static VALUE robject_bit_or(VALUE self, VALUE other) {
|
2739
2748
|
return robject_bit_or_self(self, other);
|
2740
2749
|
}
|
2741
2750
|
|
2742
|
-
#define check_intdivzero(y)
|
2751
|
+
#define check_intdivzero(y) \
|
2743
2752
|
{}
|
2744
2753
|
|
2745
2754
|
static void iter_robject_bit_xor(na_loop_t* const lp) {
|
@@ -2809,8 +2818,8 @@ static VALUE robject_bit_xor_self(VALUE self, VALUE other) {
|
|
2809
2818
|
/*
|
2810
2819
|
Binary bit_xor.
|
2811
2820
|
@overload ^ other
|
2812
|
-
|
2813
|
-
|
2821
|
+
@param [Numo::NArray,Numeric] other
|
2822
|
+
@return [Numo::NArray] self ^ other
|
2814
2823
|
*/
|
2815
2824
|
static VALUE robject_bit_xor(VALUE self, VALUE other) {
|
2816
2825
|
return robject_bit_xor_self(self, other);
|
@@ -2864,7 +2873,7 @@ static void iter_robject_bit_not(na_loop_t* const lp) {
|
|
2864
2873
|
/*
|
2865
2874
|
Unary bit_not.
|
2866
2875
|
@overload ~
|
2867
|
-
|
2876
|
+
@return [Numo::RObject] bit_not of self.
|
2868
2877
|
*/
|
2869
2878
|
static VALUE robject_bit_not(VALUE self) {
|
2870
2879
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -2874,7 +2883,7 @@ static VALUE robject_bit_not(VALUE self) {
|
|
2874
2883
|
return na_ndloop(&ndf, 1, self);
|
2875
2884
|
}
|
2876
2885
|
|
2877
|
-
#define check_intdivzero(y)
|
2886
|
+
#define check_intdivzero(y) \
|
2878
2887
|
{}
|
2879
2888
|
|
2880
2889
|
static void iter_robject_left_shift(na_loop_t* const lp) {
|
@@ -2944,14 +2953,14 @@ static VALUE robject_left_shift_self(VALUE self, VALUE other) {
|
|
2944
2953
|
/*
|
2945
2954
|
Binary left_shift.
|
2946
2955
|
@overload << other
|
2947
|
-
|
2948
|
-
|
2956
|
+
@param [Numo::NArray,Numeric] other
|
2957
|
+
@return [Numo::NArray] self << other
|
2949
2958
|
*/
|
2950
2959
|
static VALUE robject_left_shift(VALUE self, VALUE other) {
|
2951
2960
|
return robject_left_shift_self(self, other);
|
2952
2961
|
}
|
2953
2962
|
|
2954
|
-
#define check_intdivzero(y)
|
2963
|
+
#define check_intdivzero(y) \
|
2955
2964
|
{}
|
2956
2965
|
|
2957
2966
|
static void iter_robject_right_shift(na_loop_t* const lp) {
|
@@ -3021,8 +3030,8 @@ static VALUE robject_right_shift_self(VALUE self, VALUE other) {
|
|
3021
3030
|
/*
|
3022
3031
|
Binary right_shift.
|
3023
3032
|
@overload >> other
|
3024
|
-
|
3025
|
-
|
3033
|
+
@param [Numo::NArray,Numeric] other
|
3034
|
+
@return [Numo::NArray] self >> other
|
3026
3035
|
*/
|
3027
3036
|
static VALUE robject_right_shift(VALUE self, VALUE other) {
|
3028
3037
|
return robject_right_shift_self(self, other);
|
@@ -3076,7 +3085,7 @@ static void iter_robject_floor(na_loop_t* const lp) {
|
|
3076
3085
|
/*
|
3077
3086
|
Unary floor.
|
3078
3087
|
@overload floor
|
3079
|
-
|
3088
|
+
@return [Numo::RObject] floor of self.
|
3080
3089
|
*/
|
3081
3090
|
static VALUE robject_floor(VALUE self) {
|
3082
3091
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -3134,7 +3143,7 @@ static void iter_robject_round(na_loop_t* const lp) {
|
|
3134
3143
|
/*
|
3135
3144
|
Unary round.
|
3136
3145
|
@overload round
|
3137
|
-
|
3146
|
+
@return [Numo::RObject] round of self.
|
3138
3147
|
*/
|
3139
3148
|
static VALUE robject_round(VALUE self) {
|
3140
3149
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -3192,7 +3201,7 @@ static void iter_robject_ceil(na_loop_t* const lp) {
|
|
3192
3201
|
/*
|
3193
3202
|
Unary ceil.
|
3194
3203
|
@overload ceil
|
3195
|
-
|
3204
|
+
@return [Numo::RObject] ceil of self.
|
3196
3205
|
*/
|
3197
3206
|
static VALUE robject_ceil(VALUE self) {
|
3198
3207
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -3250,7 +3259,7 @@ static void iter_robject_trunc(na_loop_t* const lp) {
|
|
3250
3259
|
/*
|
3251
3260
|
Unary trunc.
|
3252
3261
|
@overload trunc
|
3253
|
-
|
3262
|
+
@return [Numo::RObject] trunc of self.
|
3254
3263
|
*/
|
3255
3264
|
static VALUE robject_trunc(VALUE self) {
|
3256
3265
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -3292,8 +3301,8 @@ static VALUE robject_gt_self(VALUE self, VALUE other) {
|
|
3292
3301
|
/*
|
3293
3302
|
Comparison gt other.
|
3294
3303
|
@overload gt other
|
3295
|
-
|
3296
|
-
|
3304
|
+
@param [Numo::NArray,Numeric] other
|
3305
|
+
@return [Numo::Bit] result of self gt other.
|
3297
3306
|
*/
|
3298
3307
|
static VALUE robject_gt(VALUE self, VALUE other) {
|
3299
3308
|
return robject_gt_self(self, other);
|
@@ -3331,8 +3340,8 @@ static VALUE robject_ge_self(VALUE self, VALUE other) {
|
|
3331
3340
|
/*
|
3332
3341
|
Comparison ge other.
|
3333
3342
|
@overload ge other
|
3334
|
-
|
3335
|
-
|
3343
|
+
@param [Numo::NArray,Numeric] other
|
3344
|
+
@return [Numo::Bit] result of self ge other.
|
3336
3345
|
*/
|
3337
3346
|
static VALUE robject_ge(VALUE self, VALUE other) {
|
3338
3347
|
return robject_ge_self(self, other);
|
@@ -3370,8 +3379,8 @@ static VALUE robject_lt_self(VALUE self, VALUE other) {
|
|
3370
3379
|
/*
|
3371
3380
|
Comparison lt other.
|
3372
3381
|
@overload lt other
|
3373
|
-
|
3374
|
-
|
3382
|
+
@param [Numo::NArray,Numeric] other
|
3383
|
+
@return [Numo::Bit] result of self lt other.
|
3375
3384
|
*/
|
3376
3385
|
static VALUE robject_lt(VALUE self, VALUE other) {
|
3377
3386
|
return robject_lt_self(self, other);
|
@@ -3409,8 +3418,8 @@ static VALUE robject_le_self(VALUE self, VALUE other) {
|
|
3409
3418
|
/*
|
3410
3419
|
Comparison le other.
|
3411
3420
|
@overload le other
|
3412
|
-
|
3413
|
-
|
3421
|
+
@param [Numo::NArray,Numeric] other
|
3422
|
+
@return [Numo::Bit] result of self le other.
|
3414
3423
|
*/
|
3415
3424
|
static VALUE robject_le(VALUE self, VALUE other) {
|
3416
3425
|
return robject_le_self(self, other);
|
@@ -3485,9 +3494,9 @@ static void iter_robject_clip_max(na_loop_t* const lp) {
|
|
3485
3494
|
Clip array elements by [min,max].
|
3486
3495
|
If either of min or max is nil, one side is clipped.
|
3487
3496
|
@overload clip(min,max)
|
3488
|
-
|
3489
|
-
|
3490
|
-
|
3497
|
+
@param [Numo::NArray,Numeric] min
|
3498
|
+
@param [Numo::NArray,Numeric] max
|
3499
|
+
@return [Numo::NArray] result of clip.
|
3491
3500
|
|
3492
3501
|
@example
|
3493
3502
|
a = Numo::Int32.new(10).seq
|
@@ -3565,7 +3574,7 @@ static void iter_robject_isnan(na_loop_t* const lp) {
|
|
3565
3574
|
/*
|
3566
3575
|
Condition of isnan.
|
3567
3576
|
@overload isnan
|
3568
|
-
|
3577
|
+
@return [Numo::Bit] Condition of isnan.
|
3569
3578
|
*/
|
3570
3579
|
static VALUE robject_isnan(VALUE self) {
|
3571
3580
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -3607,7 +3616,7 @@ static void iter_robject_isinf(na_loop_t* const lp) {
|
|
3607
3616
|
/*
|
3608
3617
|
Condition of isinf.
|
3609
3618
|
@overload isinf
|
3610
|
-
|
3619
|
+
@return [Numo::Bit] Condition of isinf.
|
3611
3620
|
*/
|
3612
3621
|
static VALUE robject_isinf(VALUE self) {
|
3613
3622
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -3649,7 +3658,7 @@ static void iter_robject_isposinf(na_loop_t* const lp) {
|
|
3649
3658
|
/*
|
3650
3659
|
Condition of isposinf.
|
3651
3660
|
@overload isposinf
|
3652
|
-
|
3661
|
+
@return [Numo::Bit] Condition of isposinf.
|
3653
3662
|
*/
|
3654
3663
|
static VALUE robject_isposinf(VALUE self) {
|
3655
3664
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -3691,7 +3700,7 @@ static void iter_robject_isneginf(na_loop_t* const lp) {
|
|
3691
3700
|
/*
|
3692
3701
|
Condition of isneginf.
|
3693
3702
|
@overload isneginf
|
3694
|
-
|
3703
|
+
@return [Numo::Bit] Condition of isneginf.
|
3695
3704
|
*/
|
3696
3705
|
static VALUE robject_isneginf(VALUE self) {
|
3697
3706
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -3733,7 +3742,7 @@ static void iter_robject_isfinite(na_loop_t* const lp) {
|
|
3733
3742
|
/*
|
3734
3743
|
Condition of isfinite.
|
3735
3744
|
@overload isfinite
|
3736
|
-
|
3745
|
+
@return [Numo::Bit] Condition of isfinite.
|
3737
3746
|
*/
|
3738
3747
|
static VALUE robject_isfinite(VALUE self) {
|
3739
3748
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
@@ -3769,12 +3778,12 @@ static void iter_robject_sum_nan(na_loop_t* const lp) {
|
|
3769
3778
|
/*
|
3770
3779
|
sum of self.
|
3771
3780
|
@overload sum(axis:nil, keepdims:false, nan:false)
|
3772
|
-
|
3773
|
-
|
3774
|
-
|
3775
|
-
|
3776
|
-
|
3777
|
-
|
3781
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
3782
|
+
return NaN for min/max etc).
|
3783
|
+
@param [Numeric,Array,Range] axis Performs sum along the axis.
|
3784
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3785
|
+
dimensions with size one.
|
3786
|
+
@return [Numo::RObject] returns result of sum.
|
3778
3787
|
*/
|
3779
3788
|
static VALUE robject_sum(int argc, VALUE* argv, VALUE self) {
|
3780
3789
|
VALUE v, reduce;
|
@@ -3815,12 +3824,12 @@ static void iter_robject_prod_nan(na_loop_t* const lp) {
|
|
3815
3824
|
/*
|
3816
3825
|
prod of self.
|
3817
3826
|
@overload prod(axis:nil, keepdims:false, nan:false)
|
3818
|
-
|
3819
|
-
|
3820
|
-
|
3821
|
-
|
3822
|
-
|
3823
|
-
|
3827
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
3828
|
+
return NaN for min/max etc).
|
3829
|
+
@param [Numeric,Array,Range] axis Performs prod along the axis.
|
3830
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3831
|
+
dimensions with size one.
|
3832
|
+
@return [Numo::RObject] returns result of prod.
|
3824
3833
|
*/
|
3825
3834
|
static VALUE robject_prod(int argc, VALUE* argv, VALUE self) {
|
3826
3835
|
VALUE v, reduce;
|
@@ -3835,190 +3844,6 @@ static VALUE robject_prod(int argc, VALUE* argv, VALUE self) {
|
|
3835
3844
|
return robject_extract(v);
|
3836
3845
|
}
|
3837
3846
|
|
3838
|
-
static void iter_robject_mean(na_loop_t* const lp) {
|
3839
|
-
size_t n;
|
3840
|
-
char *p1, *p2;
|
3841
|
-
ssize_t s1;
|
3842
|
-
|
3843
|
-
INIT_COUNTER(lp, n);
|
3844
|
-
INIT_PTR(lp, 0, p1, s1);
|
3845
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
3846
|
-
|
3847
|
-
*(dtype*)p2 = f_mean(n, p1, s1);
|
3848
|
-
}
|
3849
|
-
static void iter_robject_mean_nan(na_loop_t* const lp) {
|
3850
|
-
size_t n;
|
3851
|
-
char *p1, *p2;
|
3852
|
-
ssize_t s1;
|
3853
|
-
|
3854
|
-
INIT_COUNTER(lp, n);
|
3855
|
-
INIT_PTR(lp, 0, p1, s1);
|
3856
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
3857
|
-
|
3858
|
-
*(dtype*)p2 = f_mean_nan(n, p1, s1);
|
3859
|
-
}
|
3860
|
-
|
3861
|
-
/*
|
3862
|
-
mean of self.
|
3863
|
-
@overload mean(axis:nil, keepdims:false, nan:false)
|
3864
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
3865
|
-
return NaN for min/max etc).
|
3866
|
-
@param [Numeric,Array,Range] axis Performs mean 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::RObject] returns result of mean.
|
3870
|
-
*/
|
3871
|
-
static VALUE robject_mean(int argc, VALUE* argv, VALUE self) {
|
3872
|
-
VALUE v, reduce;
|
3873
|
-
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3874
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3875
|
-
ndfunc_t ndf = { iter_robject_mean, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
3876
|
-
|
3877
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_mean_nan);
|
3878
|
-
|
3879
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
3880
|
-
|
3881
|
-
return robject_extract(v);
|
3882
|
-
}
|
3883
|
-
|
3884
|
-
static void iter_robject_stddev(na_loop_t* const lp) {
|
3885
|
-
size_t n;
|
3886
|
-
char *p1, *p2;
|
3887
|
-
ssize_t s1;
|
3888
|
-
|
3889
|
-
INIT_COUNTER(lp, n);
|
3890
|
-
INIT_PTR(lp, 0, p1, s1);
|
3891
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
3892
|
-
|
3893
|
-
*(rtype*)p2 = f_stddev(n, p1, s1);
|
3894
|
-
}
|
3895
|
-
static void iter_robject_stddev_nan(na_loop_t* const lp) {
|
3896
|
-
size_t n;
|
3897
|
-
char *p1, *p2;
|
3898
|
-
ssize_t s1;
|
3899
|
-
|
3900
|
-
INIT_COUNTER(lp, n);
|
3901
|
-
INIT_PTR(lp, 0, p1, s1);
|
3902
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
3903
|
-
|
3904
|
-
*(rtype*)p2 = f_stddev_nan(n, p1, s1);
|
3905
|
-
}
|
3906
|
-
|
3907
|
-
/*
|
3908
|
-
stddev of self.
|
3909
|
-
@overload stddev(axis:nil, keepdims:false, nan:false)
|
3910
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
3911
|
-
return NaN for min/max etc).
|
3912
|
-
@param [Numeric,Array,Range] axis Performs stddev along the axis.
|
3913
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3914
|
-
dimensions with size one.
|
3915
|
-
@return [Numo::RObject] returns result of stddev.
|
3916
|
-
*/
|
3917
|
-
static VALUE robject_stddev(int argc, VALUE* argv, VALUE self) {
|
3918
|
-
VALUE v, reduce;
|
3919
|
-
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3920
|
-
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
3921
|
-
ndfunc_t ndf = { iter_robject_stddev, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
3922
|
-
|
3923
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_stddev_nan);
|
3924
|
-
|
3925
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
3926
|
-
|
3927
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
3928
|
-
}
|
3929
|
-
|
3930
|
-
static void iter_robject_var(na_loop_t* const lp) {
|
3931
|
-
size_t n;
|
3932
|
-
char *p1, *p2;
|
3933
|
-
ssize_t s1;
|
3934
|
-
|
3935
|
-
INIT_COUNTER(lp, n);
|
3936
|
-
INIT_PTR(lp, 0, p1, s1);
|
3937
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
3938
|
-
|
3939
|
-
*(rtype*)p2 = f_var(n, p1, s1);
|
3940
|
-
}
|
3941
|
-
static void iter_robject_var_nan(na_loop_t* const lp) {
|
3942
|
-
size_t n;
|
3943
|
-
char *p1, *p2;
|
3944
|
-
ssize_t s1;
|
3945
|
-
|
3946
|
-
INIT_COUNTER(lp, n);
|
3947
|
-
INIT_PTR(lp, 0, p1, s1);
|
3948
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
3949
|
-
|
3950
|
-
*(rtype*)p2 = f_var_nan(n, p1, s1);
|
3951
|
-
}
|
3952
|
-
|
3953
|
-
/*
|
3954
|
-
var of self.
|
3955
|
-
@overload var(axis:nil, keepdims:false, nan:false)
|
3956
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
3957
|
-
return NaN for min/max etc).
|
3958
|
-
@param [Numeric,Array,Range] axis Performs var along the axis.
|
3959
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3960
|
-
dimensions with size one.
|
3961
|
-
@return [Numo::RObject] returns result of var.
|
3962
|
-
*/
|
3963
|
-
static VALUE robject_var(int argc, VALUE* argv, VALUE self) {
|
3964
|
-
VALUE v, reduce;
|
3965
|
-
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3966
|
-
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
3967
|
-
ndfunc_t ndf = { iter_robject_var, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
3968
|
-
|
3969
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_var_nan);
|
3970
|
-
|
3971
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
3972
|
-
|
3973
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
3974
|
-
}
|
3975
|
-
|
3976
|
-
static void iter_robject_rms(na_loop_t* const lp) {
|
3977
|
-
size_t n;
|
3978
|
-
char *p1, *p2;
|
3979
|
-
ssize_t s1;
|
3980
|
-
|
3981
|
-
INIT_COUNTER(lp, n);
|
3982
|
-
INIT_PTR(lp, 0, p1, s1);
|
3983
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
3984
|
-
|
3985
|
-
*(rtype*)p2 = f_rms(n, p1, s1);
|
3986
|
-
}
|
3987
|
-
static void iter_robject_rms_nan(na_loop_t* const lp) {
|
3988
|
-
size_t n;
|
3989
|
-
char *p1, *p2;
|
3990
|
-
ssize_t s1;
|
3991
|
-
|
3992
|
-
INIT_COUNTER(lp, n);
|
3993
|
-
INIT_PTR(lp, 0, p1, s1);
|
3994
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
3995
|
-
|
3996
|
-
*(rtype*)p2 = f_rms_nan(n, p1, s1);
|
3997
|
-
}
|
3998
|
-
|
3999
|
-
/*
|
4000
|
-
rms of self.
|
4001
|
-
@overload rms(axis:nil, keepdims:false, nan:false)
|
4002
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4003
|
-
return NaN for min/max etc).
|
4004
|
-
@param [Numeric,Array,Range] axis Performs rms along the axis.
|
4005
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4006
|
-
dimensions with size one.
|
4007
|
-
@return [Numo::RObject] returns result of rms.
|
4008
|
-
*/
|
4009
|
-
static VALUE robject_rms(int argc, VALUE* argv, VALUE self) {
|
4010
|
-
VALUE v, reduce;
|
4011
|
-
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4012
|
-
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
4013
|
-
ndfunc_t ndf = { iter_robject_rms, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4014
|
-
|
4015
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_robject_rms_nan);
|
4016
|
-
|
4017
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4018
|
-
|
4019
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
4020
|
-
}
|
4021
|
-
|
4022
3847
|
static void iter_robject_min(na_loop_t* const lp) {
|
4023
3848
|
size_t n;
|
4024
3849
|
char *p1, *p2;
|
@@ -4045,12 +3870,12 @@ static void iter_robject_min_nan(na_loop_t* const lp) {
|
|
4045
3870
|
/*
|
4046
3871
|
min of self.
|
4047
3872
|
@overload min(axis:nil, keepdims:false, nan:false)
|
4048
|
-
|
4049
|
-
|
4050
|
-
|
4051
|
-
|
4052
|
-
|
4053
|
-
|
3873
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
3874
|
+
return NaN for min/max etc).
|
3875
|
+
@param [Numeric,Array,Range] axis Performs min along the axis.
|
3876
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3877
|
+
dimensions with size one.
|
3878
|
+
@return [Numo::RObject] returns result of min.
|
4054
3879
|
*/
|
4055
3880
|
static VALUE robject_min(int argc, VALUE* argv, VALUE self) {
|
4056
3881
|
VALUE v, reduce;
|
@@ -4091,12 +3916,12 @@ static void iter_robject_max_nan(na_loop_t* const lp) {
|
|
4091
3916
|
/*
|
4092
3917
|
max of self.
|
4093
3918
|
@overload max(axis:nil, keepdims:false, nan:false)
|
4094
|
-
|
4095
|
-
|
4096
|
-
|
4097
|
-
|
4098
|
-
|
4099
|
-
|
3919
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
3920
|
+
return NaN for min/max etc).
|
3921
|
+
@param [Numeric,Array,Range] axis Performs max along the axis.
|
3922
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3923
|
+
dimensions with size one.
|
3924
|
+
@return [Numo::RObject] returns result of max.
|
4100
3925
|
*/
|
4101
3926
|
static VALUE robject_max(int argc, VALUE* argv, VALUE self) {
|
4102
3927
|
VALUE v, reduce;
|
@@ -4137,12 +3962,12 @@ static void iter_robject_ptp_nan(na_loop_t* const lp) {
|
|
4137
3962
|
/*
|
4138
3963
|
ptp of self.
|
4139
3964
|
@overload ptp(axis:nil, keepdims:false, nan:false)
|
4140
|
-
|
4141
|
-
|
4142
|
-
|
4143
|
-
|
4144
|
-
|
4145
|
-
|
3965
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
3966
|
+
return NaN for min/max etc).
|
3967
|
+
@param [Numeric,Array,Range] axis Performs ptp along the axis.
|
3968
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3969
|
+
dimensions with size one.
|
3970
|
+
@return [Numo::RObject] returns result of ptp.
|
4146
3971
|
*/
|
4147
3972
|
static VALUE robject_ptp(int argc, VALUE* argv, VALUE self) {
|
4148
3973
|
VALUE v, reduce;
|
@@ -4228,10 +4053,10 @@ static void iter_robject_max_index_index32_nan(na_loop_t* const lp) {
|
|
4228
4053
|
/*
|
4229
4054
|
Index of the maximum value.
|
4230
4055
|
@overload max_index(axis:nil, nan:false)
|
4231
|
-
|
4232
|
-
|
4233
|
-
|
4234
|
-
|
4056
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
4057
|
+
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat
|
4058
|
+
1-d indices**.
|
4059
|
+
@return [Integer,Numo::Int] returns result indices.
|
4235
4060
|
@see #argmax
|
4236
4061
|
@see #max
|
4237
4062
|
|
@@ -4348,10 +4173,10 @@ static void iter_robject_min_index_index32_nan(na_loop_t* const lp) {
|
|
4348
4173
|
/*
|
4349
4174
|
Index of the minimum value.
|
4350
4175
|
@overload min_index(axis:nil, nan:false)
|
4351
|
-
|
4352
|
-
|
4353
|
-
|
4354
|
-
|
4176
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
4177
|
+
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat
|
4178
|
+
1-d indices**.
|
4179
|
+
@return [Integer,Numo::Int] returns result indices.
|
4355
4180
|
@see #argmin
|
4356
4181
|
@see #min
|
4357
4182
|
|
@@ -4464,10 +4289,10 @@ static void iter_robject_argmax_arg32_nan(na_loop_t* const lp) {
|
|
4464
4289
|
/*
|
4465
4290
|
Index of the maximum value.
|
4466
4291
|
@overload argmax(axis:nil, nan:false)
|
4467
|
-
|
4468
|
-
|
4469
|
-
|
4470
|
-
|
4292
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
4293
|
+
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices
|
4294
|
+
along the axis**.
|
4295
|
+
@return [Integer,Numo::Int] returns the result indices.
|
4471
4296
|
@see #max_index
|
4472
4297
|
@see #max
|
4473
4298
|
|
@@ -4575,10 +4400,10 @@ static void iter_robject_argmin_arg32_nan(na_loop_t* const lp) {
|
|
4575
4400
|
/*
|
4576
4401
|
Index of the minimum value.
|
4577
4402
|
@overload argmin(axis:nil, nan:false)
|
4578
|
-
|
4579
|
-
|
4580
|
-
|
4581
|
-
|
4403
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
4404
|
+
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices
|
4405
|
+
along the axis**.
|
4406
|
+
@return [Integer,Numo::Int] returns the result indices.
|
4582
4407
|
@see #min_index
|
4583
4408
|
@see #min
|
4584
4409
|
|
@@ -4651,11 +4476,11 @@ static void iter_robject_minmax_nan(na_loop_t* const lp) {
|
|
4651
4476
|
/*
|
4652
4477
|
minmax of self.
|
4653
4478
|
@overload minmax(axis:nil, keepdims:false, nan:false)
|
4654
|
-
|
4655
|
-
|
4656
|
-
|
4657
|
-
|
4658
|
-
|
4479
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
4480
|
+
@param [Numeric,Array,Range] axis Finds min-max along the axis.
|
4481
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
4482
|
+
as dimensions with size one.
|
4483
|
+
@return [Numo::RObject,Numo::RObject] min and max of self.
|
4659
4484
|
*/
|
4660
4485
|
static VALUE robject_minmax(int argc, VALUE* argv, VALUE self) {
|
4661
4486
|
VALUE reduce;
|
@@ -4670,16 +4495,6 @@ static VALUE robject_minmax(int argc, VALUE* argv, VALUE self) {
|
|
4670
4495
|
return na_ndloop(&ndf, 2, self, reduce);
|
4671
4496
|
}
|
4672
4497
|
|
4673
|
-
/*
|
4674
|
-
Element-wise maximum of two arrays.
|
4675
|
-
|
4676
|
-
@overload maximum(a1, a2, nan:false)
|
4677
|
-
@param [Numo::NArray,Numeric] a1 The array to be compared.
|
4678
|
-
@param [Numo::NArray,Numeric] a2 The array to be compared.
|
4679
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
4680
|
-
@return [Numo::RObject]
|
4681
|
-
*/
|
4682
|
-
|
4683
4498
|
static void iter_robject_s_maximum(na_loop_t* const lp) {
|
4684
4499
|
size_t i, n;
|
4685
4500
|
char *p1, *p2, *p3;
|
@@ -4743,10 +4558,10 @@ static VALUE robject_s_maximum(int argc, VALUE* argv, VALUE mod) {
|
|
4743
4558
|
Element-wise minimum of two arrays.
|
4744
4559
|
|
4745
4560
|
@overload minimum(a1, a2, nan:false)
|
4746
|
-
|
4747
|
-
|
4748
|
-
|
4749
|
-
|
4561
|
+
@param [Numo::NArray,Numeric] a1 The array to be compared.
|
4562
|
+
@param [Numo::NArray,Numeric] a2 The array to be compared.
|
4563
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
4564
|
+
@return [Numo::RObject]
|
4750
4565
|
*/
|
4751
4566
|
|
4752
4567
|
static void iter_robject_s_minimum(na_loop_t* const lp) {
|
@@ -4848,9 +4663,9 @@ static void iter_robject_cumsum_nan(na_loop_t* const lp) {
|
|
4848
4663
|
/*
|
4849
4664
|
cumsum of self.
|
4850
4665
|
@overload cumsum(axis:nil, nan:false)
|
4851
|
-
|
4852
|
-
|
4853
|
-
|
4666
|
+
@param [Numeric,Array,Range] axis Performs cumsum along the axis.
|
4667
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
4668
|
+
@return [Numo::RObject] cumsum of self.
|
4854
4669
|
*/
|
4855
4670
|
static VALUE robject_cumsum(int argc, VALUE* argv, VALUE self) {
|
4856
4671
|
VALUE reduce;
|
@@ -4905,9 +4720,9 @@ static void iter_robject_cumprod_nan(na_loop_t* const lp) {
|
|
4905
4720
|
/*
|
4906
4721
|
cumprod of self.
|
4907
4722
|
@overload cumprod(axis:nil, nan:false)
|
4908
|
-
|
4909
|
-
|
4910
|
-
|
4723
|
+
@param [Numeric,Array,Range] axis Performs cumprod along the axis.
|
4724
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
4725
|
+
@return [Numo::RObject] cumprod of self.
|
4911
4726
|
*/
|
4912
4727
|
static VALUE robject_cumprod(int argc, VALUE* argv, VALUE self) {
|
4913
4728
|
VALUE reduce;
|
@@ -5017,12 +4832,12 @@ static VALUE robject_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
|
5017
4832
|
Binary mulsum.
|
5018
4833
|
|
5019
4834
|
@overload mulsum(other, axis:nil, keepdims:false, nan:false)
|
5020
|
-
|
5021
|
-
|
5022
|
-
|
5023
|
-
|
5024
|
-
|
5025
|
-
|
4835
|
+
@param [Numo::NArray,Numeric] other
|
4836
|
+
@param [Numeric,Array,Range] axis Performs mulsum along the axis.
|
4837
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
4838
|
+
as dimensions with size one.
|
4839
|
+
@param [TrueClass] nan (keyword) If true, apply NaN-aware algorithm (avoid NaN if exists).
|
4840
|
+
@return [Numo::NArray] mulsum of self and other.
|
5026
4841
|
*/
|
5027
4842
|
static VALUE robject_mulsum(int argc, VALUE* argv, VALUE self) {
|
5028
4843
|
//
|
@@ -5081,9 +4896,9 @@ static void iter_robject_seq(na_loop_t* const lp) {
|
|
5081
4896
|
beg+i*step
|
5082
4897
|
where i is 1-dimensional index.
|
5083
4898
|
@overload seq([beg,[step]])
|
5084
|
-
|
5085
|
-
|
5086
|
-
|
4899
|
+
@param [Numeric] beg beginning of sequence. (default=0)
|
4900
|
+
@param [Numeric] step step of sequence. (default=1)
|
4901
|
+
@return [Numo::RObject] self.
|
5087
4902
|
@example
|
5088
4903
|
Numo::DFloat.new(6).seq(1,-0.2)
|
5089
4904
|
# => Numo::DFloat#shape=[6]
|
@@ -5093,7 +4908,7 @@ static void iter_robject_seq(na_loop_t* const lp) {
|
|
5093
4908
|
# => Numo::DComplex#shape=[6]
|
5094
4909
|
# [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
5095
4910
|
*/
|
5096
|
-
static VALUE robject_seq(int argc, VALUE*
|
4911
|
+
static VALUE robject_seq(int argc, VALUE* argv, VALUE self) {
|
5097
4912
|
seq_opt_t* g;
|
5098
4913
|
VALUE vbeg = Qnil, vstep = Qnil;
|
5099
4914
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
@@ -5103,7 +4918,7 @@ static VALUE robject_seq(int argc, VALUE* args, VALUE self) {
|
|
5103
4918
|
g->beg = m_zero;
|
5104
4919
|
g->step = m_one;
|
5105
4920
|
g->count = 0;
|
5106
|
-
rb_scan_args(argc,
|
4921
|
+
rb_scan_args(argc, argv, "02", &vbeg, &vstep);
|
5107
4922
|
if (vbeg != Qnil) {
|
5108
4923
|
g->beg = m_num_to_data(vbeg);
|
5109
4924
|
}
|
@@ -5162,10 +4977,10 @@ static void iter_robject_logseq(na_loop_t* const lp) {
|
|
5162
4977
|
Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
|
5163
4978
|
|
5164
4979
|
@overload logseq(beg,step,[base])
|
5165
|
-
|
5166
|
-
|
5167
|
-
|
5168
|
-
|
4980
|
+
@param [Numeric] beg The beginning of sequence.
|
4981
|
+
@param [Numeric] step The step of sequence.
|
4982
|
+
@param [Numeric] base The base of log space. (default=10)
|
4983
|
+
@return [Numo::RObject] self.
|
5169
4984
|
|
5170
4985
|
@example
|
5171
4986
|
Numo::DFloat.new(5).logseq(4,-1,2)
|
@@ -5176,14 +4991,14 @@ static void iter_robject_logseq(na_loop_t* const lp) {
|
|
5176
4991
|
# => Numo::DComplex#shape=[5]
|
5177
4992
|
# [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
|
5178
4993
|
*/
|
5179
|
-
static VALUE robject_logseq(int argc, VALUE*
|
4994
|
+
static VALUE robject_logseq(int argc, VALUE* argv, VALUE self) {
|
5180
4995
|
logseq_opt_t* g;
|
5181
4996
|
VALUE vbeg, vstep, vbase;
|
5182
4997
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
5183
4998
|
ndfunc_t ndf = { iter_robject_logseq, FULL_LOOP, 1, 0, ain, 0 };
|
5184
4999
|
|
5185
5000
|
g = ALLOCA_N(logseq_opt_t, 1);
|
5186
|
-
rb_scan_args(argc,
|
5001
|
+
rb_scan_args(argc, argv, "21", &vbeg, &vstep, &vbase);
|
5187
5002
|
g->beg = m_num_to_data(vbeg);
|
5188
5003
|
g->step = m_num_to_data(vstep);
|
5189
5004
|
if (vbase == Qnil) {
|
@@ -5227,11 +5042,11 @@ static void iter_robject_eye(na_loop_t* const lp) {
|
|
5227
5042
|
/*
|
5228
5043
|
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
|
5229
5044
|
@overload eye([element,offset])
|
5230
|
-
|
5231
|
-
|
5232
|
-
|
5233
|
-
|
5234
|
-
|
5045
|
+
@param [Numeric] element Diagonal element to be stored. Default is 1.
|
5046
|
+
@param [Integer] offset Diagonal offset from the main diagonal. The
|
5047
|
+
default is 0. k>0 for diagonals above the main diagonal, and k<0
|
5048
|
+
for diagonals below the main diagonal.
|
5049
|
+
@return [Numo::RObject] eye of self.
|
5235
5050
|
*/
|
5236
5051
|
static VALUE robject_eye(int argc, VALUE* argv, VALUE self) {
|
5237
5052
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
|
@@ -5328,10 +5143,10 @@ static void iter_robject_rand(na_loop_t* const lp) {
|
|
5328
5143
|
/*
|
5329
5144
|
Generate uniformly distributed random numbers on self narray.
|
5330
5145
|
@overload rand([[low],high])
|
5331
|
-
|
5332
|
-
|
5333
|
-
|
5334
|
-
|
5146
|
+
@param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
5147
|
+
@param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
|
5148
|
+
complex types)
|
5149
|
+
@return [Numo::RObject] self.
|
5335
5150
|
@example
|
5336
5151
|
Numo::DFloat.new(6).rand
|
5337
5152
|
# => Numo::DFloat#shape=[6]
|
@@ -5345,14 +5160,14 @@ static void iter_robject_rand(na_loop_t* const lp) {
|
|
5345
5160
|
# => Numo::Int32#shape=[6]
|
5346
5161
|
# [4, 3, 3, 2, 4, 2]
|
5347
5162
|
*/
|
5348
|
-
static VALUE robject_rand(int argc, VALUE*
|
5163
|
+
static VALUE robject_rand(int argc, VALUE* argv, VALUE self) {
|
5349
5164
|
rand_opt_t g;
|
5350
5165
|
VALUE v1 = Qnil, v2 = Qnil;
|
5351
5166
|
dtype high;
|
5352
5167
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
5353
5168
|
ndfunc_t ndf = { iter_robject_rand, FULL_LOOP, 1, 0, ain, 0 };
|
5354
5169
|
|
5355
|
-
rb_scan_args(argc,
|
5170
|
+
rb_scan_args(argc, argv, "02", &v1, &v2);
|
5356
5171
|
if (v2 == Qnil) {
|
5357
5172
|
g.low = m_zero;
|
5358
5173
|
if (v1 == Qnil) {
|
@@ -5393,8 +5208,8 @@ static void iter_robject_poly(na_loop_t* const lp) {
|
|
5393
5208
|
Calculate polynomial.
|
5394
5209
|
`x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
|
5395
5210
|
@overload poly a0, a1, ..., an
|
5396
|
-
|
5397
|
-
|
5211
|
+
@param [Numo::NArray,Numeric] a0,a1,...,an
|
5212
|
+
@return [Numo::RObject]
|
5398
5213
|
*/
|
5399
5214
|
static VALUE robject_poly(VALUE self, VALUE args) {
|
5400
5215
|
int argc, i;
|
@@ -5457,13 +5272,15 @@ void Init_numo_robject(void) {
|
|
5457
5272
|
id_to_a = rb_intern("to_a");
|
5458
5273
|
id_truncate = rb_intern("truncate");
|
5459
5274
|
|
5460
|
-
|
5461
|
-
|
5462
|
-
|
5463
|
-
|
5275
|
+
/**
|
5276
|
+
* Document-class: Numo::RObject
|
5277
|
+
*
|
5278
|
+
* Ruby object N-dimensional array class.
|
5279
|
+
*/
|
5464
5280
|
cT = rb_define_class_under(mNumo, "RObject", cNArray);
|
5465
5281
|
|
5466
5282
|
hCast = rb_hash_new();
|
5283
|
+
/* Upcasting rules of RObject. */
|
5467
5284
|
rb_define_const(cT, "UPCAST", hCast);
|
5468
5285
|
rb_hash_aset(hCast, rb_cArray, cT);
|
5469
5286
|
|
@@ -5489,11 +5306,11 @@ void Init_numo_robject(void) {
|
|
5489
5306
|
rb_hash_aset(hCast, numo_cUInt8, numo_cRObject);
|
5490
5307
|
rb_obj_freeze(hCast);
|
5491
5308
|
|
5492
|
-
|
5309
|
+
/* Element size of RObject in bits. */
|
5493
5310
|
rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
|
5494
|
-
|
5311
|
+
/* Element size of RObject in bytes. */
|
5495
5312
|
rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
|
5496
|
-
|
5313
|
+
/* Stride size of contiguous RObject array. */
|
5497
5314
|
rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
|
5498
5315
|
rb_undef_method(rb_singleton_class(cT), "from_binary");
|
5499
5316
|
rb_undef_method(cT, "to_binary");
|
@@ -5567,9 +5384,49 @@ void Init_numo_robject(void) {
|
|
5567
5384
|
rb_define_method(cT, "isfinite", robject_isfinite, 0);
|
5568
5385
|
rb_define_method(cT, "sum", robject_sum, -1);
|
5569
5386
|
rb_define_method(cT, "prod", robject_prod, -1);
|
5387
|
+
/**
|
5388
|
+
* mean of self.
|
5389
|
+
* @overload mean(axis: nil, keepdims: false, nan: false)
|
5390
|
+
* @param axis [Numeric, Array, Range] Performs mean along the axis.
|
5391
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5392
|
+
* dimensions with size one.
|
5393
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5394
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5395
|
+
* @return [Numo::RObject] returns result of mean.
|
5396
|
+
*/
|
5570
5397
|
rb_define_method(cT, "mean", robject_mean, -1);
|
5571
|
-
|
5398
|
+
/**
|
5399
|
+
* var of self.
|
5400
|
+
* @overload var(axis: nil, keepdims: false, nan: false)
|
5401
|
+
* @param axis [Numeric, Array, Range] Performs var along the axis.
|
5402
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5403
|
+
* dimensions with size one.
|
5404
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5405
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5406
|
+
* @return [Numo::RObject] returns result of var.
|
5407
|
+
*/
|
5572
5408
|
rb_define_method(cT, "var", robject_var, -1);
|
5409
|
+
/**
|
5410
|
+
* stddev of self.
|
5411
|
+
* @overload stddev(axis: nil, keepdims: false, nan: false)
|
5412
|
+
* @param axis [Numeric, Array, Range] Performs stddev along the axis.
|
5413
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5414
|
+
* dimensions with size one.
|
5415
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5416
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5417
|
+
* @return [Numo::RObject] returns result of stddev.
|
5418
|
+
*/
|
5419
|
+
rb_define_method(cT, "stddev", robject_stddev, -1);
|
5420
|
+
/**
|
5421
|
+
* rms of self.
|
5422
|
+
* @overload rms(axis: nil, keepdims: false, nan: false)
|
5423
|
+
* @param axis [Numeric, Array, Range] Performs rms along the axis.
|
5424
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
5425
|
+
* dimensions with size one.
|
5426
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
5427
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
5428
|
+
* @return [Numo::RObject] returns result of rms.
|
5429
|
+
*/
|
5573
5430
|
rb_define_method(cT, "rms", robject_rms, -1);
|
5574
5431
|
rb_define_method(cT, "min", robject_min, -1);
|
5575
5432
|
rb_define_method(cT, "max", robject_max, -1);
|
@@ -5579,7 +5436,23 @@ void Init_numo_robject(void) {
|
|
5579
5436
|
rb_define_method(cT, "argmax", robject_argmax, -1);
|
5580
5437
|
rb_define_method(cT, "argmin", robject_argmin, -1);
|
5581
5438
|
rb_define_method(cT, "minmax", robject_minmax, -1);
|
5439
|
+
/**
|
5440
|
+
* Element-wise maximum of two arrays.
|
5441
|
+
* @overload maximum(a1, a2, nan:false)
|
5442
|
+
* @param [Numo::NArray,Numeric] a1 The array to be compared.
|
5443
|
+
* @param [Numo::NArray,Numeric] a2 The array to be compared.
|
5444
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
5445
|
+
* @return [Numo::RObject]
|
5446
|
+
*/
|
5582
5447
|
rb_define_module_function(cT, "maximum", robject_s_maximum, -1);
|
5448
|
+
/**
|
5449
|
+
* Element-wise minimum of two arrays.
|
5450
|
+
* @overload minimum(a1, a2, nan:false)
|
5451
|
+
* @param [Numo::NArray,Numeric] a1 The array to be compared.
|
5452
|
+
* @param [Numo::NArray,Numeric] a2 The array to be compared.
|
5453
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
5454
|
+
* @return [Numo::RObject]
|
5455
|
+
*/
|
5583
5456
|
rb_define_module_function(cT, "minimum", robject_s_minimum, -1);
|
5584
5457
|
rb_define_method(cT, "cumsum", robject_cumsum, -1);
|
5585
5458
|
rb_define_method(cT, "cumprod", robject_cumprod, -1);
|