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
@@ -36,14 +36,23 @@ static ID id_to_a;
|
|
36
36
|
|
37
37
|
#include <numo/types/sfloat.h>
|
38
38
|
|
39
|
-
VALUE cT;
|
40
|
-
extern VALUE cRT;
|
41
|
-
|
42
39
|
/*
|
43
40
|
class definition: Numo::SFloat
|
44
41
|
*/
|
45
|
-
|
46
42
|
VALUE cT;
|
43
|
+
extern VALUE cRT;
|
44
|
+
|
45
|
+
#include "mh/mean.h"
|
46
|
+
#include "mh/var.h"
|
47
|
+
#include "mh/stddev.h"
|
48
|
+
#include "mh/rms.h"
|
49
|
+
|
50
|
+
typedef float sfloat; // Type aliases for shorter notation
|
51
|
+
// following the codebase naming convention.
|
52
|
+
DEF_NARRAY_FLT_MEAN_METHOD_FUNC(sfloat, float, numo_cSFloat, numo_cSFloat)
|
53
|
+
DEF_NARRAY_FLT_VAR_METHOD_FUNC(sfloat, float, numo_cSFloat, numo_cSFloat)
|
54
|
+
DEF_NARRAY_FLT_STDDEV_METHOD_FUNC(sfloat, float, numo_cSFloat, numo_cSFloat)
|
55
|
+
DEF_NARRAY_FLT_RMS_METHOD_FUNC(sfloat, float, numo_cSFloat, numo_cSFloat)
|
47
56
|
|
48
57
|
static VALUE sfloat_store(VALUE, VALUE);
|
49
58
|
|
@@ -148,13 +157,6 @@ static VALUE sfloat_allocate(VALUE self) {
|
|
148
157
|
return self;
|
149
158
|
}
|
150
159
|
|
151
|
-
/*
|
152
|
-
Extract an element only if self is a dimensionless NArray.
|
153
|
-
@overload extract
|
154
|
-
@return [Numeric,Numo::NArray]
|
155
|
-
--- Extract element value as Ruby Object if self is a dimensionless NArray,
|
156
|
-
otherwise returns self.
|
157
|
-
*/
|
158
160
|
static VALUE sfloat_extract(VALUE self) {
|
159
161
|
volatile VALUE v;
|
160
162
|
char* ptr;
|
@@ -892,12 +894,6 @@ static VALUE sfloat_store_array(VALUE self, VALUE rary) {
|
|
892
894
|
return self;
|
893
895
|
}
|
894
896
|
|
895
|
-
/*
|
896
|
-
Store elements to Numo::SFloat from other.
|
897
|
-
@overload store(other)
|
898
|
-
@param [Object] other
|
899
|
-
@return [Numo::SFloat] self
|
900
|
-
*/
|
901
897
|
static VALUE sfloat_store(VALUE self, VALUE obj) {
|
902
898
|
VALUE r, klass;
|
903
899
|
|
@@ -1104,14 +1100,6 @@ static VALUE sfloat_cast_array(VALUE rary) {
|
|
1104
1100
|
return nary;
|
1105
1101
|
}
|
1106
1102
|
|
1107
|
-
/*
|
1108
|
-
Cast object to Numo::SFloat.
|
1109
|
-
@overload [](elements)
|
1110
|
-
@overload cast(array)
|
1111
|
-
@param [Numeric,Array] elements
|
1112
|
-
@param [Array] array
|
1113
|
-
@return [Numo::SFloat]
|
1114
|
-
*/
|
1115
1103
|
static VALUE sfloat_s_cast(VALUE type, VALUE obj) {
|
1116
1104
|
VALUE v;
|
1117
1105
|
narray_t* na;
|
@@ -1147,15 +1135,6 @@ static VALUE sfloat_s_cast(VALUE type, VALUE obj) {
|
|
1147
1135
|
return Qnil;
|
1148
1136
|
}
|
1149
1137
|
|
1150
|
-
/*
|
1151
|
-
Multi-dimensional element reference.
|
1152
|
-
@overload [](dim0,...,dimL)
|
1153
|
-
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
|
1154
|
-
dim0,...,dimL multi-dimensional indices.
|
1155
|
-
@return [Numeric,Numo::SFloat] an element or NArray view.
|
1156
|
-
@see Numo::NArray#[]
|
1157
|
-
@see #[]=
|
1158
|
-
*/
|
1159
1138
|
static VALUE sfloat_aref(int argc, VALUE* argv, VALUE self) {
|
1160
1139
|
int nd;
|
1161
1140
|
size_t pos;
|
@@ -1170,16 +1149,6 @@ static VALUE sfloat_aref(int argc, VALUE* argv, VALUE self) {
|
|
1170
1149
|
}
|
1171
1150
|
}
|
1172
1151
|
|
1173
|
-
/*
|
1174
|
-
Multi-dimensional element assignment.
|
1175
|
-
@overload []=(dim0,...,dimL,val)
|
1176
|
-
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
|
1177
|
-
dim0,...,dimL multi-dimensional indices.
|
1178
|
-
@param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
|
1179
|
-
@return [Numeric,Numo::NArray,Array] returns `val` (last argument).
|
1180
|
-
@see Numo::NArray#[]=
|
1181
|
-
@see #[]
|
1182
|
-
*/
|
1183
1152
|
static VALUE sfloat_aset(int argc, VALUE* argv, VALUE self) {
|
1184
1153
|
int nd;
|
1185
1154
|
size_t pos;
|
@@ -1204,11 +1173,6 @@ static VALUE sfloat_aset(int argc, VALUE* argv, VALUE self) {
|
|
1204
1173
|
return argv[argc];
|
1205
1174
|
}
|
1206
1175
|
|
1207
|
-
/*
|
1208
|
-
return NArray with cast to the type of self.
|
1209
|
-
@overload coerce_cast(type)
|
1210
|
-
@return [nil]
|
1211
|
-
*/
|
1212
1176
|
static VALUE sfloat_coerce_cast(VALUE self, VALUE type) {
|
1213
1177
|
return Qnil;
|
1214
1178
|
}
|
@@ -1239,11 +1203,6 @@ static void iter_sfloat_to_a(na_loop_t* const lp) {
|
|
1239
1203
|
}
|
1240
1204
|
}
|
1241
1205
|
|
1242
|
-
/*
|
1243
|
-
Convert self to Array.
|
1244
|
-
@overload to_a
|
1245
|
-
@return [Array]
|
1246
|
-
*/
|
1247
1206
|
static VALUE sfloat_to_a(VALUE self) {
|
1248
1207
|
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
|
1249
1208
|
ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
|
@@ -1272,12 +1231,6 @@ static void iter_sfloat_fill(na_loop_t* const lp) {
|
|
1272
1231
|
}
|
1273
1232
|
}
|
1274
1233
|
|
1275
|
-
/*
|
1276
|
-
Fill elements with other.
|
1277
|
-
@overload fill other
|
1278
|
-
@param [Numeric] other
|
1279
|
-
@return [Numo::SFloat] self.
|
1280
|
-
*/
|
1281
1234
|
static VALUE sfloat_fill(VALUE self, VALUE val) {
|
1282
1235
|
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
|
1283
1236
|
ndfunc_t ndf = { iter_sfloat_fill, FULL_LOOP, 2, 0, ain, 0 };
|
@@ -1326,12 +1279,6 @@ static void iter_sfloat_format(na_loop_t* const lp) {
|
|
1326
1279
|
}
|
1327
1280
|
}
|
1328
1281
|
|
1329
|
-
/*
|
1330
|
-
Format elements into strings.
|
1331
|
-
@overload format format
|
1332
|
-
@param [String] format
|
1333
|
-
@return [Numo::RObject] array of formatted strings.
|
1334
|
-
*/
|
1335
1282
|
static VALUE sfloat_format(int argc, VALUE* argv, VALUE self) {
|
1336
1283
|
VALUE fmt = Qnil;
|
1337
1284
|
|
@@ -1373,12 +1320,6 @@ static void iter_sfloat_format_to_a(na_loop_t* const lp) {
|
|
1373
1320
|
}
|
1374
1321
|
}
|
1375
1322
|
|
1376
|
-
/*
|
1377
|
-
Format elements into strings.
|
1378
|
-
@overload format_to_a format
|
1379
|
-
@param [String] format
|
1380
|
-
@return [Array] array of formatted strings.
|
1381
|
-
*/
|
1382
1323
|
static VALUE sfloat_format_to_a(int argc, VALUE* argv, VALUE self) {
|
1383
1324
|
VALUE fmt = Qnil;
|
1384
1325
|
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
|
@@ -1393,11 +1334,6 @@ static VALUE iter_sfloat_inspect(char* ptr, size_t pos, VALUE fmt) {
|
|
1393
1334
|
return format_sfloat(fmt, (dtype*)(ptr + pos));
|
1394
1335
|
}
|
1395
1336
|
|
1396
|
-
/*
|
1397
|
-
Returns a string containing a human-readable representation of NArray.
|
1398
|
-
@overload inspect
|
1399
|
-
@return [String]
|
1400
|
-
*/
|
1401
1337
|
static VALUE sfloat_inspect(VALUE ary) {
|
1402
1338
|
return na_ndloop_inspect(ary, iter_sfloat_inspect, Qnil);
|
1403
1339
|
}
|
@@ -1426,16 +1362,6 @@ static void iter_sfloat_each(na_loop_t* const lp) {
|
|
1426
1362
|
}
|
1427
1363
|
}
|
1428
1364
|
|
1429
|
-
/*
|
1430
|
-
Calls the given block once for each element in self,
|
1431
|
-
passing that element as a parameter.
|
1432
|
-
@overload each
|
1433
|
-
@return [Numo::NArray] self
|
1434
|
-
For a block `{|x| ... }`,
|
1435
|
-
@yieldparam [Numeric] x an element of NArray.
|
1436
|
-
@see #each_with_index
|
1437
|
-
@see #map
|
1438
|
-
*/
|
1439
1365
|
static VALUE sfloat_each(VALUE self) {
|
1440
1366
|
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1441
1367
|
ndfunc_t ndf = { iter_sfloat_each, FULL_LOOP_NIP, 1, 0, ain, 0 };
|
@@ -1506,11 +1432,6 @@ static void iter_sfloat_map(na_loop_t* const lp) {
|
|
1506
1432
|
}
|
1507
1433
|
}
|
1508
1434
|
|
1509
|
-
/*
|
1510
|
-
Unary map.
|
1511
|
-
@overload map
|
1512
|
-
@return [Numo::SFloat] map of self.
|
1513
|
-
*/
|
1514
1435
|
static VALUE sfloat_map(VALUE self) {
|
1515
1436
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
1516
1437
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -1564,17 +1485,6 @@ static void iter_sfloat_each_with_index(na_loop_t* const lp) {
|
|
1564
1485
|
}
|
1565
1486
|
}
|
1566
1487
|
|
1567
|
-
/*
|
1568
|
-
Invokes the given block once for each element of self,
|
1569
|
-
passing that element and indices along each axis as parameters.
|
1570
|
-
@overload each_with_index
|
1571
|
-
For a block `{|x,i,j,...| ... }`,
|
1572
|
-
@yieldparam [Numeric] x an element
|
1573
|
-
@yieldparam [Integer] i,j,... multitimensional indices
|
1574
|
-
@return [Numo::NArray] self
|
1575
|
-
@see #each
|
1576
|
-
@see #map_with_index
|
1577
|
-
*/
|
1578
1488
|
static VALUE sfloat_each_with_index(VALUE self) {
|
1579
1489
|
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1580
1490
|
ndfunc_t ndf = { iter_sfloat_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0 };
|
@@ -1653,19 +1563,6 @@ static void iter_sfloat_map_with_index(na_loop_t* const lp) {
|
|
1653
1563
|
}
|
1654
1564
|
}
|
1655
1565
|
|
1656
|
-
/*
|
1657
|
-
Invokes the given block once for each element of self,
|
1658
|
-
passing that element and indices along each axis as parameters.
|
1659
|
-
Creates a new NArray containing the values returned by the block.
|
1660
|
-
Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
|
1661
|
-
@overload map_with_index
|
1662
|
-
For a block `{|x,i,j,...| ... }`,
|
1663
|
-
@yieldparam [Numeric] x an element
|
1664
|
-
@yieldparam [Integer] i,j,... multitimensional indices
|
1665
|
-
@return [Numo::NArray] mapped array
|
1666
|
-
@see #map
|
1667
|
-
@see #each_with_index
|
1668
|
-
*/
|
1669
1566
|
static VALUE sfloat_map_with_index(VALUE self) {
|
1670
1567
|
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1671
1568
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -1715,11 +1612,6 @@ static void iter_sfloat_abs(na_loop_t* const lp) {
|
|
1715
1612
|
}
|
1716
1613
|
}
|
1717
1614
|
|
1718
|
-
/*
|
1719
|
-
abs of self.
|
1720
|
-
@overload abs
|
1721
|
-
@return [Numo::SFloat] abs of self.
|
1722
|
-
*/
|
1723
1615
|
static VALUE sfloat_abs(VALUE self) {
|
1724
1616
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
1725
1617
|
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
@@ -1728,7 +1620,7 @@ static VALUE sfloat_abs(VALUE self) {
|
|
1728
1620
|
return na_ndloop(&ndf, 1, self);
|
1729
1621
|
}
|
1730
1622
|
|
1731
|
-
#define check_intdivzero(y)
|
1623
|
+
#define check_intdivzero(y) \
|
1732
1624
|
{}
|
1733
1625
|
|
1734
1626
|
static void iter_sfloat_add(na_loop_t* const lp) {
|
@@ -1948,12 +1840,6 @@ static VALUE sfloat_add_self(VALUE self, VALUE other) {
|
|
1948
1840
|
return na_ndloop(&ndf, 2, self, other);
|
1949
1841
|
}
|
1950
1842
|
|
1951
|
-
/*
|
1952
|
-
Binary add.
|
1953
|
-
@overload + other
|
1954
|
-
@param [Numo::NArray,Numeric] other
|
1955
|
-
@return [Numo::NArray] self + other
|
1956
|
-
*/
|
1957
1843
|
static VALUE sfloat_add(VALUE self, VALUE other) {
|
1958
1844
|
|
1959
1845
|
VALUE klass, v;
|
@@ -1967,7 +1853,7 @@ static VALUE sfloat_add(VALUE self, VALUE other) {
|
|
1967
1853
|
}
|
1968
1854
|
}
|
1969
1855
|
|
1970
|
-
#define check_intdivzero(y)
|
1856
|
+
#define check_intdivzero(y) \
|
1971
1857
|
{}
|
1972
1858
|
|
1973
1859
|
static void iter_sfloat_sub(na_loop_t* const lp) {
|
@@ -2187,12 +2073,6 @@ static VALUE sfloat_sub_self(VALUE self, VALUE other) {
|
|
2187
2073
|
return na_ndloop(&ndf, 2, self, other);
|
2188
2074
|
}
|
2189
2075
|
|
2190
|
-
/*
|
2191
|
-
Binary sub.
|
2192
|
-
@overload - other
|
2193
|
-
@param [Numo::NArray,Numeric] other
|
2194
|
-
@return [Numo::NArray] self - other
|
2195
|
-
*/
|
2196
2076
|
static VALUE sfloat_sub(VALUE self, VALUE other) {
|
2197
2077
|
|
2198
2078
|
VALUE klass, v;
|
@@ -2206,7 +2086,7 @@ static VALUE sfloat_sub(VALUE self, VALUE other) {
|
|
2206
2086
|
}
|
2207
2087
|
}
|
2208
2088
|
|
2209
|
-
#define check_intdivzero(y)
|
2089
|
+
#define check_intdivzero(y) \
|
2210
2090
|
{}
|
2211
2091
|
|
2212
2092
|
static void iter_sfloat_mul(na_loop_t* const lp) {
|
@@ -2426,12 +2306,6 @@ static VALUE sfloat_mul_self(VALUE self, VALUE other) {
|
|
2426
2306
|
return na_ndloop(&ndf, 2, self, other);
|
2427
2307
|
}
|
2428
2308
|
|
2429
|
-
/*
|
2430
|
-
Binary mul.
|
2431
|
-
@overload * other
|
2432
|
-
@param [Numo::NArray,Numeric] other
|
2433
|
-
@return [Numo::NArray] self * other
|
2434
|
-
*/
|
2435
2309
|
static VALUE sfloat_mul(VALUE self, VALUE other) {
|
2436
2310
|
|
2437
2311
|
VALUE klass, v;
|
@@ -2445,7 +2319,7 @@ static VALUE sfloat_mul(VALUE self, VALUE other) {
|
|
2445
2319
|
}
|
2446
2320
|
}
|
2447
2321
|
|
2448
|
-
#define check_intdivzero(y)
|
2322
|
+
#define check_intdivzero(y) \
|
2449
2323
|
{}
|
2450
2324
|
|
2451
2325
|
static void iter_sfloat_div(na_loop_t* const lp) {
|
@@ -2665,12 +2539,6 @@ static VALUE sfloat_div_self(VALUE self, VALUE other) {
|
|
2665
2539
|
return na_ndloop(&ndf, 2, self, other);
|
2666
2540
|
}
|
2667
2541
|
|
2668
|
-
/*
|
2669
|
-
Binary div.
|
2670
|
-
@overload / other
|
2671
|
-
@param [Numo::NArray,Numeric] other
|
2672
|
-
@return [Numo::NArray] self / other
|
2673
|
-
*/
|
2674
2542
|
static VALUE sfloat_div(VALUE self, VALUE other) {
|
2675
2543
|
|
2676
2544
|
VALUE klass, v;
|
@@ -2684,7 +2552,7 @@ static VALUE sfloat_div(VALUE self, VALUE other) {
|
|
2684
2552
|
}
|
2685
2553
|
}
|
2686
2554
|
|
2687
|
-
#define check_intdivzero(y)
|
2555
|
+
#define check_intdivzero(y) \
|
2688
2556
|
{}
|
2689
2557
|
|
2690
2558
|
static void iter_sfloat_mod(na_loop_t* const lp) {
|
@@ -2783,12 +2651,6 @@ static VALUE sfloat_mod_self(VALUE self, VALUE other) {
|
|
2783
2651
|
return na_ndloop(&ndf, 2, self, other);
|
2784
2652
|
}
|
2785
2653
|
|
2786
|
-
/*
|
2787
|
-
Binary mod.
|
2788
|
-
@overload % other
|
2789
|
-
@param [Numo::NArray,Numeric] other
|
2790
|
-
@return [Numo::NArray] self % other
|
2791
|
-
*/
|
2792
2654
|
static VALUE sfloat_mod(VALUE self, VALUE other) {
|
2793
2655
|
|
2794
2656
|
VALUE klass, v;
|
@@ -2829,12 +2691,6 @@ static VALUE sfloat_divmod_self(VALUE self, VALUE other) {
|
|
2829
2691
|
return na_ndloop(&ndf, 2, self, other);
|
2830
2692
|
}
|
2831
2693
|
|
2832
|
-
/*
|
2833
|
-
Binary divmod.
|
2834
|
-
@overload divmod other
|
2835
|
-
@param [Numo::NArray,Numeric] other
|
2836
|
-
@return [Numo::NArray] divmod of self and other.
|
2837
|
-
*/
|
2838
2694
|
static VALUE sfloat_divmod(VALUE self, VALUE other) {
|
2839
2695
|
|
2840
2696
|
VALUE klass, v;
|
@@ -2897,12 +2753,6 @@ static VALUE sfloat_pow_self(VALUE self, VALUE other) {
|
|
2897
2753
|
}
|
2898
2754
|
}
|
2899
2755
|
|
2900
|
-
/*
|
2901
|
-
Binary power.
|
2902
|
-
@overload ** other
|
2903
|
-
@param [Numo::NArray,Numeric] other
|
2904
|
-
@return [Numo::NArray] self to the other-th power.
|
2905
|
-
*/
|
2906
2756
|
static VALUE sfloat_pow(VALUE self, VALUE other) {
|
2907
2757
|
|
2908
2758
|
VALUE klass, v;
|
@@ -2977,11 +2827,6 @@ static void iter_sfloat_minus(na_loop_t* const lp) {
|
|
2977
2827
|
}
|
2978
2828
|
}
|
2979
2829
|
|
2980
|
-
/*
|
2981
|
-
Unary minus.
|
2982
|
-
@overload -@
|
2983
|
-
@return [Numo::SFloat] minus of self.
|
2984
|
-
*/
|
2985
2830
|
static VALUE sfloat_minus(VALUE self) {
|
2986
2831
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2987
2832
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3052,11 +2897,6 @@ static void iter_sfloat_reciprocal(na_loop_t* const lp) {
|
|
3052
2897
|
}
|
3053
2898
|
}
|
3054
2899
|
|
3055
|
-
/*
|
3056
|
-
Unary reciprocal.
|
3057
|
-
@overload reciprocal
|
3058
|
-
@return [Numo::SFloat] reciprocal of self.
|
3059
|
-
*/
|
3060
2900
|
static VALUE sfloat_reciprocal(VALUE self) {
|
3061
2901
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3062
2902
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3127,11 +2967,6 @@ static void iter_sfloat_sign(na_loop_t* const lp) {
|
|
3127
2967
|
}
|
3128
2968
|
}
|
3129
2969
|
|
3130
|
-
/*
|
3131
|
-
Unary sign.
|
3132
|
-
@overload sign
|
3133
|
-
@return [Numo::SFloat] sign of self.
|
3134
|
-
*/
|
3135
2970
|
static VALUE sfloat_sign(VALUE self) {
|
3136
2971
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3137
2972
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3202,11 +3037,6 @@ static void iter_sfloat_square(na_loop_t* const lp) {
|
|
3202
3037
|
}
|
3203
3038
|
}
|
3204
3039
|
|
3205
|
-
/*
|
3206
|
-
Unary square.
|
3207
|
-
@overload square
|
3208
|
-
@return [Numo::SFloat] square of self.
|
3209
|
-
*/
|
3210
3040
|
static VALUE sfloat_square(VALUE self) {
|
3211
3041
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3212
3042
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3244,12 +3074,6 @@ static VALUE sfloat_eq_self(VALUE self, VALUE other) {
|
|
3244
3074
|
return na_ndloop(&ndf, 2, self, other);
|
3245
3075
|
}
|
3246
3076
|
|
3247
|
-
/*
|
3248
|
-
Comparison eq other.
|
3249
|
-
@overload eq other
|
3250
|
-
@param [Numo::NArray,Numeric] other
|
3251
|
-
@return [Numo::Bit] result of self eq other.
|
3252
|
-
*/
|
3253
3077
|
static VALUE sfloat_eq(VALUE self, VALUE other) {
|
3254
3078
|
|
3255
3079
|
VALUE klass, v;
|
@@ -3291,12 +3115,6 @@ static VALUE sfloat_ne_self(VALUE self, VALUE other) {
|
|
3291
3115
|
return na_ndloop(&ndf, 2, self, other);
|
3292
3116
|
}
|
3293
3117
|
|
3294
|
-
/*
|
3295
|
-
Comparison ne other.
|
3296
|
-
@overload ne other
|
3297
|
-
@param [Numo::NArray,Numeric] other
|
3298
|
-
@return [Numo::Bit] result of self ne other.
|
3299
|
-
*/
|
3300
3118
|
static VALUE sfloat_ne(VALUE self, VALUE other) {
|
3301
3119
|
|
3302
3120
|
VALUE klass, v;
|
@@ -3338,12 +3156,6 @@ static VALUE sfloat_nearly_eq_self(VALUE self, VALUE other) {
|
|
3338
3156
|
return na_ndloop(&ndf, 2, self, other);
|
3339
3157
|
}
|
3340
3158
|
|
3341
|
-
/*
|
3342
|
-
Comparison nearly_eq other.
|
3343
|
-
@overload nearly_eq other
|
3344
|
-
@param [Numo::NArray,Numeric] other
|
3345
|
-
@return [Numo::Bit] result of self nearly_eq other.
|
3346
|
-
*/
|
3347
3159
|
static VALUE sfloat_nearly_eq(VALUE self, VALUE other) {
|
3348
3160
|
|
3349
3161
|
VALUE klass, v;
|
@@ -3418,11 +3230,6 @@ static void iter_sfloat_floor(na_loop_t* const lp) {
|
|
3418
3230
|
}
|
3419
3231
|
}
|
3420
3232
|
|
3421
|
-
/*
|
3422
|
-
Unary floor.
|
3423
|
-
@overload floor
|
3424
|
-
@return [Numo::SFloat] floor of self.
|
3425
|
-
*/
|
3426
3233
|
static VALUE sfloat_floor(VALUE self) {
|
3427
3234
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3428
3235
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3493,11 +3300,6 @@ static void iter_sfloat_round(na_loop_t* const lp) {
|
|
3493
3300
|
}
|
3494
3301
|
}
|
3495
3302
|
|
3496
|
-
/*
|
3497
|
-
Unary round.
|
3498
|
-
@overload round
|
3499
|
-
@return [Numo::SFloat] round of self.
|
3500
|
-
*/
|
3501
3303
|
static VALUE sfloat_round(VALUE self) {
|
3502
3304
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3503
3305
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3568,11 +3370,6 @@ static void iter_sfloat_ceil(na_loop_t* const lp) {
|
|
3568
3370
|
}
|
3569
3371
|
}
|
3570
3372
|
|
3571
|
-
/*
|
3572
|
-
Unary ceil.
|
3573
|
-
@overload ceil
|
3574
|
-
@return [Numo::SFloat] ceil of self.
|
3575
|
-
*/
|
3576
3373
|
static VALUE sfloat_ceil(VALUE self) {
|
3577
3374
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3578
3375
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3643,11 +3440,6 @@ static void iter_sfloat_trunc(na_loop_t* const lp) {
|
|
3643
3440
|
}
|
3644
3441
|
}
|
3645
3442
|
|
3646
|
-
/*
|
3647
|
-
Unary trunc.
|
3648
|
-
@overload trunc
|
3649
|
-
@return [Numo::SFloat] trunc of self.
|
3650
|
-
*/
|
3651
3443
|
static VALUE sfloat_trunc(VALUE self) {
|
3652
3444
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3653
3445
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3718,11 +3510,6 @@ static void iter_sfloat_rint(na_loop_t* const lp) {
|
|
3718
3510
|
}
|
3719
3511
|
}
|
3720
3512
|
|
3721
|
-
/*
|
3722
|
-
Unary rint.
|
3723
|
-
@overload rint
|
3724
|
-
@return [Numo::SFloat] rint of self.
|
3725
|
-
*/
|
3726
3513
|
static VALUE sfloat_rint(VALUE self) {
|
3727
3514
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3728
3515
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3731,7 +3518,7 @@ static VALUE sfloat_rint(VALUE self) {
|
|
3731
3518
|
return na_ndloop(&ndf, 1, self);
|
3732
3519
|
}
|
3733
3520
|
|
3734
|
-
#define check_intdivzero(y)
|
3521
|
+
#define check_intdivzero(y) \
|
3735
3522
|
{}
|
3736
3523
|
|
3737
3524
|
static void iter_sfloat_copysign(na_loop_t* const lp) {
|
@@ -3830,12 +3617,6 @@ static VALUE sfloat_copysign_self(VALUE self, VALUE other) {
|
|
3830
3617
|
return na_ndloop(&ndf, 2, self, other);
|
3831
3618
|
}
|
3832
3619
|
|
3833
|
-
/*
|
3834
|
-
Binary copysign.
|
3835
|
-
@overload copysign other
|
3836
|
-
@param [Numo::NArray,Numeric] other
|
3837
|
-
@return [Numo::NArray] self copysign other
|
3838
|
-
*/
|
3839
3620
|
static VALUE sfloat_copysign(VALUE self, VALUE other) {
|
3840
3621
|
|
3841
3622
|
VALUE klass, v;
|
@@ -3878,11 +3659,6 @@ static void iter_sfloat_signbit(na_loop_t* const lp) {
|
|
3878
3659
|
}
|
3879
3660
|
}
|
3880
3661
|
|
3881
|
-
/*
|
3882
|
-
Condition of signbit.
|
3883
|
-
@overload signbit
|
3884
|
-
@return [Numo::Bit] Condition of signbit.
|
3885
|
-
*/
|
3886
3662
|
static VALUE sfloat_signbit(VALUE self) {
|
3887
3663
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3888
3664
|
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
@@ -3908,11 +3684,6 @@ static void iter_sfloat_modf(na_loop_t* const lp) {
|
|
3908
3684
|
}
|
3909
3685
|
}
|
3910
3686
|
|
3911
|
-
/*
|
3912
|
-
modf of self.
|
3913
|
-
@overload modf
|
3914
|
-
@return [Numo::SFloat] modf of self.
|
3915
|
-
*/
|
3916
3687
|
static VALUE sfloat_modf(VALUE self) {
|
3917
3688
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3918
3689
|
ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
|
@@ -3950,12 +3721,6 @@ static VALUE sfloat_gt_self(VALUE self, VALUE other) {
|
|
3950
3721
|
return na_ndloop(&ndf, 2, self, other);
|
3951
3722
|
}
|
3952
3723
|
|
3953
|
-
/*
|
3954
|
-
Comparison gt other.
|
3955
|
-
@overload gt other
|
3956
|
-
@param [Numo::NArray,Numeric] other
|
3957
|
-
@return [Numo::Bit] result of self gt other.
|
3958
|
-
*/
|
3959
3724
|
static VALUE sfloat_gt(VALUE self, VALUE other) {
|
3960
3725
|
|
3961
3726
|
VALUE klass, v;
|
@@ -3997,12 +3762,6 @@ static VALUE sfloat_ge_self(VALUE self, VALUE other) {
|
|
3997
3762
|
return na_ndloop(&ndf, 2, self, other);
|
3998
3763
|
}
|
3999
3764
|
|
4000
|
-
/*
|
4001
|
-
Comparison ge other.
|
4002
|
-
@overload ge other
|
4003
|
-
@param [Numo::NArray,Numeric] other
|
4004
|
-
@return [Numo::Bit] result of self ge other.
|
4005
|
-
*/
|
4006
3765
|
static VALUE sfloat_ge(VALUE self, VALUE other) {
|
4007
3766
|
|
4008
3767
|
VALUE klass, v;
|
@@ -4044,12 +3803,6 @@ static VALUE sfloat_lt_self(VALUE self, VALUE other) {
|
|
4044
3803
|
return na_ndloop(&ndf, 2, self, other);
|
4045
3804
|
}
|
4046
3805
|
|
4047
|
-
/*
|
4048
|
-
Comparison lt other.
|
4049
|
-
@overload lt other
|
4050
|
-
@param [Numo::NArray,Numeric] other
|
4051
|
-
@return [Numo::Bit] result of self lt other.
|
4052
|
-
*/
|
4053
3806
|
static VALUE sfloat_lt(VALUE self, VALUE other) {
|
4054
3807
|
|
4055
3808
|
VALUE klass, v;
|
@@ -4091,12 +3844,6 @@ static VALUE sfloat_le_self(VALUE self, VALUE other) {
|
|
4091
3844
|
return na_ndloop(&ndf, 2, self, other);
|
4092
3845
|
}
|
4093
3846
|
|
4094
|
-
/*
|
4095
|
-
Comparison le other.
|
4096
|
-
@overload le other
|
4097
|
-
@param [Numo::NArray,Numeric] other
|
4098
|
-
@return [Numo::Bit] result of self le other.
|
4099
|
-
*/
|
4100
3847
|
static VALUE sfloat_le(VALUE self, VALUE other) {
|
4101
3848
|
|
4102
3849
|
VALUE klass, v;
|
@@ -4174,36 +3921,6 @@ static void iter_sfloat_clip_max(na_loop_t* const lp) {
|
|
4174
3921
|
}
|
4175
3922
|
}
|
4176
3923
|
|
4177
|
-
/*
|
4178
|
-
Clip array elements by [min,max].
|
4179
|
-
If either of min or max is nil, one side is clipped.
|
4180
|
-
@overload clip(min,max)
|
4181
|
-
@param [Numo::NArray,Numeric] min
|
4182
|
-
@param [Numo::NArray,Numeric] max
|
4183
|
-
@return [Numo::NArray] result of clip.
|
4184
|
-
|
4185
|
-
@example
|
4186
|
-
a = Numo::Int32.new(10).seq
|
4187
|
-
# => Numo::Int32#shape=[10]
|
4188
|
-
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
4189
|
-
|
4190
|
-
a.clip(1,8)
|
4191
|
-
# => Numo::Int32#shape=[10]
|
4192
|
-
# [1, 1, 2, 3, 4, 5, 6, 7, 8, 8]
|
4193
|
-
|
4194
|
-
a.inplace.clip(3,6)
|
4195
|
-
a
|
4196
|
-
# => Numo::Int32#shape=[10]
|
4197
|
-
# [3, 3, 3, 3, 4, 5, 6, 6, 6, 6]
|
4198
|
-
|
4199
|
-
b = Numo::Int32.new(10).seq
|
4200
|
-
# => Numo::Int32#shape=[10]
|
4201
|
-
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
4202
|
-
|
4203
|
-
b.clip([3,4,1,1,1,4,4,4,4,4], 8)
|
4204
|
-
# => Numo::Int32#shape=[10]
|
4205
|
-
# [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]
|
4206
|
-
*/
|
4207
3924
|
static VALUE sfloat_clip(VALUE self, VALUE min, VALUE max) {
|
4208
3925
|
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { cT, 0 }, { cT, 0 } };
|
4209
3926
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -4255,11 +3972,6 @@ static void iter_sfloat_isnan(na_loop_t* const lp) {
|
|
4255
3972
|
}
|
4256
3973
|
}
|
4257
3974
|
|
4258
|
-
/*
|
4259
|
-
Condition of isnan.
|
4260
|
-
@overload isnan
|
4261
|
-
@return [Numo::Bit] Condition of isnan.
|
4262
|
-
*/
|
4263
3975
|
static VALUE sfloat_isnan(VALUE self) {
|
4264
3976
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4265
3977
|
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
@@ -4297,11 +4009,6 @@ static void iter_sfloat_isinf(na_loop_t* const lp) {
|
|
4297
4009
|
}
|
4298
4010
|
}
|
4299
4011
|
|
4300
|
-
/*
|
4301
|
-
Condition of isinf.
|
4302
|
-
@overload isinf
|
4303
|
-
@return [Numo::Bit] Condition of isinf.
|
4304
|
-
*/
|
4305
4012
|
static VALUE sfloat_isinf(VALUE self) {
|
4306
4013
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4307
4014
|
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
@@ -4339,11 +4046,6 @@ static void iter_sfloat_isposinf(na_loop_t* const lp) {
|
|
4339
4046
|
}
|
4340
4047
|
}
|
4341
4048
|
|
4342
|
-
/*
|
4343
|
-
Condition of isposinf.
|
4344
|
-
@overload isposinf
|
4345
|
-
@return [Numo::Bit] Condition of isposinf.
|
4346
|
-
*/
|
4347
4049
|
static VALUE sfloat_isposinf(VALUE self) {
|
4348
4050
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4349
4051
|
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
@@ -4381,11 +4083,6 @@ static void iter_sfloat_isneginf(na_loop_t* const lp) {
|
|
4381
4083
|
}
|
4382
4084
|
}
|
4383
4085
|
|
4384
|
-
/*
|
4385
|
-
Condition of isneginf.
|
4386
|
-
@overload isneginf
|
4387
|
-
@return [Numo::Bit] Condition of isneginf.
|
4388
|
-
*/
|
4389
4086
|
static VALUE sfloat_isneginf(VALUE self) {
|
4390
4087
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4391
4088
|
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
@@ -4423,11 +4120,6 @@ static void iter_sfloat_isfinite(na_loop_t* const lp) {
|
|
4423
4120
|
}
|
4424
4121
|
}
|
4425
4122
|
|
4426
|
-
/*
|
4427
|
-
Condition of isfinite.
|
4428
|
-
@overload isfinite
|
4429
|
-
@return [Numo::Bit] Condition of isfinite.
|
4430
|
-
*/
|
4431
4123
|
static VALUE sfloat_isfinite(VALUE self) {
|
4432
4124
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4433
4125
|
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
@@ -4459,16 +4151,6 @@ static void iter_sfloat_sum_nan(na_loop_t* const lp) {
|
|
4459
4151
|
*(dtype*)p2 = f_sum_nan(n, p1, s1);
|
4460
4152
|
}
|
4461
4153
|
|
4462
|
-
/*
|
4463
|
-
sum of self.
|
4464
|
-
@overload sum(axis:nil, keepdims:false, nan:false)
|
4465
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4466
|
-
return NaN for min/max etc).
|
4467
|
-
@param [Numeric,Array,Range] axis Performs sum along the axis.
|
4468
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4469
|
-
dimensions with size one.
|
4470
|
-
@return [Numo::SFloat] returns result of sum.
|
4471
|
-
*/
|
4472
4154
|
static VALUE sfloat_sum(int argc, VALUE* argv, VALUE self) {
|
4473
4155
|
VALUE v, reduce;
|
4474
4156
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -4505,16 +4187,6 @@ static void iter_sfloat_prod_nan(na_loop_t* const lp) {
|
|
4505
4187
|
*(dtype*)p2 = f_prod_nan(n, p1, s1);
|
4506
4188
|
}
|
4507
4189
|
|
4508
|
-
/*
|
4509
|
-
prod of self.
|
4510
|
-
@overload prod(axis:nil, keepdims:false, nan:false)
|
4511
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4512
|
-
return NaN for min/max etc).
|
4513
|
-
@param [Numeric,Array,Range] axis Performs prod along the axis.
|
4514
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4515
|
-
dimensions with size one.
|
4516
|
-
@return [Numo::SFloat] returns result of prod.
|
4517
|
-
*/
|
4518
4190
|
static VALUE sfloat_prod(int argc, VALUE* argv, VALUE self) {
|
4519
4191
|
VALUE v, reduce;
|
4520
4192
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -4528,190 +4200,6 @@ static VALUE sfloat_prod(int argc, VALUE* argv, VALUE self) {
|
|
4528
4200
|
return sfloat_extract(v);
|
4529
4201
|
}
|
4530
4202
|
|
4531
|
-
static void iter_sfloat_mean(na_loop_t* const lp) {
|
4532
|
-
size_t n;
|
4533
|
-
char *p1, *p2;
|
4534
|
-
ssize_t s1;
|
4535
|
-
|
4536
|
-
INIT_COUNTER(lp, n);
|
4537
|
-
INIT_PTR(lp, 0, p1, s1);
|
4538
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4539
|
-
|
4540
|
-
*(dtype*)p2 = f_mean(n, p1, s1);
|
4541
|
-
}
|
4542
|
-
static void iter_sfloat_mean_nan(na_loop_t* const lp) {
|
4543
|
-
size_t n;
|
4544
|
-
char *p1, *p2;
|
4545
|
-
ssize_t s1;
|
4546
|
-
|
4547
|
-
INIT_COUNTER(lp, n);
|
4548
|
-
INIT_PTR(lp, 0, p1, s1);
|
4549
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4550
|
-
|
4551
|
-
*(dtype*)p2 = f_mean_nan(n, p1, s1);
|
4552
|
-
}
|
4553
|
-
|
4554
|
-
/*
|
4555
|
-
mean of self.
|
4556
|
-
@overload mean(axis:nil, keepdims:false, nan:false)
|
4557
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4558
|
-
return NaN for min/max etc).
|
4559
|
-
@param [Numeric,Array,Range] axis Performs mean along the axis.
|
4560
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4561
|
-
dimensions with size one.
|
4562
|
-
@return [Numo::SFloat] returns result of mean.
|
4563
|
-
*/
|
4564
|
-
static VALUE sfloat_mean(int argc, VALUE* argv, VALUE self) {
|
4565
|
-
VALUE v, reduce;
|
4566
|
-
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4567
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4568
|
-
ndfunc_t ndf = { iter_sfloat_mean, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4569
|
-
|
4570
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_mean_nan);
|
4571
|
-
|
4572
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4573
|
-
|
4574
|
-
return sfloat_extract(v);
|
4575
|
-
}
|
4576
|
-
|
4577
|
-
static void iter_sfloat_stddev(na_loop_t* const lp) {
|
4578
|
-
size_t n;
|
4579
|
-
char *p1, *p2;
|
4580
|
-
ssize_t s1;
|
4581
|
-
|
4582
|
-
INIT_COUNTER(lp, n);
|
4583
|
-
INIT_PTR(lp, 0, p1, s1);
|
4584
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4585
|
-
|
4586
|
-
*(rtype*)p2 = f_stddev(n, p1, s1);
|
4587
|
-
}
|
4588
|
-
static void iter_sfloat_stddev_nan(na_loop_t* const lp) {
|
4589
|
-
size_t n;
|
4590
|
-
char *p1, *p2;
|
4591
|
-
ssize_t s1;
|
4592
|
-
|
4593
|
-
INIT_COUNTER(lp, n);
|
4594
|
-
INIT_PTR(lp, 0, p1, s1);
|
4595
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4596
|
-
|
4597
|
-
*(rtype*)p2 = f_stddev_nan(n, p1, s1);
|
4598
|
-
}
|
4599
|
-
|
4600
|
-
/*
|
4601
|
-
stddev of self.
|
4602
|
-
@overload stddev(axis:nil, keepdims:false, nan:false)
|
4603
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4604
|
-
return NaN for min/max etc).
|
4605
|
-
@param [Numeric,Array,Range] axis Performs stddev along the axis.
|
4606
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4607
|
-
dimensions with size one.
|
4608
|
-
@return [Numo::SFloat] returns result of stddev.
|
4609
|
-
*/
|
4610
|
-
static VALUE sfloat_stddev(int argc, VALUE* argv, VALUE self) {
|
4611
|
-
VALUE v, reduce;
|
4612
|
-
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4613
|
-
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
4614
|
-
ndfunc_t ndf = { iter_sfloat_stddev, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4615
|
-
|
4616
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_stddev_nan);
|
4617
|
-
|
4618
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4619
|
-
|
4620
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
4621
|
-
}
|
4622
|
-
|
4623
|
-
static void iter_sfloat_var(na_loop_t* const lp) {
|
4624
|
-
size_t n;
|
4625
|
-
char *p1, *p2;
|
4626
|
-
ssize_t s1;
|
4627
|
-
|
4628
|
-
INIT_COUNTER(lp, n);
|
4629
|
-
INIT_PTR(lp, 0, p1, s1);
|
4630
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4631
|
-
|
4632
|
-
*(rtype*)p2 = f_var(n, p1, s1);
|
4633
|
-
}
|
4634
|
-
static void iter_sfloat_var_nan(na_loop_t* const lp) {
|
4635
|
-
size_t n;
|
4636
|
-
char *p1, *p2;
|
4637
|
-
ssize_t s1;
|
4638
|
-
|
4639
|
-
INIT_COUNTER(lp, n);
|
4640
|
-
INIT_PTR(lp, 0, p1, s1);
|
4641
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4642
|
-
|
4643
|
-
*(rtype*)p2 = f_var_nan(n, p1, s1);
|
4644
|
-
}
|
4645
|
-
|
4646
|
-
/*
|
4647
|
-
var of self.
|
4648
|
-
@overload var(axis:nil, keepdims:false, nan:false)
|
4649
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4650
|
-
return NaN for min/max etc).
|
4651
|
-
@param [Numeric,Array,Range] axis Performs var along the axis.
|
4652
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4653
|
-
dimensions with size one.
|
4654
|
-
@return [Numo::SFloat] returns result of var.
|
4655
|
-
*/
|
4656
|
-
static VALUE sfloat_var(int argc, VALUE* argv, VALUE self) {
|
4657
|
-
VALUE v, reduce;
|
4658
|
-
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4659
|
-
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
4660
|
-
ndfunc_t ndf = { iter_sfloat_var, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4661
|
-
|
4662
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_var_nan);
|
4663
|
-
|
4664
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4665
|
-
|
4666
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
4667
|
-
}
|
4668
|
-
|
4669
|
-
static void iter_sfloat_rms(na_loop_t* const lp) {
|
4670
|
-
size_t n;
|
4671
|
-
char *p1, *p2;
|
4672
|
-
ssize_t s1;
|
4673
|
-
|
4674
|
-
INIT_COUNTER(lp, n);
|
4675
|
-
INIT_PTR(lp, 0, p1, s1);
|
4676
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4677
|
-
|
4678
|
-
*(rtype*)p2 = f_rms(n, p1, s1);
|
4679
|
-
}
|
4680
|
-
static void iter_sfloat_rms_nan(na_loop_t* const lp) {
|
4681
|
-
size_t n;
|
4682
|
-
char *p1, *p2;
|
4683
|
-
ssize_t s1;
|
4684
|
-
|
4685
|
-
INIT_COUNTER(lp, n);
|
4686
|
-
INIT_PTR(lp, 0, p1, s1);
|
4687
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4688
|
-
|
4689
|
-
*(rtype*)p2 = f_rms_nan(n, p1, s1);
|
4690
|
-
}
|
4691
|
-
|
4692
|
-
/*
|
4693
|
-
rms of self.
|
4694
|
-
@overload rms(axis:nil, keepdims:false, nan:false)
|
4695
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4696
|
-
return NaN for min/max etc).
|
4697
|
-
@param [Numeric,Array,Range] axis Performs rms along the axis.
|
4698
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4699
|
-
dimensions with size one.
|
4700
|
-
@return [Numo::SFloat] returns result of rms.
|
4701
|
-
*/
|
4702
|
-
static VALUE sfloat_rms(int argc, VALUE* argv, VALUE self) {
|
4703
|
-
VALUE v, reduce;
|
4704
|
-
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4705
|
-
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
4706
|
-
ndfunc_t ndf = { iter_sfloat_rms, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4707
|
-
|
4708
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_rms_nan);
|
4709
|
-
|
4710
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4711
|
-
|
4712
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
4713
|
-
}
|
4714
|
-
|
4715
4203
|
static void iter_sfloat_min(na_loop_t* const lp) {
|
4716
4204
|
size_t n;
|
4717
4205
|
char *p1, *p2;
|
@@ -4735,16 +4223,6 @@ static void iter_sfloat_min_nan(na_loop_t* const lp) {
|
|
4735
4223
|
*(dtype*)p2 = f_min_nan(n, p1, s1);
|
4736
4224
|
}
|
4737
4225
|
|
4738
|
-
/*
|
4739
|
-
min of self.
|
4740
|
-
@overload min(axis:nil, keepdims:false, nan:false)
|
4741
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4742
|
-
return NaN for min/max etc).
|
4743
|
-
@param [Numeric,Array,Range] axis Performs min along the axis.
|
4744
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4745
|
-
dimensions with size one.
|
4746
|
-
@return [Numo::SFloat] returns result of min.
|
4747
|
-
*/
|
4748
4226
|
static VALUE sfloat_min(int argc, VALUE* argv, VALUE self) {
|
4749
4227
|
VALUE v, reduce;
|
4750
4228
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -4781,16 +4259,6 @@ static void iter_sfloat_max_nan(na_loop_t* const lp) {
|
|
4781
4259
|
*(dtype*)p2 = f_max_nan(n, p1, s1);
|
4782
4260
|
}
|
4783
4261
|
|
4784
|
-
/*
|
4785
|
-
max of self.
|
4786
|
-
@overload max(axis:nil, keepdims:false, nan:false)
|
4787
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4788
|
-
return NaN for min/max etc).
|
4789
|
-
@param [Numeric,Array,Range] axis Performs max along the axis.
|
4790
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4791
|
-
dimensions with size one.
|
4792
|
-
@return [Numo::SFloat] returns result of max.
|
4793
|
-
*/
|
4794
4262
|
static VALUE sfloat_max(int argc, VALUE* argv, VALUE self) {
|
4795
4263
|
VALUE v, reduce;
|
4796
4264
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -4827,16 +4295,6 @@ static void iter_sfloat_ptp_nan(na_loop_t* const lp) {
|
|
4827
4295
|
*(dtype*)p2 = f_ptp_nan(n, p1, s1);
|
4828
4296
|
}
|
4829
4297
|
|
4830
|
-
/*
|
4831
|
-
ptp of self.
|
4832
|
-
@overload ptp(axis:nil, keepdims:false, nan:false)
|
4833
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4834
|
-
return NaN for min/max etc).
|
4835
|
-
@param [Numeric,Array,Range] axis Performs ptp along the axis.
|
4836
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4837
|
-
dimensions with size one.
|
4838
|
-
@return [Numo::SFloat] returns result of ptp.
|
4839
|
-
*/
|
4840
4298
|
static VALUE sfloat_ptp(int argc, VALUE* argv, VALUE self) {
|
4841
4299
|
VALUE v, reduce;
|
4842
4300
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -4918,26 +4376,6 @@ static void iter_sfloat_max_index_index32_nan(na_loop_t* const lp) {
|
|
4918
4376
|
}
|
4919
4377
|
#undef idx_t
|
4920
4378
|
|
4921
|
-
/*
|
4922
|
-
Index of the maximum value.
|
4923
|
-
@overload max_index(axis:nil, nan:false)
|
4924
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
4925
|
-
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat 1-d
|
4926
|
-
indices**.
|
4927
|
-
@return [Integer,Numo::Int] returns result indices.
|
4928
|
-
@see #argmax
|
4929
|
-
@see #max
|
4930
|
-
|
4931
|
-
@example
|
4932
|
-
a = Numo::NArray[3,4,1,2]
|
4933
|
-
a.max_index #=> 1
|
4934
|
-
|
4935
|
-
b = Numo::NArray[[3,4,1],[2,0,5]]
|
4936
|
-
b.max_index #=> 5
|
4937
|
-
b.max_index(axis:1) #=> [1, 5]
|
4938
|
-
b.max_index(axis:0) #=> [0, 1, 5]
|
4939
|
-
b[b.max_index(axis:0)] #=> [3, 4, 5]
|
4940
|
-
*/
|
4941
4379
|
static VALUE sfloat_max_index(int argc, VALUE* argv, VALUE self) {
|
4942
4380
|
narray_t* na;
|
4943
4381
|
VALUE idx, reduce;
|
@@ -5036,26 +4474,6 @@ static void iter_sfloat_min_index_index32_nan(na_loop_t* const lp) {
|
|
5036
4474
|
}
|
5037
4475
|
#undef idx_t
|
5038
4476
|
|
5039
|
-
/*
|
5040
|
-
Index of the minimum value.
|
5041
|
-
@overload min_index(axis:nil, nan:false)
|
5042
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
5043
|
-
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat 1-d
|
5044
|
-
indices**.
|
5045
|
-
@return [Integer,Numo::Int] returns result indices.
|
5046
|
-
@see #argmin
|
5047
|
-
@see #min
|
5048
|
-
|
5049
|
-
@example
|
5050
|
-
a = Numo::NArray[3,4,1,2]
|
5051
|
-
a.min_index #=> 2
|
5052
|
-
|
5053
|
-
b = Numo::NArray[[3,4,1],[2,0,5]]
|
5054
|
-
b.min_index #=> 4
|
5055
|
-
b.min_index(axis:1) #=> [2, 4]
|
5056
|
-
b.min_index(axis:0) #=> [3, 4, 2]
|
5057
|
-
b[b.min_index(axis:0)] #=> [2, 0, 1]
|
5058
|
-
*/
|
5059
4477
|
static VALUE sfloat_min_index(int argc, VALUE* argv, VALUE self) {
|
5060
4478
|
narray_t* na;
|
5061
4479
|
VALUE idx, reduce;
|
@@ -5150,26 +4568,6 @@ static void iter_sfloat_argmax_arg32_nan(na_loop_t* const lp) {
|
|
5150
4568
|
}
|
5151
4569
|
#undef idx_t
|
5152
4570
|
|
5153
|
-
/*
|
5154
|
-
Index of the maximum value.
|
5155
|
-
@overload argmax(axis:nil, nan:false)
|
5156
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
5157
|
-
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices
|
5158
|
-
along the axis**.
|
5159
|
-
@return [Integer,Numo::Int] returns the result indices.
|
5160
|
-
@see #max_index
|
5161
|
-
@see #max
|
5162
|
-
|
5163
|
-
@example
|
5164
|
-
a = Numo::NArray[3,4,1,2]
|
5165
|
-
a.argmax #=> 1
|
5166
|
-
|
5167
|
-
b = Numo::NArray[[3,4,1],[2,0,5]]
|
5168
|
-
b.argmax #=> 5
|
5169
|
-
b.argmax(axis:1) #=> [1, 2]
|
5170
|
-
b.argmax(axis:0) #=> [0, 0, 1]
|
5171
|
-
b.at(b.argmax(axis:0), 0..-1) #=> [3, 4, 5]
|
5172
|
-
*/
|
5173
4571
|
static VALUE sfloat_argmax(int argc, VALUE* argv, VALUE self) {
|
5174
4572
|
narray_t* na;
|
5175
4573
|
VALUE reduce;
|
@@ -5261,26 +4659,6 @@ static void iter_sfloat_argmin_arg32_nan(na_loop_t* const lp) {
|
|
5261
4659
|
}
|
5262
4660
|
#undef idx_t
|
5263
4661
|
|
5264
|
-
/*
|
5265
|
-
Index of the minimum value.
|
5266
|
-
@overload argmin(axis:nil, nan:false)
|
5267
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
5268
|
-
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices
|
5269
|
-
along the axis**.
|
5270
|
-
@return [Integer,Numo::Int] returns the result indices.
|
5271
|
-
@see #min_index
|
5272
|
-
@see #min
|
5273
|
-
|
5274
|
-
@example
|
5275
|
-
a = Numo::NArray[3,4,1,2]
|
5276
|
-
a.argmin #=> 2
|
5277
|
-
|
5278
|
-
b = Numo::NArray[[3,4,1],[2,0,5]]
|
5279
|
-
b.argmin #=> 4
|
5280
|
-
b.argmin(axis:1) #=> [2, 1]
|
5281
|
-
b.argmin(axis:0) #=> [1, 1, 0]
|
5282
|
-
b.at(b.argmin(axis:0), 0..-1) #=> [2, 0, 1]
|
5283
|
-
*/
|
5284
4662
|
static VALUE sfloat_argmin(int argc, VALUE* argv, VALUE self) {
|
5285
4663
|
narray_t* na;
|
5286
4664
|
VALUE reduce;
|
@@ -5337,15 +4715,6 @@ static void iter_sfloat_minmax_nan(na_loop_t* const lp) {
|
|
5337
4715
|
*(dtype*)(lp->args[2].ptr + lp->args[2].iter[0].pos) = xmax;
|
5338
4716
|
}
|
5339
4717
|
|
5340
|
-
/*
|
5341
|
-
minmax of self.
|
5342
|
-
@overload minmax(axis:nil, keepdims:false, nan:false)
|
5343
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
5344
|
-
@param [Numeric,Array,Range] axis Finds min-max along the axis.
|
5345
|
-
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
5346
|
-
as dimensions with size one.
|
5347
|
-
@return [Numo::SFloat,Numo::SFloat] min and max of self.
|
5348
|
-
*/
|
5349
4718
|
static VALUE sfloat_minmax(int argc, VALUE* argv, VALUE self) {
|
5350
4719
|
VALUE reduce;
|
5351
4720
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -5359,16 +4728,6 @@ static VALUE sfloat_minmax(int argc, VALUE* argv, VALUE self) {
|
|
5359
4728
|
return na_ndloop(&ndf, 2, self, reduce);
|
5360
4729
|
}
|
5361
4730
|
|
5362
|
-
/*
|
5363
|
-
Element-wise maximum of two arrays.
|
5364
|
-
|
5365
|
-
@overload maximum(a1, a2, nan:false)
|
5366
|
-
@param [Numo::NArray,Numeric] a1 The array to be compared.
|
5367
|
-
@param [Numo::NArray,Numeric] a2 The array to be compared.
|
5368
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
5369
|
-
@return [Numo::SFloat]
|
5370
|
-
*/
|
5371
|
-
|
5372
4731
|
static void iter_sfloat_s_maximum(na_loop_t* const lp) {
|
5373
4732
|
size_t i, n;
|
5374
4733
|
char *p1, *p2, *p3;
|
@@ -5428,16 +4787,6 @@ static VALUE sfloat_s_maximum(int argc, VALUE* argv, VALUE mod) {
|
|
5428
4787
|
return na_ndloop(&ndf, 2, a1, a2);
|
5429
4788
|
}
|
5430
4789
|
|
5431
|
-
/*
|
5432
|
-
Element-wise minimum of two arrays.
|
5433
|
-
|
5434
|
-
@overload minimum(a1, a2, nan:false)
|
5435
|
-
@param [Numo::NArray,Numeric] a1 The array to be compared.
|
5436
|
-
@param [Numo::NArray,Numeric] a2 The array to be compared.
|
5437
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
5438
|
-
@return [Numo::SFloat]
|
5439
|
-
*/
|
5440
|
-
|
5441
4790
|
static void iter_sfloat_s_minimum(na_loop_t* const lp) {
|
5442
4791
|
size_t i, n;
|
5443
4792
|
char *p1, *p2, *p3;
|
@@ -5534,13 +4883,6 @@ static void iter_sfloat_cumsum_nan(na_loop_t* const lp) {
|
|
5534
4883
|
}
|
5535
4884
|
}
|
5536
4885
|
|
5537
|
-
/*
|
5538
|
-
cumsum of self.
|
5539
|
-
@overload cumsum(axis:nil, nan:false)
|
5540
|
-
@param [Numeric,Array,Range] axis Performs cumsum along the axis.
|
5541
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
5542
|
-
@return [Numo::SFloat] cumsum of self.
|
5543
|
-
*/
|
5544
4886
|
static VALUE sfloat_cumsum(int argc, VALUE* argv, VALUE self) {
|
5545
4887
|
VALUE reduce;
|
5546
4888
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -5591,13 +4933,6 @@ static void iter_sfloat_cumprod_nan(na_loop_t* const lp) {
|
|
5591
4933
|
}
|
5592
4934
|
}
|
5593
4935
|
|
5594
|
-
/*
|
5595
|
-
cumprod of self.
|
5596
|
-
@overload cumprod(axis:nil, nan:false)
|
5597
|
-
@param [Numeric,Array,Range] axis Performs cumprod along the axis.
|
5598
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
5599
|
-
@return [Numo::SFloat] cumprod of self.
|
5600
|
-
*/
|
5601
4936
|
static VALUE sfloat_cumprod(int argc, VALUE* argv, VALUE self) {
|
5602
4937
|
VALUE reduce;
|
5603
4938
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -5702,17 +5037,6 @@ static VALUE sfloat_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
|
5702
5037
|
return sfloat_extract(v);
|
5703
5038
|
}
|
5704
5039
|
|
5705
|
-
/*
|
5706
|
-
Binary mulsum.
|
5707
|
-
|
5708
|
-
@overload mulsum(other, axis:nil, keepdims:false, nan:false)
|
5709
|
-
@param [Numo::NArray,Numeric] other
|
5710
|
-
@param [Numeric,Array,Range] axis Performs mulsum along the axis.
|
5711
|
-
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
5712
|
-
as dimensions with size one.
|
5713
|
-
@param [TrueClass] nan (keyword) If true, apply NaN-aware algorithm (avoid NaN if exists).
|
5714
|
-
@return [Numo::NArray] mulsum of self and other.
|
5715
|
-
*/
|
5716
5040
|
static VALUE sfloat_mulsum(int argc, VALUE* argv, VALUE self) {
|
5717
5041
|
//
|
5718
5042
|
VALUE klass, v;
|
@@ -5775,23 +5099,6 @@ static void iter_sfloat_seq(na_loop_t* const lp) {
|
|
5775
5099
|
g->count = c;
|
5776
5100
|
}
|
5777
5101
|
|
5778
|
-
/*
|
5779
|
-
Set linear sequence of numbers to self. The sequence is obtained from
|
5780
|
-
beg+i*step
|
5781
|
-
where i is 1-dimensional index.
|
5782
|
-
@overload seq([beg,[step]])
|
5783
|
-
@param [Numeric] beg beginning of sequence. (default=0)
|
5784
|
-
@param [Numeric] step step of sequence. (default=1)
|
5785
|
-
@return [Numo::SFloat] self.
|
5786
|
-
@example
|
5787
|
-
Numo::DFloat.new(6).seq(1,-0.2)
|
5788
|
-
# => Numo::DFloat#shape=[6]
|
5789
|
-
# [1, 0.8, 0.6, 0.4, 0.2, 0]
|
5790
|
-
|
5791
|
-
Numo::DComplex.new(6).seq(1,-0.2+0.2i)
|
5792
|
-
# => Numo::DComplex#shape=[6]
|
5793
|
-
# [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
5794
|
-
*/
|
5795
5102
|
static VALUE sfloat_seq(int argc, VALUE* args, VALUE self) {
|
5796
5103
|
seq_opt_t* g;
|
5797
5104
|
VALUE vbeg = Qnil, vstep = Qnil;
|
@@ -5854,27 +5161,6 @@ static void iter_sfloat_logseq(na_loop_t* const lp) {
|
|
5854
5161
|
g->count = c;
|
5855
5162
|
}
|
5856
5163
|
|
5857
|
-
/*
|
5858
|
-
Set logarithmic sequence of numbers to self. The sequence is obtained from
|
5859
|
-
`base**(beg+i*step)`
|
5860
|
-
where i is 1-dimensional index.
|
5861
|
-
Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
|
5862
|
-
|
5863
|
-
@overload logseq(beg,step,[base])
|
5864
|
-
@param [Numeric] beg The beginning of sequence.
|
5865
|
-
@param [Numeric] step The step of sequence.
|
5866
|
-
@param [Numeric] base The base of log space. (default=10)
|
5867
|
-
@return [Numo::SFloat] self.
|
5868
|
-
|
5869
|
-
@example
|
5870
|
-
Numo::DFloat.new(5).logseq(4,-1,2)
|
5871
|
-
# => Numo::DFloat#shape=[5]
|
5872
|
-
# [16, 8, 4, 2, 1]
|
5873
|
-
|
5874
|
-
Numo::DComplex.new(5).logseq(0,1i*Math::PI/3,Math::E)
|
5875
|
-
# => Numo::DComplex#shape=[5]
|
5876
|
-
# [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
|
5877
|
-
*/
|
5878
5164
|
static VALUE sfloat_logseq(int argc, VALUE* args, VALUE self) {
|
5879
5165
|
logseq_opt_t* g;
|
5880
5166
|
VALUE vbeg, vstep, vbase;
|
@@ -5923,15 +5209,6 @@ static void iter_sfloat_eye(na_loop_t* const lp) {
|
|
5923
5209
|
}
|
5924
5210
|
}
|
5925
5211
|
|
5926
|
-
/*
|
5927
|
-
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
|
5928
|
-
@overload eye([element,offset])
|
5929
|
-
@param [Numeric] element Diagonal element to be stored. Default is 1.
|
5930
|
-
@param [Integer] offset Diagonal offset from the main diagonal. The
|
5931
|
-
default is 0. k>0 for diagonals above the main diagonal, and k<0
|
5932
|
-
for diagonals below the main diagonal.
|
5933
|
-
@return [Numo::SFloat] eye of self.
|
5934
|
-
*/
|
5935
5212
|
static VALUE sfloat_eye(int argc, VALUE* argv, VALUE self) {
|
5936
5213
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
|
5937
5214
|
ndfunc_t ndf = { iter_sfloat_eye, NO_LOOP, 1, 0, ain, 0 };
|
@@ -6024,26 +5301,6 @@ static void iter_sfloat_rand(na_loop_t* const lp) {
|
|
6024
5301
|
}
|
6025
5302
|
}
|
6026
5303
|
|
6027
|
-
/*
|
6028
|
-
Generate uniformly distributed random numbers on self narray.
|
6029
|
-
@overload rand([[low],high])
|
6030
|
-
@param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
6031
|
-
@param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
|
6032
|
-
complex types)
|
6033
|
-
@return [Numo::SFloat] self.
|
6034
|
-
@example
|
6035
|
-
Numo::DFloat.new(6).rand
|
6036
|
-
# => Numo::DFloat#shape=[6]
|
6037
|
-
# [0.0617545, 0.373067, 0.794815, 0.201042, 0.116041, 0.344032]
|
6038
|
-
|
6039
|
-
Numo::DComplex.new(6).rand(5+5i)
|
6040
|
-
# => Numo::DComplex#shape=[6]
|
6041
|
-
# [2.69974+3.68908i, 0.825443+0.254414i, 0.540323+0.34354i, 4.52061+2.39322i, ...]
|
6042
|
-
|
6043
|
-
Numo::Int32.new(6).rand(2,5)
|
6044
|
-
# => Numo::Int32#shape=[6]
|
6045
|
-
# [4, 3, 3, 2, 4, 2]
|
6046
|
-
*/
|
6047
5304
|
static VALUE sfloat_rand(int argc, VALUE* args, VALUE self) {
|
6048
5305
|
rand_opt_t g;
|
6049
5306
|
VALUE v1 = Qnil, v2 = Qnil;
|
@@ -6123,36 +5380,6 @@ static void iter_sfloat_rand_norm(na_loop_t* const lp) {
|
|
6123
5380
|
}
|
6124
5381
|
}
|
6125
5382
|
|
6126
|
-
/*
|
6127
|
-
Generates random numbers from the normal distribution on self narray
|
6128
|
-
using Box-Muller Transformation.
|
6129
|
-
@overload rand_norm([mu,[sigma]])
|
6130
|
-
@param [Numeric] mu mean of normal distribution. (default=0)
|
6131
|
-
@param [Numeric] sigma standard deviation of normal distribution. (default=1)
|
6132
|
-
@return [Numo::SFloat] self.
|
6133
|
-
@example
|
6134
|
-
Numo::DFloat.new(5,5).rand_norm
|
6135
|
-
# => Numo::DFloat#shape=[5,5]
|
6136
|
-
# [[-0.581255, -0.168354, 0.586895, -0.595142, -0.802802],
|
6137
|
-
# [-0.326106, 0.282922, 1.68427, 0.918499, -0.0485384],
|
6138
|
-
# [-0.464453, -0.992194, 0.413794, -0.60717, -0.699695],
|
6139
|
-
# [-1.64168, 0.48676, -0.875871, -1.43275, 0.812172],
|
6140
|
-
# [-0.209975, -0.103612, -0.878617, -1.42495, 1.0968]]
|
6141
|
-
|
6142
|
-
Numo::DFloat.new(5,5).rand_norm(10,0.1)
|
6143
|
-
# => Numo::DFloat#shape=[5,5]
|
6144
|
-
# [[9.9019, 9.90339, 10.0826, 9.98384, 9.72861],
|
6145
|
-
# [9.81507, 10.0272, 9.91445, 10.0568, 9.88923],
|
6146
|
-
# [10.0234, 9.97874, 9.96011, 9.9006, 9.99964],
|
6147
|
-
# [10.0186, 9.94598, 9.92236, 9.99811, 9.97003],
|
6148
|
-
# [9.79266, 9.95044, 9.95212, 9.93692, 10.2027]]
|
6149
|
-
|
6150
|
-
Numo::DComplex.new(3,3).rand_norm(5+5i)
|
6151
|
-
# => Numo::DComplex#shape=[3,3]
|
6152
|
-
# [[5.84303+4.40052i, 4.00984+6.08982i, 5.10979+5.13215i],
|
6153
|
-
# [4.26477+3.99655i, 4.90052+5.00763i, 4.46607+2.3444i],
|
6154
|
-
# [4.5528+7.11003i, 5.62117+6.69094i, 5.05443+5.35133i]]
|
6155
|
-
*/
|
6156
5383
|
static VALUE sfloat_rand_norm(int argc, VALUE* args, VALUE self) {
|
6157
5384
|
int n;
|
6158
5385
|
randn_opt_t g;
|
@@ -6191,13 +5418,6 @@ static void iter_sfloat_poly(na_loop_t* const lp) {
|
|
6191
5418
|
*(dtype*)(lp->args[i].ptr + lp->args[i].iter[0].pos) = y;
|
6192
5419
|
}
|
6193
5420
|
|
6194
|
-
/*
|
6195
|
-
Calculate polynomial.
|
6196
|
-
`x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
|
6197
|
-
@overload poly a0, a1, ..., an
|
6198
|
-
@param [Numo::NArray,Numeric] a0,a1,...,an
|
6199
|
-
@return [Numo::SFloat]
|
6200
|
-
*/
|
6201
5421
|
static VALUE sfloat_poly(VALUE self, VALUE args) {
|
6202
5422
|
int argc, i;
|
6203
5423
|
VALUE* argv;
|
@@ -6283,27 +5503,27 @@ static VALUE sfloat_poly(VALUE self, VALUE args) {
|
|
6283
5503
|
* We have modified their original by adding a check for already-sorted input,
|
6284
5504
|
* which seems to be a win per discussions on pgsql-hackers around 2006-03-21.
|
6285
5505
|
*/
|
6286
|
-
#define swapcode(TYPE, parmi, parmj, n)
|
6287
|
-
do {
|
6288
|
-
size_t i = (n) / sizeof(TYPE);
|
6289
|
-
TYPE* pi = (TYPE*)(void*)(parmi);
|
6290
|
-
TYPE* pj = (TYPE*)(void*)(parmj);
|
6291
|
-
do {
|
6292
|
-
TYPE t = *pi;
|
6293
|
-
*pi++ = *pj;
|
6294
|
-
*pj++ = t;
|
6295
|
-
} while (--i > 0);
|
5506
|
+
#define swapcode(TYPE, parmi, parmj, n) \
|
5507
|
+
do { \
|
5508
|
+
size_t i = (n) / sizeof(TYPE); \
|
5509
|
+
TYPE* pi = (TYPE*)(void*)(parmi); \
|
5510
|
+
TYPE* pj = (TYPE*)(void*)(parmj); \
|
5511
|
+
do { \
|
5512
|
+
TYPE t = *pi; \
|
5513
|
+
*pi++ = *pj; \
|
5514
|
+
*pj++ = t; \
|
5515
|
+
} while (--i > 0); \
|
6296
5516
|
} while (0)
|
6297
5517
|
|
6298
5518
|
#ifdef HAVE_STDINT_H
|
6299
|
-
#define SWAPINIT(a, es)
|
6300
|
-
swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2
|
6301
|
-
: (es) == sizeof(long) ? 0
|
5519
|
+
#define SWAPINIT(a, es) \
|
5520
|
+
swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
5521
|
+
: (es) == sizeof(long) ? 0 \
|
6302
5522
|
: 1;
|
6303
5523
|
#else
|
6304
|
-
#define SWAPINIT(a, es)
|
6305
|
-
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2
|
6306
|
-
: (es) == sizeof(long) ? 0
|
5524
|
+
#define SWAPINIT(a, es) \
|
5525
|
+
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
5526
|
+
: (es) == sizeof(long) ? 0 \
|
6307
5527
|
: 1;
|
6308
5528
|
#endif
|
6309
5529
|
|
@@ -6314,19 +5534,19 @@ static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
|
|
6314
5534
|
swapcode(char, a, b, n);
|
6315
5535
|
}
|
6316
5536
|
|
6317
|
-
#define swap(a, b)
|
6318
|
-
if (swaptype == 0) {
|
6319
|
-
long t = *(long*)(void*)(a);
|
6320
|
-
*(long*)(void*)(a) = *(long*)(void*)(b);
|
6321
|
-
*(long*)(void*)(b) = t;
|
6322
|
-
} else
|
5537
|
+
#define swap(a, b) \
|
5538
|
+
if (swaptype == 0) { \
|
5539
|
+
long t = *(long*)(void*)(a); \
|
5540
|
+
*(long*)(void*)(a) = *(long*)(void*)(b); \
|
5541
|
+
*(long*)(void*)(b) = t; \
|
5542
|
+
} else \
|
6323
5543
|
swapfunc(a, b, es, swaptype)
|
6324
5544
|
|
6325
|
-
#define vecswap(a, b, n)
|
5545
|
+
#define vecswap(a, b, n) \
|
6326
5546
|
if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
|
6327
5547
|
|
6328
|
-
#define med3(a, b, c, _cmp)
|
6329
|
-
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a))
|
5548
|
+
#define med3(a, b, c, _cmp) \
|
5549
|
+
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) \
|
6330
5550
|
: (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
|
6331
5551
|
#endif
|
6332
5552
|
|
@@ -6556,15 +5776,6 @@ static void iter_sfloat_sort_prnan(na_loop_t* const lp) {
|
|
6556
5776
|
sfloat_qsort_prnan(ptr, n, step);
|
6557
5777
|
}
|
6558
5778
|
|
6559
|
-
/*
|
6560
|
-
sort of self.
|
6561
|
-
@overload sort(axis:nil, nan:false)
|
6562
|
-
@param [TrueClass] nan If true, propagete NaN. If false, ignore NaN.
|
6563
|
-
@param [Numeric,Array,Range] axis Performs sort along the axis.
|
6564
|
-
@return [Numo::SFloat] returns result of sort.
|
6565
|
-
@example
|
6566
|
-
Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
|
6567
|
-
*/
|
6568
5779
|
static VALUE sfloat_sort(int argc, VALUE* argv, VALUE self) {
|
6569
5780
|
VALUE reduce;
|
6570
5781
|
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
|
@@ -6981,15 +6192,6 @@ static void sfloat_index32_qsort_prnan(na_loop_t* const lp) {
|
|
6981
6192
|
}
|
6982
6193
|
#undef idx_t
|
6983
6194
|
|
6984
|
-
/*
|
6985
|
-
sort_index. Returns an index array of sort result.
|
6986
|
-
@overload sort_index(axis:nil, nan:false)
|
6987
|
-
@param [TrueClass] nan If true, propagete NaN. If false, ignore NaN.
|
6988
|
-
@param [Numeric,Array,Range] axis Performs sort_index along the axis.
|
6989
|
-
@return [Integer,Numo::Int] returns result index of sort_index.
|
6990
|
-
@example
|
6991
|
-
Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
|
6992
|
-
*/
|
6993
6195
|
static VALUE sfloat_sort_index(int argc, VALUE* argv, VALUE self) {
|
6994
6196
|
size_t size;
|
6995
6197
|
narray_t* na;
|
@@ -7075,16 +6277,6 @@ static void iter_sfloat_median_prnan(na_loop_t* const lp) {
|
|
7075
6277
|
}
|
7076
6278
|
}
|
7077
6279
|
|
7078
|
-
/*
|
7079
|
-
median of self.
|
7080
|
-
@overload median(axis:nil, keepdims:false, nan:false)
|
7081
|
-
@param [TrueClass] nan (keyword) If true, propagete NaN. If false, ignore NaN.
|
7082
|
-
@param [Numeric,Array,Range] axis Finds median along the axis.
|
7083
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
7084
|
-
dimensions with size one.
|
7085
|
-
@return [Numo::SFloat] returns median of self.
|
7086
|
-
*/
|
7087
|
-
|
7088
6280
|
static VALUE sfloat_median(int argc, VALUE* argv, VALUE self) {
|
7089
6281
|
VALUE v, reduce;
|
7090
6282
|
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
|
@@ -7100,10 +6292,6 @@ static VALUE sfloat_median(int argc, VALUE* argv, VALUE self) {
|
|
7100
6292
|
return sfloat_extract(v);
|
7101
6293
|
}
|
7102
6294
|
|
7103
|
-
/*
|
7104
|
-
module definition: Numo::SFloat::NMath
|
7105
|
-
*/
|
7106
|
-
|
7107
6295
|
VALUE mTM;
|
7108
6296
|
|
7109
6297
|
static void iter_sfloat_math_s_sqrt(na_loop_t* const lp) {
|
@@ -7221,12 +6409,6 @@ static void iter_sfloat_math_s_sqrt(na_loop_t* const lp) {
|
|
7221
6409
|
}
|
7222
6410
|
}
|
7223
6411
|
|
7224
|
-
/*
|
7225
|
-
Calculate sqrt(x).
|
7226
|
-
@overload sqrt(x)
|
7227
|
-
@param [Numo::NArray,Numeric] x input value
|
7228
|
-
@return [Numo::SFloat] result of sqrt(x).
|
7229
|
-
*/
|
7230
6412
|
static VALUE sfloat_math_s_sqrt(VALUE mod, VALUE a1) {
|
7231
6413
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7232
6414
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7299,12 +6481,6 @@ static void iter_sfloat_math_s_cbrt(na_loop_t* const lp) {
|
|
7299
6481
|
}
|
7300
6482
|
}
|
7301
6483
|
|
7302
|
-
/*
|
7303
|
-
Calculate cbrt(x).
|
7304
|
-
@overload cbrt(x)
|
7305
|
-
@param [Numo::NArray,Numeric] x input value
|
7306
|
-
@return [Numo::SFloat] result of cbrt(x).
|
7307
|
-
*/
|
7308
6484
|
static VALUE sfloat_math_s_cbrt(VALUE mod, VALUE a1) {
|
7309
6485
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7310
6486
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7377,12 +6553,6 @@ static void iter_sfloat_math_s_log(na_loop_t* const lp) {
|
|
7377
6553
|
}
|
7378
6554
|
}
|
7379
6555
|
|
7380
|
-
/*
|
7381
|
-
Calculate log(x).
|
7382
|
-
@overload log(x)
|
7383
|
-
@param [Numo::NArray,Numeric] x input value
|
7384
|
-
@return [Numo::SFloat] result of log(x).
|
7385
|
-
*/
|
7386
6556
|
static VALUE sfloat_math_s_log(VALUE mod, VALUE a1) {
|
7387
6557
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7388
6558
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7455,12 +6625,6 @@ static void iter_sfloat_math_s_log2(na_loop_t* const lp) {
|
|
7455
6625
|
}
|
7456
6626
|
}
|
7457
6627
|
|
7458
|
-
/*
|
7459
|
-
Calculate log2(x).
|
7460
|
-
@overload log2(x)
|
7461
|
-
@param [Numo::NArray,Numeric] x input value
|
7462
|
-
@return [Numo::SFloat] result of log2(x).
|
7463
|
-
*/
|
7464
6628
|
static VALUE sfloat_math_s_log2(VALUE mod, VALUE a1) {
|
7465
6629
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7466
6630
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7533,12 +6697,6 @@ static void iter_sfloat_math_s_log10(na_loop_t* const lp) {
|
|
7533
6697
|
}
|
7534
6698
|
}
|
7535
6699
|
|
7536
|
-
/*
|
7537
|
-
Calculate log10(x).
|
7538
|
-
@overload log10(x)
|
7539
|
-
@param [Numo::NArray,Numeric] x input value
|
7540
|
-
@return [Numo::SFloat] result of log10(x).
|
7541
|
-
*/
|
7542
6700
|
static VALUE sfloat_math_s_log10(VALUE mod, VALUE a1) {
|
7543
6701
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7544
6702
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7611,12 +6769,6 @@ static void iter_sfloat_math_s_exp(na_loop_t* const lp) {
|
|
7611
6769
|
}
|
7612
6770
|
}
|
7613
6771
|
|
7614
|
-
/*
|
7615
|
-
Calculate exp(x).
|
7616
|
-
@overload exp(x)
|
7617
|
-
@param [Numo::NArray,Numeric] x input value
|
7618
|
-
@return [Numo::SFloat] result of exp(x).
|
7619
|
-
*/
|
7620
6772
|
static VALUE sfloat_math_s_exp(VALUE mod, VALUE a1) {
|
7621
6773
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7622
6774
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7689,12 +6841,6 @@ static void iter_sfloat_math_s_exp2(na_loop_t* const lp) {
|
|
7689
6841
|
}
|
7690
6842
|
}
|
7691
6843
|
|
7692
|
-
/*
|
7693
|
-
Calculate exp2(x).
|
7694
|
-
@overload exp2(x)
|
7695
|
-
@param [Numo::NArray,Numeric] x input value
|
7696
|
-
@return [Numo::SFloat] result of exp2(x).
|
7697
|
-
*/
|
7698
6844
|
static VALUE sfloat_math_s_exp2(VALUE mod, VALUE a1) {
|
7699
6845
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7700
6846
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7767,12 +6913,6 @@ static void iter_sfloat_math_s_exp10(na_loop_t* const lp) {
|
|
7767
6913
|
}
|
7768
6914
|
}
|
7769
6915
|
|
7770
|
-
/*
|
7771
|
-
Calculate exp10(x).
|
7772
|
-
@overload exp10(x)
|
7773
|
-
@param [Numo::NArray,Numeric] x input value
|
7774
|
-
@return [Numo::SFloat] result of exp10(x).
|
7775
|
-
*/
|
7776
6916
|
static VALUE sfloat_math_s_exp10(VALUE mod, VALUE a1) {
|
7777
6917
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7778
6918
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7845,12 +6985,6 @@ static void iter_sfloat_math_s_sin(na_loop_t* const lp) {
|
|
7845
6985
|
}
|
7846
6986
|
}
|
7847
6987
|
|
7848
|
-
/*
|
7849
|
-
Calculate sin(x).
|
7850
|
-
@overload sin(x)
|
7851
|
-
@param [Numo::NArray,Numeric] x input value
|
7852
|
-
@return [Numo::SFloat] result of sin(x).
|
7853
|
-
*/
|
7854
6988
|
static VALUE sfloat_math_s_sin(VALUE mod, VALUE a1) {
|
7855
6989
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7856
6990
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7923,12 +7057,6 @@ static void iter_sfloat_math_s_cos(na_loop_t* const lp) {
|
|
7923
7057
|
}
|
7924
7058
|
}
|
7925
7059
|
|
7926
|
-
/*
|
7927
|
-
Calculate cos(x).
|
7928
|
-
@overload cos(x)
|
7929
|
-
@param [Numo::NArray,Numeric] x input value
|
7930
|
-
@return [Numo::SFloat] result of cos(x).
|
7931
|
-
*/
|
7932
7060
|
static VALUE sfloat_math_s_cos(VALUE mod, VALUE a1) {
|
7933
7061
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7934
7062
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8001,12 +7129,6 @@ static void iter_sfloat_math_s_tan(na_loop_t* const lp) {
|
|
8001
7129
|
}
|
8002
7130
|
}
|
8003
7131
|
|
8004
|
-
/*
|
8005
|
-
Calculate tan(x).
|
8006
|
-
@overload tan(x)
|
8007
|
-
@param [Numo::NArray,Numeric] x input value
|
8008
|
-
@return [Numo::SFloat] result of tan(x).
|
8009
|
-
*/
|
8010
7132
|
static VALUE sfloat_math_s_tan(VALUE mod, VALUE a1) {
|
8011
7133
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8012
7134
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8079,12 +7201,6 @@ static void iter_sfloat_math_s_asin(na_loop_t* const lp) {
|
|
8079
7201
|
}
|
8080
7202
|
}
|
8081
7203
|
|
8082
|
-
/*
|
8083
|
-
Calculate asin(x).
|
8084
|
-
@overload asin(x)
|
8085
|
-
@param [Numo::NArray,Numeric] x input value
|
8086
|
-
@return [Numo::SFloat] result of asin(x).
|
8087
|
-
*/
|
8088
7204
|
static VALUE sfloat_math_s_asin(VALUE mod, VALUE a1) {
|
8089
7205
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8090
7206
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8157,12 +7273,6 @@ static void iter_sfloat_math_s_acos(na_loop_t* const lp) {
|
|
8157
7273
|
}
|
8158
7274
|
}
|
8159
7275
|
|
8160
|
-
/*
|
8161
|
-
Calculate acos(x).
|
8162
|
-
@overload acos(x)
|
8163
|
-
@param [Numo::NArray,Numeric] x input value
|
8164
|
-
@return [Numo::SFloat] result of acos(x).
|
8165
|
-
*/
|
8166
7276
|
static VALUE sfloat_math_s_acos(VALUE mod, VALUE a1) {
|
8167
7277
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8168
7278
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8235,12 +7345,6 @@ static void iter_sfloat_math_s_atan(na_loop_t* const lp) {
|
|
8235
7345
|
}
|
8236
7346
|
}
|
8237
7347
|
|
8238
|
-
/*
|
8239
|
-
Calculate atan(x).
|
8240
|
-
@overload atan(x)
|
8241
|
-
@param [Numo::NArray,Numeric] x input value
|
8242
|
-
@return [Numo::SFloat] result of atan(x).
|
8243
|
-
*/
|
8244
7348
|
static VALUE sfloat_math_s_atan(VALUE mod, VALUE a1) {
|
8245
7349
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8246
7350
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8313,12 +7417,6 @@ static void iter_sfloat_math_s_sinh(na_loop_t* const lp) {
|
|
8313
7417
|
}
|
8314
7418
|
}
|
8315
7419
|
|
8316
|
-
/*
|
8317
|
-
Calculate sinh(x).
|
8318
|
-
@overload sinh(x)
|
8319
|
-
@param [Numo::NArray,Numeric] x input value
|
8320
|
-
@return [Numo::SFloat] result of sinh(x).
|
8321
|
-
*/
|
8322
7420
|
static VALUE sfloat_math_s_sinh(VALUE mod, VALUE a1) {
|
8323
7421
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8324
7422
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8391,12 +7489,6 @@ static void iter_sfloat_math_s_cosh(na_loop_t* const lp) {
|
|
8391
7489
|
}
|
8392
7490
|
}
|
8393
7491
|
|
8394
|
-
/*
|
8395
|
-
Calculate cosh(x).
|
8396
|
-
@overload cosh(x)
|
8397
|
-
@param [Numo::NArray,Numeric] x input value
|
8398
|
-
@return [Numo::SFloat] result of cosh(x).
|
8399
|
-
*/
|
8400
7492
|
static VALUE sfloat_math_s_cosh(VALUE mod, VALUE a1) {
|
8401
7493
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8402
7494
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8469,12 +7561,6 @@ static void iter_sfloat_math_s_tanh(na_loop_t* const lp) {
|
|
8469
7561
|
}
|
8470
7562
|
}
|
8471
7563
|
|
8472
|
-
/*
|
8473
|
-
Calculate tanh(x).
|
8474
|
-
@overload tanh(x)
|
8475
|
-
@param [Numo::NArray,Numeric] x input value
|
8476
|
-
@return [Numo::SFloat] result of tanh(x).
|
8477
|
-
*/
|
8478
7564
|
static VALUE sfloat_math_s_tanh(VALUE mod, VALUE a1) {
|
8479
7565
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8480
7566
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8547,12 +7633,6 @@ static void iter_sfloat_math_s_asinh(na_loop_t* const lp) {
|
|
8547
7633
|
}
|
8548
7634
|
}
|
8549
7635
|
|
8550
|
-
/*
|
8551
|
-
Calculate asinh(x).
|
8552
|
-
@overload asinh(x)
|
8553
|
-
@param [Numo::NArray,Numeric] x input value
|
8554
|
-
@return [Numo::SFloat] result of asinh(x).
|
8555
|
-
*/
|
8556
7636
|
static VALUE sfloat_math_s_asinh(VALUE mod, VALUE a1) {
|
8557
7637
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8558
7638
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8625,12 +7705,6 @@ static void iter_sfloat_math_s_acosh(na_loop_t* const lp) {
|
|
8625
7705
|
}
|
8626
7706
|
}
|
8627
7707
|
|
8628
|
-
/*
|
8629
|
-
Calculate acosh(x).
|
8630
|
-
@overload acosh(x)
|
8631
|
-
@param [Numo::NArray,Numeric] x input value
|
8632
|
-
@return [Numo::SFloat] result of acosh(x).
|
8633
|
-
*/
|
8634
7708
|
static VALUE sfloat_math_s_acosh(VALUE mod, VALUE a1) {
|
8635
7709
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8636
7710
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8703,12 +7777,6 @@ static void iter_sfloat_math_s_atanh(na_loop_t* const lp) {
|
|
8703
7777
|
}
|
8704
7778
|
}
|
8705
7779
|
|
8706
|
-
/*
|
8707
|
-
Calculate atanh(x).
|
8708
|
-
@overload atanh(x)
|
8709
|
-
@param [Numo::NArray,Numeric] x input value
|
8710
|
-
@return [Numo::SFloat] result of atanh(x).
|
8711
|
-
*/
|
8712
7780
|
static VALUE sfloat_math_s_atanh(VALUE mod, VALUE a1) {
|
8713
7781
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8714
7782
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8781,12 +7849,6 @@ static void iter_sfloat_math_s_sinc(na_loop_t* const lp) {
|
|
8781
7849
|
}
|
8782
7850
|
}
|
8783
7851
|
|
8784
|
-
/*
|
8785
|
-
Calculate sinc(x).
|
8786
|
-
@overload sinc(x)
|
8787
|
-
@param [Numo::NArray,Numeric] x input value
|
8788
|
-
@return [Numo::SFloat] result of sinc(x).
|
8789
|
-
*/
|
8790
7852
|
static VALUE sfloat_math_s_sinc(VALUE mod, VALUE a1) {
|
8791
7853
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8792
7854
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8812,13 +7874,6 @@ static void iter_sfloat_math_s_atan2(na_loop_t* const lp) {
|
|
8812
7874
|
}
|
8813
7875
|
}
|
8814
7876
|
|
8815
|
-
/*
|
8816
|
-
Calculate atan2(a1,a2).
|
8817
|
-
@overload atan2(a1,a2)
|
8818
|
-
@param [Numo::NArray,Numeric] a1 first value
|
8819
|
-
@param [Numo::NArray,Numeric] a2 second value
|
8820
|
-
@return [Numo::SFloat] atan2(a1,a2).
|
8821
|
-
*/
|
8822
7877
|
static VALUE sfloat_math_s_atan2(VALUE mod, VALUE a1, VALUE a2) {
|
8823
7878
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
8824
7879
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8843,13 +7898,6 @@ static void iter_sfloat_math_s_hypot(na_loop_t* const lp) {
|
|
8843
7898
|
}
|
8844
7899
|
}
|
8845
7900
|
|
8846
|
-
/*
|
8847
|
-
Calculate hypot(a1,a2).
|
8848
|
-
@overload hypot(a1,a2)
|
8849
|
-
@param [Numo::NArray,Numeric] a1 first value
|
8850
|
-
@param [Numo::NArray,Numeric] a2 second value
|
8851
|
-
@return [Numo::SFloat] hypot(a1,a2).
|
8852
|
-
*/
|
8853
7901
|
static VALUE sfloat_math_s_hypot(VALUE mod, VALUE a1, VALUE a2) {
|
8854
7902
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
8855
7903
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8921,12 +7969,6 @@ static void iter_sfloat_math_s_erf(na_loop_t* const lp) {
|
|
8921
7969
|
}
|
8922
7970
|
}
|
8923
7971
|
|
8924
|
-
/*
|
8925
|
-
Calculate erf(x).
|
8926
|
-
@overload erf(x)
|
8927
|
-
@param [Numo::NArray,Numeric] x input value
|
8928
|
-
@return [Numo::SFloat] result of erf(x).
|
8929
|
-
*/
|
8930
7972
|
static VALUE sfloat_math_s_erf(VALUE mod, VALUE a1) {
|
8931
7973
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8932
7974
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8999,12 +8041,6 @@ static void iter_sfloat_math_s_erfc(na_loop_t* const lp) {
|
|
8999
8041
|
}
|
9000
8042
|
}
|
9001
8043
|
|
9002
|
-
/*
|
9003
|
-
Calculate erfc(x).
|
9004
|
-
@overload erfc(x)
|
9005
|
-
@param [Numo::NArray,Numeric] x input value
|
9006
|
-
@return [Numo::SFloat] result of erfc(x).
|
9007
|
-
*/
|
9008
8044
|
static VALUE sfloat_math_s_erfc(VALUE mod, VALUE a1) {
|
9009
8045
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
9010
8046
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -9077,12 +8113,6 @@ static void iter_sfloat_math_s_log1p(na_loop_t* const lp) {
|
|
9077
8113
|
}
|
9078
8114
|
}
|
9079
8115
|
|
9080
|
-
/*
|
9081
|
-
Calculate log1p(x).
|
9082
|
-
@overload log1p(x)
|
9083
|
-
@param [Numo::NArray,Numeric] x input value
|
9084
|
-
@return [Numo::SFloat] result of log1p(x).
|
9085
|
-
*/
|
9086
8116
|
static VALUE sfloat_math_s_log1p(VALUE mod, VALUE a1) {
|
9087
8117
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
9088
8118
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -9155,12 +8185,6 @@ static void iter_sfloat_math_s_expm1(na_loop_t* const lp) {
|
|
9155
8185
|
}
|
9156
8186
|
}
|
9157
8187
|
|
9158
|
-
/*
|
9159
|
-
Calculate expm1(x).
|
9160
|
-
@overload expm1(x)
|
9161
|
-
@param [Numo::NArray,Numeric] x input value
|
9162
|
-
@return [Numo::SFloat] result of expm1(x).
|
9163
|
-
*/
|
9164
8188
|
static VALUE sfloat_math_s_expm1(VALUE mod, VALUE a1) {
|
9165
8189
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
9166
8190
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -9186,13 +8210,6 @@ static void iter_sfloat_math_s_ldexp(na_loop_t* const lp) {
|
|
9186
8210
|
}
|
9187
8211
|
}
|
9188
8212
|
|
9189
|
-
/*
|
9190
|
-
Calculate ldexp(a1,a2).
|
9191
|
-
@overload ldexp(a1,a2)
|
9192
|
-
@param [Numo::NArray,Numeric] a1 first value
|
9193
|
-
@param [Numo::NArray,Numeric] a2 second value
|
9194
|
-
@return [Numo::SFloat] ldexp(a1,a2).
|
9195
|
-
*/
|
9196
8213
|
static VALUE sfloat_math_s_ldexp(VALUE mod, VALUE a1, VALUE a2) {
|
9197
8214
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
9198
8215
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -9218,15 +8235,6 @@ static void iter_sfloat_math_s_frexp(na_loop_t* const lp) {
|
|
9218
8235
|
}
|
9219
8236
|
}
|
9220
8237
|
|
9221
|
-
/*
|
9222
|
-
split the number x into a normalized fraction and an exponent.
|
9223
|
-
Returns [mantissa, exponent], where x = mantissa * 2**exponent.
|
9224
|
-
|
9225
|
-
@overload frexp(x)
|
9226
|
-
@param [Numo::NArray,Numeric] x
|
9227
|
-
@return [Numo::SFloat,Numo::Int32] mantissa and exponent.
|
9228
|
-
|
9229
|
-
*/
|
9230
8238
|
static VALUE sfloat_math_s_frexp(VALUE mod, VALUE a1) {
|
9231
8239
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
9232
8240
|
ndfunc_arg_out_t aout[2] = { { cT, 0 }, { numo_cInt32, 0 } };
|
@@ -9254,16 +8262,18 @@ void Init_numo_sfloat(void) {
|
|
9254
8262
|
id_nearly_eq = rb_intern("nearly_eq");
|
9255
8263
|
id_to_a = rb_intern("to_a");
|
9256
8264
|
|
9257
|
-
|
9258
|
-
|
9259
|
-
|
9260
|
-
|
8265
|
+
/**
|
8266
|
+
* Document-class: Numo::SFloat
|
8267
|
+
*
|
8268
|
+
* Single precision floating point number (32-bit float) N-dimensional array class.
|
8269
|
+
*/
|
9261
8270
|
cT = rb_define_class_under(mNumo, "SFloat", cNArray);
|
9262
8271
|
|
9263
8272
|
// alias of SFloat
|
9264
8273
|
rb_define_const(mNumo, "Float32", numo_cSFloat);
|
9265
8274
|
|
9266
8275
|
hCast = rb_hash_new();
|
8276
|
+
/* Upcasting rules of SFloat. */
|
9267
8277
|
rb_define_const(cT, "UPCAST", hCast);
|
9268
8278
|
rb_hash_aset(hCast, rb_cArray, cT);
|
9269
8279
|
|
@@ -9290,147 +8300,995 @@ void Init_numo_sfloat(void) {
|
|
9290
8300
|
rb_hash_aset(hCast, numo_cUInt8, numo_cSFloat);
|
9291
8301
|
rb_obj_freeze(hCast);
|
9292
8302
|
|
9293
|
-
|
8303
|
+
/* Element size of SFloat in bits. */
|
9294
8304
|
rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
|
9295
|
-
|
8305
|
+
/* Element size of SFloat in bytes. */
|
9296
8306
|
rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
|
9297
|
-
|
8307
|
+
/* Stride size of contiguous SFloat array. */
|
9298
8308
|
rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
|
9299
|
-
|
8309
|
+
/* Machine epsilon of SFloat */
|
9300
8310
|
rb_define_const(cT, "EPSILON", M_EPSILON);
|
9301
|
-
|
8311
|
+
/* The largest respresentable value of SFloat */
|
9302
8312
|
rb_define_const(cT, "MAX", M_MAX);
|
9303
|
-
|
8313
|
+
/* The smallest respresentable value of SFloat */
|
9304
8314
|
rb_define_const(cT, "MIN", M_MIN);
|
9305
8315
|
rb_define_alloc_func(cT, sfloat_s_alloc_func);
|
9306
8316
|
rb_define_method(cT, "allocate", sfloat_allocate, 0);
|
8317
|
+
/**
|
8318
|
+
* Extract an element only if self is a dimensionless NArray.
|
8319
|
+
* @overload extract
|
8320
|
+
* @return [Numeric,Numo::NArray] Extract element value as Ruby Object
|
8321
|
+
* if self is a dimensionless NArray, otherwise returns self.
|
8322
|
+
*/
|
9307
8323
|
rb_define_method(cT, "extract", sfloat_extract, 0);
|
9308
|
-
|
8324
|
+
/**
|
8325
|
+
* Store elements to Numo::SFloat from other.
|
8326
|
+
* @overload store(other)
|
8327
|
+
* @param [Object] other
|
8328
|
+
* @return [Numo::SFloat] self
|
8329
|
+
*/
|
9309
8330
|
rb_define_method(cT, "store", sfloat_store, 1);
|
9310
|
-
|
8331
|
+
/**
|
8332
|
+
* Cast object to Numo::SFloat.
|
8333
|
+
* @overload cast(array)
|
8334
|
+
* @param [Numeric,Array] elements
|
8335
|
+
* @param [Array] array
|
8336
|
+
* @return [Numo::SFloat]
|
8337
|
+
*/
|
9311
8338
|
rb_define_singleton_method(cT, "cast", sfloat_s_cast, 1);
|
8339
|
+
/**
|
8340
|
+
* Cast object to Numo::SFloat.
|
8341
|
+
* @overload [](elements)
|
8342
|
+
* @param [Numeric,Array] elements
|
8343
|
+
* @param [Array] array
|
8344
|
+
* @return [Numo::SFloat]
|
8345
|
+
*/
|
8346
|
+
rb_define_singleton_method(cT, "[]", sfloat_s_cast, -2);
|
8347
|
+
/**
|
8348
|
+
* Multi-dimensional element reference.
|
8349
|
+
* @overload [](dim0,...,dimL)
|
8350
|
+
* @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,Boolean,Symbol]
|
8351
|
+
* dim0,...,dimL multi-dimensional indices.
|
8352
|
+
* @return [Numeric,Numo::SFloat] an element or NArray view.
|
8353
|
+
* @see Numo::NArray#[]
|
8354
|
+
* @see #[]=
|
8355
|
+
*/
|
9312
8356
|
rb_define_method(cT, "[]", sfloat_aref, -1);
|
8357
|
+
/**
|
8358
|
+
* Multi-dimensional element assignment.
|
8359
|
+
* @overload []=(dim0,...,dimL,val)
|
8360
|
+
* @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,Boolean,Symbol]
|
8361
|
+
* dim0,...,dimL multi-dimensional indices.
|
8362
|
+
* @param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
|
8363
|
+
* @return [Numeric,Numo::NArray,Array] returns `val` (last argument).
|
8364
|
+
* @see Numo::NArray#[]=
|
8365
|
+
* @see #[]
|
8366
|
+
*/
|
9313
8367
|
rb_define_method(cT, "[]=", sfloat_aset, -1);
|
8368
|
+
/**
|
8369
|
+
* Return NArray with cast to the type of self.
|
8370
|
+
* @overload coerce_cast(type)
|
8371
|
+
* @return [nil]
|
8372
|
+
*/
|
9314
8373
|
rb_define_method(cT, "coerce_cast", sfloat_coerce_cast, 1);
|
8374
|
+
/**
|
8375
|
+
* Convert self to Array.
|
8376
|
+
* @overload to_a
|
8377
|
+
* @return [Array]
|
8378
|
+
*/
|
9315
8379
|
rb_define_method(cT, "to_a", sfloat_to_a, 0);
|
8380
|
+
/**
|
8381
|
+
* Fill elements with other.
|
8382
|
+
* @overload fill other
|
8383
|
+
* @param [Numeric] other
|
8384
|
+
* @return [Numo::SFloat] self.
|
8385
|
+
*/
|
9316
8386
|
rb_define_method(cT, "fill", sfloat_fill, 1);
|
8387
|
+
/**
|
8388
|
+
* Format elements into strings.
|
8389
|
+
* @overload format format
|
8390
|
+
* @param [String] format
|
8391
|
+
* @return [Numo::RObject] array of formatted strings.
|
8392
|
+
*/
|
9317
8393
|
rb_define_method(cT, "format", sfloat_format, -1);
|
8394
|
+
/**
|
8395
|
+
* Format elements into strings.
|
8396
|
+
* @overload format_to_a format
|
8397
|
+
* @param [String] format
|
8398
|
+
* @return [Array] array of formatted strings.
|
8399
|
+
*/
|
9318
8400
|
rb_define_method(cT, "format_to_a", sfloat_format_to_a, -1);
|
8401
|
+
/**
|
8402
|
+
* Returns a string containing a human-readable representation of NArray.
|
8403
|
+
* @overload inspect
|
8404
|
+
* @return [String]
|
8405
|
+
*/
|
9319
8406
|
rb_define_method(cT, "inspect", sfloat_inspect, 0);
|
8407
|
+
/**
|
8408
|
+
* Calls the given block once for each element in self, passing that element as a parameter.
|
8409
|
+
* For a block `{|x| ... }`,
|
8410
|
+
* @overload each
|
8411
|
+
* @return [Numo::NArray] self
|
8412
|
+
* @yieldparam [Numeric] x an element of NArray.
|
8413
|
+
* @see #each_with_index
|
8414
|
+
* @see #map
|
8415
|
+
*/
|
9320
8416
|
rb_define_method(cT, "each", sfloat_each, 0);
|
8417
|
+
/**
|
8418
|
+
* Unary map.
|
8419
|
+
* @overload map
|
8420
|
+
* @return [Numo::SFloat] map of self.
|
8421
|
+
*/
|
9321
8422
|
rb_define_method(cT, "map", sfloat_map, 0);
|
8423
|
+
/**
|
8424
|
+
* Invokes the given block once for each element of self, passing that element and
|
8425
|
+
* indices along each axis as parameters. For a block `{|x,i,j,...| ... }`,
|
8426
|
+
* @overload each_with_index
|
8427
|
+
* @yieldparam [Numeric] x an element
|
8428
|
+
* @yieldparam [Integer] i,j,... multitimensional indices
|
8429
|
+
* @return [Numo::NArray] self
|
8430
|
+
* @see #each
|
8431
|
+
* @see #map_with_index
|
8432
|
+
*/
|
9322
8433
|
rb_define_method(cT, "each_with_index", sfloat_each_with_index, 0);
|
8434
|
+
/**
|
8435
|
+
* Invokes the given block once for each element of self,
|
8436
|
+
* passing that element and indices along each axis as parameters.
|
8437
|
+
* Creates a new NArray containing the values returned by the block.
|
8438
|
+
* Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
|
8439
|
+
* For a block `{|x,i,j,...| ... }`,
|
8440
|
+
* @overload map_with_index
|
8441
|
+
* @yieldparam [Numeric] x an element
|
8442
|
+
* @yieldparam [Integer] i,j,... multitimensional indices
|
8443
|
+
* @return [Numo::NArray] mapped array
|
8444
|
+
* @see #map
|
8445
|
+
* @see #each_with_index
|
8446
|
+
*/
|
9323
8447
|
rb_define_method(cT, "map_with_index", sfloat_map_with_index, 0);
|
8448
|
+
/**
|
8449
|
+
* abs of self.
|
8450
|
+
* @overload abs
|
8451
|
+
* @return [Numo::SFloat] abs of self.
|
8452
|
+
*/
|
9324
8453
|
rb_define_method(cT, "abs", sfloat_abs, 0);
|
8454
|
+
/**
|
8455
|
+
* Binary add.
|
8456
|
+
* @overload + other
|
8457
|
+
* @param [Numo::NArray,Numeric] other
|
8458
|
+
* @return [Numo::NArray] self + other
|
8459
|
+
*/
|
9325
8460
|
rb_define_method(cT, "+", sfloat_add, 1);
|
8461
|
+
/**
|
8462
|
+
* Binary sub.
|
8463
|
+
* @overload - other
|
8464
|
+
* @param [Numo::NArray,Numeric] other
|
8465
|
+
* @return [Numo::NArray] self - other
|
8466
|
+
*/
|
9326
8467
|
rb_define_method(cT, "-", sfloat_sub, 1);
|
8468
|
+
/**
|
8469
|
+
* Binary mul.
|
8470
|
+
* @overload * other
|
8471
|
+
* @param [Numo::NArray,Numeric] other
|
8472
|
+
* @return [Numo::NArray] self * other
|
8473
|
+
*/
|
9327
8474
|
rb_define_method(cT, "*", sfloat_mul, 1);
|
8475
|
+
/**
|
8476
|
+
* Binary div.
|
8477
|
+
* @overload / other
|
8478
|
+
* @param [Numo::NArray,Numeric] other
|
8479
|
+
* @return [Numo::NArray] self / other
|
8480
|
+
*/
|
9328
8481
|
rb_define_method(cT, "/", sfloat_div, 1);
|
8482
|
+
/**
|
8483
|
+
* Binary mod.
|
8484
|
+
* @overload % other
|
8485
|
+
* @param [Numo::NArray,Numeric] other
|
8486
|
+
* @return [Numo::NArray] self % other
|
8487
|
+
*/
|
9329
8488
|
rb_define_method(cT, "%", sfloat_mod, 1);
|
8489
|
+
/**
|
8490
|
+
* Binary divmod.
|
8491
|
+
* @overload divmod other
|
8492
|
+
* @param [Numo::NArray,Numeric] other
|
8493
|
+
* @return [Numo::NArray] divmod of self and other.
|
8494
|
+
*/
|
9330
8495
|
rb_define_method(cT, "divmod", sfloat_divmod, 1);
|
8496
|
+
/**
|
8497
|
+
* Binary power.
|
8498
|
+
* @overload ** other
|
8499
|
+
* @param [Numo::NArray,Numeric] other
|
8500
|
+
* @return [Numo::NArray] self to the other-th power.
|
8501
|
+
*/
|
9331
8502
|
rb_define_method(cT, "**", sfloat_pow, 1);
|
9332
8503
|
rb_define_alias(cT, "pow", "**");
|
8504
|
+
/**
|
8505
|
+
* Unary minus.
|
8506
|
+
* @overload -@
|
8507
|
+
* @return [Numo::SFloat] minus of self.
|
8508
|
+
*/
|
9333
8509
|
rb_define_method(cT, "-@", sfloat_minus, 0);
|
8510
|
+
/**
|
8511
|
+
* Unary reciprocal.
|
8512
|
+
* @overload reciprocal
|
8513
|
+
* @return [Numo::SFloat] reciprocal of self.
|
8514
|
+
*/
|
9334
8515
|
rb_define_method(cT, "reciprocal", sfloat_reciprocal, 0);
|
8516
|
+
/**
|
8517
|
+
* Unary sign.
|
8518
|
+
* @overload sign
|
8519
|
+
* @return [Numo::SFloat] sign of self.
|
8520
|
+
*/
|
9335
8521
|
rb_define_method(cT, "sign", sfloat_sign, 0);
|
8522
|
+
/**
|
8523
|
+
* Unary square.
|
8524
|
+
* @overload square
|
8525
|
+
* @return [Numo::SFloat] square of self.
|
8526
|
+
*/
|
9336
8527
|
rb_define_method(cT, "square", sfloat_square, 0);
|
9337
8528
|
rb_define_alias(cT, "conj", "view");
|
9338
8529
|
rb_define_alias(cT, "im", "view");
|
9339
8530
|
rb_define_alias(cT, "conjugate", "conj");
|
8531
|
+
/**
|
8532
|
+
* Comparison eq other.
|
8533
|
+
* @overload eq other
|
8534
|
+
* @param [Numo::NArray,Numeric] other
|
8535
|
+
* @return [Numo::Bit] result of self eq other.
|
8536
|
+
*/
|
9340
8537
|
rb_define_method(cT, "eq", sfloat_eq, 1);
|
8538
|
+
/**
|
8539
|
+
* Comparison ne other.
|
8540
|
+
* @overload ne other
|
8541
|
+
* @param [Numo::NArray,Numeric] other
|
8542
|
+
* @return [Numo::Bit] result of self ne other.
|
8543
|
+
*/
|
9341
8544
|
rb_define_method(cT, "ne", sfloat_ne, 1);
|
8545
|
+
/**
|
8546
|
+
* Comparison nearly_eq other.
|
8547
|
+
* @overload nearly_eq other
|
8548
|
+
* @param [Numo::NArray,Numeric] other
|
8549
|
+
* @return [Numo::Bit] result of self nearly_eq other.
|
8550
|
+
*/
|
9342
8551
|
rb_define_method(cT, "nearly_eq", sfloat_nearly_eq, 1);
|
9343
8552
|
rb_define_alias(cT, "close_to", "nearly_eq");
|
8553
|
+
/**
|
8554
|
+
* Unary floor.
|
8555
|
+
* @overload floor
|
8556
|
+
* @return [Numo::SFloat] floor of self.
|
8557
|
+
*/
|
9344
8558
|
rb_define_method(cT, "floor", sfloat_floor, 0);
|
8559
|
+
/**
|
8560
|
+
* Unary round.
|
8561
|
+
* @overload round
|
8562
|
+
* @return [Numo::SFloat] round of self.
|
8563
|
+
*/
|
9345
8564
|
rb_define_method(cT, "round", sfloat_round, 0);
|
8565
|
+
/**
|
8566
|
+
* Unary ceil.
|
8567
|
+
* @overload ceil
|
8568
|
+
* @return [Numo::SFloat] ceil of self.
|
8569
|
+
*/
|
9346
8570
|
rb_define_method(cT, "ceil", sfloat_ceil, 0);
|
8571
|
+
/**
|
8572
|
+
* Unary trunc.
|
8573
|
+
* @overload trunc
|
8574
|
+
* @return [Numo::SFloat] trunc of self.
|
8575
|
+
*/
|
9347
8576
|
rb_define_method(cT, "trunc", sfloat_trunc, 0);
|
8577
|
+
/**
|
8578
|
+
* Unary rint.
|
8579
|
+
* @overload rint
|
8580
|
+
* @return [Numo::SFloat] rint of self.
|
8581
|
+
*/
|
9348
8582
|
rb_define_method(cT, "rint", sfloat_rint, 0);
|
8583
|
+
/**
|
8584
|
+
* Binary copysign.
|
8585
|
+
* @overload copysign other
|
8586
|
+
* @param [Numo::NArray,Numeric] other
|
8587
|
+
* @return [Numo::NArray] self copysign other
|
8588
|
+
*/
|
9349
8589
|
rb_define_method(cT, "copysign", sfloat_copysign, 1);
|
8590
|
+
/**
|
8591
|
+
* Condition of signbit.
|
8592
|
+
* @overload signbit
|
8593
|
+
* @return [Numo::Bit] Condition of signbit.
|
8594
|
+
*/
|
9350
8595
|
rb_define_method(cT, "signbit", sfloat_signbit, 0);
|
8596
|
+
/**
|
8597
|
+
* modf of self.
|
8598
|
+
* @overload modf
|
8599
|
+
* @return [Numo::SFloat] modf of self.
|
8600
|
+
*/
|
9351
8601
|
rb_define_method(cT, "modf", sfloat_modf, 0);
|
8602
|
+
/**
|
8603
|
+
* Comparison gt other.
|
8604
|
+
* @overload gt other
|
8605
|
+
* @param [Numo::NArray,Numeric] other
|
8606
|
+
* @return [Numo::Bit] result of self gt other.
|
8607
|
+
*/
|
9352
8608
|
rb_define_method(cT, "gt", sfloat_gt, 1);
|
8609
|
+
/**
|
8610
|
+
* Comparison ge other.
|
8611
|
+
* @overload ge other
|
8612
|
+
* @param [Numo::NArray,Numeric] other
|
8613
|
+
* @return [Numo::Bit] result of self ge other.
|
8614
|
+
*/
|
9353
8615
|
rb_define_method(cT, "ge", sfloat_ge, 1);
|
8616
|
+
/**
|
8617
|
+
* Comparison lt other.
|
8618
|
+
* @overload lt other
|
8619
|
+
* @param [Numo::NArray,Numeric] other
|
8620
|
+
* @return [Numo::Bit] result of self lt other.
|
8621
|
+
*/
|
9354
8622
|
rb_define_method(cT, "lt", sfloat_lt, 1);
|
8623
|
+
/**
|
8624
|
+
* Comparison le other.
|
8625
|
+
* @overload le other
|
8626
|
+
* @param [Numo::NArray,Numeric] other
|
8627
|
+
* @return [Numo::Bit] result of self le other.
|
8628
|
+
*/
|
9355
8629
|
rb_define_method(cT, "le", sfloat_le, 1);
|
9356
8630
|
rb_define_alias(cT, ">", "gt");
|
9357
8631
|
rb_define_alias(cT, ">=", "ge");
|
9358
8632
|
rb_define_alias(cT, "<", "lt");
|
9359
8633
|
rb_define_alias(cT, "<=", "le");
|
8634
|
+
/**
|
8635
|
+
* Clip array elements by [min,max].
|
8636
|
+
* If either of min or max is nil, one side is clipped.
|
8637
|
+
* @overload clip(min,max)
|
8638
|
+
* @param [Numo::NArray,Numeric] min
|
8639
|
+
* @param [Numo::NArray,Numeric] max
|
8640
|
+
* @return [Numo::NArray] result of clip.
|
8641
|
+
*
|
8642
|
+
* @example
|
8643
|
+
* a = Numo::Int32.new(10).seq
|
8644
|
+
* # => Numo::Int32#shape=[10]
|
8645
|
+
* # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
8646
|
+
*
|
8647
|
+
* a.clip(1,8)
|
8648
|
+
* # => Numo::Int32#shape=[10]
|
8649
|
+
* # [1, 1, 2, 3, 4, 5, 6, 7, 8, 8]
|
8650
|
+
*
|
8651
|
+
* a.inplace.clip(3,6)
|
8652
|
+
* a
|
8653
|
+
* # => Numo::Int32#shape=[10]
|
8654
|
+
* # [3, 3, 3, 3, 4, 5, 6, 6, 6, 6]
|
8655
|
+
*
|
8656
|
+
* b = Numo::Int32.new(10).seq
|
8657
|
+
* # => Numo::Int32#shape=[10]
|
8658
|
+
* # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
8659
|
+
*
|
8660
|
+
* b.clip([3,4,1,1,1,4,4,4,4,4], 8)
|
8661
|
+
* # => Numo::Int32#shape=[10]
|
8662
|
+
* # [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]
|
8663
|
+
*/
|
9360
8664
|
rb_define_method(cT, "clip", sfloat_clip, 2);
|
8665
|
+
/**
|
8666
|
+
* Condition of isnan.
|
8667
|
+
* @overload isnan
|
8668
|
+
* @return [Numo::Bit] Condition of isnan.
|
8669
|
+
*/
|
9361
8670
|
rb_define_method(cT, "isnan", sfloat_isnan, 0);
|
8671
|
+
/**
|
8672
|
+
* Condition of isinf.
|
8673
|
+
* @overload isinf
|
8674
|
+
* @return [Numo::Bit] Condition of isinf.
|
8675
|
+
*/
|
9362
8676
|
rb_define_method(cT, "isinf", sfloat_isinf, 0);
|
8677
|
+
/**
|
8678
|
+
* Condition of isposinf.
|
8679
|
+
* @overload isposinf
|
8680
|
+
* @return [Numo::Bit] Condition of isposinf.
|
8681
|
+
*/
|
9363
8682
|
rb_define_method(cT, "isposinf", sfloat_isposinf, 0);
|
8683
|
+
/**
|
8684
|
+
* Condition of isneginf.
|
8685
|
+
* @overload isneginf
|
8686
|
+
* @return [Numo::Bit] Condition of isneginf.
|
8687
|
+
*/
|
9364
8688
|
rb_define_method(cT, "isneginf", sfloat_isneginf, 0);
|
8689
|
+
/**
|
8690
|
+
* Condition of isfinite.
|
8691
|
+
* @overload isfinite
|
8692
|
+
* @return [Numo::Bit] Condition of isfinite.
|
8693
|
+
*/
|
9365
8694
|
rb_define_method(cT, "isfinite", sfloat_isfinite, 0);
|
8695
|
+
/**
|
8696
|
+
* sum of self.
|
8697
|
+
* @overload sum(axis:nil, keepdims:false, nan:false)
|
8698
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8699
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8700
|
+
* @param [Numeric,Array,Range] axis Performs sum along the axis.
|
8701
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8702
|
+
* dimensions with size one.
|
8703
|
+
* @return [Numo::SFloat] returns result of sum.
|
8704
|
+
*/
|
9366
8705
|
rb_define_method(cT, "sum", sfloat_sum, -1);
|
8706
|
+
/**
|
8707
|
+
* prod of self.
|
8708
|
+
* @overload prod(axis:nil, keepdims:false, nan:false)
|
8709
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8710
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8711
|
+
* @param [Numeric,Array,Range] axis Performs prod along the axis.
|
8712
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8713
|
+
* dimensions with size one.
|
8714
|
+
* @return [Numo::SFloat] returns result of prod.
|
8715
|
+
*/
|
9367
8716
|
rb_define_method(cT, "prod", sfloat_prod, -1);
|
8717
|
+
/**
|
8718
|
+
* mean of self.
|
8719
|
+
* @overload mean(axis: nil, keepdims: false, nan: false)
|
8720
|
+
* @param axis [Numeric, Array, Range] Performs mean along the axis.
|
8721
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
8722
|
+
* dimensions with size one.
|
8723
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
8724
|
+
* (avoid NaN for sum/mean etc, or return NaN for min/max etc).
|
8725
|
+
* @return [Numo::SFloat] returns result of mean.
|
8726
|
+
*/
|
9368
8727
|
rb_define_method(cT, "mean", sfloat_mean, -1);
|
9369
|
-
|
8728
|
+
/**
|
8729
|
+
* var of self.
|
8730
|
+
* @overload var(axis: nil, keepdims: false, nan: false)
|
8731
|
+
* @param axis [Numeric, Array, Range] Performs var along the axis.
|
8732
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
8733
|
+
* dimensions with size one.
|
8734
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
8735
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8736
|
+
* @return [Numo::SFloat] returns result of var.
|
8737
|
+
*/
|
9370
8738
|
rb_define_method(cT, "var", sfloat_var, -1);
|
8739
|
+
/**
|
8740
|
+
* stddev of self.
|
8741
|
+
* @overload stddev(axis: nil, keepdims: false, nan: false)
|
8742
|
+
* @param axis [Numeric, Array, Range] Performs stddev along the axis.
|
8743
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
8744
|
+
* dimensions with size one.
|
8745
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
8746
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8747
|
+
* @return [Numo::SFloat] returns result of stddev.
|
8748
|
+
*/
|
8749
|
+
rb_define_method(cT, "stddev", sfloat_stddev, -1);
|
8750
|
+
/**
|
8751
|
+
* rms of self.
|
8752
|
+
* @overload rms(axis: nil, keepdims: false, nan: false)
|
8753
|
+
* @param axis [Numeric, Array, Range] Performs rms along the axis.
|
8754
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
8755
|
+
* dimensions with size one.
|
8756
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
8757
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8758
|
+
* @return [Numo::SFloat] returns result of rms.
|
8759
|
+
*/
|
9371
8760
|
rb_define_method(cT, "rms", sfloat_rms, -1);
|
8761
|
+
/**
|
8762
|
+
* min of self.
|
8763
|
+
* @overload min(axis:nil, keepdims:false, nan:false)
|
8764
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8765
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8766
|
+
* @param [Numeric,Array,Range] axis Performs min along the axis.
|
8767
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8768
|
+
* dimensions with size one.
|
8769
|
+
* @return [Numo::SFloat] returns result of min.
|
8770
|
+
*/
|
9372
8771
|
rb_define_method(cT, "min", sfloat_min, -1);
|
8772
|
+
/**
|
8773
|
+
* max of self.
|
8774
|
+
* @overload max(axis:nil, keepdims:false, nan:false)
|
8775
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8776
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8777
|
+
* @param [Numeric,Array,Range] axis Performs max along the axis.
|
8778
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8779
|
+
* dimensions with size one.
|
8780
|
+
* @return [Numo::SFloat] returns result of max.
|
8781
|
+
*/
|
9373
8782
|
rb_define_method(cT, "max", sfloat_max, -1);
|
8783
|
+
/**
|
8784
|
+
* ptp of self.
|
8785
|
+
* @overload ptp(axis:nil, keepdims:false, nan:false)
|
8786
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8787
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8788
|
+
* @param [Numeric,Array,Range] axis Performs ptp along the axis.
|
8789
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8790
|
+
* dimensions with size one.
|
8791
|
+
* @return [Numo::SFloat] returns result of ptp.
|
8792
|
+
*/
|
9374
8793
|
rb_define_method(cT, "ptp", sfloat_ptp, -1);
|
8794
|
+
/**
|
8795
|
+
* Index of the maximum value.
|
8796
|
+
* @overload max_index(axis:nil, nan:false)
|
8797
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8798
|
+
* (return NaN posision if exist).
|
8799
|
+
* @param [Numeric,Array,Range] axis Finds maximum values along the axis
|
8800
|
+
* and returns **flat 1-d indices**.
|
8801
|
+
* @return [Integer,Numo::Int] returns result indices.
|
8802
|
+
* @see #argmax
|
8803
|
+
* @see #max
|
8804
|
+
*
|
8805
|
+
* @example
|
8806
|
+
* a = Numo::NArray[3,4,1,2]
|
8807
|
+
* a.max_index #=> 1
|
8808
|
+
*
|
8809
|
+
* b = Numo::NArray[[3,4,1],[2,0,5]]
|
8810
|
+
* b.max_index #=> 5
|
8811
|
+
* b.max_index(axis:1) #=> [1, 5]
|
8812
|
+
* b.max_index(axis:0) #=> [0, 1, 5]
|
8813
|
+
* b[b.max_index(axis:0)] #=> [3, 4, 5]
|
8814
|
+
*/
|
9375
8815
|
rb_define_method(cT, "max_index", sfloat_max_index, -1);
|
8816
|
+
/**
|
8817
|
+
* Index of the minimum value.
|
8818
|
+
* @overload min_index(axis:nil, nan:false)
|
8819
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8820
|
+
* (return NaN posision if exist).
|
8821
|
+
* @param [Numeric,Array,Range] axis Finds minimum values along the axis
|
8822
|
+
* and returns **flat 1-d indices**.
|
8823
|
+
* @return [Integer,Numo::Int] returns result indices.
|
8824
|
+
* @see #argmin
|
8825
|
+
* @see #min
|
8826
|
+
*
|
8827
|
+
* @example
|
8828
|
+
* a = Numo::NArray[3,4,1,2]
|
8829
|
+
* a.min_index #=> 2
|
8830
|
+
*
|
8831
|
+
* b = Numo::NArray[[3,4,1],[2,0,5]]
|
8832
|
+
* b.min_index #=> 4
|
8833
|
+
* b.min_index(axis:1) #=> [2, 4]
|
8834
|
+
* b.min_index(axis:0) #=> [3, 4, 2]
|
8835
|
+
* b[b.min_index(axis:0)] #=> [2, 0, 1]
|
8836
|
+
*/
|
9376
8837
|
rb_define_method(cT, "min_index", sfloat_min_index, -1);
|
8838
|
+
/**
|
8839
|
+
* Index of the maximum value.
|
8840
|
+
* @overload argmax(axis:nil, nan:false)
|
8841
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8842
|
+
* (return NaN posision if exist).
|
8843
|
+
* @param [Numeric,Array,Range] axis Finds maximum values along the axis
|
8844
|
+
* and returns **indices along the axis**.
|
8845
|
+
* @return [Integer,Numo::Int] returns the result indices.
|
8846
|
+
* @see #max_index
|
8847
|
+
* @see #max
|
8848
|
+
*
|
8849
|
+
* @example
|
8850
|
+
* a = Numo::NArray[3,4,1,2]
|
8851
|
+
* a.argmax #=> 1
|
8852
|
+
*
|
8853
|
+
* b = Numo::NArray[[3,4,1],[2,0,5]]
|
8854
|
+
* b.argmax #=> 5
|
8855
|
+
* b.argmax(axis:1) #=> [1, 2]
|
8856
|
+
* b.argmax(axis:0) #=> [0, 0, 1]
|
8857
|
+
* b.at(b.argmax(axis:0), 0..-1) #=> [3, 4, 5]
|
8858
|
+
*/
|
9377
8859
|
rb_define_method(cT, "argmax", sfloat_argmax, -1);
|
8860
|
+
/**
|
8861
|
+
* Index of the minimum value.
|
8862
|
+
* @overload argmin(axis:nil, nan:false)
|
8863
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8864
|
+
* (return NaN posision if exist).
|
8865
|
+
* @param [Numeric,Array,Range] axis Finds minimum values along the axis
|
8866
|
+
* and returns **indices along the axis**.
|
8867
|
+
* @return [Integer,Numo::Int] returns the result indices.
|
8868
|
+
* @see #min_index
|
8869
|
+
* @see #min
|
8870
|
+
*
|
8871
|
+
* @example
|
8872
|
+
* a = Numo::NArray[3,4,1,2]
|
8873
|
+
* a.argmin #=> 2
|
8874
|
+
*
|
8875
|
+
* b = Numo::NArray[[3,4,1],[2,0,5]]
|
8876
|
+
* b.argmin #=> 4
|
8877
|
+
* b.argmin(axis:1) #=> [2, 1]
|
8878
|
+
* b.argmin(axis:0) #=> [1, 1, 0]
|
8879
|
+
* b.at(b.argmin(axis:0), 0..-1) #=> [2, 0, 1]
|
8880
|
+
*/
|
9378
8881
|
rb_define_method(cT, "argmin", sfloat_argmin, -1);
|
8882
|
+
/**
|
8883
|
+
* minmax of self.
|
8884
|
+
* @overload minmax(axis:nil, keepdims:false, nan:false)
|
8885
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
8886
|
+
* @param [Numeric,Array,Range] axis Finds min-max along the axis.
|
8887
|
+
* @param [Boolean] keepdims (keyword) If true, the reduced axes are left
|
8888
|
+
* in the result array as dimensions with size one.
|
8889
|
+
* @return [Numo::SFloat,Numo::SFloat] min and max of self.
|
8890
|
+
*/
|
9379
8891
|
rb_define_method(cT, "minmax", sfloat_minmax, -1);
|
8892
|
+
/**
|
8893
|
+
* Element-wise maximum of two arrays.
|
8894
|
+
* @overload maximum(a1, a2, nan:false)
|
8895
|
+
* @param [Numo::NArray,Numeric] a1 The array to be compared.
|
8896
|
+
* @param [Numo::NArray,Numeric] a2 The array to be compared.
|
8897
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
8898
|
+
* @return [Numo::SFloat]
|
8899
|
+
*/
|
9380
8900
|
rb_define_module_function(cT, "maximum", sfloat_s_maximum, -1);
|
8901
|
+
/**
|
8902
|
+
* Element-wise minimum of two arrays.
|
8903
|
+
* @overload minimum(a1, a2, nan:false)
|
8904
|
+
* @param [Numo::NArray,Numeric] a1 The array to be compared.
|
8905
|
+
* @param [Numo::NArray,Numeric] a2 The array to be compared.
|
8906
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
8907
|
+
* @return [Numo::SFloat]
|
8908
|
+
*/
|
9381
8909
|
rb_define_module_function(cT, "minimum", sfloat_s_minimum, -1);
|
8910
|
+
/**
|
8911
|
+
* cumsum of self.
|
8912
|
+
* @overload cumsum(axis:nil, nan:false)
|
8913
|
+
* @param [Numeric,Array,Range] axis Performs cumsum along the axis.
|
8914
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
8915
|
+
* @return [Numo::SFloat] cumsum of self.
|
8916
|
+
*/
|
9382
8917
|
rb_define_method(cT, "cumsum", sfloat_cumsum, -1);
|
8918
|
+
/**
|
8919
|
+
* cumprod of self.
|
8920
|
+
* @overload cumprod(axis:nil, nan:false)
|
8921
|
+
* @param [Numeric,Array,Range] axis Performs cumprod along the axis.
|
8922
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
8923
|
+
* @return [Numo::SFloat] cumprod of self.
|
8924
|
+
*/
|
9383
8925
|
rb_define_method(cT, "cumprod", sfloat_cumprod, -1);
|
8926
|
+
/**
|
8927
|
+
* Binary mulsum.
|
8928
|
+
* @overload mulsum(other, axis:nil, keepdims:false, nan:false)
|
8929
|
+
* @param [Numo::NArray,Numeric] other
|
8930
|
+
* @param [Numeric,Array,Range] axis Performs mulsum along the axis.
|
8931
|
+
* @param [Boolean] keepdims (keyword) If true, the reduced axes are left
|
8932
|
+
* in the result array as dimensions with size one.
|
8933
|
+
* @param [Boolean] nan (keyword) If true, apply NaN-aware algorithm
|
8934
|
+
* (avoid NaN if exists).
|
8935
|
+
* @return [Numo::NArray] mulsum of self and other.
|
8936
|
+
*/
|
9384
8937
|
rb_define_method(cT, "mulsum", sfloat_mulsum, -1);
|
8938
|
+
/**
|
8939
|
+
* Set linear sequence of numbers to self. The sequence is obtained from
|
8940
|
+
* beg+i*step
|
8941
|
+
* where i is 1-dimensional index.
|
8942
|
+
* @overload seq([beg,[step]])
|
8943
|
+
* @param [Numeric] beg beginning of sequence. (default=0)
|
8944
|
+
* @param [Numeric] step step of sequence. (default=1)
|
8945
|
+
* @return [Numo::SFloat] self.
|
8946
|
+
* @example
|
8947
|
+
* Numo::DFloat.new(6).seq(1,-0.2)
|
8948
|
+
* # => Numo::DFloat#shape=[6]
|
8949
|
+
* # [1, 0.8, 0.6, 0.4, 0.2, 0]
|
8950
|
+
*
|
8951
|
+
* Numo::DComplex.new(6).seq(1,-0.2+0.2i)
|
8952
|
+
* # => Numo::DComplex#shape=[6]
|
8953
|
+
* # [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
8954
|
+
*/
|
9385
8955
|
rb_define_method(cT, "seq", sfloat_seq, -1);
|
8956
|
+
/**
|
8957
|
+
* Set logarithmic sequence of numbers to self. The sequence is obtained from
|
8958
|
+
* `base**(beg+i*step)`
|
8959
|
+
* where i is 1-dimensional index.
|
8960
|
+
* Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
|
8961
|
+
*
|
8962
|
+
* @overload logseq(beg,step,[base])
|
8963
|
+
* @param [Numeric] beg The beginning of sequence.
|
8964
|
+
* @param [Numeric] step The step of sequence.
|
8965
|
+
* @param [Numeric] base The base of log space. (default=10)
|
8966
|
+
* @return [Numo::SFloat] self.
|
8967
|
+
*
|
8968
|
+
* @example
|
8969
|
+
* Numo::DFloat.new(5).logseq(4,-1,2)
|
8970
|
+
* # => Numo::DFloat#shape=[5]
|
8971
|
+
* # [16, 8, 4, 2, 1]
|
8972
|
+
*
|
8973
|
+
* Numo::DComplex.new(5).logseq(0,1i*Math::PI/3,Math::E)
|
8974
|
+
* # => Numo::DComplex#shape=[5]
|
8975
|
+
* # [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
|
8976
|
+
*/
|
9386
8977
|
rb_define_method(cT, "logseq", sfloat_logseq, -1);
|
8978
|
+
/**
|
8979
|
+
* Eye: Set a value to diagonal components, set 0 to non-diagonal components.
|
8980
|
+
* @overload eye([element,offset])
|
8981
|
+
* @param [Numeric] element Diagonal element to be stored. Default is 1.
|
8982
|
+
* @param [Integer] offset Diagonal offset from the main diagonal.
|
8983
|
+
* The default is 0. k>0 for diagonals above the main diagonal,
|
8984
|
+
* and k<0 for diagonals below the main diagonal.
|
8985
|
+
* @return [Numo::SFloat] eye of self.
|
8986
|
+
*/
|
9387
8987
|
rb_define_method(cT, "eye", sfloat_eye, -1);
|
9388
8988
|
rb_define_alias(cT, "indgen", "seq");
|
8989
|
+
/**
|
8990
|
+
* Generate uniformly distributed random numbers on self narray.
|
8991
|
+
* @overload rand([[low],high])
|
8992
|
+
* @param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
8993
|
+
* @param [Numeric] high upper exclusive boundary of random numbers.
|
8994
|
+
* (default=1 or 1+1i for complex types)
|
8995
|
+
* @return [Numo::SFloat] self.
|
8996
|
+
* @example
|
8997
|
+
* Numo::DFloat.new(6).rand
|
8998
|
+
* # => Numo::DFloat#shape=[6]
|
8999
|
+
* # [0.0617545, 0.373067, 0.794815, 0.201042, 0.116041, 0.344032]
|
9000
|
+
*
|
9001
|
+
* Numo::DComplex.new(6).rand(5+5i)
|
9002
|
+
* # => Numo::DComplex#shape=[6]
|
9003
|
+
* # [2.69974+3.68908i, 0.825443+0.254414i, 0.540323+0.34354i, 4.52061+2.39322i, ...]
|
9004
|
+
*
|
9005
|
+
* Numo::Int32.new(6).rand(2,5)
|
9006
|
+
* # => Numo::Int32#shape=[6]
|
9007
|
+
* # [4, 3, 3, 2, 4, 2]
|
9008
|
+
*/
|
9389
9009
|
rb_define_method(cT, "rand", sfloat_rand, -1);
|
9010
|
+
/**
|
9011
|
+
* Generates random numbers from the normal distribution on self narray
|
9012
|
+
* using Box-Muller Transformation.
|
9013
|
+
* @overload rand_norm([mu,[sigma]])
|
9014
|
+
* @param [Numeric] mu mean of normal distribution. (default=0)
|
9015
|
+
* @param [Numeric] sigma standard deviation of normal distribution. (default=1)
|
9016
|
+
* @return [Numo::SFloat] self.
|
9017
|
+
* @example
|
9018
|
+
* Numo::DFloat.new(5,5).rand_norm
|
9019
|
+
* # => Numo::DFloat#shape=[5,5]
|
9020
|
+
* # [[-0.581255, -0.168354, 0.586895, -0.595142, -0.802802],
|
9021
|
+
* # [-0.326106, 0.282922, 1.68427, 0.918499, -0.0485384],
|
9022
|
+
* # [-0.464453, -0.992194, 0.413794, -0.60717, -0.699695],
|
9023
|
+
* # [-1.64168, 0.48676, -0.875871, -1.43275, 0.812172],
|
9024
|
+
* # [-0.209975, -0.103612, -0.878617, -1.42495, 1.0968]]
|
9025
|
+
*
|
9026
|
+
* Numo::DFloat.new(5,5).rand_norm(10,0.1)
|
9027
|
+
* # => Numo::DFloat#shape=[5,5]
|
9028
|
+
* # [[9.9019, 9.90339, 10.0826, 9.98384, 9.72861],
|
9029
|
+
* # [9.81507, 10.0272, 9.91445, 10.0568, 9.88923],
|
9030
|
+
* # [10.0234, 9.97874, 9.96011, 9.9006, 9.99964],
|
9031
|
+
* # [10.0186, 9.94598, 9.92236, 9.99811, 9.97003],
|
9032
|
+
* # [9.79266, 9.95044, 9.95212, 9.93692, 10.2027]]
|
9033
|
+
*
|
9034
|
+
* Numo::DComplex.new(3,3).rand_norm(5+5i)
|
9035
|
+
* # => Numo::DComplex#shape=[3,3]
|
9036
|
+
* # [[5.84303+4.40052i, 4.00984+6.08982i, 5.10979+5.13215i],
|
9037
|
+
* # [4.26477+3.99655i, 4.90052+5.00763i, 4.46607+2.3444i],
|
9038
|
+
* # [4.5528+7.11003i, 5.62117+6.69094i, 5.05443+5.35133i]]
|
9039
|
+
*/
|
9390
9040
|
rb_define_method(cT, "rand_norm", sfloat_rand_norm, -1);
|
9041
|
+
/**
|
9042
|
+
* Calculate polynomial.
|
9043
|
+
* `x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
|
9044
|
+
* @overload poly a0, a1, ..., an
|
9045
|
+
* @param [Numo::NArray,Numeric] a0,a1,...,an
|
9046
|
+
* @return [Numo::SFloat]
|
9047
|
+
*/
|
9391
9048
|
rb_define_method(cT, "poly", sfloat_poly, -2);
|
9392
|
-
|
9049
|
+
/**
|
9050
|
+
* sort of self.
|
9051
|
+
* @overload sort(axis:nil, nan:false)
|
9052
|
+
* @param [Boolean] nan If true, propagete NaN. If false, ignore NaN.
|
9053
|
+
* @param [Numeric,Array,Range] axis Performs sort along the axis.
|
9054
|
+
* @return [Numo::SFloat] returns result of sort.
|
9055
|
+
* @example
|
9056
|
+
* Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
|
9057
|
+
*/
|
9393
9058
|
rb_define_method(cT, "sort", sfloat_sort, -1);
|
9394
|
-
|
9059
|
+
/**
|
9060
|
+
* sort_index. Returns an index array of sort result.
|
9061
|
+
* @overload sort_index(axis:nil, nan:false)
|
9062
|
+
* @param [Boolean] nan If true, propagete NaN. If false, ignore NaN.
|
9063
|
+
* @param [Numeric,Array,Range] axis Performs sort_index along the axis.
|
9064
|
+
* @return [Integer,Numo::Int] returns result index of sort_index.
|
9065
|
+
* @example
|
9066
|
+
* Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
|
9067
|
+
*/
|
9395
9068
|
rb_define_method(cT, "sort_index", sfloat_sort_index, -1);
|
9069
|
+
/**
|
9070
|
+
* median of self.
|
9071
|
+
* @overload median(axis:nil, keepdims:false, nan:false)
|
9072
|
+
* @param [Boolean] nan (keyword) If true, propagete NaN. If false, ignore NaN.
|
9073
|
+
* @param [Numeric,Array,Range] axis Finds median along the axis.
|
9074
|
+
* @param [Boolean] keepdims If true, the reduced axes are left
|
9075
|
+
* in the result array as dimensions with size one.
|
9076
|
+
* @return [Numo::SFloat] returns median of self.
|
9077
|
+
*/
|
9396
9078
|
rb_define_method(cT, "median", sfloat_median, -1);
|
9397
|
-
rb_define_singleton_method(cT, "[]", sfloat_s_cast, -2);
|
9398
|
-
|
9399
|
-
/*
|
9400
|
-
Document-module: Numo::SFloat::NMath
|
9401
|
-
|
9402
|
-
*/
|
9403
9079
|
|
9080
|
+
/**
|
9081
|
+
* Document-module: Numo::SFloat::Math
|
9082
|
+
*
|
9083
|
+
* This module contains mathematical functions for Numo::SFloat.
|
9084
|
+
*/
|
9404
9085
|
mTM = rb_define_module_under(cT, "Math");
|
9405
|
-
|
9086
|
+
/**
|
9087
|
+
* Calculate sqrt(x).
|
9088
|
+
* @overload sqrt(x)
|
9089
|
+
* @param [Numo::NArray,Numeric] x input value
|
9090
|
+
* @return [Numo::SFloat] result of sqrt(x).
|
9091
|
+
*/
|
9406
9092
|
rb_define_module_function(mTM, "sqrt", sfloat_math_s_sqrt, 1);
|
9093
|
+
/**
|
9094
|
+
* Calculate cbrt(x).
|
9095
|
+
* @overload cbrt(x)
|
9096
|
+
* @param [Numo::NArray,Numeric] x input value
|
9097
|
+
* @return [Numo::SFloat] result of cbrt(x).
|
9098
|
+
*/
|
9407
9099
|
rb_define_module_function(mTM, "cbrt", sfloat_math_s_cbrt, 1);
|
9100
|
+
/**
|
9101
|
+
* Calculate log(x).
|
9102
|
+
* @overload log(x)
|
9103
|
+
* @param [Numo::NArray,Numeric] x input value
|
9104
|
+
* @return [Numo::SFloat] result of log(x).
|
9105
|
+
*/
|
9408
9106
|
rb_define_module_function(mTM, "log", sfloat_math_s_log, 1);
|
9107
|
+
/**
|
9108
|
+
* Calculate log2(x).
|
9109
|
+
* @overload log2(x)
|
9110
|
+
* @param [Numo::NArray,Numeric] x input value
|
9111
|
+
* @return [Numo::SFloat] result of log2(x).
|
9112
|
+
*/
|
9409
9113
|
rb_define_module_function(mTM, "log2", sfloat_math_s_log2, 1);
|
9114
|
+
/**
|
9115
|
+
* Calculate log10(x).
|
9116
|
+
* @overload log10(x)
|
9117
|
+
* @param [Numo::NArray,Numeric] x input value
|
9118
|
+
* @return [Numo::SFloat] result of log10(x).
|
9119
|
+
*/
|
9410
9120
|
rb_define_module_function(mTM, "log10", sfloat_math_s_log10, 1);
|
9121
|
+
/**
|
9122
|
+
* Calculate exp(x).
|
9123
|
+
* @overload exp(x)
|
9124
|
+
* @param [Numo::NArray,Numeric] x input value
|
9125
|
+
* @return [Numo::SFloat] result of exp(x).
|
9126
|
+
*/
|
9411
9127
|
rb_define_module_function(mTM, "exp", sfloat_math_s_exp, 1);
|
9128
|
+
/**
|
9129
|
+
* Calculate exp2(x).
|
9130
|
+
* @overload exp2(x)
|
9131
|
+
* @param [Numo::NArray,Numeric] x input value
|
9132
|
+
* @return [Numo::SFloat] result of exp2(x).
|
9133
|
+
*/
|
9412
9134
|
rb_define_module_function(mTM, "exp2", sfloat_math_s_exp2, 1);
|
9135
|
+
/**
|
9136
|
+
* Calculate exp10(x).
|
9137
|
+
* @overload exp10(x)
|
9138
|
+
* @param [Numo::NArray,Numeric] x input value
|
9139
|
+
* @return [Numo::SFloat] result of exp10(x).
|
9140
|
+
*/
|
9413
9141
|
rb_define_module_function(mTM, "exp10", sfloat_math_s_exp10, 1);
|
9142
|
+
/**
|
9143
|
+
* Calculate sin(x).
|
9144
|
+
* @overload sin(x)
|
9145
|
+
* @param [Numo::NArray,Numeric] x input value
|
9146
|
+
* @return [Numo::SFloat] result of sin(x).
|
9147
|
+
*/
|
9414
9148
|
rb_define_module_function(mTM, "sin", sfloat_math_s_sin, 1);
|
9149
|
+
/**
|
9150
|
+
* Calculate cos(x).
|
9151
|
+
* @overload cos(x)
|
9152
|
+
* @param [Numo::NArray,Numeric] x input value
|
9153
|
+
* @return [Numo::SFloat] result of cos(x).
|
9154
|
+
*/
|
9415
9155
|
rb_define_module_function(mTM, "cos", sfloat_math_s_cos, 1);
|
9156
|
+
/**
|
9157
|
+
* Calculate tan(x).
|
9158
|
+
* @overload tan(x)
|
9159
|
+
* @param [Numo::NArray,Numeric] x input value
|
9160
|
+
* @return [Numo::SFloat] result of tan(x).
|
9161
|
+
*/
|
9416
9162
|
rb_define_module_function(mTM, "tan", sfloat_math_s_tan, 1);
|
9163
|
+
/**
|
9164
|
+
* Calculate asin(x).
|
9165
|
+
* @overload asin(x)
|
9166
|
+
* @param [Numo::NArray,Numeric] x input value
|
9167
|
+
* @return [Numo::SFloat] result of asin(x).
|
9168
|
+
*/
|
9417
9169
|
rb_define_module_function(mTM, "asin", sfloat_math_s_asin, 1);
|
9170
|
+
/**
|
9171
|
+
* Calculate acos(x).
|
9172
|
+
* @overload acos(x)
|
9173
|
+
* @param [Numo::NArray,Numeric] x input value
|
9174
|
+
* @return [Numo::SFloat] result of acos(x).
|
9175
|
+
*/
|
9418
9176
|
rb_define_module_function(mTM, "acos", sfloat_math_s_acos, 1);
|
9177
|
+
/**
|
9178
|
+
* Calculate atan(x).
|
9179
|
+
* @overload atan(x)
|
9180
|
+
* @param [Numo::NArray,Numeric] x input value
|
9181
|
+
* @return [Numo::SFloat] result of atan(x).
|
9182
|
+
*/
|
9419
9183
|
rb_define_module_function(mTM, "atan", sfloat_math_s_atan, 1);
|
9184
|
+
/**
|
9185
|
+
* Calculate sinh(x).
|
9186
|
+
* @overload sinh(x)
|
9187
|
+
* @param [Numo::NArray,Numeric] x input value
|
9188
|
+
* @return [Numo::SFloat] result of sinh(x).
|
9189
|
+
*/
|
9420
9190
|
rb_define_module_function(mTM, "sinh", sfloat_math_s_sinh, 1);
|
9191
|
+
/**
|
9192
|
+
* Calculate cosh(x).
|
9193
|
+
* @overload cosh(x)
|
9194
|
+
* @param [Numo::NArray,Numeric] x input value
|
9195
|
+
* @return [Numo::SFloat] result of cosh(x).
|
9196
|
+
*/
|
9421
9197
|
rb_define_module_function(mTM, "cosh", sfloat_math_s_cosh, 1);
|
9198
|
+
/**
|
9199
|
+
* Calculate tanh(x).
|
9200
|
+
* @overload tanh(x)
|
9201
|
+
* @param [Numo::NArray,Numeric] x input value
|
9202
|
+
* @return [Numo::SFloat] result of tanh(x).
|
9203
|
+
*/
|
9422
9204
|
rb_define_module_function(mTM, "tanh", sfloat_math_s_tanh, 1);
|
9205
|
+
/**
|
9206
|
+
* Calculate asinh(x).
|
9207
|
+
* @overload asinh(x)
|
9208
|
+
* @param [Numo::NArray,Numeric] x input value
|
9209
|
+
* @return [Numo::SFloat] result of asinh(x).
|
9210
|
+
*/
|
9423
9211
|
rb_define_module_function(mTM, "asinh", sfloat_math_s_asinh, 1);
|
9212
|
+
/**
|
9213
|
+
* Calculate acosh(x).
|
9214
|
+
* @overload acosh(x)
|
9215
|
+
* @param [Numo::NArray,Numeric] x input value
|
9216
|
+
* @return [Numo::SFloat] result of acosh(x).
|
9217
|
+
*/
|
9424
9218
|
rb_define_module_function(mTM, "acosh", sfloat_math_s_acosh, 1);
|
9219
|
+
/**
|
9220
|
+
* Calculate atanh(x).
|
9221
|
+
* @overload atanh(x)
|
9222
|
+
* @param [Numo::NArray,Numeric] x input value
|
9223
|
+
* @return [Numo::SFloat] result of atanh(x).
|
9224
|
+
*/
|
9425
9225
|
rb_define_module_function(mTM, "atanh", sfloat_math_s_atanh, 1);
|
9226
|
+
/**
|
9227
|
+
* Calculate sinc(x).
|
9228
|
+
* @overload sinc(x)
|
9229
|
+
* @param [Numo::NArray,Numeric] x input value
|
9230
|
+
* @return [Numo::SFloat] result of sinc(x).
|
9231
|
+
*/
|
9426
9232
|
rb_define_module_function(mTM, "sinc", sfloat_math_s_sinc, 1);
|
9233
|
+
/**
|
9234
|
+
* Calculate atan2(a1,a2).
|
9235
|
+
* @overload atan2(a1,a2)
|
9236
|
+
* @param [Numo::NArray,Numeric] a1 first value
|
9237
|
+
* @param [Numo::NArray,Numeric] a2 second value
|
9238
|
+
* @return [Numo::SFloat] atan2(a1,a2).
|
9239
|
+
*/
|
9427
9240
|
rb_define_module_function(mTM, "atan2", sfloat_math_s_atan2, 2);
|
9241
|
+
/**
|
9242
|
+
* Calculate hypot(a1,a2).
|
9243
|
+
* @overload hypot(a1,a2)
|
9244
|
+
* @param [Numo::NArray,Numeric] a1 first value
|
9245
|
+
* @param [Numo::NArray,Numeric] a2 second value
|
9246
|
+
* @return [Numo::SFloat] hypot(a1,a2).
|
9247
|
+
*/
|
9428
9248
|
rb_define_module_function(mTM, "hypot", sfloat_math_s_hypot, 2);
|
9249
|
+
/**
|
9250
|
+
* Calculate erf(x).
|
9251
|
+
* @overload erf(x)
|
9252
|
+
* @param [Numo::NArray,Numeric] x input value
|
9253
|
+
* @return [Numo::SFloat] result of erf(x).
|
9254
|
+
*/
|
9429
9255
|
rb_define_module_function(mTM, "erf", sfloat_math_s_erf, 1);
|
9256
|
+
/**
|
9257
|
+
* Calculate erfc(x).
|
9258
|
+
* @overload erfc(x)
|
9259
|
+
* @param [Numo::NArray,Numeric] x input value
|
9260
|
+
* @return [Numo::SFloat] result of erfc(x).
|
9261
|
+
*/
|
9430
9262
|
rb_define_module_function(mTM, "erfc", sfloat_math_s_erfc, 1);
|
9263
|
+
/**
|
9264
|
+
* Calculate log1p(x).
|
9265
|
+
* @overload log1p(x)
|
9266
|
+
* @param [Numo::NArray,Numeric] x input value
|
9267
|
+
* @return [Numo::SFloat] result of log1p(x).
|
9268
|
+
*/
|
9431
9269
|
rb_define_module_function(mTM, "log1p", sfloat_math_s_log1p, 1);
|
9270
|
+
/**
|
9271
|
+
* Calculate expm1(x).
|
9272
|
+
* @overload expm1(x)
|
9273
|
+
* @param [Numo::NArray,Numeric] x input value
|
9274
|
+
* @return [Numo::SFloat] result of expm1(x).
|
9275
|
+
*/
|
9432
9276
|
rb_define_module_function(mTM, "expm1", sfloat_math_s_expm1, 1);
|
9277
|
+
/**
|
9278
|
+
* Calculate ldexp(a1,a2).
|
9279
|
+
* @overload ldexp(a1,a2)
|
9280
|
+
* @param [Numo::NArray,Numeric] a1 first value
|
9281
|
+
* @param [Numo::NArray,Numeric] a2 second value
|
9282
|
+
* @return [Numo::SFloat] ldexp(a1,a2).
|
9283
|
+
*/
|
9433
9284
|
rb_define_module_function(mTM, "ldexp", sfloat_math_s_ldexp, 2);
|
9285
|
+
/**
|
9286
|
+
* split the number x into a normalized fraction and an exponent.
|
9287
|
+
* Returns [mantissa, exponent], where x = mantissa * 2**exponent.
|
9288
|
+
* @overload frexp(x)
|
9289
|
+
* @param [Numo::NArray,Numeric] x
|
9290
|
+
* @return [Numo::SFloat,Numo::Int32] mantissa and exponent.
|
9291
|
+
*/
|
9434
9292
|
rb_define_module_function(mTM, "frexp", sfloat_math_s_frexp, 1);
|
9435
9293
|
|
9436
9294
|
// how to do this?
|