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/dfloat.h>
|
38
38
|
|
39
|
-
VALUE cT;
|
40
|
-
extern VALUE cRT;
|
41
|
-
|
42
39
|
/*
|
43
40
|
class definition: Numo::DFloat
|
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 double dfloat; // Type aliases for shorter notation
|
51
|
+
// following the codebase naming convention.
|
52
|
+
DEF_NARRAY_FLT_MEAN_METHOD_FUNC(dfloat, double, numo_cDFloat, numo_cDFloat)
|
53
|
+
DEF_NARRAY_FLT_VAR_METHOD_FUNC(dfloat, double, numo_cDFloat, numo_cDFloat)
|
54
|
+
DEF_NARRAY_FLT_STDDEV_METHOD_FUNC(dfloat, double, numo_cDFloat, numo_cDFloat)
|
55
|
+
DEF_NARRAY_FLT_RMS_METHOD_FUNC(dfloat, double, numo_cDFloat, numo_cDFloat)
|
47
56
|
|
48
57
|
static VALUE dfloat_store(VALUE, VALUE);
|
49
58
|
|
@@ -148,13 +157,6 @@ static VALUE dfloat_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 dfloat_extract(VALUE self) {
|
159
161
|
volatile VALUE v;
|
160
162
|
char* ptr;
|
@@ -892,12 +894,6 @@ static VALUE dfloat_store_array(VALUE self, VALUE rary) {
|
|
892
894
|
return self;
|
893
895
|
}
|
894
896
|
|
895
|
-
/*
|
896
|
-
Store elements to Numo::DFloat from other.
|
897
|
-
@overload store(other)
|
898
|
-
@param [Object] other
|
899
|
-
@return [Numo::DFloat] self
|
900
|
-
*/
|
901
897
|
static VALUE dfloat_store(VALUE self, VALUE obj) {
|
902
898
|
VALUE r, klass;
|
903
899
|
|
@@ -1104,14 +1100,6 @@ static VALUE dfloat_cast_array(VALUE rary) {
|
|
1104
1100
|
return nary;
|
1105
1101
|
}
|
1106
1102
|
|
1107
|
-
/*
|
1108
|
-
Cast object to Numo::DFloat.
|
1109
|
-
@overload [](elements)
|
1110
|
-
@overload cast(array)
|
1111
|
-
@param [Numeric,Array] elements
|
1112
|
-
@param [Array] array
|
1113
|
-
@return [Numo::DFloat]
|
1114
|
-
*/
|
1115
1103
|
static VALUE dfloat_s_cast(VALUE type, VALUE obj) {
|
1116
1104
|
VALUE v;
|
1117
1105
|
narray_t* na;
|
@@ -1147,15 +1135,6 @@ static VALUE dfloat_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::DFloat] an element or NArray view.
|
1156
|
-
@see Numo::NArray#[]
|
1157
|
-
@see #[]=
|
1158
|
-
*/
|
1159
1138
|
static VALUE dfloat_aref(int argc, VALUE* argv, VALUE self) {
|
1160
1139
|
int nd;
|
1161
1140
|
size_t pos;
|
@@ -1170,16 +1149,6 @@ static VALUE dfloat_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 dfloat_aset(int argc, VALUE* argv, VALUE self) {
|
1184
1153
|
int nd;
|
1185
1154
|
size_t pos;
|
@@ -1204,11 +1173,6 @@ static VALUE dfloat_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 dfloat_coerce_cast(VALUE self, VALUE type) {
|
1213
1177
|
return Qnil;
|
1214
1178
|
}
|
@@ -1239,11 +1203,6 @@ static void iter_dfloat_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 dfloat_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_dfloat_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::DFloat] self.
|
1280
|
-
*/
|
1281
1234
|
static VALUE dfloat_fill(VALUE self, VALUE val) {
|
1282
1235
|
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
|
1283
1236
|
ndfunc_t ndf = { iter_dfloat_fill, FULL_LOOP, 2, 0, ain, 0 };
|
@@ -1326,12 +1279,6 @@ static void iter_dfloat_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 dfloat_format(int argc, VALUE* argv, VALUE self) {
|
1336
1283
|
VALUE fmt = Qnil;
|
1337
1284
|
|
@@ -1373,12 +1320,6 @@ static void iter_dfloat_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 dfloat_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_dfloat_inspect(char* ptr, size_t pos, VALUE fmt) {
|
|
1393
1334
|
return format_dfloat(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 dfloat_inspect(VALUE ary) {
|
1402
1338
|
return na_ndloop_inspect(ary, iter_dfloat_inspect, Qnil);
|
1403
1339
|
}
|
@@ -1426,16 +1362,6 @@ static void iter_dfloat_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 dfloat_each(VALUE self) {
|
1440
1366
|
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1441
1367
|
ndfunc_t ndf = { iter_dfloat_each, FULL_LOOP_NIP, 1, 0, ain, 0 };
|
@@ -1506,11 +1432,6 @@ static void iter_dfloat_map(na_loop_t* const lp) {
|
|
1506
1432
|
}
|
1507
1433
|
}
|
1508
1434
|
|
1509
|
-
/*
|
1510
|
-
Unary map.
|
1511
|
-
@overload map
|
1512
|
-
@return [Numo::DFloat] map of self.
|
1513
|
-
*/
|
1514
1435
|
static VALUE dfloat_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_dfloat_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 dfloat_each_with_index(VALUE self) {
|
1579
1489
|
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1580
1490
|
ndfunc_t ndf = { iter_dfloat_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0 };
|
@@ -1653,19 +1563,6 @@ static void iter_dfloat_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 dfloat_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_dfloat_abs(na_loop_t* const lp) {
|
|
1715
1612
|
}
|
1716
1613
|
}
|
1717
1614
|
|
1718
|
-
/*
|
1719
|
-
abs of self.
|
1720
|
-
@overload abs
|
1721
|
-
@return [Numo::DFloat] abs of self.
|
1722
|
-
*/
|
1723
1615
|
static VALUE dfloat_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 dfloat_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_dfloat_add(na_loop_t* const lp) {
|
@@ -1946,12 +1838,6 @@ static VALUE dfloat_add_self(VALUE self, VALUE other) {
|
|
1946
1838
|
return na_ndloop(&ndf, 2, self, other);
|
1947
1839
|
}
|
1948
1840
|
|
1949
|
-
/*
|
1950
|
-
Binary add.
|
1951
|
-
@overload + other
|
1952
|
-
@param [Numo::NArray,Numeric] other
|
1953
|
-
@return [Numo::NArray] self + other
|
1954
|
-
*/
|
1955
1841
|
static VALUE dfloat_add(VALUE self, VALUE other) {
|
1956
1842
|
|
1957
1843
|
VALUE klass, v;
|
@@ -1965,7 +1851,7 @@ static VALUE dfloat_add(VALUE self, VALUE other) {
|
|
1965
1851
|
}
|
1966
1852
|
}
|
1967
1853
|
|
1968
|
-
#define check_intdivzero(y)
|
1854
|
+
#define check_intdivzero(y) \
|
1969
1855
|
{}
|
1970
1856
|
|
1971
1857
|
static void iter_dfloat_sub(na_loop_t* const lp) {
|
@@ -2185,12 +2071,6 @@ static VALUE dfloat_sub_self(VALUE self, VALUE other) {
|
|
2185
2071
|
return na_ndloop(&ndf, 2, self, other);
|
2186
2072
|
}
|
2187
2073
|
|
2188
|
-
/*
|
2189
|
-
Binary sub.
|
2190
|
-
@overload - other
|
2191
|
-
@param [Numo::NArray,Numeric] other
|
2192
|
-
@return [Numo::NArray] self - other
|
2193
|
-
*/
|
2194
2074
|
static VALUE dfloat_sub(VALUE self, VALUE other) {
|
2195
2075
|
|
2196
2076
|
VALUE klass, v;
|
@@ -2204,7 +2084,7 @@ static VALUE dfloat_sub(VALUE self, VALUE other) {
|
|
2204
2084
|
}
|
2205
2085
|
}
|
2206
2086
|
|
2207
|
-
#define check_intdivzero(y)
|
2087
|
+
#define check_intdivzero(y) \
|
2208
2088
|
{}
|
2209
2089
|
|
2210
2090
|
static void iter_dfloat_mul(na_loop_t* const lp) {
|
@@ -2424,12 +2304,6 @@ static VALUE dfloat_mul_self(VALUE self, VALUE other) {
|
|
2424
2304
|
return na_ndloop(&ndf, 2, self, other);
|
2425
2305
|
}
|
2426
2306
|
|
2427
|
-
/*
|
2428
|
-
Binary mul.
|
2429
|
-
@overload * other
|
2430
|
-
@param [Numo::NArray,Numeric] other
|
2431
|
-
@return [Numo::NArray] self * other
|
2432
|
-
*/
|
2433
2307
|
static VALUE dfloat_mul(VALUE self, VALUE other) {
|
2434
2308
|
|
2435
2309
|
VALUE klass, v;
|
@@ -2443,7 +2317,7 @@ static VALUE dfloat_mul(VALUE self, VALUE other) {
|
|
2443
2317
|
}
|
2444
2318
|
}
|
2445
2319
|
|
2446
|
-
#define check_intdivzero(y)
|
2320
|
+
#define check_intdivzero(y) \
|
2447
2321
|
{}
|
2448
2322
|
|
2449
2323
|
static void iter_dfloat_div(na_loop_t* const lp) {
|
@@ -2663,12 +2537,6 @@ static VALUE dfloat_div_self(VALUE self, VALUE other) {
|
|
2663
2537
|
return na_ndloop(&ndf, 2, self, other);
|
2664
2538
|
}
|
2665
2539
|
|
2666
|
-
/*
|
2667
|
-
Binary div.
|
2668
|
-
@overload / other
|
2669
|
-
@param [Numo::NArray,Numeric] other
|
2670
|
-
@return [Numo::NArray] self / other
|
2671
|
-
*/
|
2672
2540
|
static VALUE dfloat_div(VALUE self, VALUE other) {
|
2673
2541
|
|
2674
2542
|
VALUE klass, v;
|
@@ -2682,7 +2550,7 @@ static VALUE dfloat_div(VALUE self, VALUE other) {
|
|
2682
2550
|
}
|
2683
2551
|
}
|
2684
2552
|
|
2685
|
-
#define check_intdivzero(y)
|
2553
|
+
#define check_intdivzero(y) \
|
2686
2554
|
{}
|
2687
2555
|
|
2688
2556
|
static void iter_dfloat_mod(na_loop_t* const lp) {
|
@@ -2781,12 +2649,6 @@ static VALUE dfloat_mod_self(VALUE self, VALUE other) {
|
|
2781
2649
|
return na_ndloop(&ndf, 2, self, other);
|
2782
2650
|
}
|
2783
2651
|
|
2784
|
-
/*
|
2785
|
-
Binary mod.
|
2786
|
-
@overload % other
|
2787
|
-
@param [Numo::NArray,Numeric] other
|
2788
|
-
@return [Numo::NArray] self % other
|
2789
|
-
*/
|
2790
2652
|
static VALUE dfloat_mod(VALUE self, VALUE other) {
|
2791
2653
|
|
2792
2654
|
VALUE klass, v;
|
@@ -2827,12 +2689,6 @@ static VALUE dfloat_divmod_self(VALUE self, VALUE other) {
|
|
2827
2689
|
return na_ndloop(&ndf, 2, self, other);
|
2828
2690
|
}
|
2829
2691
|
|
2830
|
-
/*
|
2831
|
-
Binary divmod.
|
2832
|
-
@overload divmod other
|
2833
|
-
@param [Numo::NArray,Numeric] other
|
2834
|
-
@return [Numo::NArray] divmod of self and other.
|
2835
|
-
*/
|
2836
2692
|
static VALUE dfloat_divmod(VALUE self, VALUE other) {
|
2837
2693
|
|
2838
2694
|
VALUE klass, v;
|
@@ -2895,12 +2751,6 @@ static VALUE dfloat_pow_self(VALUE self, VALUE other) {
|
|
2895
2751
|
}
|
2896
2752
|
}
|
2897
2753
|
|
2898
|
-
/*
|
2899
|
-
Binary power.
|
2900
|
-
@overload ** other
|
2901
|
-
@param [Numo::NArray,Numeric] other
|
2902
|
-
@return [Numo::NArray] self to the other-th power.
|
2903
|
-
*/
|
2904
2754
|
static VALUE dfloat_pow(VALUE self, VALUE other) {
|
2905
2755
|
|
2906
2756
|
VALUE klass, v;
|
@@ -2975,11 +2825,6 @@ static void iter_dfloat_minus(na_loop_t* const lp) {
|
|
2975
2825
|
}
|
2976
2826
|
}
|
2977
2827
|
|
2978
|
-
/*
|
2979
|
-
Unary minus.
|
2980
|
-
@overload -@
|
2981
|
-
@return [Numo::DFloat] minus of self.
|
2982
|
-
*/
|
2983
2828
|
static VALUE dfloat_minus(VALUE self) {
|
2984
2829
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2985
2830
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3050,11 +2895,6 @@ static void iter_dfloat_reciprocal(na_loop_t* const lp) {
|
|
3050
2895
|
}
|
3051
2896
|
}
|
3052
2897
|
|
3053
|
-
/*
|
3054
|
-
Unary reciprocal.
|
3055
|
-
@overload reciprocal
|
3056
|
-
@return [Numo::DFloat] reciprocal of self.
|
3057
|
-
*/
|
3058
2898
|
static VALUE dfloat_reciprocal(VALUE self) {
|
3059
2899
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3060
2900
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3125,11 +2965,6 @@ static void iter_dfloat_sign(na_loop_t* const lp) {
|
|
3125
2965
|
}
|
3126
2966
|
}
|
3127
2967
|
|
3128
|
-
/*
|
3129
|
-
Unary sign.
|
3130
|
-
@overload sign
|
3131
|
-
@return [Numo::DFloat] sign of self.
|
3132
|
-
*/
|
3133
2968
|
static VALUE dfloat_sign(VALUE self) {
|
3134
2969
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3135
2970
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3200,11 +3035,6 @@ static void iter_dfloat_square(na_loop_t* const lp) {
|
|
3200
3035
|
}
|
3201
3036
|
}
|
3202
3037
|
|
3203
|
-
/*
|
3204
|
-
Unary square.
|
3205
|
-
@overload square
|
3206
|
-
@return [Numo::DFloat] square of self.
|
3207
|
-
*/
|
3208
3038
|
static VALUE dfloat_square(VALUE self) {
|
3209
3039
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3210
3040
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3242,12 +3072,6 @@ static VALUE dfloat_eq_self(VALUE self, VALUE other) {
|
|
3242
3072
|
return na_ndloop(&ndf, 2, self, other);
|
3243
3073
|
}
|
3244
3074
|
|
3245
|
-
/*
|
3246
|
-
Comparison eq other.
|
3247
|
-
@overload eq other
|
3248
|
-
@param [Numo::NArray,Numeric] other
|
3249
|
-
@return [Numo::Bit] result of self eq other.
|
3250
|
-
*/
|
3251
3075
|
static VALUE dfloat_eq(VALUE self, VALUE other) {
|
3252
3076
|
|
3253
3077
|
VALUE klass, v;
|
@@ -3289,12 +3113,6 @@ static VALUE dfloat_ne_self(VALUE self, VALUE other) {
|
|
3289
3113
|
return na_ndloop(&ndf, 2, self, other);
|
3290
3114
|
}
|
3291
3115
|
|
3292
|
-
/*
|
3293
|
-
Comparison ne other.
|
3294
|
-
@overload ne other
|
3295
|
-
@param [Numo::NArray,Numeric] other
|
3296
|
-
@return [Numo::Bit] result of self ne other.
|
3297
|
-
*/
|
3298
3116
|
static VALUE dfloat_ne(VALUE self, VALUE other) {
|
3299
3117
|
|
3300
3118
|
VALUE klass, v;
|
@@ -3336,12 +3154,6 @@ static VALUE dfloat_nearly_eq_self(VALUE self, VALUE other) {
|
|
3336
3154
|
return na_ndloop(&ndf, 2, self, other);
|
3337
3155
|
}
|
3338
3156
|
|
3339
|
-
/*
|
3340
|
-
Comparison nearly_eq other.
|
3341
|
-
@overload nearly_eq other
|
3342
|
-
@param [Numo::NArray,Numeric] other
|
3343
|
-
@return [Numo::Bit] result of self nearly_eq other.
|
3344
|
-
*/
|
3345
3157
|
static VALUE dfloat_nearly_eq(VALUE self, VALUE other) {
|
3346
3158
|
|
3347
3159
|
VALUE klass, v;
|
@@ -3416,11 +3228,6 @@ static void iter_dfloat_floor(na_loop_t* const lp) {
|
|
3416
3228
|
}
|
3417
3229
|
}
|
3418
3230
|
|
3419
|
-
/*
|
3420
|
-
Unary floor.
|
3421
|
-
@overload floor
|
3422
|
-
@return [Numo::DFloat] floor of self.
|
3423
|
-
*/
|
3424
3231
|
static VALUE dfloat_floor(VALUE self) {
|
3425
3232
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3426
3233
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3491,11 +3298,6 @@ static void iter_dfloat_round(na_loop_t* const lp) {
|
|
3491
3298
|
}
|
3492
3299
|
}
|
3493
3300
|
|
3494
|
-
/*
|
3495
|
-
Unary round.
|
3496
|
-
@overload round
|
3497
|
-
@return [Numo::DFloat] round of self.
|
3498
|
-
*/
|
3499
3301
|
static VALUE dfloat_round(VALUE self) {
|
3500
3302
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3501
3303
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3566,11 +3368,6 @@ static void iter_dfloat_ceil(na_loop_t* const lp) {
|
|
3566
3368
|
}
|
3567
3369
|
}
|
3568
3370
|
|
3569
|
-
/*
|
3570
|
-
Unary ceil.
|
3571
|
-
@overload ceil
|
3572
|
-
@return [Numo::DFloat] ceil of self.
|
3573
|
-
*/
|
3574
3371
|
static VALUE dfloat_ceil(VALUE self) {
|
3575
3372
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3576
3373
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3641,11 +3438,6 @@ static void iter_dfloat_trunc(na_loop_t* const lp) {
|
|
3641
3438
|
}
|
3642
3439
|
}
|
3643
3440
|
|
3644
|
-
/*
|
3645
|
-
Unary trunc.
|
3646
|
-
@overload trunc
|
3647
|
-
@return [Numo::DFloat] trunc of self.
|
3648
|
-
*/
|
3649
3441
|
static VALUE dfloat_trunc(VALUE self) {
|
3650
3442
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3651
3443
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3716,11 +3508,6 @@ static void iter_dfloat_rint(na_loop_t* const lp) {
|
|
3716
3508
|
}
|
3717
3509
|
}
|
3718
3510
|
|
3719
|
-
/*
|
3720
|
-
Unary rint.
|
3721
|
-
@overload rint
|
3722
|
-
@return [Numo::DFloat] rint of self.
|
3723
|
-
*/
|
3724
3511
|
static VALUE dfloat_rint(VALUE self) {
|
3725
3512
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3726
3513
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -3729,7 +3516,7 @@ static VALUE dfloat_rint(VALUE self) {
|
|
3729
3516
|
return na_ndloop(&ndf, 1, self);
|
3730
3517
|
}
|
3731
3518
|
|
3732
|
-
#define check_intdivzero(y)
|
3519
|
+
#define check_intdivzero(y) \
|
3733
3520
|
{}
|
3734
3521
|
|
3735
3522
|
static void iter_dfloat_copysign(na_loop_t* const lp) {
|
@@ -3828,12 +3615,6 @@ static VALUE dfloat_copysign_self(VALUE self, VALUE other) {
|
|
3828
3615
|
return na_ndloop(&ndf, 2, self, other);
|
3829
3616
|
}
|
3830
3617
|
|
3831
|
-
/*
|
3832
|
-
Binary copysign.
|
3833
|
-
@overload copysign other
|
3834
|
-
@param [Numo::NArray,Numeric] other
|
3835
|
-
@return [Numo::NArray] self copysign other
|
3836
|
-
*/
|
3837
3618
|
static VALUE dfloat_copysign(VALUE self, VALUE other) {
|
3838
3619
|
|
3839
3620
|
VALUE klass, v;
|
@@ -3876,11 +3657,6 @@ static void iter_dfloat_signbit(na_loop_t* const lp) {
|
|
3876
3657
|
}
|
3877
3658
|
}
|
3878
3659
|
|
3879
|
-
/*
|
3880
|
-
Condition of signbit.
|
3881
|
-
@overload signbit
|
3882
|
-
@return [Numo::Bit] Condition of signbit.
|
3883
|
-
*/
|
3884
3660
|
static VALUE dfloat_signbit(VALUE self) {
|
3885
3661
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3886
3662
|
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
@@ -3906,11 +3682,6 @@ static void iter_dfloat_modf(na_loop_t* const lp) {
|
|
3906
3682
|
}
|
3907
3683
|
}
|
3908
3684
|
|
3909
|
-
/*
|
3910
|
-
modf of self.
|
3911
|
-
@overload modf
|
3912
|
-
@return [Numo::DFloat] modf of self.
|
3913
|
-
*/
|
3914
3685
|
static VALUE dfloat_modf(VALUE self) {
|
3915
3686
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3916
3687
|
ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
|
@@ -3948,12 +3719,6 @@ static VALUE dfloat_gt_self(VALUE self, VALUE other) {
|
|
3948
3719
|
return na_ndloop(&ndf, 2, self, other);
|
3949
3720
|
}
|
3950
3721
|
|
3951
|
-
/*
|
3952
|
-
Comparison gt other.
|
3953
|
-
@overload gt other
|
3954
|
-
@param [Numo::NArray,Numeric] other
|
3955
|
-
@return [Numo::Bit] result of self gt other.
|
3956
|
-
*/
|
3957
3722
|
static VALUE dfloat_gt(VALUE self, VALUE other) {
|
3958
3723
|
|
3959
3724
|
VALUE klass, v;
|
@@ -3995,12 +3760,6 @@ static VALUE dfloat_ge_self(VALUE self, VALUE other) {
|
|
3995
3760
|
return na_ndloop(&ndf, 2, self, other);
|
3996
3761
|
}
|
3997
3762
|
|
3998
|
-
/*
|
3999
|
-
Comparison ge other.
|
4000
|
-
@overload ge other
|
4001
|
-
@param [Numo::NArray,Numeric] other
|
4002
|
-
@return [Numo::Bit] result of self ge other.
|
4003
|
-
*/
|
4004
3763
|
static VALUE dfloat_ge(VALUE self, VALUE other) {
|
4005
3764
|
|
4006
3765
|
VALUE klass, v;
|
@@ -4042,12 +3801,6 @@ static VALUE dfloat_lt_self(VALUE self, VALUE other) {
|
|
4042
3801
|
return na_ndloop(&ndf, 2, self, other);
|
4043
3802
|
}
|
4044
3803
|
|
4045
|
-
/*
|
4046
|
-
Comparison lt other.
|
4047
|
-
@overload lt other
|
4048
|
-
@param [Numo::NArray,Numeric] other
|
4049
|
-
@return [Numo::Bit] result of self lt other.
|
4050
|
-
*/
|
4051
3804
|
static VALUE dfloat_lt(VALUE self, VALUE other) {
|
4052
3805
|
|
4053
3806
|
VALUE klass, v;
|
@@ -4089,12 +3842,6 @@ static VALUE dfloat_le_self(VALUE self, VALUE other) {
|
|
4089
3842
|
return na_ndloop(&ndf, 2, self, other);
|
4090
3843
|
}
|
4091
3844
|
|
4092
|
-
/*
|
4093
|
-
Comparison le other.
|
4094
|
-
@overload le other
|
4095
|
-
@param [Numo::NArray,Numeric] other
|
4096
|
-
@return [Numo::Bit] result of self le other.
|
4097
|
-
*/
|
4098
3845
|
static VALUE dfloat_le(VALUE self, VALUE other) {
|
4099
3846
|
|
4100
3847
|
VALUE klass, v;
|
@@ -4172,36 +3919,6 @@ static void iter_dfloat_clip_max(na_loop_t* const lp) {
|
|
4172
3919
|
}
|
4173
3920
|
}
|
4174
3921
|
|
4175
|
-
/*
|
4176
|
-
Clip array elements by [min,max].
|
4177
|
-
If either of min or max is nil, one side is clipped.
|
4178
|
-
@overload clip(min,max)
|
4179
|
-
@param [Numo::NArray,Numeric] min
|
4180
|
-
@param [Numo::NArray,Numeric] max
|
4181
|
-
@return [Numo::NArray] result of clip.
|
4182
|
-
|
4183
|
-
@example
|
4184
|
-
a = Numo::Int32.new(10).seq
|
4185
|
-
# => Numo::Int32#shape=[10]
|
4186
|
-
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
4187
|
-
|
4188
|
-
a.clip(1,8)
|
4189
|
-
# => Numo::Int32#shape=[10]
|
4190
|
-
# [1, 1, 2, 3, 4, 5, 6, 7, 8, 8]
|
4191
|
-
|
4192
|
-
a.inplace.clip(3,6)
|
4193
|
-
a
|
4194
|
-
# => Numo::Int32#shape=[10]
|
4195
|
-
# [3, 3, 3, 3, 4, 5, 6, 6, 6, 6]
|
4196
|
-
|
4197
|
-
b = Numo::Int32.new(10).seq
|
4198
|
-
# => Numo::Int32#shape=[10]
|
4199
|
-
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
4200
|
-
|
4201
|
-
b.clip([3,4,1,1,1,4,4,4,4,4], 8)
|
4202
|
-
# => Numo::Int32#shape=[10]
|
4203
|
-
# [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]
|
4204
|
-
*/
|
4205
3922
|
static VALUE dfloat_clip(VALUE self, VALUE min, VALUE max) {
|
4206
3923
|
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { cT, 0 }, { cT, 0 } };
|
4207
3924
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -4253,11 +3970,6 @@ static void iter_dfloat_isnan(na_loop_t* const lp) {
|
|
4253
3970
|
}
|
4254
3971
|
}
|
4255
3972
|
|
4256
|
-
/*
|
4257
|
-
Condition of isnan.
|
4258
|
-
@overload isnan
|
4259
|
-
@return [Numo::Bit] Condition of isnan.
|
4260
|
-
*/
|
4261
3973
|
static VALUE dfloat_isnan(VALUE self) {
|
4262
3974
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4263
3975
|
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
@@ -4295,11 +4007,6 @@ static void iter_dfloat_isinf(na_loop_t* const lp) {
|
|
4295
4007
|
}
|
4296
4008
|
}
|
4297
4009
|
|
4298
|
-
/*
|
4299
|
-
Condition of isinf.
|
4300
|
-
@overload isinf
|
4301
|
-
@return [Numo::Bit] Condition of isinf.
|
4302
|
-
*/
|
4303
4010
|
static VALUE dfloat_isinf(VALUE self) {
|
4304
4011
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4305
4012
|
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
@@ -4337,11 +4044,6 @@ static void iter_dfloat_isposinf(na_loop_t* const lp) {
|
|
4337
4044
|
}
|
4338
4045
|
}
|
4339
4046
|
|
4340
|
-
/*
|
4341
|
-
Condition of isposinf.
|
4342
|
-
@overload isposinf
|
4343
|
-
@return [Numo::Bit] Condition of isposinf.
|
4344
|
-
*/
|
4345
4047
|
static VALUE dfloat_isposinf(VALUE self) {
|
4346
4048
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4347
4049
|
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
@@ -4379,11 +4081,6 @@ static void iter_dfloat_isneginf(na_loop_t* const lp) {
|
|
4379
4081
|
}
|
4380
4082
|
}
|
4381
4083
|
|
4382
|
-
/*
|
4383
|
-
Condition of isneginf.
|
4384
|
-
@overload isneginf
|
4385
|
-
@return [Numo::Bit] Condition of isneginf.
|
4386
|
-
*/
|
4387
4084
|
static VALUE dfloat_isneginf(VALUE self) {
|
4388
4085
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4389
4086
|
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
@@ -4421,11 +4118,6 @@ static void iter_dfloat_isfinite(na_loop_t* const lp) {
|
|
4421
4118
|
}
|
4422
4119
|
}
|
4423
4120
|
|
4424
|
-
/*
|
4425
|
-
Condition of isfinite.
|
4426
|
-
@overload isfinite
|
4427
|
-
@return [Numo::Bit] Condition of isfinite.
|
4428
|
-
*/
|
4429
4121
|
static VALUE dfloat_isfinite(VALUE self) {
|
4430
4122
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4431
4123
|
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
@@ -4457,16 +4149,6 @@ static void iter_dfloat_sum_nan(na_loop_t* const lp) {
|
|
4457
4149
|
*(dtype*)p2 = f_sum_nan(n, p1, s1);
|
4458
4150
|
}
|
4459
4151
|
|
4460
|
-
/*
|
4461
|
-
sum of self.
|
4462
|
-
@overload sum(axis:nil, keepdims:false, nan:false)
|
4463
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4464
|
-
return NaN for min/max etc).
|
4465
|
-
@param [Numeric,Array,Range] axis Performs sum along the axis.
|
4466
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4467
|
-
dimensions with size one.
|
4468
|
-
@return [Numo::DFloat] returns result of sum.
|
4469
|
-
*/
|
4470
4152
|
static VALUE dfloat_sum(int argc, VALUE* argv, VALUE self) {
|
4471
4153
|
VALUE v, reduce;
|
4472
4154
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -4503,16 +4185,6 @@ static void iter_dfloat_prod_nan(na_loop_t* const lp) {
|
|
4503
4185
|
*(dtype*)p2 = f_prod_nan(n, p1, s1);
|
4504
4186
|
}
|
4505
4187
|
|
4506
|
-
/*
|
4507
|
-
prod of self.
|
4508
|
-
@overload prod(axis:nil, keepdims:false, nan:false)
|
4509
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4510
|
-
return NaN for min/max etc).
|
4511
|
-
@param [Numeric,Array,Range] axis Performs prod along the axis.
|
4512
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4513
|
-
dimensions with size one.
|
4514
|
-
@return [Numo::DFloat] returns result of prod.
|
4515
|
-
*/
|
4516
4188
|
static VALUE dfloat_prod(int argc, VALUE* argv, VALUE self) {
|
4517
4189
|
VALUE v, reduce;
|
4518
4190
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -4549,16 +4221,6 @@ static void iter_dfloat_kahan_sum_nan(na_loop_t* const lp) {
|
|
4549
4221
|
*(dtype*)p2 = f_kahan_sum_nan(n, p1, s1);
|
4550
4222
|
}
|
4551
4223
|
|
4552
|
-
/*
|
4553
|
-
kahan_sum of self.
|
4554
|
-
@overload kahan_sum(axis:nil, keepdims:false, nan:false)
|
4555
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4556
|
-
return NaN for min/max etc).
|
4557
|
-
@param [Numeric,Array,Range] axis Performs kahan_sum along the axis.
|
4558
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4559
|
-
dimensions with size one.
|
4560
|
-
@return [Numo::DFloat] returns result of kahan_sum.
|
4561
|
-
*/
|
4562
4224
|
static VALUE dfloat_kahan_sum(int argc, VALUE* argv, VALUE self) {
|
4563
4225
|
VALUE v, reduce;
|
4564
4226
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -4572,190 +4234,6 @@ static VALUE dfloat_kahan_sum(int argc, VALUE* argv, VALUE self) {
|
|
4572
4234
|
return dfloat_extract(v);
|
4573
4235
|
}
|
4574
4236
|
|
4575
|
-
static void iter_dfloat_mean(na_loop_t* const lp) {
|
4576
|
-
size_t n;
|
4577
|
-
char *p1, *p2;
|
4578
|
-
ssize_t s1;
|
4579
|
-
|
4580
|
-
INIT_COUNTER(lp, n);
|
4581
|
-
INIT_PTR(lp, 0, p1, s1);
|
4582
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4583
|
-
|
4584
|
-
*(dtype*)p2 = f_mean(n, p1, s1);
|
4585
|
-
}
|
4586
|
-
static void iter_dfloat_mean_nan(na_loop_t* const lp) {
|
4587
|
-
size_t n;
|
4588
|
-
char *p1, *p2;
|
4589
|
-
ssize_t s1;
|
4590
|
-
|
4591
|
-
INIT_COUNTER(lp, n);
|
4592
|
-
INIT_PTR(lp, 0, p1, s1);
|
4593
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4594
|
-
|
4595
|
-
*(dtype*)p2 = f_mean_nan(n, p1, s1);
|
4596
|
-
}
|
4597
|
-
|
4598
|
-
/*
|
4599
|
-
mean of self.
|
4600
|
-
@overload mean(axis:nil, keepdims:false, nan:false)
|
4601
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4602
|
-
return NaN for min/max etc).
|
4603
|
-
@param [Numeric,Array,Range] axis Performs mean along the axis.
|
4604
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4605
|
-
dimensions with size one.
|
4606
|
-
@return [Numo::DFloat] returns result of mean.
|
4607
|
-
*/
|
4608
|
-
static VALUE dfloat_mean(int argc, VALUE* argv, VALUE self) {
|
4609
|
-
VALUE v, reduce;
|
4610
|
-
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4611
|
-
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4612
|
-
ndfunc_t ndf = { iter_dfloat_mean, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4613
|
-
|
4614
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_mean_nan);
|
4615
|
-
|
4616
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4617
|
-
|
4618
|
-
return dfloat_extract(v);
|
4619
|
-
}
|
4620
|
-
|
4621
|
-
static void iter_dfloat_stddev(na_loop_t* const lp) {
|
4622
|
-
size_t n;
|
4623
|
-
char *p1, *p2;
|
4624
|
-
ssize_t s1;
|
4625
|
-
|
4626
|
-
INIT_COUNTER(lp, n);
|
4627
|
-
INIT_PTR(lp, 0, p1, s1);
|
4628
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4629
|
-
|
4630
|
-
*(rtype*)p2 = f_stddev(n, p1, s1);
|
4631
|
-
}
|
4632
|
-
static void iter_dfloat_stddev_nan(na_loop_t* const lp) {
|
4633
|
-
size_t n;
|
4634
|
-
char *p1, *p2;
|
4635
|
-
ssize_t s1;
|
4636
|
-
|
4637
|
-
INIT_COUNTER(lp, n);
|
4638
|
-
INIT_PTR(lp, 0, p1, s1);
|
4639
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4640
|
-
|
4641
|
-
*(rtype*)p2 = f_stddev_nan(n, p1, s1);
|
4642
|
-
}
|
4643
|
-
|
4644
|
-
/*
|
4645
|
-
stddev of self.
|
4646
|
-
@overload stddev(axis:nil, keepdims:false, nan:false)
|
4647
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4648
|
-
return NaN for min/max etc).
|
4649
|
-
@param [Numeric,Array,Range] axis Performs stddev along the axis.
|
4650
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4651
|
-
dimensions with size one.
|
4652
|
-
@return [Numo::DFloat] returns result of stddev.
|
4653
|
-
*/
|
4654
|
-
static VALUE dfloat_stddev(int argc, VALUE* argv, VALUE self) {
|
4655
|
-
VALUE v, reduce;
|
4656
|
-
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4657
|
-
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
4658
|
-
ndfunc_t ndf = { iter_dfloat_stddev, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4659
|
-
|
4660
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_stddev_nan);
|
4661
|
-
|
4662
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4663
|
-
|
4664
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
4665
|
-
}
|
4666
|
-
|
4667
|
-
static void iter_dfloat_var(na_loop_t* const lp) {
|
4668
|
-
size_t n;
|
4669
|
-
char *p1, *p2;
|
4670
|
-
ssize_t s1;
|
4671
|
-
|
4672
|
-
INIT_COUNTER(lp, n);
|
4673
|
-
INIT_PTR(lp, 0, p1, s1);
|
4674
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4675
|
-
|
4676
|
-
*(rtype*)p2 = f_var(n, p1, s1);
|
4677
|
-
}
|
4678
|
-
static void iter_dfloat_var_nan(na_loop_t* const lp) {
|
4679
|
-
size_t n;
|
4680
|
-
char *p1, *p2;
|
4681
|
-
ssize_t s1;
|
4682
|
-
|
4683
|
-
INIT_COUNTER(lp, n);
|
4684
|
-
INIT_PTR(lp, 0, p1, s1);
|
4685
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4686
|
-
|
4687
|
-
*(rtype*)p2 = f_var_nan(n, p1, s1);
|
4688
|
-
}
|
4689
|
-
|
4690
|
-
/*
|
4691
|
-
var of self.
|
4692
|
-
@overload var(axis:nil, keepdims:false, nan:false)
|
4693
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4694
|
-
return NaN for min/max etc).
|
4695
|
-
@param [Numeric,Array,Range] axis Performs var along the axis.
|
4696
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4697
|
-
dimensions with size one.
|
4698
|
-
@return [Numo::DFloat] returns result of var.
|
4699
|
-
*/
|
4700
|
-
static VALUE dfloat_var(int argc, VALUE* argv, VALUE self) {
|
4701
|
-
VALUE v, reduce;
|
4702
|
-
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4703
|
-
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
4704
|
-
ndfunc_t ndf = { iter_dfloat_var, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4705
|
-
|
4706
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_var_nan);
|
4707
|
-
|
4708
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4709
|
-
|
4710
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
4711
|
-
}
|
4712
|
-
|
4713
|
-
static void iter_dfloat_rms(na_loop_t* const lp) {
|
4714
|
-
size_t n;
|
4715
|
-
char *p1, *p2;
|
4716
|
-
ssize_t s1;
|
4717
|
-
|
4718
|
-
INIT_COUNTER(lp, n);
|
4719
|
-
INIT_PTR(lp, 0, p1, s1);
|
4720
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4721
|
-
|
4722
|
-
*(rtype*)p2 = f_rms(n, p1, s1);
|
4723
|
-
}
|
4724
|
-
static void iter_dfloat_rms_nan(na_loop_t* const lp) {
|
4725
|
-
size_t n;
|
4726
|
-
char *p1, *p2;
|
4727
|
-
ssize_t s1;
|
4728
|
-
|
4729
|
-
INIT_COUNTER(lp, n);
|
4730
|
-
INIT_PTR(lp, 0, p1, s1);
|
4731
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4732
|
-
|
4733
|
-
*(rtype*)p2 = f_rms_nan(n, p1, s1);
|
4734
|
-
}
|
4735
|
-
|
4736
|
-
/*
|
4737
|
-
rms of self.
|
4738
|
-
@overload rms(axis:nil, keepdims:false, nan:false)
|
4739
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4740
|
-
return NaN for min/max etc).
|
4741
|
-
@param [Numeric,Array,Range] axis Performs rms along the axis.
|
4742
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4743
|
-
dimensions with size one.
|
4744
|
-
@return [Numo::DFloat] returns result of rms.
|
4745
|
-
*/
|
4746
|
-
static VALUE dfloat_rms(int argc, VALUE* argv, VALUE self) {
|
4747
|
-
VALUE v, reduce;
|
4748
|
-
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4749
|
-
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
4750
|
-
ndfunc_t ndf = { iter_dfloat_rms, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4751
|
-
|
4752
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_dfloat_rms_nan);
|
4753
|
-
|
4754
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4755
|
-
|
4756
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
4757
|
-
}
|
4758
|
-
|
4759
4237
|
static void iter_dfloat_min(na_loop_t* const lp) {
|
4760
4238
|
size_t n;
|
4761
4239
|
char *p1, *p2;
|
@@ -4779,16 +4257,6 @@ static void iter_dfloat_min_nan(na_loop_t* const lp) {
|
|
4779
4257
|
*(dtype*)p2 = f_min_nan(n, p1, s1);
|
4780
4258
|
}
|
4781
4259
|
|
4782
|
-
/*
|
4783
|
-
min of self.
|
4784
|
-
@overload min(axis:nil, keepdims:false, nan:false)
|
4785
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4786
|
-
return NaN for min/max etc).
|
4787
|
-
@param [Numeric,Array,Range] axis Performs min along the axis.
|
4788
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4789
|
-
dimensions with size one.
|
4790
|
-
@return [Numo::DFloat] returns result of min.
|
4791
|
-
*/
|
4792
4260
|
static VALUE dfloat_min(int argc, VALUE* argv, VALUE self) {
|
4793
4261
|
VALUE v, reduce;
|
4794
4262
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -4825,16 +4293,6 @@ static void iter_dfloat_max_nan(na_loop_t* const lp) {
|
|
4825
4293
|
*(dtype*)p2 = f_max_nan(n, p1, s1);
|
4826
4294
|
}
|
4827
4295
|
|
4828
|
-
/*
|
4829
|
-
max of self.
|
4830
|
-
@overload max(axis:nil, keepdims:false, nan:false)
|
4831
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4832
|
-
return NaN for min/max etc).
|
4833
|
-
@param [Numeric,Array,Range] axis Performs max along the axis.
|
4834
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4835
|
-
dimensions with size one.
|
4836
|
-
@return [Numo::DFloat] returns result of max.
|
4837
|
-
*/
|
4838
4296
|
static VALUE dfloat_max(int argc, VALUE* argv, VALUE self) {
|
4839
4297
|
VALUE v, reduce;
|
4840
4298
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -4871,16 +4329,6 @@ static void iter_dfloat_ptp_nan(na_loop_t* const lp) {
|
|
4871
4329
|
*(dtype*)p2 = f_ptp_nan(n, p1, s1);
|
4872
4330
|
}
|
4873
4331
|
|
4874
|
-
/*
|
4875
|
-
ptp of self.
|
4876
|
-
@overload ptp(axis:nil, keepdims:false, nan:false)
|
4877
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4878
|
-
return NaN for min/max etc).
|
4879
|
-
@param [Numeric,Array,Range] axis Performs ptp along the axis.
|
4880
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4881
|
-
dimensions with size one.
|
4882
|
-
@return [Numo::DFloat] returns result of ptp.
|
4883
|
-
*/
|
4884
4332
|
static VALUE dfloat_ptp(int argc, VALUE* argv, VALUE self) {
|
4885
4333
|
VALUE v, reduce;
|
4886
4334
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -4962,26 +4410,6 @@ static void iter_dfloat_max_index_index32_nan(na_loop_t* const lp) {
|
|
4962
4410
|
}
|
4963
4411
|
#undef idx_t
|
4964
4412
|
|
4965
|
-
/*
|
4966
|
-
Index of the maximum value.
|
4967
|
-
@overload max_index(axis:nil, nan:false)
|
4968
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
4969
|
-
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat 1-d
|
4970
|
-
indices**.
|
4971
|
-
@return [Integer,Numo::Int] returns result indices.
|
4972
|
-
@see #argmax
|
4973
|
-
@see #max
|
4974
|
-
|
4975
|
-
@example
|
4976
|
-
a = Numo::NArray[3,4,1,2]
|
4977
|
-
a.max_index #=> 1
|
4978
|
-
|
4979
|
-
b = Numo::NArray[[3,4,1],[2,0,5]]
|
4980
|
-
b.max_index #=> 5
|
4981
|
-
b.max_index(axis:1) #=> [1, 5]
|
4982
|
-
b.max_index(axis:0) #=> [0, 1, 5]
|
4983
|
-
b[b.max_index(axis:0)] #=> [3, 4, 5]
|
4984
|
-
*/
|
4985
4413
|
static VALUE dfloat_max_index(int argc, VALUE* argv, VALUE self) {
|
4986
4414
|
narray_t* na;
|
4987
4415
|
VALUE idx, reduce;
|
@@ -5080,26 +4508,6 @@ static void iter_dfloat_min_index_index32_nan(na_loop_t* const lp) {
|
|
5080
4508
|
}
|
5081
4509
|
#undef idx_t
|
5082
4510
|
|
5083
|
-
/*
|
5084
|
-
Index of the minimum value.
|
5085
|
-
@overload min_index(axis:nil, nan:false)
|
5086
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
5087
|
-
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat 1-d
|
5088
|
-
indices**.
|
5089
|
-
@return [Integer,Numo::Int] returns result indices.
|
5090
|
-
@see #argmin
|
5091
|
-
@see #min
|
5092
|
-
|
5093
|
-
@example
|
5094
|
-
a = Numo::NArray[3,4,1,2]
|
5095
|
-
a.min_index #=> 2
|
5096
|
-
|
5097
|
-
b = Numo::NArray[[3,4,1],[2,0,5]]
|
5098
|
-
b.min_index #=> 4
|
5099
|
-
b.min_index(axis:1) #=> [2, 4]
|
5100
|
-
b.min_index(axis:0) #=> [3, 4, 2]
|
5101
|
-
b[b.min_index(axis:0)] #=> [2, 0, 1]
|
5102
|
-
*/
|
5103
4511
|
static VALUE dfloat_min_index(int argc, VALUE* argv, VALUE self) {
|
5104
4512
|
narray_t* na;
|
5105
4513
|
VALUE idx, reduce;
|
@@ -5194,26 +4602,6 @@ static void iter_dfloat_argmax_arg32_nan(na_loop_t* const lp) {
|
|
5194
4602
|
}
|
5195
4603
|
#undef idx_t
|
5196
4604
|
|
5197
|
-
/*
|
5198
|
-
Index of the maximum value.
|
5199
|
-
@overload argmax(axis:nil, nan:false)
|
5200
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
5201
|
-
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices
|
5202
|
-
along the axis**.
|
5203
|
-
@return [Integer,Numo::Int] returns the result indices.
|
5204
|
-
@see #max_index
|
5205
|
-
@see #max
|
5206
|
-
|
5207
|
-
@example
|
5208
|
-
a = Numo::NArray[3,4,1,2]
|
5209
|
-
a.argmax #=> 1
|
5210
|
-
|
5211
|
-
b = Numo::NArray[[3,4,1],[2,0,5]]
|
5212
|
-
b.argmax #=> 5
|
5213
|
-
b.argmax(axis:1) #=> [1, 2]
|
5214
|
-
b.argmax(axis:0) #=> [0, 0, 1]
|
5215
|
-
b.at(b.argmax(axis:0), 0..-1) #=> [3, 4, 5]
|
5216
|
-
*/
|
5217
4605
|
static VALUE dfloat_argmax(int argc, VALUE* argv, VALUE self) {
|
5218
4606
|
narray_t* na;
|
5219
4607
|
VALUE reduce;
|
@@ -5305,26 +4693,6 @@ static void iter_dfloat_argmin_arg32_nan(na_loop_t* const lp) {
|
|
5305
4693
|
}
|
5306
4694
|
#undef idx_t
|
5307
4695
|
|
5308
|
-
/*
|
5309
|
-
Index of the minimum value.
|
5310
|
-
@overload argmin(axis:nil, nan:false)
|
5311
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
5312
|
-
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices
|
5313
|
-
along the axis**.
|
5314
|
-
@return [Integer,Numo::Int] returns the result indices.
|
5315
|
-
@see #min_index
|
5316
|
-
@see #min
|
5317
|
-
|
5318
|
-
@example
|
5319
|
-
a = Numo::NArray[3,4,1,2]
|
5320
|
-
a.argmin #=> 2
|
5321
|
-
|
5322
|
-
b = Numo::NArray[[3,4,1],[2,0,5]]
|
5323
|
-
b.argmin #=> 4
|
5324
|
-
b.argmin(axis:1) #=> [2, 1]
|
5325
|
-
b.argmin(axis:0) #=> [1, 1, 0]
|
5326
|
-
b.at(b.argmin(axis:0), 0..-1) #=> [2, 0, 1]
|
5327
|
-
*/
|
5328
4696
|
static VALUE dfloat_argmin(int argc, VALUE* argv, VALUE self) {
|
5329
4697
|
narray_t* na;
|
5330
4698
|
VALUE reduce;
|
@@ -5381,15 +4749,6 @@ static void iter_dfloat_minmax_nan(na_loop_t* const lp) {
|
|
5381
4749
|
*(dtype*)(lp->args[2].ptr + lp->args[2].iter[0].pos) = xmax;
|
5382
4750
|
}
|
5383
4751
|
|
5384
|
-
/*
|
5385
|
-
minmax of self.
|
5386
|
-
@overload minmax(axis:nil, keepdims:false, nan:false)
|
5387
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
5388
|
-
@param [Numeric,Array,Range] axis Finds min-max along the axis.
|
5389
|
-
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
5390
|
-
as dimensions with size one.
|
5391
|
-
@return [Numo::DFloat,Numo::DFloat] min and max of self.
|
5392
|
-
*/
|
5393
4752
|
static VALUE dfloat_minmax(int argc, VALUE* argv, VALUE self) {
|
5394
4753
|
VALUE reduce;
|
5395
4754
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -5403,16 +4762,6 @@ static VALUE dfloat_minmax(int argc, VALUE* argv, VALUE self) {
|
|
5403
4762
|
return na_ndloop(&ndf, 2, self, reduce);
|
5404
4763
|
}
|
5405
4764
|
|
5406
|
-
/*
|
5407
|
-
Element-wise maximum of two arrays.
|
5408
|
-
|
5409
|
-
@overload maximum(a1, a2, nan:false)
|
5410
|
-
@param [Numo::NArray,Numeric] a1 The array to be compared.
|
5411
|
-
@param [Numo::NArray,Numeric] a2 The array to be compared.
|
5412
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
5413
|
-
@return [Numo::DFloat]
|
5414
|
-
*/
|
5415
|
-
|
5416
4765
|
static void iter_dfloat_s_maximum(na_loop_t* const lp) {
|
5417
4766
|
size_t i, n;
|
5418
4767
|
char *p1, *p2, *p3;
|
@@ -5472,16 +4821,6 @@ static VALUE dfloat_s_maximum(int argc, VALUE* argv, VALUE mod) {
|
|
5472
4821
|
return na_ndloop(&ndf, 2, a1, a2);
|
5473
4822
|
}
|
5474
4823
|
|
5475
|
-
/*
|
5476
|
-
Element-wise minimum of two arrays.
|
5477
|
-
|
5478
|
-
@overload minimum(a1, a2, nan:false)
|
5479
|
-
@param [Numo::NArray,Numeric] a1 The array to be compared.
|
5480
|
-
@param [Numo::NArray,Numeric] a2 The array to be compared.
|
5481
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
5482
|
-
@return [Numo::DFloat]
|
5483
|
-
*/
|
5484
|
-
|
5485
4824
|
static void iter_dfloat_s_minimum(na_loop_t* const lp) {
|
5486
4825
|
size_t i, n;
|
5487
4826
|
char *p1, *p2, *p3;
|
@@ -5578,13 +4917,6 @@ static void iter_dfloat_cumsum_nan(na_loop_t* const lp) {
|
|
5578
4917
|
}
|
5579
4918
|
}
|
5580
4919
|
|
5581
|
-
/*
|
5582
|
-
cumsum of self.
|
5583
|
-
@overload cumsum(axis:nil, nan:false)
|
5584
|
-
@param [Numeric,Array,Range] axis Performs cumsum along the axis.
|
5585
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
5586
|
-
@return [Numo::DFloat] cumsum of self.
|
5587
|
-
*/
|
5588
4920
|
static VALUE dfloat_cumsum(int argc, VALUE* argv, VALUE self) {
|
5589
4921
|
VALUE reduce;
|
5590
4922
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -5635,13 +4967,6 @@ static void iter_dfloat_cumprod_nan(na_loop_t* const lp) {
|
|
5635
4967
|
}
|
5636
4968
|
}
|
5637
4969
|
|
5638
|
-
/*
|
5639
|
-
cumprod of self.
|
5640
|
-
@overload cumprod(axis:nil, nan:false)
|
5641
|
-
@param [Numeric,Array,Range] axis Performs cumprod along the axis.
|
5642
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
5643
|
-
@return [Numo::DFloat] cumprod of self.
|
5644
|
-
*/
|
5645
4970
|
static VALUE dfloat_cumprod(int argc, VALUE* argv, VALUE self) {
|
5646
4971
|
VALUE reduce;
|
5647
4972
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
@@ -5746,17 +5071,6 @@ static VALUE dfloat_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
|
5746
5071
|
return dfloat_extract(v);
|
5747
5072
|
}
|
5748
5073
|
|
5749
|
-
/*
|
5750
|
-
Binary mulsum.
|
5751
|
-
|
5752
|
-
@overload mulsum(other, axis:nil, keepdims:false, nan:false)
|
5753
|
-
@param [Numo::NArray,Numeric] other
|
5754
|
-
@param [Numeric,Array,Range] axis Performs mulsum along the axis.
|
5755
|
-
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
5756
|
-
as dimensions with size one.
|
5757
|
-
@param [TrueClass] nan (keyword) If true, apply NaN-aware algorithm (avoid NaN if exists).
|
5758
|
-
@return [Numo::NArray] mulsum of self and other.
|
5759
|
-
*/
|
5760
5074
|
static VALUE dfloat_mulsum(int argc, VALUE* argv, VALUE self) {
|
5761
5075
|
//
|
5762
5076
|
VALUE klass, v;
|
@@ -5819,23 +5133,6 @@ static void iter_dfloat_seq(na_loop_t* const lp) {
|
|
5819
5133
|
g->count = c;
|
5820
5134
|
}
|
5821
5135
|
|
5822
|
-
/*
|
5823
|
-
Set linear sequence of numbers to self. The sequence is obtained from
|
5824
|
-
beg+i*step
|
5825
|
-
where i is 1-dimensional index.
|
5826
|
-
@overload seq([beg,[step]])
|
5827
|
-
@param [Numeric] beg beginning of sequence. (default=0)
|
5828
|
-
@param [Numeric] step step of sequence. (default=1)
|
5829
|
-
@return [Numo::DFloat] self.
|
5830
|
-
@example
|
5831
|
-
Numo::DFloat.new(6).seq(1,-0.2)
|
5832
|
-
# => Numo::DFloat#shape=[6]
|
5833
|
-
# [1, 0.8, 0.6, 0.4, 0.2, 0]
|
5834
|
-
|
5835
|
-
Numo::DComplex.new(6).seq(1,-0.2+0.2i)
|
5836
|
-
# => Numo::DComplex#shape=[6]
|
5837
|
-
# [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
5838
|
-
*/
|
5839
5136
|
static VALUE dfloat_seq(int argc, VALUE* args, VALUE self) {
|
5840
5137
|
seq_opt_t* g;
|
5841
5138
|
VALUE vbeg = Qnil, vstep = Qnil;
|
@@ -5898,27 +5195,6 @@ static void iter_dfloat_logseq(na_loop_t* const lp) {
|
|
5898
5195
|
g->count = c;
|
5899
5196
|
}
|
5900
5197
|
|
5901
|
-
/*
|
5902
|
-
Set logarithmic sequence of numbers to self. The sequence is obtained from
|
5903
|
-
`base**(beg+i*step)`
|
5904
|
-
where i is 1-dimensional index.
|
5905
|
-
Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
|
5906
|
-
|
5907
|
-
@overload logseq(beg,step,[base])
|
5908
|
-
@param [Numeric] beg The beginning of sequence.
|
5909
|
-
@param [Numeric] step The step of sequence.
|
5910
|
-
@param [Numeric] base The base of log space. (default=10)
|
5911
|
-
@return [Numo::DFloat] self.
|
5912
|
-
|
5913
|
-
@example
|
5914
|
-
Numo::DFloat.new(5).logseq(4,-1,2)
|
5915
|
-
# => Numo::DFloat#shape=[5]
|
5916
|
-
# [16, 8, 4, 2, 1]
|
5917
|
-
|
5918
|
-
Numo::DComplex.new(5).logseq(0,1i*Math::PI/3,Math::E)
|
5919
|
-
# => Numo::DComplex#shape=[5]
|
5920
|
-
# [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
|
5921
|
-
*/
|
5922
5198
|
static VALUE dfloat_logseq(int argc, VALUE* args, VALUE self) {
|
5923
5199
|
logseq_opt_t* g;
|
5924
5200
|
VALUE vbeg, vstep, vbase;
|
@@ -5967,15 +5243,6 @@ static void iter_dfloat_eye(na_loop_t* const lp) {
|
|
5967
5243
|
}
|
5968
5244
|
}
|
5969
5245
|
|
5970
|
-
/*
|
5971
|
-
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
|
5972
|
-
@overload eye([element,offset])
|
5973
|
-
@param [Numeric] element Diagonal element to be stored. Default is 1.
|
5974
|
-
@param [Integer] offset Diagonal offset from the main diagonal. The
|
5975
|
-
default is 0. k>0 for diagonals above the main diagonal, and k<0
|
5976
|
-
for diagonals below the main diagonal.
|
5977
|
-
@return [Numo::DFloat] eye of self.
|
5978
|
-
*/
|
5979
5246
|
static VALUE dfloat_eye(int argc, VALUE* argv, VALUE self) {
|
5980
5247
|
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
|
5981
5248
|
ndfunc_t ndf = { iter_dfloat_eye, NO_LOOP, 1, 0, ain, 0 };
|
@@ -6068,26 +5335,6 @@ static void iter_dfloat_rand(na_loop_t* const lp) {
|
|
6068
5335
|
}
|
6069
5336
|
}
|
6070
5337
|
|
6071
|
-
/*
|
6072
|
-
Generate uniformly distributed random numbers on self narray.
|
6073
|
-
@overload rand([[low],high])
|
6074
|
-
@param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
6075
|
-
@param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
|
6076
|
-
complex types)
|
6077
|
-
@return [Numo::DFloat] self.
|
6078
|
-
@example
|
6079
|
-
Numo::DFloat.new(6).rand
|
6080
|
-
# => Numo::DFloat#shape=[6]
|
6081
|
-
# [0.0617545, 0.373067, 0.794815, 0.201042, 0.116041, 0.344032]
|
6082
|
-
|
6083
|
-
Numo::DComplex.new(6).rand(5+5i)
|
6084
|
-
# => Numo::DComplex#shape=[6]
|
6085
|
-
# [2.69974+3.68908i, 0.825443+0.254414i, 0.540323+0.34354i, 4.52061+2.39322i, ...]
|
6086
|
-
|
6087
|
-
Numo::Int32.new(6).rand(2,5)
|
6088
|
-
# => Numo::Int32#shape=[6]
|
6089
|
-
# [4, 3, 3, 2, 4, 2]
|
6090
|
-
*/
|
6091
5338
|
static VALUE dfloat_rand(int argc, VALUE* args, VALUE self) {
|
6092
5339
|
rand_opt_t g;
|
6093
5340
|
VALUE v1 = Qnil, v2 = Qnil;
|
@@ -6167,36 +5414,6 @@ static void iter_dfloat_rand_norm(na_loop_t* const lp) {
|
|
6167
5414
|
}
|
6168
5415
|
}
|
6169
5416
|
|
6170
|
-
/*
|
6171
|
-
Generates random numbers from the normal distribution on self narray
|
6172
|
-
using Box-Muller Transformation.
|
6173
|
-
@overload rand_norm([mu,[sigma]])
|
6174
|
-
@param [Numeric] mu mean of normal distribution. (default=0)
|
6175
|
-
@param [Numeric] sigma standard deviation of normal distribution. (default=1)
|
6176
|
-
@return [Numo::DFloat] self.
|
6177
|
-
@example
|
6178
|
-
Numo::DFloat.new(5,5).rand_norm
|
6179
|
-
# => Numo::DFloat#shape=[5,5]
|
6180
|
-
# [[-0.581255, -0.168354, 0.586895, -0.595142, -0.802802],
|
6181
|
-
# [-0.326106, 0.282922, 1.68427, 0.918499, -0.0485384],
|
6182
|
-
# [-0.464453, -0.992194, 0.413794, -0.60717, -0.699695],
|
6183
|
-
# [-1.64168, 0.48676, -0.875871, -1.43275, 0.812172],
|
6184
|
-
# [-0.209975, -0.103612, -0.878617, -1.42495, 1.0968]]
|
6185
|
-
|
6186
|
-
Numo::DFloat.new(5,5).rand_norm(10,0.1)
|
6187
|
-
# => Numo::DFloat#shape=[5,5]
|
6188
|
-
# [[9.9019, 9.90339, 10.0826, 9.98384, 9.72861],
|
6189
|
-
# [9.81507, 10.0272, 9.91445, 10.0568, 9.88923],
|
6190
|
-
# [10.0234, 9.97874, 9.96011, 9.9006, 9.99964],
|
6191
|
-
# [10.0186, 9.94598, 9.92236, 9.99811, 9.97003],
|
6192
|
-
# [9.79266, 9.95044, 9.95212, 9.93692, 10.2027]]
|
6193
|
-
|
6194
|
-
Numo::DComplex.new(3,3).rand_norm(5+5i)
|
6195
|
-
# => Numo::DComplex#shape=[3,3]
|
6196
|
-
# [[5.84303+4.40052i, 4.00984+6.08982i, 5.10979+5.13215i],
|
6197
|
-
# [4.26477+3.99655i, 4.90052+5.00763i, 4.46607+2.3444i],
|
6198
|
-
# [4.5528+7.11003i, 5.62117+6.69094i, 5.05443+5.35133i]]
|
6199
|
-
*/
|
6200
5417
|
static VALUE dfloat_rand_norm(int argc, VALUE* args, VALUE self) {
|
6201
5418
|
int n;
|
6202
5419
|
randn_opt_t g;
|
@@ -6235,13 +5452,6 @@ static void iter_dfloat_poly(na_loop_t* const lp) {
|
|
6235
5452
|
*(dtype*)(lp->args[i].ptr + lp->args[i].iter[0].pos) = y;
|
6236
5453
|
}
|
6237
5454
|
|
6238
|
-
/*
|
6239
|
-
Calculate polynomial.
|
6240
|
-
`x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
|
6241
|
-
@overload poly a0, a1, ..., an
|
6242
|
-
@param [Numo::NArray,Numeric] a0,a1,...,an
|
6243
|
-
@return [Numo::DFloat]
|
6244
|
-
*/
|
6245
5455
|
static VALUE dfloat_poly(VALUE self, VALUE args) {
|
6246
5456
|
int argc, i;
|
6247
5457
|
VALUE* argv;
|
@@ -6327,27 +5537,27 @@ static VALUE dfloat_poly(VALUE self, VALUE args) {
|
|
6327
5537
|
* We have modified their original by adding a check for already-sorted input,
|
6328
5538
|
* which seems to be a win per discussions on pgsql-hackers around 2006-03-21.
|
6329
5539
|
*/
|
6330
|
-
#define swapcode(TYPE, parmi, parmj, n)
|
6331
|
-
do {
|
6332
|
-
size_t i = (n) / sizeof(TYPE);
|
6333
|
-
TYPE* pi = (TYPE*)(void*)(parmi);
|
6334
|
-
TYPE* pj = (TYPE*)(void*)(parmj);
|
6335
|
-
do {
|
6336
|
-
TYPE t = *pi;
|
6337
|
-
*pi++ = *pj;
|
6338
|
-
*pj++ = t;
|
6339
|
-
} while (--i > 0);
|
5540
|
+
#define swapcode(TYPE, parmi, parmj, n) \
|
5541
|
+
do { \
|
5542
|
+
size_t i = (n) / sizeof(TYPE); \
|
5543
|
+
TYPE* pi = (TYPE*)(void*)(parmi); \
|
5544
|
+
TYPE* pj = (TYPE*)(void*)(parmj); \
|
5545
|
+
do { \
|
5546
|
+
TYPE t = *pi; \
|
5547
|
+
*pi++ = *pj; \
|
5548
|
+
*pj++ = t; \
|
5549
|
+
} while (--i > 0); \
|
6340
5550
|
} while (0)
|
6341
5551
|
|
6342
5552
|
#ifdef HAVE_STDINT_H
|
6343
|
-
#define SWAPINIT(a, es)
|
6344
|
-
swaptype = (uintptr_t)a % sizeof(long) || (es) % sizeof(long) ? 2
|
6345
|
-
: (es) == sizeof(long) ? 0
|
5553
|
+
#define SWAPINIT(a, es) \
|
5554
|
+
swaptype = (uintptr_t)a % sizeof(long) || (es) % sizeof(long) ? 2 \
|
5555
|
+
: (es) == sizeof(long) ? 0 \
|
6346
5556
|
: 1;
|
6347
5557
|
#else
|
6348
|
-
#define SWAPINIT(a, es)
|
6349
|
-
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2
|
6350
|
-
: (es) == sizeof(long) ? 0
|
5558
|
+
#define SWAPINIT(a, es) \
|
5559
|
+
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
5560
|
+
: (es) == sizeof(long) ? 0 \
|
6351
5561
|
: 1;
|
6352
5562
|
#endif
|
6353
5563
|
|
@@ -6358,19 +5568,19 @@ static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
|
|
6358
5568
|
swapcode(char, a, b, n);
|
6359
5569
|
}
|
6360
5570
|
|
6361
|
-
#define swap(a, b)
|
6362
|
-
if (swaptype == 0) {
|
6363
|
-
long t = *(long*)(void*)(a);
|
6364
|
-
*(long*)(void*)(a) = *(long*)(void*)(b);
|
6365
|
-
*(long*)(void*)(b) = t;
|
6366
|
-
} else
|
5571
|
+
#define swap(a, b) \
|
5572
|
+
if (swaptype == 0) { \
|
5573
|
+
long t = *(long*)(void*)(a); \
|
5574
|
+
*(long*)(void*)(a) = *(long*)(void*)(b); \
|
5575
|
+
*(long*)(void*)(b) = t; \
|
5576
|
+
} else \
|
6367
5577
|
swapfunc(a, b, es, swaptype)
|
6368
5578
|
|
6369
|
-
#define vecswap(a, b, n)
|
5579
|
+
#define vecswap(a, b, n) \
|
6370
5580
|
if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
|
6371
5581
|
|
6372
|
-
#define med3(a, b, c, _cmp)
|
6373
|
-
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a))
|
5582
|
+
#define med3(a, b, c, _cmp) \
|
5583
|
+
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) \
|
6374
5584
|
: (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
|
6375
5585
|
#endif
|
6376
5586
|
|
@@ -6600,15 +5810,6 @@ static void iter_dfloat_sort_prnan(na_loop_t* const lp) {
|
|
6600
5810
|
dfloat_qsort_prnan(ptr, n, step);
|
6601
5811
|
}
|
6602
5812
|
|
6603
|
-
/*
|
6604
|
-
sort of self.
|
6605
|
-
@overload sort(axis:nil, nan:false)
|
6606
|
-
@param [TrueClass] nan If true, propagete NaN. If false, ignore NaN.
|
6607
|
-
@param [Numeric,Array,Range] axis Performs sort along the axis.
|
6608
|
-
@return [Numo::DFloat] returns result of sort.
|
6609
|
-
@example
|
6610
|
-
Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
|
6611
|
-
*/
|
6612
5813
|
static VALUE dfloat_sort(int argc, VALUE* argv, VALUE self) {
|
6613
5814
|
VALUE reduce;
|
6614
5815
|
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
|
@@ -7025,15 +6226,6 @@ static void dfloat_index32_qsort_prnan(na_loop_t* const lp) {
|
|
7025
6226
|
}
|
7026
6227
|
#undef idx_t
|
7027
6228
|
|
7028
|
-
/*
|
7029
|
-
sort_index. Returns an index array of sort result.
|
7030
|
-
@overload sort_index(axis:nil, nan:false)
|
7031
|
-
@param [TrueClass] nan If true, propagete NaN. If false, ignore NaN.
|
7032
|
-
@param [Numeric,Array,Range] axis Performs sort_index along the axis.
|
7033
|
-
@return [Integer,Numo::Int] returns result index of sort_index.
|
7034
|
-
@example
|
7035
|
-
Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
|
7036
|
-
*/
|
7037
6229
|
static VALUE dfloat_sort_index(int argc, VALUE* argv, VALUE self) {
|
7038
6230
|
size_t size;
|
7039
6231
|
narray_t* na;
|
@@ -7119,16 +6311,6 @@ static void iter_dfloat_median_prnan(na_loop_t* const lp) {
|
|
7119
6311
|
}
|
7120
6312
|
}
|
7121
6313
|
|
7122
|
-
/*
|
7123
|
-
median of self.
|
7124
|
-
@overload median(axis:nil, keepdims:false, nan:false)
|
7125
|
-
@param [TrueClass] nan (keyword) If true, propagete NaN. If false, ignore NaN.
|
7126
|
-
@param [Numeric,Array,Range] axis Finds median along the axis.
|
7127
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
7128
|
-
dimensions with size one.
|
7129
|
-
@return [Numo::DFloat] returns median of self.
|
7130
|
-
*/
|
7131
|
-
|
7132
6314
|
static VALUE dfloat_median(int argc, VALUE* argv, VALUE self) {
|
7133
6315
|
VALUE v, reduce;
|
7134
6316
|
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
|
@@ -7144,10 +6326,6 @@ static VALUE dfloat_median(int argc, VALUE* argv, VALUE self) {
|
|
7144
6326
|
return dfloat_extract(v);
|
7145
6327
|
}
|
7146
6328
|
|
7147
|
-
/*
|
7148
|
-
module definition: Numo::DFloat::NMath
|
7149
|
-
*/
|
7150
|
-
|
7151
6329
|
VALUE mTM;
|
7152
6330
|
|
7153
6331
|
static void iter_dfloat_math_s_sqrt(na_loop_t* const lp) {
|
@@ -7265,12 +6443,6 @@ static void iter_dfloat_math_s_sqrt(na_loop_t* const lp) {
|
|
7265
6443
|
}
|
7266
6444
|
}
|
7267
6445
|
|
7268
|
-
/*
|
7269
|
-
Calculate sqrt(x).
|
7270
|
-
@overload sqrt(x)
|
7271
|
-
@param [Numo::NArray,Numeric] x input value
|
7272
|
-
@return [Numo::DFloat] result of sqrt(x).
|
7273
|
-
*/
|
7274
6446
|
static VALUE dfloat_math_s_sqrt(VALUE mod, VALUE a1) {
|
7275
6447
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7276
6448
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7343,12 +6515,6 @@ static void iter_dfloat_math_s_cbrt(na_loop_t* const lp) {
|
|
7343
6515
|
}
|
7344
6516
|
}
|
7345
6517
|
|
7346
|
-
/*
|
7347
|
-
Calculate cbrt(x).
|
7348
|
-
@overload cbrt(x)
|
7349
|
-
@param [Numo::NArray,Numeric] x input value
|
7350
|
-
@return [Numo::DFloat] result of cbrt(x).
|
7351
|
-
*/
|
7352
6518
|
static VALUE dfloat_math_s_cbrt(VALUE mod, VALUE a1) {
|
7353
6519
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7354
6520
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7421,12 +6587,6 @@ static void iter_dfloat_math_s_log(na_loop_t* const lp) {
|
|
7421
6587
|
}
|
7422
6588
|
}
|
7423
6589
|
|
7424
|
-
/*
|
7425
|
-
Calculate log(x).
|
7426
|
-
@overload log(x)
|
7427
|
-
@param [Numo::NArray,Numeric] x input value
|
7428
|
-
@return [Numo::DFloat] result of log(x).
|
7429
|
-
*/
|
7430
6590
|
static VALUE dfloat_math_s_log(VALUE mod, VALUE a1) {
|
7431
6591
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7432
6592
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7499,12 +6659,6 @@ static void iter_dfloat_math_s_log2(na_loop_t* const lp) {
|
|
7499
6659
|
}
|
7500
6660
|
}
|
7501
6661
|
|
7502
|
-
/*
|
7503
|
-
Calculate log2(x).
|
7504
|
-
@overload log2(x)
|
7505
|
-
@param [Numo::NArray,Numeric] x input value
|
7506
|
-
@return [Numo::DFloat] result of log2(x).
|
7507
|
-
*/
|
7508
6662
|
static VALUE dfloat_math_s_log2(VALUE mod, VALUE a1) {
|
7509
6663
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7510
6664
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7577,12 +6731,6 @@ static void iter_dfloat_math_s_log10(na_loop_t* const lp) {
|
|
7577
6731
|
}
|
7578
6732
|
}
|
7579
6733
|
|
7580
|
-
/*
|
7581
|
-
Calculate log10(x).
|
7582
|
-
@overload log10(x)
|
7583
|
-
@param [Numo::NArray,Numeric] x input value
|
7584
|
-
@return [Numo::DFloat] result of log10(x).
|
7585
|
-
*/
|
7586
6734
|
static VALUE dfloat_math_s_log10(VALUE mod, VALUE a1) {
|
7587
6735
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7588
6736
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7655,12 +6803,6 @@ static void iter_dfloat_math_s_exp(na_loop_t* const lp) {
|
|
7655
6803
|
}
|
7656
6804
|
}
|
7657
6805
|
|
7658
|
-
/*
|
7659
|
-
Calculate exp(x).
|
7660
|
-
@overload exp(x)
|
7661
|
-
@param [Numo::NArray,Numeric] x input value
|
7662
|
-
@return [Numo::DFloat] result of exp(x).
|
7663
|
-
*/
|
7664
6806
|
static VALUE dfloat_math_s_exp(VALUE mod, VALUE a1) {
|
7665
6807
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7666
6808
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7733,12 +6875,6 @@ static void iter_dfloat_math_s_exp2(na_loop_t* const lp) {
|
|
7733
6875
|
}
|
7734
6876
|
}
|
7735
6877
|
|
7736
|
-
/*
|
7737
|
-
Calculate exp2(x).
|
7738
|
-
@overload exp2(x)
|
7739
|
-
@param [Numo::NArray,Numeric] x input value
|
7740
|
-
@return [Numo::DFloat] result of exp2(x).
|
7741
|
-
*/
|
7742
6878
|
static VALUE dfloat_math_s_exp2(VALUE mod, VALUE a1) {
|
7743
6879
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7744
6880
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7811,12 +6947,6 @@ static void iter_dfloat_math_s_exp10(na_loop_t* const lp) {
|
|
7811
6947
|
}
|
7812
6948
|
}
|
7813
6949
|
|
7814
|
-
/*
|
7815
|
-
Calculate exp10(x).
|
7816
|
-
@overload exp10(x)
|
7817
|
-
@param [Numo::NArray,Numeric] x input value
|
7818
|
-
@return [Numo::DFloat] result of exp10(x).
|
7819
|
-
*/
|
7820
6950
|
static VALUE dfloat_math_s_exp10(VALUE mod, VALUE a1) {
|
7821
6951
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7822
6952
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7889,12 +7019,6 @@ static void iter_dfloat_math_s_sin(na_loop_t* const lp) {
|
|
7889
7019
|
}
|
7890
7020
|
}
|
7891
7021
|
|
7892
|
-
/*
|
7893
|
-
Calculate sin(x).
|
7894
|
-
@overload sin(x)
|
7895
|
-
@param [Numo::NArray,Numeric] x input value
|
7896
|
-
@return [Numo::DFloat] result of sin(x).
|
7897
|
-
*/
|
7898
7022
|
static VALUE dfloat_math_s_sin(VALUE mod, VALUE a1) {
|
7899
7023
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7900
7024
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -7967,12 +7091,6 @@ static void iter_dfloat_math_s_cos(na_loop_t* const lp) {
|
|
7967
7091
|
}
|
7968
7092
|
}
|
7969
7093
|
|
7970
|
-
/*
|
7971
|
-
Calculate cos(x).
|
7972
|
-
@overload cos(x)
|
7973
|
-
@param [Numo::NArray,Numeric] x input value
|
7974
|
-
@return [Numo::DFloat] result of cos(x).
|
7975
|
-
*/
|
7976
7094
|
static VALUE dfloat_math_s_cos(VALUE mod, VALUE a1) {
|
7977
7095
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7978
7096
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8045,12 +7163,6 @@ static void iter_dfloat_math_s_tan(na_loop_t* const lp) {
|
|
8045
7163
|
}
|
8046
7164
|
}
|
8047
7165
|
|
8048
|
-
/*
|
8049
|
-
Calculate tan(x).
|
8050
|
-
@overload tan(x)
|
8051
|
-
@param [Numo::NArray,Numeric] x input value
|
8052
|
-
@return [Numo::DFloat] result of tan(x).
|
8053
|
-
*/
|
8054
7166
|
static VALUE dfloat_math_s_tan(VALUE mod, VALUE a1) {
|
8055
7167
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8056
7168
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8123,12 +7235,6 @@ static void iter_dfloat_math_s_asin(na_loop_t* const lp) {
|
|
8123
7235
|
}
|
8124
7236
|
}
|
8125
7237
|
|
8126
|
-
/*
|
8127
|
-
Calculate asin(x).
|
8128
|
-
@overload asin(x)
|
8129
|
-
@param [Numo::NArray,Numeric] x input value
|
8130
|
-
@return [Numo::DFloat] result of asin(x).
|
8131
|
-
*/
|
8132
7238
|
static VALUE dfloat_math_s_asin(VALUE mod, VALUE a1) {
|
8133
7239
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8134
7240
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8201,12 +7307,6 @@ static void iter_dfloat_math_s_acos(na_loop_t* const lp) {
|
|
8201
7307
|
}
|
8202
7308
|
}
|
8203
7309
|
|
8204
|
-
/*
|
8205
|
-
Calculate acos(x).
|
8206
|
-
@overload acos(x)
|
8207
|
-
@param [Numo::NArray,Numeric] x input value
|
8208
|
-
@return [Numo::DFloat] result of acos(x).
|
8209
|
-
*/
|
8210
7310
|
static VALUE dfloat_math_s_acos(VALUE mod, VALUE a1) {
|
8211
7311
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8212
7312
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8279,12 +7379,6 @@ static void iter_dfloat_math_s_atan(na_loop_t* const lp) {
|
|
8279
7379
|
}
|
8280
7380
|
}
|
8281
7381
|
|
8282
|
-
/*
|
8283
|
-
Calculate atan(x).
|
8284
|
-
@overload atan(x)
|
8285
|
-
@param [Numo::NArray,Numeric] x input value
|
8286
|
-
@return [Numo::DFloat] result of atan(x).
|
8287
|
-
*/
|
8288
7382
|
static VALUE dfloat_math_s_atan(VALUE mod, VALUE a1) {
|
8289
7383
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8290
7384
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8357,12 +7451,6 @@ static void iter_dfloat_math_s_sinh(na_loop_t* const lp) {
|
|
8357
7451
|
}
|
8358
7452
|
}
|
8359
7453
|
|
8360
|
-
/*
|
8361
|
-
Calculate sinh(x).
|
8362
|
-
@overload sinh(x)
|
8363
|
-
@param [Numo::NArray,Numeric] x input value
|
8364
|
-
@return [Numo::DFloat] result of sinh(x).
|
8365
|
-
*/
|
8366
7454
|
static VALUE dfloat_math_s_sinh(VALUE mod, VALUE a1) {
|
8367
7455
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8368
7456
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8435,12 +7523,6 @@ static void iter_dfloat_math_s_cosh(na_loop_t* const lp) {
|
|
8435
7523
|
}
|
8436
7524
|
}
|
8437
7525
|
|
8438
|
-
/*
|
8439
|
-
Calculate cosh(x).
|
8440
|
-
@overload cosh(x)
|
8441
|
-
@param [Numo::NArray,Numeric] x input value
|
8442
|
-
@return [Numo::DFloat] result of cosh(x).
|
8443
|
-
*/
|
8444
7526
|
static VALUE dfloat_math_s_cosh(VALUE mod, VALUE a1) {
|
8445
7527
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8446
7528
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8513,12 +7595,6 @@ static void iter_dfloat_math_s_tanh(na_loop_t* const lp) {
|
|
8513
7595
|
}
|
8514
7596
|
}
|
8515
7597
|
|
8516
|
-
/*
|
8517
|
-
Calculate tanh(x).
|
8518
|
-
@overload tanh(x)
|
8519
|
-
@param [Numo::NArray,Numeric] x input value
|
8520
|
-
@return [Numo::DFloat] result of tanh(x).
|
8521
|
-
*/
|
8522
7598
|
static VALUE dfloat_math_s_tanh(VALUE mod, VALUE a1) {
|
8523
7599
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8524
7600
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8591,12 +7667,6 @@ static void iter_dfloat_math_s_asinh(na_loop_t* const lp) {
|
|
8591
7667
|
}
|
8592
7668
|
}
|
8593
7669
|
|
8594
|
-
/*
|
8595
|
-
Calculate asinh(x).
|
8596
|
-
@overload asinh(x)
|
8597
|
-
@param [Numo::NArray,Numeric] x input value
|
8598
|
-
@return [Numo::DFloat] result of asinh(x).
|
8599
|
-
*/
|
8600
7670
|
static VALUE dfloat_math_s_asinh(VALUE mod, VALUE a1) {
|
8601
7671
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8602
7672
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8669,12 +7739,6 @@ static void iter_dfloat_math_s_acosh(na_loop_t* const lp) {
|
|
8669
7739
|
}
|
8670
7740
|
}
|
8671
7741
|
|
8672
|
-
/*
|
8673
|
-
Calculate acosh(x).
|
8674
|
-
@overload acosh(x)
|
8675
|
-
@param [Numo::NArray,Numeric] x input value
|
8676
|
-
@return [Numo::DFloat] result of acosh(x).
|
8677
|
-
*/
|
8678
7742
|
static VALUE dfloat_math_s_acosh(VALUE mod, VALUE a1) {
|
8679
7743
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8680
7744
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8747,12 +7811,6 @@ static void iter_dfloat_math_s_atanh(na_loop_t* const lp) {
|
|
8747
7811
|
}
|
8748
7812
|
}
|
8749
7813
|
|
8750
|
-
/*
|
8751
|
-
Calculate atanh(x).
|
8752
|
-
@overload atanh(x)
|
8753
|
-
@param [Numo::NArray,Numeric] x input value
|
8754
|
-
@return [Numo::DFloat] result of atanh(x).
|
8755
|
-
*/
|
8756
7814
|
static VALUE dfloat_math_s_atanh(VALUE mod, VALUE a1) {
|
8757
7815
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8758
7816
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8825,12 +7883,6 @@ static void iter_dfloat_math_s_sinc(na_loop_t* const lp) {
|
|
8825
7883
|
}
|
8826
7884
|
}
|
8827
7885
|
|
8828
|
-
/*
|
8829
|
-
Calculate sinc(x).
|
8830
|
-
@overload sinc(x)
|
8831
|
-
@param [Numo::NArray,Numeric] x input value
|
8832
|
-
@return [Numo::DFloat] result of sinc(x).
|
8833
|
-
*/
|
8834
7886
|
static VALUE dfloat_math_s_sinc(VALUE mod, VALUE a1) {
|
8835
7887
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8836
7888
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8856,13 +7908,6 @@ static void iter_dfloat_math_s_atan2(na_loop_t* const lp) {
|
|
8856
7908
|
}
|
8857
7909
|
}
|
8858
7910
|
|
8859
|
-
/*
|
8860
|
-
Calculate atan2(a1,a2).
|
8861
|
-
@overload atan2(a1,a2)
|
8862
|
-
@param [Numo::NArray,Numeric] a1 first value
|
8863
|
-
@param [Numo::NArray,Numeric] a2 second value
|
8864
|
-
@return [Numo::DFloat] atan2(a1,a2).
|
8865
|
-
*/
|
8866
7911
|
static VALUE dfloat_math_s_atan2(VALUE mod, VALUE a1, VALUE a2) {
|
8867
7912
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
8868
7913
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8887,13 +7932,6 @@ static void iter_dfloat_math_s_hypot(na_loop_t* const lp) {
|
|
8887
7932
|
}
|
8888
7933
|
}
|
8889
7934
|
|
8890
|
-
/*
|
8891
|
-
Calculate hypot(a1,a2).
|
8892
|
-
@overload hypot(a1,a2)
|
8893
|
-
@param [Numo::NArray,Numeric] a1 first value
|
8894
|
-
@param [Numo::NArray,Numeric] a2 second value
|
8895
|
-
@return [Numo::DFloat] hypot(a1,a2).
|
8896
|
-
*/
|
8897
7935
|
static VALUE dfloat_math_s_hypot(VALUE mod, VALUE a1, VALUE a2) {
|
8898
7936
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
8899
7937
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -8965,12 +8003,6 @@ static void iter_dfloat_math_s_erf(na_loop_t* const lp) {
|
|
8965
8003
|
}
|
8966
8004
|
}
|
8967
8005
|
|
8968
|
-
/*
|
8969
|
-
Calculate erf(x).
|
8970
|
-
@overload erf(x)
|
8971
|
-
@param [Numo::NArray,Numeric] x input value
|
8972
|
-
@return [Numo::DFloat] result of erf(x).
|
8973
|
-
*/
|
8974
8006
|
static VALUE dfloat_math_s_erf(VALUE mod, VALUE a1) {
|
8975
8007
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8976
8008
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -9043,12 +8075,6 @@ static void iter_dfloat_math_s_erfc(na_loop_t* const lp) {
|
|
9043
8075
|
}
|
9044
8076
|
}
|
9045
8077
|
|
9046
|
-
/*
|
9047
|
-
Calculate erfc(x).
|
9048
|
-
@overload erfc(x)
|
9049
|
-
@param [Numo::NArray,Numeric] x input value
|
9050
|
-
@return [Numo::DFloat] result of erfc(x).
|
9051
|
-
*/
|
9052
8078
|
static VALUE dfloat_math_s_erfc(VALUE mod, VALUE a1) {
|
9053
8079
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
9054
8080
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -9121,12 +8147,6 @@ static void iter_dfloat_math_s_log1p(na_loop_t* const lp) {
|
|
9121
8147
|
}
|
9122
8148
|
}
|
9123
8149
|
|
9124
|
-
/*
|
9125
|
-
Calculate log1p(x).
|
9126
|
-
@overload log1p(x)
|
9127
|
-
@param [Numo::NArray,Numeric] x input value
|
9128
|
-
@return [Numo::DFloat] result of log1p(x).
|
9129
|
-
*/
|
9130
8150
|
static VALUE dfloat_math_s_log1p(VALUE mod, VALUE a1) {
|
9131
8151
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
9132
8152
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -9199,12 +8219,6 @@ static void iter_dfloat_math_s_expm1(na_loop_t* const lp) {
|
|
9199
8219
|
}
|
9200
8220
|
}
|
9201
8221
|
|
9202
|
-
/*
|
9203
|
-
Calculate expm1(x).
|
9204
|
-
@overload expm1(x)
|
9205
|
-
@param [Numo::NArray,Numeric] x input value
|
9206
|
-
@return [Numo::DFloat] result of expm1(x).
|
9207
|
-
*/
|
9208
8222
|
static VALUE dfloat_math_s_expm1(VALUE mod, VALUE a1) {
|
9209
8223
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
9210
8224
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -9230,13 +8244,6 @@ static void iter_dfloat_math_s_ldexp(na_loop_t* const lp) {
|
|
9230
8244
|
}
|
9231
8245
|
}
|
9232
8246
|
|
9233
|
-
/*
|
9234
|
-
Calculate ldexp(a1,a2).
|
9235
|
-
@overload ldexp(a1,a2)
|
9236
|
-
@param [Numo::NArray,Numeric] a1 first value
|
9237
|
-
@param [Numo::NArray,Numeric] a2 second value
|
9238
|
-
@return [Numo::DFloat] ldexp(a1,a2).
|
9239
|
-
*/
|
9240
8247
|
static VALUE dfloat_math_s_ldexp(VALUE mod, VALUE a1, VALUE a2) {
|
9241
8248
|
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
9242
8249
|
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
@@ -9262,15 +8269,6 @@ static void iter_dfloat_math_s_frexp(na_loop_t* const lp) {
|
|
9262
8269
|
}
|
9263
8270
|
}
|
9264
8271
|
|
9265
|
-
/*
|
9266
|
-
split the number x into a normalized fraction and an exponent.
|
9267
|
-
Returns [mantissa, exponent], where x = mantissa * 2**exponent.
|
9268
|
-
|
9269
|
-
@overload frexp(x)
|
9270
|
-
@param [Numo::NArray,Numeric] x
|
9271
|
-
@return [Numo::DFloat,Numo::Int32] mantissa and exponent.
|
9272
|
-
|
9273
|
-
*/
|
9274
8272
|
static VALUE dfloat_math_s_frexp(VALUE mod, VALUE a1) {
|
9275
8273
|
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
9276
8274
|
ndfunc_arg_out_t aout[2] = { { cT, 0 }, { numo_cInt32, 0 } };
|
@@ -9298,16 +8296,18 @@ void Init_numo_dfloat(void) {
|
|
9298
8296
|
id_nearly_eq = rb_intern("nearly_eq");
|
9299
8297
|
id_to_a = rb_intern("to_a");
|
9300
8298
|
|
9301
|
-
|
9302
|
-
|
9303
|
-
|
9304
|
-
|
8299
|
+
/**
|
8300
|
+
* Document-class: Numo::DFloat
|
8301
|
+
*
|
8302
|
+
* Double precision floating point number (64-bit float) N-dimensional array class.
|
8303
|
+
*/
|
9305
8304
|
cT = rb_define_class_under(mNumo, "DFloat", cNArray);
|
9306
8305
|
|
9307
8306
|
// alias of DFloat
|
9308
8307
|
rb_define_const(mNumo, "Float64", numo_cDFloat);
|
9309
8308
|
|
9310
8309
|
hCast = rb_hash_new();
|
8310
|
+
/* Upcasting rules of DFloat. */
|
9311
8311
|
rb_define_const(cT, "UPCAST", hCast);
|
9312
8312
|
rb_hash_aset(hCast, rb_cArray, cT);
|
9313
8313
|
|
@@ -9334,148 +8334,1002 @@ void Init_numo_dfloat(void) {
|
|
9334
8334
|
rb_hash_aset(hCast, numo_cUInt8, numo_cDFloat);
|
9335
8335
|
rb_obj_freeze(hCast);
|
9336
8336
|
|
9337
|
-
|
8337
|
+
/* Element size of DFloat in bits. */
|
9338
8338
|
rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
|
9339
|
-
|
8339
|
+
/* Element size of DFloat in bytes. */
|
9340
8340
|
rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
|
9341
|
-
|
8341
|
+
/* Stride size of contiguous DFloat array. */
|
9342
8342
|
rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
|
9343
|
-
|
8343
|
+
/* Machine epsilon of DFloat. */
|
9344
8344
|
rb_define_const(cT, "EPSILON", M_EPSILON);
|
9345
|
-
|
8345
|
+
/* The largest representable value of DFloat. */
|
9346
8346
|
rb_define_const(cT, "MAX", M_MAX);
|
9347
|
-
|
8347
|
+
/* The smallest representable value of DFloat. */
|
9348
8348
|
rb_define_const(cT, "MIN", M_MIN);
|
9349
8349
|
rb_define_alloc_func(cT, dfloat_s_alloc_func);
|
9350
8350
|
rb_define_method(cT, "allocate", dfloat_allocate, 0);
|
8351
|
+
/**
|
8352
|
+
* Extract an element only if self is a dimensionless NArray.
|
8353
|
+
* @overload extract
|
8354
|
+
* @return [Numeric,Numo::NArray] Extract element value as Ruby Object
|
8355
|
+
* if self is a dimensionless NArray, otherwise returns self.
|
8356
|
+
*/
|
9351
8357
|
rb_define_method(cT, "extract", dfloat_extract, 0);
|
9352
|
-
|
8358
|
+
/**
|
8359
|
+
* Store elements to Numo::DFloat from other.
|
8360
|
+
* @overload store(other)
|
8361
|
+
* @param [Object] other
|
8362
|
+
* @return [Numo::DFloat] self
|
8363
|
+
*/
|
9353
8364
|
rb_define_method(cT, "store", dfloat_store, 1);
|
9354
|
-
|
8365
|
+
/**
|
8366
|
+
* Cast object to Numo::DFloat.
|
8367
|
+
* @overload cast(array)
|
8368
|
+
* @param [Numeric,Array] elements
|
8369
|
+
* @param [Array] array
|
8370
|
+
* @return [Numo::DFloat]
|
8371
|
+
*/
|
9355
8372
|
rb_define_singleton_method(cT, "cast", dfloat_s_cast, 1);
|
8373
|
+
/**
|
8374
|
+
* Cast object to Numo::DFloat.
|
8375
|
+
* @overload [](elements)
|
8376
|
+
* @param [Numeric,Array] elements
|
8377
|
+
* @param [Array] array
|
8378
|
+
* @return [Numo::DFloat]
|
8379
|
+
*/
|
8380
|
+
rb_define_singleton_method(cT, "[]", dfloat_s_cast, -2);
|
8381
|
+
/**
|
8382
|
+
* Multi-dimensional element reference.
|
8383
|
+
* @overload [](dim0,...,dimL)
|
8384
|
+
* @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,Boolean,Symbol]
|
8385
|
+
* dim0,...,dimL multi-dimensional indices.
|
8386
|
+
* @return [Numeric,Numo::DFloat] an element or NArray view.
|
8387
|
+
* @see Numo::NArray#[]
|
8388
|
+
* @see #[]=
|
8389
|
+
*/
|
9356
8390
|
rb_define_method(cT, "[]", dfloat_aref, -1);
|
8391
|
+
/**
|
8392
|
+
* Multi-dimensional element assignment.
|
8393
|
+
* @overload []=(dim0,...,dimL,val)
|
8394
|
+
* @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,Boolean,Symbol]
|
8395
|
+
* dim0,...,dimL multi-dimensional indices.
|
8396
|
+
* @param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
|
8397
|
+
* @return [Numeric,Numo::NArray,Array] returns `val` (last argument).
|
8398
|
+
* @see Numo::NArray#[]=
|
8399
|
+
* @see #[]
|
8400
|
+
*/
|
9357
8401
|
rb_define_method(cT, "[]=", dfloat_aset, -1);
|
8402
|
+
/**
|
8403
|
+
* Return NArray with cast to the type of self.
|
8404
|
+
* @overload coerce_cast(type)
|
8405
|
+
* @return [nil]
|
8406
|
+
*/
|
9358
8407
|
rb_define_method(cT, "coerce_cast", dfloat_coerce_cast, 1);
|
8408
|
+
/**
|
8409
|
+
* Convert self to Array.
|
8410
|
+
* @overload to_a
|
8411
|
+
* @return [Array]
|
8412
|
+
*/
|
9359
8413
|
rb_define_method(cT, "to_a", dfloat_to_a, 0);
|
8414
|
+
/**
|
8415
|
+
* Fill elements with other.
|
8416
|
+
* @overload fill other
|
8417
|
+
* @param [Numeric] other
|
8418
|
+
* @return [Numo::DFloat] self.
|
8419
|
+
*/
|
9360
8420
|
rb_define_method(cT, "fill", dfloat_fill, 1);
|
8421
|
+
/**
|
8422
|
+
* Format elements into strings.
|
8423
|
+
* @overload format format
|
8424
|
+
* @param [String] format
|
8425
|
+
* @return [Numo::RObject] array of formatted strings.
|
8426
|
+
*/
|
9361
8427
|
rb_define_method(cT, "format", dfloat_format, -1);
|
8428
|
+
/**
|
8429
|
+
* Format elements into strings.
|
8430
|
+
* @overload format_to_a format
|
8431
|
+
* @param [String] format
|
8432
|
+
* @return [Array] array of formatted strings.
|
8433
|
+
*/
|
9362
8434
|
rb_define_method(cT, "format_to_a", dfloat_format_to_a, -1);
|
8435
|
+
/**
|
8436
|
+
* Returns a string containing a human-readable representation of NArray.
|
8437
|
+
* @overload inspect
|
8438
|
+
* @return [String]
|
8439
|
+
*/
|
9363
8440
|
rb_define_method(cT, "inspect", dfloat_inspect, 0);
|
8441
|
+
/**
|
8442
|
+
* Calls the given block once for each element in self,
|
8443
|
+
* passing that element as a parameter. For a block `{|x| ... }`,
|
8444
|
+
* @overload each
|
8445
|
+
* @return [Numo::NArray] self
|
8446
|
+
* @yieldparam [Numeric] x an element of NArray.
|
8447
|
+
* @see #each_with_index
|
8448
|
+
* @see #map
|
8449
|
+
*/
|
9364
8450
|
rb_define_method(cT, "each", dfloat_each, 0);
|
8451
|
+
/**
|
8452
|
+
* Unary map.
|
8453
|
+
* @overload map
|
8454
|
+
* @return [Numo::DFloat] map of self.
|
8455
|
+
*/
|
9365
8456
|
rb_define_method(cT, "map", dfloat_map, 0);
|
8457
|
+
/**
|
8458
|
+
* Invokes the given block once for each element of self, passing that element
|
8459
|
+
* and indices along each axis as parameters. For a block `{|x,i,j,...| ... }`,
|
8460
|
+
* @overload each_with_index
|
8461
|
+
* @yieldparam [Numeric] x an element
|
8462
|
+
* @yieldparam [Integer] i,j,... multitimensional indices
|
8463
|
+
* @return [Numo::NArray] self
|
8464
|
+
* @see #each
|
8465
|
+
* @see #map_with_index
|
8466
|
+
*/
|
9366
8467
|
rb_define_method(cT, "each_with_index", dfloat_each_with_index, 0);
|
8468
|
+
/**
|
8469
|
+
* Invokes the given block once for each element of self,
|
8470
|
+
* passing that element and indices along each axis as parameters.
|
8471
|
+
* Creates a new NArray containing the values returned by the block.
|
8472
|
+
* Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
|
8473
|
+
* For a block `{|x,i,j,...| ... }`,
|
8474
|
+
* @overload map_with_index
|
8475
|
+
* @yieldparam [Numeric] x an element
|
8476
|
+
* @yieldparam [Integer] i,j,... multitimensional indices
|
8477
|
+
* @return [Numo::NArray] mapped array
|
8478
|
+
* @see #map
|
8479
|
+
* @see #each_with_index
|
8480
|
+
*/
|
9367
8481
|
rb_define_method(cT, "map_with_index", dfloat_map_with_index, 0);
|
8482
|
+
/**
|
8483
|
+
* abs of self.
|
8484
|
+
* @overload abs
|
8485
|
+
* @return [Numo::DFloat] abs of self.
|
8486
|
+
*/
|
9368
8487
|
rb_define_method(cT, "abs", dfloat_abs, 0);
|
8488
|
+
/**
|
8489
|
+
* Binary add.
|
8490
|
+
* @overload + other
|
8491
|
+
* @param [Numo::NArray,Numeric] other
|
8492
|
+
* @return [Numo::NArray] self + other
|
8493
|
+
*/
|
9369
8494
|
rb_define_method(cT, "+", dfloat_add, 1);
|
8495
|
+
/**
|
8496
|
+
* Binary sub.
|
8497
|
+
* @overload - other
|
8498
|
+
* @param [Numo::NArray,Numeric] other
|
8499
|
+
* @return [Numo::NArray] self - other
|
8500
|
+
*/
|
9370
8501
|
rb_define_method(cT, "-", dfloat_sub, 1);
|
8502
|
+
/**
|
8503
|
+
* Binary mul.
|
8504
|
+
* @overload * other
|
8505
|
+
* @param [Numo::NArray,Numeric] other
|
8506
|
+
* @return [Numo::NArray] self * other
|
8507
|
+
*/
|
9371
8508
|
rb_define_method(cT, "*", dfloat_mul, 1);
|
8509
|
+
/**
|
8510
|
+
* Binary div.
|
8511
|
+
* @overload / other
|
8512
|
+
* @param [Numo::NArray,Numeric] other
|
8513
|
+
* @return [Numo::NArray] self / other
|
8514
|
+
*/
|
9372
8515
|
rb_define_method(cT, "/", dfloat_div, 1);
|
8516
|
+
/**
|
8517
|
+
* Binary mod.
|
8518
|
+
* @overload % other
|
8519
|
+
* @param [Numo::NArray,Numeric] other
|
8520
|
+
* @return [Numo::NArray] self % other
|
8521
|
+
*/
|
9373
8522
|
rb_define_method(cT, "%", dfloat_mod, 1);
|
8523
|
+
/**
|
8524
|
+
* Binary divmod.
|
8525
|
+
* @overload divmod other
|
8526
|
+
* @param [Numo::NArray,Numeric] other
|
8527
|
+
* @return [Numo::NArray] divmod of self and other.
|
8528
|
+
*/
|
9374
8529
|
rb_define_method(cT, "divmod", dfloat_divmod, 1);
|
8530
|
+
/**
|
8531
|
+
* Binary power.
|
8532
|
+
* @overload ** other
|
8533
|
+
* @param [Numo::NArray,Numeric] other
|
8534
|
+
* @return [Numo::NArray] self to the other-th power.
|
8535
|
+
*/
|
9375
8536
|
rb_define_method(cT, "**", dfloat_pow, 1);
|
9376
8537
|
rb_define_alias(cT, "pow", "**");
|
8538
|
+
/**
|
8539
|
+
* Unary minus.
|
8540
|
+
* @overload -@
|
8541
|
+
* @return [Numo::DFloat] minus of self.
|
8542
|
+
*/
|
9377
8543
|
rb_define_method(cT, "-@", dfloat_minus, 0);
|
8544
|
+
/**
|
8545
|
+
* Unary reciprocal.
|
8546
|
+
* @overload reciprocal
|
8547
|
+
* @return [Numo::DFloat] reciprocal of self.
|
8548
|
+
*/
|
9378
8549
|
rb_define_method(cT, "reciprocal", dfloat_reciprocal, 0);
|
8550
|
+
/**
|
8551
|
+
* Unary sign.
|
8552
|
+
* @overload sign
|
8553
|
+
* @return [Numo::DFloat] sign of self.
|
8554
|
+
*/
|
9379
8555
|
rb_define_method(cT, "sign", dfloat_sign, 0);
|
8556
|
+
/**
|
8557
|
+
* Unary square.
|
8558
|
+
* @overload square
|
8559
|
+
* @return [Numo::DFloat] square of self.
|
8560
|
+
*/
|
9380
8561
|
rb_define_method(cT, "square", dfloat_square, 0);
|
9381
8562
|
rb_define_alias(cT, "conj", "view");
|
9382
8563
|
rb_define_alias(cT, "im", "view");
|
9383
8564
|
rb_define_alias(cT, "conjugate", "conj");
|
8565
|
+
/**
|
8566
|
+
* Comparison eq other.
|
8567
|
+
* @overload eq other
|
8568
|
+
* @param [Numo::NArray,Numeric] other
|
8569
|
+
* @return [Numo::Bit] result of self eq other.
|
8570
|
+
*/
|
9384
8571
|
rb_define_method(cT, "eq", dfloat_eq, 1);
|
8572
|
+
/**
|
8573
|
+
* Comparison ne other.
|
8574
|
+
* @overload ne other
|
8575
|
+
* @param [Numo::NArray,Numeric] other
|
8576
|
+
* @return [Numo::Bit] result of self ne other.
|
8577
|
+
*/
|
9385
8578
|
rb_define_method(cT, "ne", dfloat_ne, 1);
|
8579
|
+
/**
|
8580
|
+
* Comparison nearly_eq other.
|
8581
|
+
* @overload nearly_eq other
|
8582
|
+
* @param [Numo::NArray,Numeric] other
|
8583
|
+
* @return [Numo::Bit] result of self nearly_eq other.
|
8584
|
+
*/
|
9386
8585
|
rb_define_method(cT, "nearly_eq", dfloat_nearly_eq, 1);
|
9387
8586
|
rb_define_alias(cT, "close_to", "nearly_eq");
|
8587
|
+
/**
|
8588
|
+
* Unary floor.
|
8589
|
+
* @overload floor
|
8590
|
+
* @return [Numo::DFloat] floor of self.
|
8591
|
+
*/
|
9388
8592
|
rb_define_method(cT, "floor", dfloat_floor, 0);
|
8593
|
+
/**
|
8594
|
+
* Unary round.
|
8595
|
+
* @overload round
|
8596
|
+
* @return [Numo::DFloat] round of self.
|
8597
|
+
*/
|
9389
8598
|
rb_define_method(cT, "round", dfloat_round, 0);
|
8599
|
+
/**
|
8600
|
+
* Unary ceil.
|
8601
|
+
* @overload ceil
|
8602
|
+
* @return [Numo::DFloat] ceil of self.
|
8603
|
+
*/
|
9390
8604
|
rb_define_method(cT, "ceil", dfloat_ceil, 0);
|
8605
|
+
/**
|
8606
|
+
* Unary trunc.
|
8607
|
+
* @overload trunc
|
8608
|
+
* @return [Numo::DFloat] trunc of self.
|
8609
|
+
*/
|
9391
8610
|
rb_define_method(cT, "trunc", dfloat_trunc, 0);
|
8611
|
+
/**
|
8612
|
+
* Unary rint.
|
8613
|
+
* @overload rint
|
8614
|
+
* @return [Numo::DFloat] rint of self.
|
8615
|
+
*/
|
9392
8616
|
rb_define_method(cT, "rint", dfloat_rint, 0);
|
8617
|
+
/**
|
8618
|
+
* Binary copysign.
|
8619
|
+
* @overload copysign other
|
8620
|
+
* @param [Numo::NArray,Numeric] other
|
8621
|
+
* @return [Numo::NArray] self copysign other
|
8622
|
+
*/
|
9393
8623
|
rb_define_method(cT, "copysign", dfloat_copysign, 1);
|
8624
|
+
/**
|
8625
|
+
* Condition of signbit.
|
8626
|
+
* @overload signbit
|
8627
|
+
* @return [Numo::Bit] Condition of signbit.
|
8628
|
+
*/
|
9394
8629
|
rb_define_method(cT, "signbit", dfloat_signbit, 0);
|
8630
|
+
/**
|
8631
|
+
* modf of self.
|
8632
|
+
* @overload modf
|
8633
|
+
* @return [Numo::DFloat] modf of self.
|
8634
|
+
*/
|
9395
8635
|
rb_define_method(cT, "modf", dfloat_modf, 0);
|
8636
|
+
/**
|
8637
|
+
* Comparison gt other.
|
8638
|
+
* @overload gt other
|
8639
|
+
* @param [Numo::NArray,Numeric] other
|
8640
|
+
* @return [Numo::Bit] result of self gt other.
|
8641
|
+
*/
|
9396
8642
|
rb_define_method(cT, "gt", dfloat_gt, 1);
|
8643
|
+
/**
|
8644
|
+
* Comparison ge other.
|
8645
|
+
* @overload ge other
|
8646
|
+
* @param [Numo::NArray,Numeric] other
|
8647
|
+
* @return [Numo::Bit] result of self ge other.
|
8648
|
+
*/
|
9397
8649
|
rb_define_method(cT, "ge", dfloat_ge, 1);
|
8650
|
+
/**
|
8651
|
+
* Comparison lt other.
|
8652
|
+
* @overload lt other
|
8653
|
+
* @param [Numo::NArray,Numeric] other
|
8654
|
+
* @return [Numo::Bit] result of self lt other.
|
8655
|
+
*/
|
9398
8656
|
rb_define_method(cT, "lt", dfloat_lt, 1);
|
8657
|
+
/**
|
8658
|
+
* Comparison le other.
|
8659
|
+
* @overload le other
|
8660
|
+
* @param [Numo::NArray,Numeric] other
|
8661
|
+
* @return [Numo::Bit] result of self le other.
|
8662
|
+
*/
|
9399
8663
|
rb_define_method(cT, "le", dfloat_le, 1);
|
9400
8664
|
rb_define_alias(cT, ">", "gt");
|
9401
8665
|
rb_define_alias(cT, ">=", "ge");
|
9402
8666
|
rb_define_alias(cT, "<", "lt");
|
9403
8667
|
rb_define_alias(cT, "<=", "le");
|
8668
|
+
/**
|
8669
|
+
* Clip array elements by [min,max].
|
8670
|
+
* If either of min or max is nil, one side is clipped.
|
8671
|
+
* @overload clip(min,max)
|
8672
|
+
* @param [Numo::NArray,Numeric] min
|
8673
|
+
* @param [Numo::NArray,Numeric] max
|
8674
|
+
* @return [Numo::NArray] result of clip.
|
8675
|
+
*
|
8676
|
+
* @example
|
8677
|
+
* a = Numo::Int32.new(10).seq
|
8678
|
+
* # => Numo::Int32#shape=[10]
|
8679
|
+
* # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
8680
|
+
*
|
8681
|
+
* a.clip(1,8)
|
8682
|
+
* # => Numo::Int32#shape=[10]
|
8683
|
+
* # [1, 1, 2, 3, 4, 5, 6, 7, 8, 8]
|
8684
|
+
*
|
8685
|
+
* a.inplace.clip(3,6)
|
8686
|
+
* a
|
8687
|
+
* # => Numo::Int32#shape=[10]
|
8688
|
+
* # [3, 3, 3, 3, 4, 5, 6, 6, 6, 6]
|
8689
|
+
*
|
8690
|
+
* b = Numo::Int32.new(10).seq
|
8691
|
+
* # => Numo::Int32#shape=[10]
|
8692
|
+
* # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
8693
|
+
*
|
8694
|
+
* b.clip([3,4,1,1,1,4,4,4,4,4], 8)
|
8695
|
+
* # => Numo::Int32#shape=[10]
|
8696
|
+
* # [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]
|
8697
|
+
*/
|
9404
8698
|
rb_define_method(cT, "clip", dfloat_clip, 2);
|
8699
|
+
/**
|
8700
|
+
* Condition of isnan.
|
8701
|
+
* @overload isnan
|
8702
|
+
* @return [Numo::Bit] Condition of isnan.
|
8703
|
+
*/
|
9405
8704
|
rb_define_method(cT, "isnan", dfloat_isnan, 0);
|
8705
|
+
/**
|
8706
|
+
* Condition of isinf.
|
8707
|
+
* @overload isinf
|
8708
|
+
* @return [Numo::Bit] Condition of isinf.
|
8709
|
+
*/
|
9406
8710
|
rb_define_method(cT, "isinf", dfloat_isinf, 0);
|
8711
|
+
/**
|
8712
|
+
* Condition of isposinf.
|
8713
|
+
* @overload isposinf
|
8714
|
+
* @return [Numo::Bit] Condition of isposinf.
|
8715
|
+
*/
|
9407
8716
|
rb_define_method(cT, "isposinf", dfloat_isposinf, 0);
|
8717
|
+
/**
|
8718
|
+
* Condition of isneginf.
|
8719
|
+
* @overload isneginf
|
8720
|
+
* @return [Numo::Bit] Condition of isneginf.
|
8721
|
+
*/
|
9408
8722
|
rb_define_method(cT, "isneginf", dfloat_isneginf, 0);
|
8723
|
+
/**
|
8724
|
+
* Condition of isfinite.
|
8725
|
+
* @overload isfinite
|
8726
|
+
* @return [Numo::Bit] Condition of isfinite.
|
8727
|
+
*/
|
9409
8728
|
rb_define_method(cT, "isfinite", dfloat_isfinite, 0);
|
8729
|
+
/**
|
8730
|
+
* sum of self.
|
8731
|
+
* @overload sum(axis:nil, keepdims:false, nan:false)
|
8732
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8733
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8734
|
+
* @param [Numeric,Array,Range] axis Performs sum along the axis.
|
8735
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8736
|
+
* dimensions with size one.
|
8737
|
+
* @return [Numo::DFloat] returns result of sum.
|
8738
|
+
*/
|
9410
8739
|
rb_define_method(cT, "sum", dfloat_sum, -1);
|
8740
|
+
/**
|
8741
|
+
* prod of self.
|
8742
|
+
* @overload prod(axis:nil, keepdims:false, nan:false)
|
8743
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8744
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8745
|
+
* @param [Numeric,Array,Range] axis Performs prod along the axis.
|
8746
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8747
|
+
* dimensions with size one.
|
8748
|
+
* @return [Numo::DFloat] returns result of prod.
|
8749
|
+
*/
|
9411
8750
|
rb_define_method(cT, "prod", dfloat_prod, -1);
|
8751
|
+
/**
|
8752
|
+
* kahan_sum of self.
|
8753
|
+
* @overload kahan_sum(axis:nil, keepdims:false, nan:false)
|
8754
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8755
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8756
|
+
* @param [Numeric,Array,Range] axis Performs kahan_sum along the axis.
|
8757
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8758
|
+
* dimensions with size one.
|
8759
|
+
* @return [Numo::DFloat] returns result of kahan_sum.
|
8760
|
+
*/
|
9412
8761
|
rb_define_method(cT, "kahan_sum", dfloat_kahan_sum, -1);
|
8762
|
+
/**
|
8763
|
+
* mean of self.
|
8764
|
+
* @overload mean(axis: nil, keepdims: false, nan: false)
|
8765
|
+
* @param axis [Numeric, Array, Range] Performs mean along the axis.
|
8766
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
8767
|
+
* dimensions with size one.
|
8768
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
8769
|
+
* (avoid NaN for sum/mean etc, or return NaN for min/max etc).
|
8770
|
+
* @return [Numo::DFloat] returns result of mean.
|
8771
|
+
*/
|
9413
8772
|
rb_define_method(cT, "mean", dfloat_mean, -1);
|
9414
|
-
|
8773
|
+
/**
|
8774
|
+
* var of self.
|
8775
|
+
* @overload var(axis: nil, keepdims: false, nan: false)
|
8776
|
+
* @param axis [Numeric, Array, Range] Performs var along the axis.
|
8777
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
8778
|
+
* dimensions with size one.
|
8779
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
8780
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8781
|
+
* @return [Numo::DFloat] returns result of var.
|
8782
|
+
*/
|
9415
8783
|
rb_define_method(cT, "var", dfloat_var, -1);
|
8784
|
+
/**
|
8785
|
+
* stddev of self.
|
8786
|
+
* @overload stddev(axis: nil, keepdims: false, nan: false)
|
8787
|
+
* @param axis [Numeric, Array, Range] Performs stddev along the axis.
|
8788
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
8789
|
+
* dimensions with size one.
|
8790
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
8791
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8792
|
+
* @return [Numo::DFloat] returns result of stddev.
|
8793
|
+
*/
|
8794
|
+
rb_define_method(cT, "stddev", dfloat_stddev, -1);
|
8795
|
+
/**
|
8796
|
+
* rms of self.
|
8797
|
+
* @overload rms(axis: nil, keepdims: false, nan: false)
|
8798
|
+
* @param axis [Numeric, Array, Range] Performs rms along the axis.
|
8799
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
8800
|
+
* dimensions with size one.
|
8801
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
8802
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8803
|
+
* @return [Numo::DFloat] returns result of rms.
|
8804
|
+
*/
|
9416
8805
|
rb_define_method(cT, "rms", dfloat_rms, -1);
|
8806
|
+
/**
|
8807
|
+
* min of self.
|
8808
|
+
* @overload min(axis:nil, keepdims:false, nan:false)
|
8809
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8810
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8811
|
+
* @param [Numeric,Array,Range] axis Performs min along the axis.
|
8812
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8813
|
+
* dimensions with size one.
|
8814
|
+
* @return [Numo::DFloat] returns result of min.
|
8815
|
+
*/
|
9417
8816
|
rb_define_method(cT, "min", dfloat_min, -1);
|
8817
|
+
/**
|
8818
|
+
* max of self.
|
8819
|
+
* @overload max(axis:nil, keepdims:false, nan:false)
|
8820
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8821
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8822
|
+
* @param [Numeric,Array,Range] axis Performs max along the axis.
|
8823
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8824
|
+
* dimensions with size one.
|
8825
|
+
* @return [Numo::DFloat] returns result of max.
|
8826
|
+
*/
|
9418
8827
|
rb_define_method(cT, "max", dfloat_max, -1);
|
8828
|
+
/**
|
8829
|
+
* ptp of self.
|
8830
|
+
* @overload ptp(axis:nil, keepdims:false, nan:false)
|
8831
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8832
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8833
|
+
* @param [Numeric,Array,Range] axis Performs ptp along the axis.
|
8834
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8835
|
+
* dimensions with size one.
|
8836
|
+
* @return [Numo::DFloat] returns result of ptp.
|
8837
|
+
*/
|
9419
8838
|
rb_define_method(cT, "ptp", dfloat_ptp, -1);
|
8839
|
+
/**
|
8840
|
+
* Index of the maximum value.
|
8841
|
+
* @overload max_index(axis:nil, nan:false)
|
8842
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
8843
|
+
* @param [Numeric,Array,Range] axis Finds maximum values along the axis
|
8844
|
+
* and returns **flat 1-d indices**.
|
8845
|
+
* @return [Integer,Numo::Int] returns result indices.
|
8846
|
+
* @see #argmax
|
8847
|
+
* @see #max
|
8848
|
+
*
|
8849
|
+
* @example
|
8850
|
+
* a = Numo::NArray[3,4,1,2]
|
8851
|
+
* a.max_index #=> 1
|
8852
|
+
*
|
8853
|
+
* b = Numo::NArray[[3,4,1],[2,0,5]]
|
8854
|
+
* b.max_index #=> 5
|
8855
|
+
* b.max_index(axis:1) #=> [1, 5]
|
8856
|
+
* b.max_index(axis:0) #=> [0, 1, 5]
|
8857
|
+
* b[b.max_index(axis:0)] #=> [3, 4, 5]
|
8858
|
+
*/
|
9420
8859
|
rb_define_method(cT, "max_index", dfloat_max_index, -1);
|
8860
|
+
/**
|
8861
|
+
* Index of the minimum value.
|
8862
|
+
* @overload min_index(axis:nil, nan:false)
|
8863
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
8864
|
+
* @param [Numeric,Array,Range] axis Finds minimum values along the axis
|
8865
|
+
* and returns **flat 1-d indices**.
|
8866
|
+
* @return [Integer,Numo::Int] returns result indices.
|
8867
|
+
* @see #argmin
|
8868
|
+
* @see #min
|
8869
|
+
*
|
8870
|
+
* @example
|
8871
|
+
* a = Numo::NArray[3,4,1,2]
|
8872
|
+
* a.min_index #=> 2
|
8873
|
+
*
|
8874
|
+
* b = Numo::NArray[[3,4,1],[2,0,5]]
|
8875
|
+
* b.min_index #=> 4
|
8876
|
+
* b.min_index(axis:1) #=> [2, 4]
|
8877
|
+
* b.min_index(axis:0) #=> [3, 4, 2]
|
8878
|
+
* b[b.min_index(axis:0)] #=> [2, 0, 1]
|
8879
|
+
*/
|
9421
8880
|
rb_define_method(cT, "min_index", dfloat_min_index, -1);
|
8881
|
+
/**
|
8882
|
+
* Index of the maximum value.
|
8883
|
+
* @overload argmax(axis:nil, nan:false)
|
8884
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
8885
|
+
* @param [Numeric,Array,Range] axis Finds maximum values along the axis
|
8886
|
+
* and returns **indices along the axis**.
|
8887
|
+
* @return [Integer,Numo::Int] returns the result indices.
|
8888
|
+
* @see #max_index
|
8889
|
+
* @see #max
|
8890
|
+
*
|
8891
|
+
* @example
|
8892
|
+
* a = Numo::NArray[3,4,1,2]
|
8893
|
+
* a.argmax #=> 1
|
8894
|
+
*
|
8895
|
+
* b = Numo::NArray[[3,4,1],[2,0,5]]
|
8896
|
+
* b.argmax #=> 5
|
8897
|
+
* b.argmax(axis:1) #=> [1, 2]
|
8898
|
+
* b.argmax(axis:0) #=> [0, 0, 1]
|
8899
|
+
* b.at(b.argmax(axis:0), 0..-1) #=> [3, 4, 5]
|
8900
|
+
*/
|
9422
8901
|
rb_define_method(cT, "argmax", dfloat_argmax, -1);
|
8902
|
+
/**
|
8903
|
+
* Index of the minimum value.
|
8904
|
+
* @overload argmin(axis:nil, nan:false)
|
8905
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
8906
|
+
* @param [Numeric,Array,Range] axis Finds minimum values along the axis
|
8907
|
+
* and returns **indices along the axis**.
|
8908
|
+
* @return [Integer,Numo::Int] returns the result indices.
|
8909
|
+
* @see #min_index
|
8910
|
+
* @see #min
|
8911
|
+
*
|
8912
|
+
* @example
|
8913
|
+
* a = Numo::NArray[3,4,1,2]
|
8914
|
+
* a.argmin #=> 2
|
8915
|
+
*
|
8916
|
+
* b = Numo::NArray[[3,4,1],[2,0,5]]
|
8917
|
+
* b.argmin #=> 4
|
8918
|
+
* b.argmin(axis:1) #=> [2, 1]
|
8919
|
+
* b.argmin(axis:0) #=> [1, 1, 0]
|
8920
|
+
* b.at(b.argmin(axis:0), 0..-1) #=> [2, 0, 1]
|
8921
|
+
*/
|
9423
8922
|
rb_define_method(cT, "argmin", dfloat_argmin, -1);
|
8923
|
+
/**
|
8924
|
+
* minmax of self.
|
8925
|
+
* @overload minmax(axis:nil, keepdims:false, nan:false)
|
8926
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
8927
|
+
* @param [Numeric,Array,Range] axis Finds min-max along the axis.
|
8928
|
+
* @param [Boolean] keepdims (keyword) If true, the reduced axes are left
|
8929
|
+
* in the result array as dimensions with size one.
|
8930
|
+
* @return [Numo::DFloat,Numo::DFloat] min and max of self.
|
8931
|
+
*/
|
9424
8932
|
rb_define_method(cT, "minmax", dfloat_minmax, -1);
|
8933
|
+
/**
|
8934
|
+
* Element-wise maximum of two arrays.
|
8935
|
+
* @overload maximum(a1, a2, nan:false)
|
8936
|
+
* @param [Numo::NArray,Numeric] a1 The array to be compared.
|
8937
|
+
* @param [Numo::NArray,Numeric] a2 The array to be compared.
|
8938
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
8939
|
+
* @return [Numo::DFloat]
|
8940
|
+
*/
|
9425
8941
|
rb_define_module_function(cT, "maximum", dfloat_s_maximum, -1);
|
8942
|
+
/**
|
8943
|
+
* Element-wise minimum of two arrays.
|
8944
|
+
* @overload minimum(a1, a2, nan:false)
|
8945
|
+
* @param [Numo::NArray,Numeric] a1 The array to be compared.
|
8946
|
+
* @param [Numo::NArray,Numeric] a2 The array to be compared.
|
8947
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
8948
|
+
* @return [Numo::DFloat]
|
8949
|
+
*/
|
9426
8950
|
rb_define_module_function(cT, "minimum", dfloat_s_minimum, -1);
|
8951
|
+
/**
|
8952
|
+
* cumsum of self.
|
8953
|
+
* @overload cumsum(axis:nil, nan:false)
|
8954
|
+
* @param [Numeric,Array,Range] axis Performs cumsum along the axis.
|
8955
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
8956
|
+
* @return [Numo::DFloat] cumsum of self.
|
8957
|
+
*/
|
9427
8958
|
rb_define_method(cT, "cumsum", dfloat_cumsum, -1);
|
8959
|
+
/**
|
8960
|
+
* cumprod of self.
|
8961
|
+
* @overload cumprod(axis:nil, nan:false)
|
8962
|
+
* @param [Numeric,Array,Range] axis Performs cumprod along the axis.
|
8963
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
8964
|
+
* @return [Numo::DFloat] cumprod of self.
|
8965
|
+
*/
|
9428
8966
|
rb_define_method(cT, "cumprod", dfloat_cumprod, -1);
|
8967
|
+
/**
|
8968
|
+
* Binary mulsum.
|
8969
|
+
* @overload mulsum(other, axis:nil, keepdims:false, nan:false)
|
8970
|
+
* @param [Numo::NArray,Numeric] other
|
8971
|
+
* @param [Numeric,Array,Range] axis Performs mulsum along the axis.
|
8972
|
+
* @param [Boolean] keepdims (keyword) If true, the reduced axes are left
|
8973
|
+
* in the result array as dimensions with size one.
|
8974
|
+
* @param [Boolean] nan (keyword) If true, apply NaN-aware algorithm (avoid NaN if exists).
|
8975
|
+
* @return [Numo::NArray] mulsum of self and other.
|
8976
|
+
*/
|
9429
8977
|
rb_define_method(cT, "mulsum", dfloat_mulsum, -1);
|
8978
|
+
/**
|
8979
|
+
* Set linear sequence of numbers to self. The sequence is obtained from
|
8980
|
+
* beg+i*step
|
8981
|
+
* where i is 1-dimensional index.
|
8982
|
+
* @overload seq([beg,[step]])
|
8983
|
+
* @param [Numeric] beg beginning of sequence. (default=0)
|
8984
|
+
* @param [Numeric] step step of sequence. (default=1)
|
8985
|
+
* @return [Numo::DFloat] self.
|
8986
|
+
* @example
|
8987
|
+
* Numo::DFloat.new(6).seq(1,-0.2)
|
8988
|
+
* # => Numo::DFloat#shape=[6]
|
8989
|
+
* # [1, 0.8, 0.6, 0.4, 0.2, 0]
|
8990
|
+
*
|
8991
|
+
* Numo::DComplex.new(6).seq(1,-0.2+0.2i)
|
8992
|
+
* # => Numo::DComplex#shape=[6]
|
8993
|
+
* # [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
8994
|
+
*/
|
9430
8995
|
rb_define_method(cT, "seq", dfloat_seq, -1);
|
8996
|
+
/**
|
8997
|
+
* Set logarithmic sequence of numbers to self. The sequence is obtained from
|
8998
|
+
* `base**(beg+i*step)`
|
8999
|
+
* where i is 1-dimensional index.
|
9000
|
+
* Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
|
9001
|
+
*
|
9002
|
+
* @overload logseq(beg,step,[base])
|
9003
|
+
* @param [Numeric] beg The beginning of sequence.
|
9004
|
+
* @param [Numeric] step The step of sequence.
|
9005
|
+
* @param [Numeric] base The base of log space. (default=10)
|
9006
|
+
* @return [Numo::DFloat] self.
|
9007
|
+
*
|
9008
|
+
* @example
|
9009
|
+
* Numo::DFloat.new(5).logseq(4,-1,2)
|
9010
|
+
* # => Numo::DFloat#shape=[5]
|
9011
|
+
* # [16, 8, 4, 2, 1]
|
9012
|
+
*
|
9013
|
+
* Numo::DComplex.new(5).logseq(0,1i*Math::PI/3,Math::E)
|
9014
|
+
* # => Numo::DComplex#shape=[5]
|
9015
|
+
* # [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
|
9016
|
+
*/
|
9431
9017
|
rb_define_method(cT, "logseq", dfloat_logseq, -1);
|
9018
|
+
/**
|
9019
|
+
* Eye: Set a value to diagonal components, set 0 to non-diagonal components.
|
9020
|
+
* @overload eye([element,offset])
|
9021
|
+
* @param [Numeric] element Diagonal element to be stored. Default is 1.
|
9022
|
+
* @param [Integer] offset Diagonal offset from the main diagonal.
|
9023
|
+
* The default is 0. k>0 for diagonals above the main diagonal,
|
9024
|
+
* and k<0 for diagonals below the main diagonal.
|
9025
|
+
* @return [Numo::DFloat] eye of self.
|
9026
|
+
*/
|
9432
9027
|
rb_define_method(cT, "eye", dfloat_eye, -1);
|
9433
9028
|
rb_define_alias(cT, "indgen", "seq");
|
9029
|
+
/**
|
9030
|
+
* Generate uniformly distributed random numbers on self narray.
|
9031
|
+
* @overload rand([[low],high])
|
9032
|
+
* @param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
9033
|
+
* @param [Numeric] high upper exclusive boundary of random numbers.
|
9034
|
+
* (default=1 or 1+1i for complex types)
|
9035
|
+
* @return [Numo::DFloat] self.
|
9036
|
+
* @example
|
9037
|
+
* Numo::DFloat.new(6).rand
|
9038
|
+
* # => Numo::DFloat#shape=[6]
|
9039
|
+
* # [0.0617545, 0.373067, 0.794815, 0.201042, 0.116041, 0.344032]
|
9040
|
+
*
|
9041
|
+
* Numo::DComplex.new(6).rand(5+5i)
|
9042
|
+
* # => Numo::DComplex#shape=[6]
|
9043
|
+
* # [2.69974+3.68908i, 0.825443+0.254414i, 0.540323+0.34354i, 4.52061+2.39322i, ...]
|
9044
|
+
*
|
9045
|
+
* Numo::Int32.new(6).rand(2,5)
|
9046
|
+
* # => Numo::Int32#shape=[6]
|
9047
|
+
* # [4, 3, 3, 2, 4, 2]
|
9048
|
+
*/
|
9434
9049
|
rb_define_method(cT, "rand", dfloat_rand, -1);
|
9050
|
+
/**
|
9051
|
+
* Generates random numbers from the normal distribution on self narray
|
9052
|
+
* using Box-Muller Transformation.
|
9053
|
+
* @overload rand_norm([mu,[sigma]])
|
9054
|
+
* @param [Numeric] mu mean of normal distribution. (default=0)
|
9055
|
+
* @param [Numeric] sigma standard deviation of normal distribution. (default=1)
|
9056
|
+
* @return [Numo::DFloat] self.
|
9057
|
+
* @example
|
9058
|
+
* Numo::DFloat.new(5,5).rand_norm
|
9059
|
+
* # => Numo::DFloat#shape=[5,5]
|
9060
|
+
* # [[-0.581255, -0.168354, 0.586895, -0.595142, -0.802802],
|
9061
|
+
* # [-0.326106, 0.282922, 1.68427, 0.918499, -0.0485384],
|
9062
|
+
* # [-0.464453, -0.992194, 0.413794, -0.60717, -0.699695],
|
9063
|
+
* # [-1.64168, 0.48676, -0.875871, -1.43275, 0.812172],
|
9064
|
+
* # [-0.209975, -0.103612, -0.878617, -1.42495, 1.0968]]
|
9065
|
+
*
|
9066
|
+
* Numo::DFloat.new(5,5).rand_norm(10,0.1)
|
9067
|
+
* # => Numo::DFloat#shape=[5,5]
|
9068
|
+
* # [[9.9019, 9.90339, 10.0826, 9.98384, 9.72861],
|
9069
|
+
* # [9.81507, 10.0272, 9.91445, 10.0568, 9.88923],
|
9070
|
+
* # [10.0234, 9.97874, 9.96011, 9.9006, 9.99964],
|
9071
|
+
* # [10.0186, 9.94598, 9.92236, 9.99811, 9.97003],
|
9072
|
+
* # [9.79266, 9.95044, 9.95212, 9.93692, 10.2027]]
|
9073
|
+
*
|
9074
|
+
* Numo::DComplex.new(3,3).rand_norm(5+5i)
|
9075
|
+
* # => Numo::DComplex#shape=[3,3]
|
9076
|
+
* # [[5.84303+4.40052i, 4.00984+6.08982i, 5.10979+5.13215i],
|
9077
|
+
* # [4.26477+3.99655i, 4.90052+5.00763i, 4.46607+2.3444i],
|
9078
|
+
* # [4.5528+7.11003i, 5.62117+6.69094i, 5.05443+5.35133i]]
|
9079
|
+
*/
|
9435
9080
|
rb_define_method(cT, "rand_norm", dfloat_rand_norm, -1);
|
9081
|
+
/**
|
9082
|
+
* Calculate polynomial.
|
9083
|
+
* `x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
|
9084
|
+
* @overload poly a0, a1, ..., an
|
9085
|
+
* @param [Numo::NArray,Numeric] a0,a1,...,an
|
9086
|
+
* @return [Numo::DFloat]
|
9087
|
+
*/
|
9436
9088
|
rb_define_method(cT, "poly", dfloat_poly, -2);
|
9437
|
-
|
9089
|
+
/**
|
9090
|
+
* sort of self.
|
9091
|
+
* @overload sort(axis:nil, nan:false)
|
9092
|
+
* @param [Boolean] nan If true, propagete NaN. If false, ignore NaN.
|
9093
|
+
* @param [Numeric,Array,Range] axis Performs sort along the axis.
|
9094
|
+
* @return [Numo::DFloat] returns result of sort.
|
9095
|
+
* @example
|
9096
|
+
* Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
|
9097
|
+
*/
|
9438
9098
|
rb_define_method(cT, "sort", dfloat_sort, -1);
|
9439
|
-
|
9099
|
+
/**
|
9100
|
+
* sort_index. Returns an index array of sort result.
|
9101
|
+
* @overload sort_index(axis:nil, nan:false)
|
9102
|
+
* @param [Boolean] nan If true, propagete NaN. If false, ignore NaN.
|
9103
|
+
* @param [Numeric,Array,Range] axis Performs sort_index along the axis.
|
9104
|
+
* @return [Integer,Numo::Int] returns result index of sort_index.
|
9105
|
+
* @example
|
9106
|
+
* Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
|
9107
|
+
*/
|
9440
9108
|
rb_define_method(cT, "sort_index", dfloat_sort_index, -1);
|
9109
|
+
/**
|
9110
|
+
* median of self.
|
9111
|
+
* @overload median(axis:nil, keepdims:false, nan:false)
|
9112
|
+
* @param [Boolean] nan (keyword) If true, propagete NaN. If false, ignore NaN.
|
9113
|
+
* @param [Numeric,Array,Range] axis Finds median along the axis.
|
9114
|
+
* @param [Boolean] keepdims If true, the reduced axes are left
|
9115
|
+
* in the result array as dimensions with size one.
|
9116
|
+
* @return [Numo::DFloat] returns median of self.
|
9117
|
+
*/
|
9441
9118
|
rb_define_method(cT, "median", dfloat_median, -1);
|
9442
|
-
rb_define_singleton_method(cT, "[]", dfloat_s_cast, -2);
|
9443
|
-
|
9444
|
-
/*
|
9445
|
-
Document-module: Numo::DFloat::NMath
|
9446
|
-
|
9447
|
-
*/
|
9448
9119
|
|
9120
|
+
/**
|
9121
|
+
* Document-module: Numo::DFloat::Math
|
9122
|
+
*
|
9123
|
+
* This module contains mathematical functions for Numo::DFloat.
|
9124
|
+
*/
|
9449
9125
|
mTM = rb_define_module_under(cT, "Math");
|
9450
|
-
|
9126
|
+
/**
|
9127
|
+
* Calculate sqrt(x).
|
9128
|
+
* @overload sqrt(x)
|
9129
|
+
* @param [Numo::NArray,Numeric] x input value
|
9130
|
+
* @return [Numo::DFloat] result of sqrt(x).
|
9131
|
+
*/
|
9451
9132
|
rb_define_module_function(mTM, "sqrt", dfloat_math_s_sqrt, 1);
|
9133
|
+
/**
|
9134
|
+
* Calculate cbrt(x).
|
9135
|
+
* @overload cbrt(x)
|
9136
|
+
* @param [Numo::NArray,Numeric] x input value
|
9137
|
+
* @return [Numo::DFloat] result of cbrt(x).
|
9138
|
+
*/
|
9452
9139
|
rb_define_module_function(mTM, "cbrt", dfloat_math_s_cbrt, 1);
|
9140
|
+
/**
|
9141
|
+
* Calculate log(x).
|
9142
|
+
* @overload log(x)
|
9143
|
+
* @param [Numo::NArray,Numeric] x input value
|
9144
|
+
* @return [Numo::DFloat] result of log(x).
|
9145
|
+
*/
|
9453
9146
|
rb_define_module_function(mTM, "log", dfloat_math_s_log, 1);
|
9147
|
+
/**
|
9148
|
+
* Calculate log2(x).
|
9149
|
+
* @overload log2(x)
|
9150
|
+
* @param [Numo::NArray,Numeric] x input value
|
9151
|
+
* @return [Numo::DFloat] result of log2(x).
|
9152
|
+
*/
|
9454
9153
|
rb_define_module_function(mTM, "log2", dfloat_math_s_log2, 1);
|
9154
|
+
/**
|
9155
|
+
* Calculate log10(x).
|
9156
|
+
* @overload log10(x)
|
9157
|
+
* @param [Numo::NArray,Numeric] x input value
|
9158
|
+
* @return [Numo::DFloat] result of log10(x).
|
9159
|
+
*/
|
9455
9160
|
rb_define_module_function(mTM, "log10", dfloat_math_s_log10, 1);
|
9161
|
+
/**
|
9162
|
+
* Calculate exp(x).
|
9163
|
+
* @overload exp(x)
|
9164
|
+
* @param [Numo::NArray,Numeric] x input value
|
9165
|
+
* @return [Numo::DFloat] result of exp(x).
|
9166
|
+
*/
|
9456
9167
|
rb_define_module_function(mTM, "exp", dfloat_math_s_exp, 1);
|
9168
|
+
/**
|
9169
|
+
* Calculate exp2(x).
|
9170
|
+
* @overload exp2(x)
|
9171
|
+
* @param [Numo::NArray,Numeric] x input value
|
9172
|
+
* @return [Numo::DFloat] result of exp2(x).
|
9173
|
+
*/
|
9457
9174
|
rb_define_module_function(mTM, "exp2", dfloat_math_s_exp2, 1);
|
9175
|
+
/**
|
9176
|
+
* Calculate exp10(x).
|
9177
|
+
* @overload exp10(x)
|
9178
|
+
* @param [Numo::NArray,Numeric] x input value
|
9179
|
+
* @return [Numo::DFloat] result of exp10(x).
|
9180
|
+
*/
|
9458
9181
|
rb_define_module_function(mTM, "exp10", dfloat_math_s_exp10, 1);
|
9182
|
+
/**
|
9183
|
+
* Calculate sin(x).
|
9184
|
+
* @overload sin(x)
|
9185
|
+
* @param [Numo::NArray,Numeric] x input value
|
9186
|
+
* @return [Numo::DFloat] result of sin(x).
|
9187
|
+
*/
|
9459
9188
|
rb_define_module_function(mTM, "sin", dfloat_math_s_sin, 1);
|
9189
|
+
/**
|
9190
|
+
* Calculate cos(x).
|
9191
|
+
* @overload cos(x)
|
9192
|
+
* @param [Numo::NArray,Numeric] x input value
|
9193
|
+
* @return [Numo::DFloat] result of cos(x).
|
9194
|
+
*/
|
9460
9195
|
rb_define_module_function(mTM, "cos", dfloat_math_s_cos, 1);
|
9196
|
+
/**
|
9197
|
+
* Calculate tan(x).
|
9198
|
+
* @overload tan(x)
|
9199
|
+
* @param [Numo::NArray,Numeric] x input value
|
9200
|
+
* @return [Numo::DFloat] result of tan(x).
|
9201
|
+
*/
|
9461
9202
|
rb_define_module_function(mTM, "tan", dfloat_math_s_tan, 1);
|
9203
|
+
/**
|
9204
|
+
* Calculate asin(x).
|
9205
|
+
* @overload asin(x)
|
9206
|
+
* @param [Numo::NArray,Numeric] x input value
|
9207
|
+
* @return [Numo::DFloat] result of asin(x).
|
9208
|
+
*/
|
9462
9209
|
rb_define_module_function(mTM, "asin", dfloat_math_s_asin, 1);
|
9210
|
+
/**
|
9211
|
+
* Calculate acos(x).
|
9212
|
+
* @overload acos(x)
|
9213
|
+
* @param [Numo::NArray,Numeric] x input value
|
9214
|
+
* @return [Numo::DFloat] result of acos(x).
|
9215
|
+
*/
|
9463
9216
|
rb_define_module_function(mTM, "acos", dfloat_math_s_acos, 1);
|
9217
|
+
/**
|
9218
|
+
* Calculate atan(x).
|
9219
|
+
* @overload atan(x)
|
9220
|
+
* @param [Numo::NArray,Numeric] x input value
|
9221
|
+
* @return [Numo::DFloat] result of atan(x).
|
9222
|
+
*/
|
9464
9223
|
rb_define_module_function(mTM, "atan", dfloat_math_s_atan, 1);
|
9224
|
+
/**
|
9225
|
+
* Calculate sinh(x).
|
9226
|
+
* @overload sinh(x)
|
9227
|
+
* @param [Numo::NArray,Numeric] x input value
|
9228
|
+
* @return [Numo::DFloat] result of sinh(x).
|
9229
|
+
*/
|
9465
9230
|
rb_define_module_function(mTM, "sinh", dfloat_math_s_sinh, 1);
|
9231
|
+
/**
|
9232
|
+
* Calculate cosh(x).
|
9233
|
+
* @overload cosh(x)
|
9234
|
+
* @param [Numo::NArray,Numeric] x input value
|
9235
|
+
* @return [Numo::DFloat] result of cosh(x).
|
9236
|
+
*/
|
9466
9237
|
rb_define_module_function(mTM, "cosh", dfloat_math_s_cosh, 1);
|
9238
|
+
/**
|
9239
|
+
* Calculate tanh(x).
|
9240
|
+
* @overload tanh(x)
|
9241
|
+
* @param [Numo::NArray,Numeric] x input value
|
9242
|
+
* @return [Numo::DFloat] result of tanh(x).
|
9243
|
+
*/
|
9467
9244
|
rb_define_module_function(mTM, "tanh", dfloat_math_s_tanh, 1);
|
9245
|
+
/**
|
9246
|
+
* Calculate asinh(x).
|
9247
|
+
* @overload asinh(x)
|
9248
|
+
* @param [Numo::NArray,Numeric] x input value
|
9249
|
+
* @return [Numo::DFloat] result of asinh(x).
|
9250
|
+
*/
|
9468
9251
|
rb_define_module_function(mTM, "asinh", dfloat_math_s_asinh, 1);
|
9252
|
+
/**
|
9253
|
+
* Calculate acosh(x).
|
9254
|
+
* @overload acosh(x)
|
9255
|
+
* @param [Numo::NArray,Numeric] x input value
|
9256
|
+
* @return [Numo::DFloat] result of acosh(x).
|
9257
|
+
*/
|
9469
9258
|
rb_define_module_function(mTM, "acosh", dfloat_math_s_acosh, 1);
|
9259
|
+
/**
|
9260
|
+
* Calculate atanh(x).
|
9261
|
+
* @overload atanh(x)
|
9262
|
+
* @param [Numo::NArray,Numeric] x input value
|
9263
|
+
* @return [Numo::DFloat] result of atanh(x).
|
9264
|
+
*/
|
9470
9265
|
rb_define_module_function(mTM, "atanh", dfloat_math_s_atanh, 1);
|
9266
|
+
/**
|
9267
|
+
* Calculate sinc(x).
|
9268
|
+
* @overload sinc(x)
|
9269
|
+
* @param [Numo::NArray,Numeric] x input value
|
9270
|
+
* @return [Numo::DFloat] result of sinc(x).
|
9271
|
+
*/
|
9471
9272
|
rb_define_module_function(mTM, "sinc", dfloat_math_s_sinc, 1);
|
9273
|
+
/**
|
9274
|
+
* Calculate atan2(a1,a2).
|
9275
|
+
* @overload atan2(a1,a2)
|
9276
|
+
* @param [Numo::NArray,Numeric] a1 first value
|
9277
|
+
* @param [Numo::NArray,Numeric] a2 second value
|
9278
|
+
* @return [Numo::DFloat] atan2(a1,a2).
|
9279
|
+
*/
|
9472
9280
|
rb_define_module_function(mTM, "atan2", dfloat_math_s_atan2, 2);
|
9281
|
+
/**
|
9282
|
+
* Calculate hypot(a1,a2).
|
9283
|
+
* @overload hypot(a1,a2)
|
9284
|
+
* @param [Numo::NArray,Numeric] a1 first value
|
9285
|
+
* @param [Numo::NArray,Numeric] a2 second value
|
9286
|
+
* @return [Numo::DFloat] hypot(a1,a2).
|
9287
|
+
*/
|
9473
9288
|
rb_define_module_function(mTM, "hypot", dfloat_math_s_hypot, 2);
|
9289
|
+
/**
|
9290
|
+
* Calculate erf(x).
|
9291
|
+
* @overload erf(x)
|
9292
|
+
* @param [Numo::NArray,Numeric] x input value
|
9293
|
+
* @return [Numo::DFloat] result of erf(x).
|
9294
|
+
*/
|
9474
9295
|
rb_define_module_function(mTM, "erf", dfloat_math_s_erf, 1);
|
9296
|
+
/**
|
9297
|
+
* Calculate erfc(x).
|
9298
|
+
* @overload erfc(x)
|
9299
|
+
* @param [Numo::NArray,Numeric] x input value
|
9300
|
+
* @return [Numo::DFloat] result of erfc(x).
|
9301
|
+
*/
|
9475
9302
|
rb_define_module_function(mTM, "erfc", dfloat_math_s_erfc, 1);
|
9303
|
+
/**
|
9304
|
+
* Calculate log1p(x).
|
9305
|
+
* @overload log1p(x)
|
9306
|
+
* @param [Numo::NArray,Numeric] x input value
|
9307
|
+
* @return [Numo::DFloat] result of log1p(x).
|
9308
|
+
*/
|
9476
9309
|
rb_define_module_function(mTM, "log1p", dfloat_math_s_log1p, 1);
|
9310
|
+
/**
|
9311
|
+
* Calculate expm1(x).
|
9312
|
+
* @overload expm1(x)
|
9313
|
+
* @param [Numo::NArray,Numeric] x input value
|
9314
|
+
* @return [Numo::DFloat] result of expm1(x).
|
9315
|
+
*/
|
9477
9316
|
rb_define_module_function(mTM, "expm1", dfloat_math_s_expm1, 1);
|
9317
|
+
/**
|
9318
|
+
* Calculate ldexp(a1,a2).
|
9319
|
+
* @overload ldexp(a1,a2)
|
9320
|
+
* @param [Numo::NArray,Numeric] a1 first value
|
9321
|
+
* @param [Numo::NArray,Numeric] a2 second value
|
9322
|
+
* @return [Numo::DFloat] ldexp(a1,a2).
|
9323
|
+
*/
|
9478
9324
|
rb_define_module_function(mTM, "ldexp", dfloat_math_s_ldexp, 2);
|
9325
|
+
/**
|
9326
|
+
* split the number x into a normalized fraction and an exponent.
|
9327
|
+
* Returns [mantissa, exponent], where x = mantissa * 2**exponent.
|
9328
|
+
*
|
9329
|
+
* @overload frexp(x)
|
9330
|
+
* @param [Numo::NArray,Numeric] x
|
9331
|
+
* @return [Numo::DFloat,Numo::Int32] mantissa and exponent.
|
9332
|
+
*/
|
9479
9333
|
rb_define_module_function(mTM, "frexp", dfloat_math_s_frexp, 1);
|
9480
9334
|
|
9481
9335
|
// how to do this?
|