numo-narray-alt 0.9.4 → 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 +22 -3
- data/Rakefile +8 -0
- data/ext/numo/narray/SFMT-params19937.h +16 -12
- data/ext/numo/narray/SFMT.c +12 -5
- data/ext/numo/narray/array.c +51 -21
- data/ext/numo/narray/data.c +88 -86
- data/ext/numo/narray/index.c +51 -28
- data/ext/numo/narray/kwargs.c +11 -9
- data/ext/numo/narray/math.c +14 -6
- data/ext/numo/narray/narray.c +93 -58
- data/ext/numo/narray/ndloop.c +52 -63
- data/ext/numo/narray/numo/intern.h +9 -3
- 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 +85 -81
- data/ext/numo/narray/numo/types/bit.h +76 -0
- data/ext/numo/narray/numo/types/complex.h +7 -3
- data/ext/numo/narray/numo/types/complex_macro.h +28 -25
- data/ext/numo/narray/numo/types/float_macro.h +21 -17
- data/ext/numo/narray/numo/types/real_accum.h +22 -22
- data/ext/numo/narray/numo/types/robj_macro.h +20 -12
- data/ext/numo/narray/numo/types/xint_macro.h +51 -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 +206 -147
- data/ext/numo/narray/src/t_dcomplex.c +531 -641
- data/ext/numo/narray/src/t_dfloat.c +1341 -1421
- data/ext/numo/narray/src/t_int16.c +562 -468
- data/ext/numo/narray/src/t_int32.c +562 -468
- data/ext/numo/narray/src/t_int64.c +561 -467
- data/ext/numo/narray/src/t_int8.c +520 -448
- data/ext/numo/narray/src/t_robject.c +519 -619
- data/ext/numo/narray/src/t_scomplex.c +524 -659
- data/ext/numo/narray/src/t_sfloat.c +1332 -1410
- data/ext/numo/narray/src/t_uint16.c +562 -468
- data/ext/numo/narray/src/t_uint32.c +562 -468
- data/ext/numo/narray/src/t_uint64.c +562 -468
- data/ext/numo/narray/src/t_uint8.c +522 -448
- data/ext/numo/narray/step.c +7 -2
- data/ext/numo/narray/struct.c +31 -24
- data/lib/numo/narray/extra.rb +74 -30
- data/numo-narray-alt.gemspec +38 -0
- metadata +10 -1
@@ -36,14 +36,23 @@ static ID id_to_a;
|
|
36
36
|
|
37
37
|
#include <numo/types/sfloat.h>
|
38
38
|
|
39
|
-
VALUE cT;
|
40
|
-
extern VALUE cRT;
|
41
|
-
|
42
39
|
/*
|
43
40
|
class definition: Numo::SFloat
|
44
41
|
*/
|
45
|
-
|
46
42
|
VALUE cT;
|
43
|
+
extern VALUE cRT;
|
44
|
+
|
45
|
+
#include "mh/mean.h"
|
46
|
+
#include "mh/var.h"
|
47
|
+
#include "mh/stddev.h"
|
48
|
+
#include "mh/rms.h"
|
49
|
+
|
50
|
+
typedef float sfloat; // Type aliases for shorter notation
|
51
|
+
// following the codebase naming convention.
|
52
|
+
DEF_NARRAY_FLT_MEAN_METHOD_FUNC(sfloat, float, numo_cSFloat, numo_cSFloat)
|
53
|
+
DEF_NARRAY_FLT_VAR_METHOD_FUNC(sfloat, float, numo_cSFloat, numo_cSFloat)
|
54
|
+
DEF_NARRAY_FLT_STDDEV_METHOD_FUNC(sfloat, float, numo_cSFloat, numo_cSFloat)
|
55
|
+
DEF_NARRAY_FLT_RMS_METHOD_FUNC(sfloat, float, numo_cSFloat, numo_cSFloat)
|
47
56
|
|
48
57
|
static VALUE sfloat_store(VALUE, VALUE);
|
49
58
|
|
@@ -148,13 +157,6 @@ static VALUE sfloat_allocate(VALUE self) {
|
|
148
157
|
return self;
|
149
158
|
}
|
150
159
|
|
151
|
-
/*
|
152
|
-
Extract an element only if self is a dimensionless NArray.
|
153
|
-
@overload extract
|
154
|
-
@return [Numeric,Numo::NArray]
|
155
|
-
--- Extract element value as Ruby Object if self is a dimensionless NArray,
|
156
|
-
otherwise returns self.
|
157
|
-
*/
|
158
160
|
static VALUE sfloat_extract(VALUE self) {
|
159
161
|
volatile VALUE v;
|
160
162
|
char* ptr;
|
@@ -237,8 +239,8 @@ static void iter_sfloat_store_bit(na_loop_t* const lp) {
|
|
237
239
|
}
|
238
240
|
|
239
241
|
static VALUE sfloat_store_bit(VALUE self, VALUE obj) {
|
240
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
241
|
-
ndfunc_t ndf = {iter_sfloat_store_bit, FULL_LOOP, 2, 0, ain, 0};
|
242
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
243
|
+
ndfunc_t ndf = { iter_sfloat_store_bit, FULL_LOOP, 2, 0, ain, 0 };
|
242
244
|
|
243
245
|
na_ndloop(&ndf, 2, self, obj);
|
244
246
|
return self;
|
@@ -286,8 +288,8 @@ static void iter_sfloat_store_dfloat(na_loop_t* const lp) {
|
|
286
288
|
}
|
287
289
|
|
288
290
|
static VALUE sfloat_store_dfloat(VALUE self, VALUE obj) {
|
289
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
290
|
-
ndfunc_t ndf = {iter_sfloat_store_dfloat, FULL_LOOP, 2, 0, ain, 0};
|
291
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
292
|
+
ndfunc_t ndf = { iter_sfloat_store_dfloat, FULL_LOOP, 2, 0, ain, 0 };
|
291
293
|
|
292
294
|
na_ndloop(&ndf, 2, self, obj);
|
293
295
|
return self;
|
@@ -335,8 +337,8 @@ static void iter_sfloat_store_sfloat(na_loop_t* const lp) {
|
|
335
337
|
}
|
336
338
|
|
337
339
|
static VALUE sfloat_store_sfloat(VALUE self, VALUE obj) {
|
338
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
339
|
-
ndfunc_t ndf = {iter_sfloat_store_sfloat, FULL_LOOP, 2, 0, ain, 0};
|
340
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
341
|
+
ndfunc_t ndf = { iter_sfloat_store_sfloat, FULL_LOOP, 2, 0, ain, 0 };
|
340
342
|
|
341
343
|
na_ndloop(&ndf, 2, self, obj);
|
342
344
|
return self;
|
@@ -384,8 +386,8 @@ static void iter_sfloat_store_int64(na_loop_t* const lp) {
|
|
384
386
|
}
|
385
387
|
|
386
388
|
static VALUE sfloat_store_int64(VALUE self, VALUE obj) {
|
387
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
388
|
-
ndfunc_t ndf = {iter_sfloat_store_int64, FULL_LOOP, 2, 0, ain, 0};
|
389
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
390
|
+
ndfunc_t ndf = { iter_sfloat_store_int64, FULL_LOOP, 2, 0, ain, 0 };
|
389
391
|
|
390
392
|
na_ndloop(&ndf, 2, self, obj);
|
391
393
|
return self;
|
@@ -433,8 +435,8 @@ static void iter_sfloat_store_int32(na_loop_t* const lp) {
|
|
433
435
|
}
|
434
436
|
|
435
437
|
static VALUE sfloat_store_int32(VALUE self, VALUE obj) {
|
436
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
437
|
-
ndfunc_t ndf = {iter_sfloat_store_int32, FULL_LOOP, 2, 0, ain, 0};
|
438
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
439
|
+
ndfunc_t ndf = { iter_sfloat_store_int32, FULL_LOOP, 2, 0, ain, 0 };
|
438
440
|
|
439
441
|
na_ndloop(&ndf, 2, self, obj);
|
440
442
|
return self;
|
@@ -482,8 +484,8 @@ static void iter_sfloat_store_int16(na_loop_t* const lp) {
|
|
482
484
|
}
|
483
485
|
|
484
486
|
static VALUE sfloat_store_int16(VALUE self, VALUE obj) {
|
485
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
486
|
-
ndfunc_t ndf = {iter_sfloat_store_int16, FULL_LOOP, 2, 0, ain, 0};
|
487
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
488
|
+
ndfunc_t ndf = { iter_sfloat_store_int16, FULL_LOOP, 2, 0, ain, 0 };
|
487
489
|
|
488
490
|
na_ndloop(&ndf, 2, self, obj);
|
489
491
|
return self;
|
@@ -531,8 +533,8 @@ static void iter_sfloat_store_int8(na_loop_t* const lp) {
|
|
531
533
|
}
|
532
534
|
|
533
535
|
static VALUE sfloat_store_int8(VALUE self, VALUE obj) {
|
534
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
535
|
-
ndfunc_t ndf = {iter_sfloat_store_int8, FULL_LOOP, 2, 0, ain, 0};
|
536
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
537
|
+
ndfunc_t ndf = { iter_sfloat_store_int8, FULL_LOOP, 2, 0, ain, 0 };
|
536
538
|
|
537
539
|
na_ndloop(&ndf, 2, self, obj);
|
538
540
|
return self;
|
@@ -580,8 +582,8 @@ static void iter_sfloat_store_uint64(na_loop_t* const lp) {
|
|
580
582
|
}
|
581
583
|
|
582
584
|
static VALUE sfloat_store_uint64(VALUE self, VALUE obj) {
|
583
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
584
|
-
ndfunc_t ndf = {iter_sfloat_store_uint64, FULL_LOOP, 2, 0, ain, 0};
|
585
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
586
|
+
ndfunc_t ndf = { iter_sfloat_store_uint64, FULL_LOOP, 2, 0, ain, 0 };
|
585
587
|
|
586
588
|
na_ndloop(&ndf, 2, self, obj);
|
587
589
|
return self;
|
@@ -629,8 +631,8 @@ static void iter_sfloat_store_uint32(na_loop_t* const lp) {
|
|
629
631
|
}
|
630
632
|
|
631
633
|
static VALUE sfloat_store_uint32(VALUE self, VALUE obj) {
|
632
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
633
|
-
ndfunc_t ndf = {iter_sfloat_store_uint32, FULL_LOOP, 2, 0, ain, 0};
|
634
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
635
|
+
ndfunc_t ndf = { iter_sfloat_store_uint32, FULL_LOOP, 2, 0, ain, 0 };
|
634
636
|
|
635
637
|
na_ndloop(&ndf, 2, self, obj);
|
636
638
|
return self;
|
@@ -678,8 +680,8 @@ static void iter_sfloat_store_uint16(na_loop_t* const lp) {
|
|
678
680
|
}
|
679
681
|
|
680
682
|
static VALUE sfloat_store_uint16(VALUE self, VALUE obj) {
|
681
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
682
|
-
ndfunc_t ndf = {iter_sfloat_store_uint16, FULL_LOOP, 2, 0, ain, 0};
|
683
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
684
|
+
ndfunc_t ndf = { iter_sfloat_store_uint16, FULL_LOOP, 2, 0, ain, 0 };
|
683
685
|
|
684
686
|
na_ndloop(&ndf, 2, self, obj);
|
685
687
|
return self;
|
@@ -727,8 +729,8 @@ static void iter_sfloat_store_uint8(na_loop_t* const lp) {
|
|
727
729
|
}
|
728
730
|
|
729
731
|
static VALUE sfloat_store_uint8(VALUE self, VALUE obj) {
|
730
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
731
|
-
ndfunc_t ndf = {iter_sfloat_store_uint8, FULL_LOOP, 2, 0, ain, 0};
|
732
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
733
|
+
ndfunc_t ndf = { iter_sfloat_store_uint8, FULL_LOOP, 2, 0, ain, 0 };
|
732
734
|
|
733
735
|
na_ndloop(&ndf, 2, self, obj);
|
734
736
|
return self;
|
@@ -776,8 +778,8 @@ static void iter_sfloat_store_robject(na_loop_t* const lp) {
|
|
776
778
|
}
|
777
779
|
|
778
780
|
static VALUE sfloat_store_robject(VALUE self, VALUE obj) {
|
779
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
780
|
-
ndfunc_t ndf = {iter_sfloat_store_robject, FULL_LOOP, 2, 0, ain, 0};
|
781
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
782
|
+
ndfunc_t ndf = { iter_sfloat_store_robject, FULL_LOOP, 2, 0, ain, 0 };
|
781
783
|
|
782
784
|
na_ndloop(&ndf, 2, self, obj);
|
783
785
|
return self;
|
@@ -885,19 +887,13 @@ loop_end:
|
|
885
887
|
}
|
886
888
|
|
887
889
|
static VALUE sfloat_store_array(VALUE self, VALUE rary) {
|
888
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {rb_cArray, 0}};
|
889
|
-
ndfunc_t ndf = {iter_sfloat_store_array, FULL_LOOP, 2, 0, ain, 0};
|
890
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { rb_cArray, 0 } };
|
891
|
+
ndfunc_t ndf = { iter_sfloat_store_array, FULL_LOOP, 2, 0, ain, 0 };
|
890
892
|
|
891
893
|
na_ndloop_store_rarray(&ndf, self, rary);
|
892
894
|
return self;
|
893
895
|
}
|
894
896
|
|
895
|
-
/*
|
896
|
-
Store elements to Numo::SFloat from other.
|
897
|
-
@overload store(other)
|
898
|
-
@param [Object] other
|
899
|
-
@return [Numo::SFloat] self
|
900
|
-
*/
|
901
897
|
static VALUE sfloat_store(VALUE self, VALUE obj) {
|
902
898
|
VALUE r, klass;
|
903
899
|
|
@@ -981,8 +977,10 @@ static VALUE sfloat_store(VALUE self, VALUE obj) {
|
|
981
977
|
}
|
982
978
|
}
|
983
979
|
|
984
|
-
rb_raise(
|
985
|
-
|
980
|
+
rb_raise(
|
981
|
+
nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
|
982
|
+
rb_class2name(rb_obj_class(self))
|
983
|
+
);
|
986
984
|
|
987
985
|
return self;
|
988
986
|
}
|
@@ -1076,7 +1074,10 @@ static dtype sfloat_extract_data(VALUE obj) {
|
|
1076
1074
|
return sfloat_extract_data(r);
|
1077
1075
|
}
|
1078
1076
|
|
1079
|
-
rb_raise(
|
1077
|
+
rb_raise(
|
1078
|
+
nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
|
1079
|
+
rb_class2name(cT)
|
1080
|
+
);
|
1080
1081
|
}
|
1081
1082
|
if (TYPE(obj) == T_ARRAY) {
|
1082
1083
|
if (RARRAY_LEN(obj) != 1) {
|
@@ -1099,14 +1100,6 @@ static VALUE sfloat_cast_array(VALUE rary) {
|
|
1099
1100
|
return nary;
|
1100
1101
|
}
|
1101
1102
|
|
1102
|
-
/*
|
1103
|
-
Cast object to Numo::SFloat.
|
1104
|
-
@overload [](elements)
|
1105
|
-
@overload cast(array)
|
1106
|
-
@param [Numeric,Array] elements
|
1107
|
-
@param [Array] array
|
1108
|
-
@return [Numo::SFloat]
|
1109
|
-
*/
|
1110
1103
|
static VALUE sfloat_s_cast(VALUE type, VALUE obj) {
|
1111
1104
|
VALUE v;
|
1112
1105
|
narray_t* na;
|
@@ -1142,15 +1135,6 @@ static VALUE sfloat_s_cast(VALUE type, VALUE obj) {
|
|
1142
1135
|
return Qnil;
|
1143
1136
|
}
|
1144
1137
|
|
1145
|
-
/*
|
1146
|
-
Multi-dimensional element reference.
|
1147
|
-
@overload [](dim0,...,dimL)
|
1148
|
-
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol] dim0,...,dimL multi-dimensional
|
1149
|
-
indices.
|
1150
|
-
@return [Numeric,Numo::SFloat] an element or NArray view.
|
1151
|
-
@see Numo::NArray#[]
|
1152
|
-
@see #[]=
|
1153
|
-
*/
|
1154
1138
|
static VALUE sfloat_aref(int argc, VALUE* argv, VALUE self) {
|
1155
1139
|
int nd;
|
1156
1140
|
size_t pos;
|
@@ -1165,16 +1149,6 @@ static VALUE sfloat_aref(int argc, VALUE* argv, VALUE self) {
|
|
1165
1149
|
}
|
1166
1150
|
}
|
1167
1151
|
|
1168
|
-
/*
|
1169
|
-
Multi-dimensional element assignment.
|
1170
|
-
@overload []=(dim0,...,dimL,val)
|
1171
|
-
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol] dim0,...,dimL multi-dimensional
|
1172
|
-
indices.
|
1173
|
-
@param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
|
1174
|
-
@return [Numeric,Numo::NArray,Array] returns `val` (last argument).
|
1175
|
-
@see Numo::NArray#[]=
|
1176
|
-
@see #[]
|
1177
|
-
*/
|
1178
1152
|
static VALUE sfloat_aset(int argc, VALUE* argv, VALUE self) {
|
1179
1153
|
int nd;
|
1180
1154
|
size_t pos;
|
@@ -1199,11 +1173,6 @@ static VALUE sfloat_aset(int argc, VALUE* argv, VALUE self) {
|
|
1199
1173
|
return argv[argc];
|
1200
1174
|
}
|
1201
1175
|
|
1202
|
-
/*
|
1203
|
-
return NArray with cast to the type of self.
|
1204
|
-
@overload coerce_cast(type)
|
1205
|
-
@return [nil]
|
1206
|
-
*/
|
1207
1176
|
static VALUE sfloat_coerce_cast(VALUE self, VALUE type) {
|
1208
1177
|
return Qnil;
|
1209
1178
|
}
|
@@ -1234,15 +1203,10 @@ static void iter_sfloat_to_a(na_loop_t* const lp) {
|
|
1234
1203
|
}
|
1235
1204
|
}
|
1236
1205
|
|
1237
|
-
/*
|
1238
|
-
Convert self to Array.
|
1239
|
-
@overload to_a
|
1240
|
-
@return [Array]
|
1241
|
-
*/
|
1242
1206
|
static VALUE sfloat_to_a(VALUE self) {
|
1243
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
|
1244
|
-
ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
|
1245
|
-
ndfunc_t ndf = {iter_sfloat_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
|
1207
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
|
1208
|
+
ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
|
1209
|
+
ndfunc_t ndf = { iter_sfloat_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
|
1246
1210
|
return na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
|
1247
1211
|
}
|
1248
1212
|
|
@@ -1267,15 +1231,9 @@ static void iter_sfloat_fill(na_loop_t* const lp) {
|
|
1267
1231
|
}
|
1268
1232
|
}
|
1269
1233
|
|
1270
|
-
/*
|
1271
|
-
Fill elements with other.
|
1272
|
-
@overload fill other
|
1273
|
-
@param [Numeric] other
|
1274
|
-
@return [Numo::SFloat] self.
|
1275
|
-
*/
|
1276
1234
|
static VALUE sfloat_fill(VALUE self, VALUE val) {
|
1277
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_option}};
|
1278
|
-
ndfunc_t ndf = {iter_sfloat_fill, FULL_LOOP, 2, 0, ain, 0};
|
1235
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
|
1236
|
+
ndfunc_t ndf = { iter_sfloat_fill, FULL_LOOP, 2, 0, ain, 0 };
|
1279
1237
|
|
1280
1238
|
na_ndloop(&ndf, 2, self, val);
|
1281
1239
|
return self;
|
@@ -1321,18 +1279,12 @@ static void iter_sfloat_format(na_loop_t* const lp) {
|
|
1321
1279
|
}
|
1322
1280
|
}
|
1323
1281
|
|
1324
|
-
/*
|
1325
|
-
Format elements into strings.
|
1326
|
-
@overload format format
|
1327
|
-
@param [String] format
|
1328
|
-
@return [Numo::RObject] array of formatted strings.
|
1329
|
-
*/
|
1330
1282
|
static VALUE sfloat_format(int argc, VALUE* argv, VALUE self) {
|
1331
1283
|
VALUE fmt = Qnil;
|
1332
1284
|
|
1333
|
-
ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_option}};
|
1334
|
-
ndfunc_arg_out_t aout[1] = {{numo_cRObject, 0}};
|
1335
|
-
ndfunc_t ndf = {iter_sfloat_format, FULL_LOOP_NIP, 2, 1, ain, aout};
|
1285
|
+
ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_option } };
|
1286
|
+
ndfunc_arg_out_t aout[1] = { { numo_cRObject, 0 } };
|
1287
|
+
ndfunc_t ndf = { iter_sfloat_format, FULL_LOOP_NIP, 2, 1, ain, aout };
|
1336
1288
|
|
1337
1289
|
rb_scan_args(argc, argv, "01", &fmt);
|
1338
1290
|
return na_ndloop(&ndf, 2, self, fmt);
|
@@ -1368,17 +1320,11 @@ static void iter_sfloat_format_to_a(na_loop_t* const lp) {
|
|
1368
1320
|
}
|
1369
1321
|
}
|
1370
1322
|
|
1371
|
-
/*
|
1372
|
-
Format elements into strings.
|
1373
|
-
@overload format_to_a format
|
1374
|
-
@param [String] format
|
1375
|
-
@return [Array] array of formatted strings.
|
1376
|
-
*/
|
1377
1323
|
static VALUE sfloat_format_to_a(int argc, VALUE* argv, VALUE self) {
|
1378
1324
|
VALUE fmt = Qnil;
|
1379
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
|
1380
|
-
ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
|
1381
|
-
ndfunc_t ndf = {iter_sfloat_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
|
1325
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
|
1326
|
+
ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
|
1327
|
+
ndfunc_t ndf = { iter_sfloat_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
|
1382
1328
|
|
1383
1329
|
rb_scan_args(argc, argv, "01", &fmt);
|
1384
1330
|
return na_ndloop_cast_narray_to_rarray(&ndf, self, fmt);
|
@@ -1388,11 +1334,6 @@ static VALUE iter_sfloat_inspect(char* ptr, size_t pos, VALUE fmt) {
|
|
1388
1334
|
return format_sfloat(fmt, (dtype*)(ptr + pos));
|
1389
1335
|
}
|
1390
1336
|
|
1391
|
-
/*
|
1392
|
-
Returns a string containing a human-readable representation of NArray.
|
1393
|
-
@overload inspect
|
1394
|
-
@return [String]
|
1395
|
-
*/
|
1396
1337
|
static VALUE sfloat_inspect(VALUE ary) {
|
1397
1338
|
return na_ndloop_inspect(ary, iter_sfloat_inspect, Qnil);
|
1398
1339
|
}
|
@@ -1421,19 +1362,9 @@ static void iter_sfloat_each(na_loop_t* const lp) {
|
|
1421
1362
|
}
|
1422
1363
|
}
|
1423
1364
|
|
1424
|
-
/*
|
1425
|
-
Calls the given block once for each element in self,
|
1426
|
-
passing that element as a parameter.
|
1427
|
-
@overload each
|
1428
|
-
@return [Numo::NArray] self
|
1429
|
-
For a block `{|x| ... }`,
|
1430
|
-
@yieldparam [Numeric] x an element of NArray.
|
1431
|
-
@see #each_with_index
|
1432
|
-
@see #map
|
1433
|
-
*/
|
1434
1365
|
static VALUE sfloat_each(VALUE self) {
|
1435
|
-
ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
|
1436
|
-
ndfunc_t ndf = {iter_sfloat_each, FULL_LOOP_NIP, 1, 0, ain, 0};
|
1366
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1367
|
+
ndfunc_t ndf = { iter_sfloat_each, FULL_LOOP_NIP, 1, 0, ain, 0 };
|
1437
1368
|
|
1438
1369
|
na_ndloop(&ndf, 1, self);
|
1439
1370
|
return self;
|
@@ -1501,15 +1432,10 @@ static void iter_sfloat_map(na_loop_t* const lp) {
|
|
1501
1432
|
}
|
1502
1433
|
}
|
1503
1434
|
|
1504
|
-
/*
|
1505
|
-
Unary map.
|
1506
|
-
@overload map
|
1507
|
-
@return [Numo::SFloat] map of self.
|
1508
|
-
*/
|
1509
1435
|
static VALUE sfloat_map(VALUE self) {
|
1510
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
1511
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1512
|
-
ndfunc_t ndf = {iter_sfloat_map, FULL_LOOP, 1, 1, ain, aout};
|
1436
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
1437
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1438
|
+
ndfunc_t ndf = { iter_sfloat_map, FULL_LOOP, 1, 1, ain, aout };
|
1513
1439
|
|
1514
1440
|
return na_ndloop(&ndf, 1, self);
|
1515
1441
|
}
|
@@ -1559,20 +1485,9 @@ static void iter_sfloat_each_with_index(na_loop_t* const lp) {
|
|
1559
1485
|
}
|
1560
1486
|
}
|
1561
1487
|
|
1562
|
-
/*
|
1563
|
-
Invokes the given block once for each element of self,
|
1564
|
-
passing that element and indices along each axis as parameters.
|
1565
|
-
@overload each_with_index
|
1566
|
-
For a block `{|x,i,j,...| ... }`,
|
1567
|
-
@yieldparam [Numeric] x an element
|
1568
|
-
@yieldparam [Integer] i,j,... multitimensional indices
|
1569
|
-
@return [Numo::NArray] self
|
1570
|
-
@see #each
|
1571
|
-
@see #map_with_index
|
1572
|
-
*/
|
1573
1488
|
static VALUE sfloat_each_with_index(VALUE self) {
|
1574
|
-
ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
|
1575
|
-
ndfunc_t ndf = {iter_sfloat_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0};
|
1489
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1490
|
+
ndfunc_t ndf = { iter_sfloat_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0 };
|
1576
1491
|
|
1577
1492
|
na_ndloop_with_index(&ndf, 1, self);
|
1578
1493
|
return self;
|
@@ -1648,23 +1563,10 @@ static void iter_sfloat_map_with_index(na_loop_t* const lp) {
|
|
1648
1563
|
}
|
1649
1564
|
}
|
1650
1565
|
|
1651
|
-
/*
|
1652
|
-
Invokes the given block once for each element of self,
|
1653
|
-
passing that element and indices along each axis as parameters.
|
1654
|
-
Creates a new NArray containing the values returned by the block.
|
1655
|
-
Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
|
1656
|
-
@overload map_with_index
|
1657
|
-
For a block `{|x,i,j,...| ... }`,
|
1658
|
-
@yieldparam [Numeric] x an element
|
1659
|
-
@yieldparam [Integer] i,j,... multitimensional indices
|
1660
|
-
@return [Numo::NArray] mapped array
|
1661
|
-
@see #map
|
1662
|
-
@see #each_with_index
|
1663
|
-
*/
|
1664
1566
|
static VALUE sfloat_map_with_index(VALUE self) {
|
1665
|
-
ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
|
1666
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1667
|
-
ndfunc_t ndf = {iter_sfloat_map_with_index, FULL_LOOP, 1, 1, ain, aout};
|
1567
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1568
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1569
|
+
ndfunc_t ndf = { iter_sfloat_map_with_index, FULL_LOOP, 1, 1, ain, aout };
|
1668
1570
|
|
1669
1571
|
return na_ndloop_with_index(&ndf, 1, self);
|
1670
1572
|
}
|
@@ -1710,20 +1612,15 @@ static void iter_sfloat_abs(na_loop_t* const lp) {
|
|
1710
1612
|
}
|
1711
1613
|
}
|
1712
1614
|
|
1713
|
-
/*
|
1714
|
-
abs of self.
|
1715
|
-
@overload abs
|
1716
|
-
@return [Numo::SFloat] abs of self.
|
1717
|
-
*/
|
1718
1615
|
static VALUE sfloat_abs(VALUE self) {
|
1719
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
1720
|
-
ndfunc_arg_out_t aout[1] = {{cRT, 0}};
|
1721
|
-
ndfunc_t ndf = {iter_sfloat_abs, FULL_LOOP, 1, 1, ain, aout};
|
1616
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
1617
|
+
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
1618
|
+
ndfunc_t ndf = { iter_sfloat_abs, FULL_LOOP, 1, 1, ain, aout };
|
1722
1619
|
|
1723
1620
|
return na_ndloop(&ndf, 1, self);
|
1724
1621
|
}
|
1725
1622
|
|
1726
|
-
#define check_intdivzero(y)
|
1623
|
+
#define check_intdivzero(y) \
|
1727
1624
|
{}
|
1728
1625
|
|
1729
1626
|
static void iter_sfloat_add(na_loop_t* const lp) {
|
@@ -1748,14 +1645,20 @@ static void iter_sfloat_add(na_loop_t* const lp) {
|
|
1748
1645
|
INIT_PTR(lp, 2, p3, s3);
|
1749
1646
|
|
1750
1647
|
//
|
1751
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
1648
|
+
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
1649
|
+
is_aligned(p3, sizeof(dtype))) {
|
1752
1650
|
|
1753
1651
|
if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
|
1754
1652
|
#ifdef __SSE2__
|
1755
1653
|
// Check number of elements. & Check same alignment.
|
1756
|
-
if ((n >= num_pack) &&
|
1654
|
+
if ((n >= num_pack) &&
|
1655
|
+
is_same_aligned3(
|
1656
|
+
&((dtype*)p1)[i], &((dtype*)p2)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE
|
1657
|
+
)) {
|
1757
1658
|
// Calculate up to the position just before the start of SIMD computation.
|
1758
|
-
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
1659
|
+
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
1660
|
+
&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
|
1661
|
+
);
|
1759
1662
|
#endif
|
1760
1663
|
if (p1 == p3) { // inplace case
|
1761
1664
|
#ifdef __SSE2__
|
@@ -1817,7 +1720,8 @@ static void iter_sfloat_add(na_loop_t* const lp) {
|
|
1817
1720
|
return;
|
1818
1721
|
}
|
1819
1722
|
|
1820
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
1723
|
+
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
1724
|
+
is_aligned_step(s3, sizeof(dtype))) {
|
1821
1725
|
//
|
1822
1726
|
|
1823
1727
|
if (s2 == 0) { // Broadcasting from scalar value.
|
@@ -1828,9 +1732,12 @@ static void iter_sfloat_add(na_loop_t* const lp) {
|
|
1828
1732
|
b = _mm_load1_ps(&((dtype*)p2)[0]);
|
1829
1733
|
|
1830
1734
|
// Check number of elements. & Check same alignment.
|
1831
|
-
if ((n >= num_pack) &&
|
1735
|
+
if ((n >= num_pack) &&
|
1736
|
+
is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
|
1832
1737
|
// Calculate up to the position just before the start of SIMD computation.
|
1833
|
-
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
1738
|
+
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
1739
|
+
&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
|
1740
|
+
);
|
1834
1741
|
#endif
|
1835
1742
|
if (p1 == p3) { // inplace case
|
1836
1743
|
#ifdef __SSE2__
|
@@ -1926,19 +1833,13 @@ static void iter_sfloat_add(na_loop_t* const lp) {
|
|
1926
1833
|
#undef check_intdivzero
|
1927
1834
|
|
1928
1835
|
static VALUE sfloat_add_self(VALUE self, VALUE other) {
|
1929
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
1930
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1931
|
-
ndfunc_t ndf = {iter_sfloat_add, STRIDE_LOOP, 2, 1, ain, aout};
|
1836
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
1837
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1838
|
+
ndfunc_t ndf = { iter_sfloat_add, STRIDE_LOOP, 2, 1, ain, aout };
|
1932
1839
|
|
1933
1840
|
return na_ndloop(&ndf, 2, self, other);
|
1934
1841
|
}
|
1935
1842
|
|
1936
|
-
/*
|
1937
|
-
Binary add.
|
1938
|
-
@overload + other
|
1939
|
-
@param [Numo::NArray,Numeric] other
|
1940
|
-
@return [Numo::NArray] self + other
|
1941
|
-
*/
|
1942
1843
|
static VALUE sfloat_add(VALUE self, VALUE other) {
|
1943
1844
|
|
1944
1845
|
VALUE klass, v;
|
@@ -1952,7 +1853,7 @@ static VALUE sfloat_add(VALUE self, VALUE other) {
|
|
1952
1853
|
}
|
1953
1854
|
}
|
1954
1855
|
|
1955
|
-
#define check_intdivzero(y)
|
1856
|
+
#define check_intdivzero(y) \
|
1956
1857
|
{}
|
1957
1858
|
|
1958
1859
|
static void iter_sfloat_sub(na_loop_t* const lp) {
|
@@ -1977,14 +1878,20 @@ static void iter_sfloat_sub(na_loop_t* const lp) {
|
|
1977
1878
|
INIT_PTR(lp, 2, p3, s3);
|
1978
1879
|
|
1979
1880
|
//
|
1980
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
1881
|
+
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
1882
|
+
is_aligned(p3, sizeof(dtype))) {
|
1981
1883
|
|
1982
1884
|
if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
|
1983
1885
|
#ifdef __SSE2__
|
1984
1886
|
// Check number of elements. & Check same alignment.
|
1985
|
-
if ((n >= num_pack) &&
|
1887
|
+
if ((n >= num_pack) &&
|
1888
|
+
is_same_aligned3(
|
1889
|
+
&((dtype*)p1)[i], &((dtype*)p2)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE
|
1890
|
+
)) {
|
1986
1891
|
// Calculate up to the position just before the start of SIMD computation.
|
1987
|
-
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
1892
|
+
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
1893
|
+
&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
|
1894
|
+
);
|
1988
1895
|
#endif
|
1989
1896
|
if (p1 == p3) { // inplace case
|
1990
1897
|
#ifdef __SSE2__
|
@@ -2046,7 +1953,8 @@ static void iter_sfloat_sub(na_loop_t* const lp) {
|
|
2046
1953
|
return;
|
2047
1954
|
}
|
2048
1955
|
|
2049
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
1956
|
+
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
1957
|
+
is_aligned_step(s3, sizeof(dtype))) {
|
2050
1958
|
//
|
2051
1959
|
|
2052
1960
|
if (s2 == 0) { // Broadcasting from scalar value.
|
@@ -2057,9 +1965,12 @@ static void iter_sfloat_sub(na_loop_t* const lp) {
|
|
2057
1965
|
b = _mm_load1_ps(&((dtype*)p2)[0]);
|
2058
1966
|
|
2059
1967
|
// Check number of elements. & Check same alignment.
|
2060
|
-
if ((n >= num_pack) &&
|
1968
|
+
if ((n >= num_pack) &&
|
1969
|
+
is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
|
2061
1970
|
// Calculate up to the position just before the start of SIMD computation.
|
2062
|
-
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
1971
|
+
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
1972
|
+
&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
|
1973
|
+
);
|
2063
1974
|
#endif
|
2064
1975
|
if (p1 == p3) { // inplace case
|
2065
1976
|
#ifdef __SSE2__
|
@@ -2155,19 +2066,13 @@ static void iter_sfloat_sub(na_loop_t* const lp) {
|
|
2155
2066
|
#undef check_intdivzero
|
2156
2067
|
|
2157
2068
|
static VALUE sfloat_sub_self(VALUE self, VALUE other) {
|
2158
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2159
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2160
|
-
ndfunc_t ndf = {iter_sfloat_sub, STRIDE_LOOP, 2, 1, ain, aout};
|
2069
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2070
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2071
|
+
ndfunc_t ndf = { iter_sfloat_sub, STRIDE_LOOP, 2, 1, ain, aout };
|
2161
2072
|
|
2162
2073
|
return na_ndloop(&ndf, 2, self, other);
|
2163
2074
|
}
|
2164
2075
|
|
2165
|
-
/*
|
2166
|
-
Binary sub.
|
2167
|
-
@overload - other
|
2168
|
-
@param [Numo::NArray,Numeric] other
|
2169
|
-
@return [Numo::NArray] self - other
|
2170
|
-
*/
|
2171
2076
|
static VALUE sfloat_sub(VALUE self, VALUE other) {
|
2172
2077
|
|
2173
2078
|
VALUE klass, v;
|
@@ -2181,7 +2086,7 @@ static VALUE sfloat_sub(VALUE self, VALUE other) {
|
|
2181
2086
|
}
|
2182
2087
|
}
|
2183
2088
|
|
2184
|
-
#define check_intdivzero(y)
|
2089
|
+
#define check_intdivzero(y) \
|
2185
2090
|
{}
|
2186
2091
|
|
2187
2092
|
static void iter_sfloat_mul(na_loop_t* const lp) {
|
@@ -2206,14 +2111,20 @@ static void iter_sfloat_mul(na_loop_t* const lp) {
|
|
2206
2111
|
INIT_PTR(lp, 2, p3, s3);
|
2207
2112
|
|
2208
2113
|
//
|
2209
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
2114
|
+
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
2115
|
+
is_aligned(p3, sizeof(dtype))) {
|
2210
2116
|
|
2211
2117
|
if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
|
2212
2118
|
#ifdef __SSE2__
|
2213
2119
|
// Check number of elements. & Check same alignment.
|
2214
|
-
if ((n >= num_pack) &&
|
2120
|
+
if ((n >= num_pack) &&
|
2121
|
+
is_same_aligned3(
|
2122
|
+
&((dtype*)p1)[i], &((dtype*)p2)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE
|
2123
|
+
)) {
|
2215
2124
|
// Calculate up to the position just before the start of SIMD computation.
|
2216
|
-
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
2125
|
+
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
2126
|
+
&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
|
2127
|
+
);
|
2217
2128
|
#endif
|
2218
2129
|
if (p1 == p3) { // inplace case
|
2219
2130
|
#ifdef __SSE2__
|
@@ -2275,7 +2186,8 @@ static void iter_sfloat_mul(na_loop_t* const lp) {
|
|
2275
2186
|
return;
|
2276
2187
|
}
|
2277
2188
|
|
2278
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
2189
|
+
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
2190
|
+
is_aligned_step(s3, sizeof(dtype))) {
|
2279
2191
|
//
|
2280
2192
|
|
2281
2193
|
if (s2 == 0) { // Broadcasting from scalar value.
|
@@ -2286,9 +2198,12 @@ static void iter_sfloat_mul(na_loop_t* const lp) {
|
|
2286
2198
|
b = _mm_load1_ps(&((dtype*)p2)[0]);
|
2287
2199
|
|
2288
2200
|
// Check number of elements. & Check same alignment.
|
2289
|
-
if ((n >= num_pack) &&
|
2201
|
+
if ((n >= num_pack) &&
|
2202
|
+
is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
|
2290
2203
|
// Calculate up to the position just before the start of SIMD computation.
|
2291
|
-
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
2204
|
+
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
2205
|
+
&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
|
2206
|
+
);
|
2292
2207
|
#endif
|
2293
2208
|
if (p1 == p3) { // inplace case
|
2294
2209
|
#ifdef __SSE2__
|
@@ -2384,19 +2299,13 @@ static void iter_sfloat_mul(na_loop_t* const lp) {
|
|
2384
2299
|
#undef check_intdivzero
|
2385
2300
|
|
2386
2301
|
static VALUE sfloat_mul_self(VALUE self, VALUE other) {
|
2387
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2388
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2389
|
-
ndfunc_t ndf = {iter_sfloat_mul, STRIDE_LOOP, 2, 1, ain, aout};
|
2302
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2303
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2304
|
+
ndfunc_t ndf = { iter_sfloat_mul, STRIDE_LOOP, 2, 1, ain, aout };
|
2390
2305
|
|
2391
2306
|
return na_ndloop(&ndf, 2, self, other);
|
2392
2307
|
}
|
2393
2308
|
|
2394
|
-
/*
|
2395
|
-
Binary mul.
|
2396
|
-
@overload * other
|
2397
|
-
@param [Numo::NArray,Numeric] other
|
2398
|
-
@return [Numo::NArray] self * other
|
2399
|
-
*/
|
2400
2309
|
static VALUE sfloat_mul(VALUE self, VALUE other) {
|
2401
2310
|
|
2402
2311
|
VALUE klass, v;
|
@@ -2410,7 +2319,7 @@ static VALUE sfloat_mul(VALUE self, VALUE other) {
|
|
2410
2319
|
}
|
2411
2320
|
}
|
2412
2321
|
|
2413
|
-
#define check_intdivzero(y)
|
2322
|
+
#define check_intdivzero(y) \
|
2414
2323
|
{}
|
2415
2324
|
|
2416
2325
|
static void iter_sfloat_div(na_loop_t* const lp) {
|
@@ -2435,14 +2344,20 @@ static void iter_sfloat_div(na_loop_t* const lp) {
|
|
2435
2344
|
INIT_PTR(lp, 2, p3, s3);
|
2436
2345
|
|
2437
2346
|
//
|
2438
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
2347
|
+
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
2348
|
+
is_aligned(p3, sizeof(dtype))) {
|
2439
2349
|
|
2440
2350
|
if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
|
2441
2351
|
#ifdef __SSE2__
|
2442
2352
|
// Check number of elements. & Check same alignment.
|
2443
|
-
if ((n >= num_pack) &&
|
2353
|
+
if ((n >= num_pack) &&
|
2354
|
+
is_same_aligned3(
|
2355
|
+
&((dtype*)p1)[i], &((dtype*)p2)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE
|
2356
|
+
)) {
|
2444
2357
|
// Calculate up to the position just before the start of SIMD computation.
|
2445
|
-
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
2358
|
+
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
2359
|
+
&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
|
2360
|
+
);
|
2446
2361
|
#endif
|
2447
2362
|
if (p1 == p3) { // inplace case
|
2448
2363
|
#ifdef __SSE2__
|
@@ -2504,7 +2419,8 @@ static void iter_sfloat_div(na_loop_t* const lp) {
|
|
2504
2419
|
return;
|
2505
2420
|
}
|
2506
2421
|
|
2507
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
2422
|
+
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
2423
|
+
is_aligned_step(s3, sizeof(dtype))) {
|
2508
2424
|
//
|
2509
2425
|
|
2510
2426
|
if (s2 == 0) { // Broadcasting from scalar value.
|
@@ -2515,9 +2431,12 @@ static void iter_sfloat_div(na_loop_t* const lp) {
|
|
2515
2431
|
b = _mm_load1_ps(&((dtype*)p2)[0]);
|
2516
2432
|
|
2517
2433
|
// Check number of elements. & Check same alignment.
|
2518
|
-
if ((n >= num_pack) &&
|
2434
|
+
if ((n >= num_pack) &&
|
2435
|
+
is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p3)[i], SIMD_ALIGNMENT_SIZE)) {
|
2519
2436
|
// Calculate up to the position just before the start of SIMD computation.
|
2520
|
-
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
2437
|
+
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
2438
|
+
&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
|
2439
|
+
);
|
2521
2440
|
#endif
|
2522
2441
|
if (p1 == p3) { // inplace case
|
2523
2442
|
#ifdef __SSE2__
|
@@ -2613,19 +2532,13 @@ static void iter_sfloat_div(na_loop_t* const lp) {
|
|
2613
2532
|
#undef check_intdivzero
|
2614
2533
|
|
2615
2534
|
static VALUE sfloat_div_self(VALUE self, VALUE other) {
|
2616
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2617
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2618
|
-
ndfunc_t ndf = {iter_sfloat_div, STRIDE_LOOP, 2, 1, ain, aout};
|
2535
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2536
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2537
|
+
ndfunc_t ndf = { iter_sfloat_div, STRIDE_LOOP, 2, 1, ain, aout };
|
2619
2538
|
|
2620
2539
|
return na_ndloop(&ndf, 2, self, other);
|
2621
2540
|
}
|
2622
2541
|
|
2623
|
-
/*
|
2624
|
-
Binary div.
|
2625
|
-
@overload / other
|
2626
|
-
@param [Numo::NArray,Numeric] other
|
2627
|
-
@return [Numo::NArray] self / other
|
2628
|
-
*/
|
2629
2542
|
static VALUE sfloat_div(VALUE self, VALUE other) {
|
2630
2543
|
|
2631
2544
|
VALUE klass, v;
|
@@ -2639,7 +2552,7 @@ static VALUE sfloat_div(VALUE self, VALUE other) {
|
|
2639
2552
|
}
|
2640
2553
|
}
|
2641
2554
|
|
2642
|
-
#define check_intdivzero(y)
|
2555
|
+
#define check_intdivzero(y) \
|
2643
2556
|
{}
|
2644
2557
|
|
2645
2558
|
static void iter_sfloat_mod(na_loop_t* const lp) {
|
@@ -2654,7 +2567,8 @@ static void iter_sfloat_mod(na_loop_t* const lp) {
|
|
2654
2567
|
INIT_PTR(lp, 2, p3, s3);
|
2655
2568
|
|
2656
2569
|
//
|
2657
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
2570
|
+
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
2571
|
+
is_aligned(p3, sizeof(dtype))) {
|
2658
2572
|
|
2659
2573
|
if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
|
2660
2574
|
if (p1 == p3) { // inplace case
|
@@ -2671,7 +2585,8 @@ static void iter_sfloat_mod(na_loop_t* const lp) {
|
|
2671
2585
|
return;
|
2672
2586
|
}
|
2673
2587
|
|
2674
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
2588
|
+
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
2589
|
+
is_aligned_step(s3, sizeof(dtype))) {
|
2675
2590
|
//
|
2676
2591
|
|
2677
2592
|
if (s2 == 0) { // Broadcasting from scalar value.
|
@@ -2729,19 +2644,13 @@ static void iter_sfloat_mod(na_loop_t* const lp) {
|
|
2729
2644
|
#undef check_intdivzero
|
2730
2645
|
|
2731
2646
|
static VALUE sfloat_mod_self(VALUE self, VALUE other) {
|
2732
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2733
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2734
|
-
ndfunc_t ndf = {iter_sfloat_mod, STRIDE_LOOP, 2, 1, ain, aout};
|
2647
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2648
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2649
|
+
ndfunc_t ndf = { iter_sfloat_mod, STRIDE_LOOP, 2, 1, ain, aout };
|
2735
2650
|
|
2736
2651
|
return na_ndloop(&ndf, 2, self, other);
|
2737
2652
|
}
|
2738
2653
|
|
2739
|
-
/*
|
2740
|
-
Binary mod.
|
2741
|
-
@overload % other
|
2742
|
-
@param [Numo::NArray,Numeric] other
|
2743
|
-
@return [Numo::NArray] self % other
|
2744
|
-
*/
|
2745
2654
|
static VALUE sfloat_mod(VALUE self, VALUE other) {
|
2746
2655
|
|
2747
2656
|
VALUE klass, v;
|
@@ -2775,19 +2684,13 @@ static void iter_sfloat_divmod(na_loop_t* const lp) {
|
|
2775
2684
|
}
|
2776
2685
|
|
2777
2686
|
static VALUE sfloat_divmod_self(VALUE self, VALUE other) {
|
2778
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2779
|
-
ndfunc_arg_out_t aout[2] = {{cT, 0}, {cT, 0}};
|
2780
|
-
ndfunc_t ndf = {iter_sfloat_divmod, STRIDE_LOOP, 2, 2, ain, aout};
|
2687
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2688
|
+
ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
|
2689
|
+
ndfunc_t ndf = { iter_sfloat_divmod, STRIDE_LOOP, 2, 2, ain, aout };
|
2781
2690
|
|
2782
2691
|
return na_ndloop(&ndf, 2, self, other);
|
2783
2692
|
}
|
2784
2693
|
|
2785
|
-
/*
|
2786
|
-
Binary divmod.
|
2787
|
-
@overload divmod other
|
2788
|
-
@param [Numo::NArray,Numeric] other
|
2789
|
-
@return [Numo::NArray] divmod of self and other.
|
2790
|
-
*/
|
2791
2694
|
static VALUE sfloat_divmod(VALUE self, VALUE other) {
|
2792
2695
|
|
2793
2696
|
VALUE klass, v;
|
@@ -2836,11 +2739,11 @@ static void iter_sfloat_pow_int32(na_loop_t* const lp) {
|
|
2836
2739
|
}
|
2837
2740
|
|
2838
2741
|
static VALUE sfloat_pow_self(VALUE self, VALUE other) {
|
2839
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2840
|
-
ndfunc_arg_in_t ain_i[2] = {{cT, 0}, {numo_cInt32, 0}};
|
2841
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2842
|
-
ndfunc_t ndf = {iter_sfloat_pow, STRIDE_LOOP, 2, 1, ain, aout};
|
2843
|
-
ndfunc_t ndf_i = {iter_sfloat_pow_int32, STRIDE_LOOP, 2, 1, ain_i, aout};
|
2742
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2743
|
+
ndfunc_arg_in_t ain_i[2] = { { cT, 0 }, { numo_cInt32, 0 } };
|
2744
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2745
|
+
ndfunc_t ndf = { iter_sfloat_pow, STRIDE_LOOP, 2, 1, ain, aout };
|
2746
|
+
ndfunc_t ndf_i = { iter_sfloat_pow_int32, STRIDE_LOOP, 2, 1, ain_i, aout };
|
2844
2747
|
|
2845
2748
|
// fixme : use na.integer?
|
2846
2749
|
if (FIXNUM_P(other) || rb_obj_is_kind_of(other, numo_cInt32)) {
|
@@ -2850,12 +2753,6 @@ static VALUE sfloat_pow_self(VALUE self, VALUE other) {
|
|
2850
2753
|
}
|
2851
2754
|
}
|
2852
2755
|
|
2853
|
-
/*
|
2854
|
-
Binary power.
|
2855
|
-
@overload ** other
|
2856
|
-
@param [Numo::NArray,Numeric] other
|
2857
|
-
@return [Numo::NArray] self to the other-th power.
|
2858
|
-
*/
|
2859
2756
|
static VALUE sfloat_pow(VALUE self, VALUE other) {
|
2860
2757
|
|
2861
2758
|
VALUE klass, v;
|
@@ -2930,15 +2827,10 @@ static void iter_sfloat_minus(na_loop_t* const lp) {
|
|
2930
2827
|
}
|
2931
2828
|
}
|
2932
2829
|
|
2933
|
-
/*
|
2934
|
-
Unary minus.
|
2935
|
-
@overload -@
|
2936
|
-
@return [Numo::SFloat] minus of self.
|
2937
|
-
*/
|
2938
2830
|
static VALUE sfloat_minus(VALUE self) {
|
2939
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2940
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2941
|
-
ndfunc_t ndf = {iter_sfloat_minus, FULL_LOOP, 1, 1, ain, aout};
|
2831
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2832
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2833
|
+
ndfunc_t ndf = { iter_sfloat_minus, FULL_LOOP, 1, 1, ain, aout };
|
2942
2834
|
|
2943
2835
|
return na_ndloop(&ndf, 1, self);
|
2944
2836
|
}
|
@@ -3005,15 +2897,10 @@ static void iter_sfloat_reciprocal(na_loop_t* const lp) {
|
|
3005
2897
|
}
|
3006
2898
|
}
|
3007
2899
|
|
3008
|
-
/*
|
3009
|
-
Unary reciprocal.
|
3010
|
-
@overload reciprocal
|
3011
|
-
@return [Numo::SFloat] reciprocal of self.
|
3012
|
-
*/
|
3013
2900
|
static VALUE sfloat_reciprocal(VALUE self) {
|
3014
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3015
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3016
|
-
ndfunc_t ndf = {iter_sfloat_reciprocal, FULL_LOOP, 1, 1, ain, aout};
|
2901
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2902
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2903
|
+
ndfunc_t ndf = { iter_sfloat_reciprocal, FULL_LOOP, 1, 1, ain, aout };
|
3017
2904
|
|
3018
2905
|
return na_ndloop(&ndf, 1, self);
|
3019
2906
|
}
|
@@ -3080,15 +2967,10 @@ static void iter_sfloat_sign(na_loop_t* const lp) {
|
|
3080
2967
|
}
|
3081
2968
|
}
|
3082
2969
|
|
3083
|
-
/*
|
3084
|
-
Unary sign.
|
3085
|
-
@overload sign
|
3086
|
-
@return [Numo::SFloat] sign of self.
|
3087
|
-
*/
|
3088
2970
|
static VALUE sfloat_sign(VALUE self) {
|
3089
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3090
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3091
|
-
ndfunc_t ndf = {iter_sfloat_sign, FULL_LOOP, 1, 1, ain, aout};
|
2971
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2972
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2973
|
+
ndfunc_t ndf = { iter_sfloat_sign, FULL_LOOP, 1, 1, ain, aout };
|
3092
2974
|
|
3093
2975
|
return na_ndloop(&ndf, 1, self);
|
3094
2976
|
}
|
@@ -3155,15 +3037,10 @@ static void iter_sfloat_square(na_loop_t* const lp) {
|
|
3155
3037
|
}
|
3156
3038
|
}
|
3157
3039
|
|
3158
|
-
/*
|
3159
|
-
Unary square.
|
3160
|
-
@overload square
|
3161
|
-
@return [Numo::SFloat] square of self.
|
3162
|
-
*/
|
3163
3040
|
static VALUE sfloat_square(VALUE self) {
|
3164
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3165
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3166
|
-
ndfunc_t ndf = {iter_sfloat_square, FULL_LOOP, 1, 1, ain, aout};
|
3041
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3042
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3043
|
+
ndfunc_t ndf = { iter_sfloat_square, FULL_LOOP, 1, 1, ain, aout };
|
3167
3044
|
|
3168
3045
|
return na_ndloop(&ndf, 1, self);
|
3169
3046
|
}
|
@@ -3190,19 +3067,13 @@ static void iter_sfloat_eq(na_loop_t* const lp) {
|
|
3190
3067
|
}
|
3191
3068
|
|
3192
3069
|
static VALUE sfloat_eq_self(VALUE self, VALUE other) {
|
3193
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3194
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3195
|
-
ndfunc_t ndf = {iter_sfloat_eq, STRIDE_LOOP, 2, 1, ain, aout};
|
3070
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3071
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3072
|
+
ndfunc_t ndf = { iter_sfloat_eq, STRIDE_LOOP, 2, 1, ain, aout };
|
3196
3073
|
|
3197
3074
|
return na_ndloop(&ndf, 2, self, other);
|
3198
3075
|
}
|
3199
3076
|
|
3200
|
-
/*
|
3201
|
-
Comparison eq other.
|
3202
|
-
@overload eq other
|
3203
|
-
@param [Numo::NArray,Numeric] other
|
3204
|
-
@return [Numo::Bit] result of self eq other.
|
3205
|
-
*/
|
3206
3077
|
static VALUE sfloat_eq(VALUE self, VALUE other) {
|
3207
3078
|
|
3208
3079
|
VALUE klass, v;
|
@@ -3237,19 +3108,13 @@ static void iter_sfloat_ne(na_loop_t* const lp) {
|
|
3237
3108
|
}
|
3238
3109
|
|
3239
3110
|
static VALUE sfloat_ne_self(VALUE self, VALUE other) {
|
3240
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3241
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3242
|
-
ndfunc_t ndf = {iter_sfloat_ne, STRIDE_LOOP, 2, 1, ain, aout};
|
3111
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3112
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3113
|
+
ndfunc_t ndf = { iter_sfloat_ne, STRIDE_LOOP, 2, 1, ain, aout };
|
3243
3114
|
|
3244
3115
|
return na_ndloop(&ndf, 2, self, other);
|
3245
3116
|
}
|
3246
3117
|
|
3247
|
-
/*
|
3248
|
-
Comparison ne other.
|
3249
|
-
@overload ne other
|
3250
|
-
@param [Numo::NArray,Numeric] other
|
3251
|
-
@return [Numo::Bit] result of self ne other.
|
3252
|
-
*/
|
3253
3118
|
static VALUE sfloat_ne(VALUE self, VALUE other) {
|
3254
3119
|
|
3255
3120
|
VALUE klass, v;
|
@@ -3284,19 +3149,13 @@ static void iter_sfloat_nearly_eq(na_loop_t* const lp) {
|
|
3284
3149
|
}
|
3285
3150
|
|
3286
3151
|
static VALUE sfloat_nearly_eq_self(VALUE self, VALUE other) {
|
3287
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3288
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3289
|
-
ndfunc_t ndf = {iter_sfloat_nearly_eq, STRIDE_LOOP, 2, 1, ain, aout};
|
3152
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3153
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3154
|
+
ndfunc_t ndf = { iter_sfloat_nearly_eq, STRIDE_LOOP, 2, 1, ain, aout };
|
3290
3155
|
|
3291
3156
|
return na_ndloop(&ndf, 2, self, other);
|
3292
3157
|
}
|
3293
3158
|
|
3294
|
-
/*
|
3295
|
-
Comparison nearly_eq other.
|
3296
|
-
@overload nearly_eq other
|
3297
|
-
@param [Numo::NArray,Numeric] other
|
3298
|
-
@return [Numo::Bit] result of self nearly_eq other.
|
3299
|
-
*/
|
3300
3159
|
static VALUE sfloat_nearly_eq(VALUE self, VALUE other) {
|
3301
3160
|
|
3302
3161
|
VALUE klass, v;
|
@@ -3371,15 +3230,10 @@ static void iter_sfloat_floor(na_loop_t* const lp) {
|
|
3371
3230
|
}
|
3372
3231
|
}
|
3373
3232
|
|
3374
|
-
/*
|
3375
|
-
Unary floor.
|
3376
|
-
@overload floor
|
3377
|
-
@return [Numo::SFloat] floor of self.
|
3378
|
-
*/
|
3379
3233
|
static VALUE sfloat_floor(VALUE self) {
|
3380
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3381
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3382
|
-
ndfunc_t ndf = {iter_sfloat_floor, FULL_LOOP, 1, 1, ain, aout};
|
3234
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3235
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3236
|
+
ndfunc_t ndf = { iter_sfloat_floor, FULL_LOOP, 1, 1, ain, aout };
|
3383
3237
|
|
3384
3238
|
return na_ndloop(&ndf, 1, self);
|
3385
3239
|
}
|
@@ -3446,15 +3300,10 @@ static void iter_sfloat_round(na_loop_t* const lp) {
|
|
3446
3300
|
}
|
3447
3301
|
}
|
3448
3302
|
|
3449
|
-
/*
|
3450
|
-
Unary round.
|
3451
|
-
@overload round
|
3452
|
-
@return [Numo::SFloat] round of self.
|
3453
|
-
*/
|
3454
3303
|
static VALUE sfloat_round(VALUE self) {
|
3455
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3456
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3457
|
-
ndfunc_t ndf = {iter_sfloat_round, FULL_LOOP, 1, 1, ain, aout};
|
3304
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3305
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3306
|
+
ndfunc_t ndf = { iter_sfloat_round, FULL_LOOP, 1, 1, ain, aout };
|
3458
3307
|
|
3459
3308
|
return na_ndloop(&ndf, 1, self);
|
3460
3309
|
}
|
@@ -3521,15 +3370,10 @@ static void iter_sfloat_ceil(na_loop_t* const lp) {
|
|
3521
3370
|
}
|
3522
3371
|
}
|
3523
3372
|
|
3524
|
-
/*
|
3525
|
-
Unary ceil.
|
3526
|
-
@overload ceil
|
3527
|
-
@return [Numo::SFloat] ceil of self.
|
3528
|
-
*/
|
3529
3373
|
static VALUE sfloat_ceil(VALUE self) {
|
3530
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3531
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3532
|
-
ndfunc_t ndf = {iter_sfloat_ceil, FULL_LOOP, 1, 1, ain, aout};
|
3374
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3375
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3376
|
+
ndfunc_t ndf = { iter_sfloat_ceil, FULL_LOOP, 1, 1, ain, aout };
|
3533
3377
|
|
3534
3378
|
return na_ndloop(&ndf, 1, self);
|
3535
3379
|
}
|
@@ -3596,15 +3440,10 @@ static void iter_sfloat_trunc(na_loop_t* const lp) {
|
|
3596
3440
|
}
|
3597
3441
|
}
|
3598
3442
|
|
3599
|
-
/*
|
3600
|
-
Unary trunc.
|
3601
|
-
@overload trunc
|
3602
|
-
@return [Numo::SFloat] trunc of self.
|
3603
|
-
*/
|
3604
3443
|
static VALUE sfloat_trunc(VALUE self) {
|
3605
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3606
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3607
|
-
ndfunc_t ndf = {iter_sfloat_trunc, FULL_LOOP, 1, 1, ain, aout};
|
3444
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3445
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3446
|
+
ndfunc_t ndf = { iter_sfloat_trunc, FULL_LOOP, 1, 1, ain, aout };
|
3608
3447
|
|
3609
3448
|
return na_ndloop(&ndf, 1, self);
|
3610
3449
|
}
|
@@ -3671,20 +3510,15 @@ static void iter_sfloat_rint(na_loop_t* const lp) {
|
|
3671
3510
|
}
|
3672
3511
|
}
|
3673
3512
|
|
3674
|
-
/*
|
3675
|
-
Unary rint.
|
3676
|
-
@overload rint
|
3677
|
-
@return [Numo::SFloat] rint of self.
|
3678
|
-
*/
|
3679
3513
|
static VALUE sfloat_rint(VALUE self) {
|
3680
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3681
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3682
|
-
ndfunc_t ndf = {iter_sfloat_rint, FULL_LOOP, 1, 1, ain, aout};
|
3514
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3515
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3516
|
+
ndfunc_t ndf = { iter_sfloat_rint, FULL_LOOP, 1, 1, ain, aout };
|
3683
3517
|
|
3684
3518
|
return na_ndloop(&ndf, 1, self);
|
3685
3519
|
}
|
3686
3520
|
|
3687
|
-
#define check_intdivzero(y)
|
3521
|
+
#define check_intdivzero(y) \
|
3688
3522
|
{}
|
3689
3523
|
|
3690
3524
|
static void iter_sfloat_copysign(na_loop_t* const lp) {
|
@@ -3699,7 +3533,8 @@ static void iter_sfloat_copysign(na_loop_t* const lp) {
|
|
3699
3533
|
INIT_PTR(lp, 2, p3, s3);
|
3700
3534
|
|
3701
3535
|
//
|
3702
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
3536
|
+
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
3537
|
+
is_aligned(p3, sizeof(dtype))) {
|
3703
3538
|
|
3704
3539
|
if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
|
3705
3540
|
if (p1 == p3) { // inplace case
|
@@ -3716,7 +3551,8 @@ static void iter_sfloat_copysign(na_loop_t* const lp) {
|
|
3716
3551
|
return;
|
3717
3552
|
}
|
3718
3553
|
|
3719
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
3554
|
+
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
3555
|
+
is_aligned_step(s3, sizeof(dtype))) {
|
3720
3556
|
//
|
3721
3557
|
|
3722
3558
|
if (s2 == 0) { // Broadcasting from scalar value.
|
@@ -3774,19 +3610,13 @@ static void iter_sfloat_copysign(na_loop_t* const lp) {
|
|
3774
3610
|
#undef check_intdivzero
|
3775
3611
|
|
3776
3612
|
static VALUE sfloat_copysign_self(VALUE self, VALUE other) {
|
3777
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3778
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3779
|
-
ndfunc_t ndf = {iter_sfloat_copysign, STRIDE_LOOP, 2, 1, ain, aout};
|
3613
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3614
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3615
|
+
ndfunc_t ndf = { iter_sfloat_copysign, STRIDE_LOOP, 2, 1, ain, aout };
|
3780
3616
|
|
3781
3617
|
return na_ndloop(&ndf, 2, self, other);
|
3782
3618
|
}
|
3783
3619
|
|
3784
|
-
/*
|
3785
|
-
Binary copysign.
|
3786
|
-
@overload copysign other
|
3787
|
-
@param [Numo::NArray,Numeric] other
|
3788
|
-
@return [Numo::NArray] self copysign other
|
3789
|
-
*/
|
3790
3620
|
static VALUE sfloat_copysign(VALUE self, VALUE other) {
|
3791
3621
|
|
3792
3622
|
VALUE klass, v;
|
@@ -3829,15 +3659,10 @@ static void iter_sfloat_signbit(na_loop_t* const lp) {
|
|
3829
3659
|
}
|
3830
3660
|
}
|
3831
3661
|
|
3832
|
-
/*
|
3833
|
-
Condition of signbit.
|
3834
|
-
@overload signbit
|
3835
|
-
@return [Numo::Bit] Condition of signbit.
|
3836
|
-
*/
|
3837
3662
|
static VALUE sfloat_signbit(VALUE self) {
|
3838
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3839
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3840
|
-
ndfunc_t ndf = {iter_sfloat_signbit, FULL_LOOP, 1, 1, ain, aout};
|
3663
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3664
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3665
|
+
ndfunc_t ndf = { iter_sfloat_signbit, FULL_LOOP, 1, 1, ain, aout };
|
3841
3666
|
|
3842
3667
|
return na_ndloop(&ndf, 1, self);
|
3843
3668
|
}
|
@@ -3859,15 +3684,10 @@ static void iter_sfloat_modf(na_loop_t* const lp) {
|
|
3859
3684
|
}
|
3860
3685
|
}
|
3861
3686
|
|
3862
|
-
/*
|
3863
|
-
modf of self.
|
3864
|
-
@overload modf
|
3865
|
-
@return [Numo::SFloat] modf of self.
|
3866
|
-
*/
|
3867
3687
|
static VALUE sfloat_modf(VALUE self) {
|
3868
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3869
|
-
ndfunc_arg_out_t aout[2] = {{cT, 0}, {cT, 0}};
|
3870
|
-
ndfunc_t ndf = {iter_sfloat_modf, STRIDE_LOOP, 1, 2, ain, aout};
|
3688
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3689
|
+
ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
|
3690
|
+
ndfunc_t ndf = { iter_sfloat_modf, STRIDE_LOOP, 1, 2, ain, aout };
|
3871
3691
|
|
3872
3692
|
return na_ndloop(&ndf, 1, self);
|
3873
3693
|
}
|
@@ -3894,19 +3714,13 @@ static void iter_sfloat_gt(na_loop_t* const lp) {
|
|
3894
3714
|
}
|
3895
3715
|
|
3896
3716
|
static VALUE sfloat_gt_self(VALUE self, VALUE other) {
|
3897
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3898
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3899
|
-
ndfunc_t ndf = {iter_sfloat_gt, STRIDE_LOOP, 2, 1, ain, aout};
|
3717
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3718
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3719
|
+
ndfunc_t ndf = { iter_sfloat_gt, STRIDE_LOOP, 2, 1, ain, aout };
|
3900
3720
|
|
3901
3721
|
return na_ndloop(&ndf, 2, self, other);
|
3902
3722
|
}
|
3903
3723
|
|
3904
|
-
/*
|
3905
|
-
Comparison gt other.
|
3906
|
-
@overload gt other
|
3907
|
-
@param [Numo::NArray,Numeric] other
|
3908
|
-
@return [Numo::Bit] result of self gt other.
|
3909
|
-
*/
|
3910
3724
|
static VALUE sfloat_gt(VALUE self, VALUE other) {
|
3911
3725
|
|
3912
3726
|
VALUE klass, v;
|
@@ -3941,19 +3755,13 @@ static void iter_sfloat_ge(na_loop_t* const lp) {
|
|
3941
3755
|
}
|
3942
3756
|
|
3943
3757
|
static VALUE sfloat_ge_self(VALUE self, VALUE other) {
|
3944
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3945
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3946
|
-
ndfunc_t ndf = {iter_sfloat_ge, STRIDE_LOOP, 2, 1, ain, aout};
|
3758
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3759
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3760
|
+
ndfunc_t ndf = { iter_sfloat_ge, STRIDE_LOOP, 2, 1, ain, aout };
|
3947
3761
|
|
3948
3762
|
return na_ndloop(&ndf, 2, self, other);
|
3949
3763
|
}
|
3950
3764
|
|
3951
|
-
/*
|
3952
|
-
Comparison ge other.
|
3953
|
-
@overload ge other
|
3954
|
-
@param [Numo::NArray,Numeric] other
|
3955
|
-
@return [Numo::Bit] result of self ge other.
|
3956
|
-
*/
|
3957
3765
|
static VALUE sfloat_ge(VALUE self, VALUE other) {
|
3958
3766
|
|
3959
3767
|
VALUE klass, v;
|
@@ -3988,19 +3796,13 @@ static void iter_sfloat_lt(na_loop_t* const lp) {
|
|
3988
3796
|
}
|
3989
3797
|
|
3990
3798
|
static VALUE sfloat_lt_self(VALUE self, VALUE other) {
|
3991
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3992
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3993
|
-
ndfunc_t ndf = {iter_sfloat_lt, STRIDE_LOOP, 2, 1, ain, aout};
|
3799
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3800
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3801
|
+
ndfunc_t ndf = { iter_sfloat_lt, STRIDE_LOOP, 2, 1, ain, aout };
|
3994
3802
|
|
3995
3803
|
return na_ndloop(&ndf, 2, self, other);
|
3996
3804
|
}
|
3997
3805
|
|
3998
|
-
/*
|
3999
|
-
Comparison lt other.
|
4000
|
-
@overload lt other
|
4001
|
-
@param [Numo::NArray,Numeric] other
|
4002
|
-
@return [Numo::Bit] result of self lt other.
|
4003
|
-
*/
|
4004
3806
|
static VALUE sfloat_lt(VALUE self, VALUE other) {
|
4005
3807
|
|
4006
3808
|
VALUE klass, v;
|
@@ -4035,19 +3837,13 @@ static void iter_sfloat_le(na_loop_t* const lp) {
|
|
4035
3837
|
}
|
4036
3838
|
|
4037
3839
|
static VALUE sfloat_le_self(VALUE self, VALUE other) {
|
4038
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
4039
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
4040
|
-
ndfunc_t ndf = {iter_sfloat_le, STRIDE_LOOP, 2, 1, ain, aout};
|
3840
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3841
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3842
|
+
ndfunc_t ndf = { iter_sfloat_le, STRIDE_LOOP, 2, 1, ain, aout };
|
4041
3843
|
|
4042
3844
|
return na_ndloop(&ndf, 2, self, other);
|
4043
3845
|
}
|
4044
3846
|
|
4045
|
-
/*
|
4046
|
-
Comparison le other.
|
4047
|
-
@overload le other
|
4048
|
-
@param [Numo::NArray,Numeric] other
|
4049
|
-
@return [Numo::Bit] result of self le other.
|
4050
|
-
*/
|
4051
3847
|
static VALUE sfloat_le(VALUE self, VALUE other) {
|
4052
3848
|
|
4053
3849
|
VALUE klass, v;
|
@@ -4125,42 +3921,12 @@ static void iter_sfloat_clip_max(na_loop_t* const lp) {
|
|
4125
3921
|
}
|
4126
3922
|
}
|
4127
3923
|
|
4128
|
-
/*
|
4129
|
-
Clip array elements by [min,max].
|
4130
|
-
If either of min or max is nil, one side is clipped.
|
4131
|
-
@overload clip(min,max)
|
4132
|
-
@param [Numo::NArray,Numeric] min
|
4133
|
-
@param [Numo::NArray,Numeric] max
|
4134
|
-
@return [Numo::NArray] result of clip.
|
4135
|
-
|
4136
|
-
@example
|
4137
|
-
a = Numo::Int32.new(10).seq
|
4138
|
-
# => Numo::Int32#shape=[10]
|
4139
|
-
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
4140
|
-
|
4141
|
-
a.clip(1,8)
|
4142
|
-
# => Numo::Int32#shape=[10]
|
4143
|
-
# [1, 1, 2, 3, 4, 5, 6, 7, 8, 8]
|
4144
|
-
|
4145
|
-
a.inplace.clip(3,6)
|
4146
|
-
a
|
4147
|
-
# => Numo::Int32#shape=[10]
|
4148
|
-
# [3, 3, 3, 3, 4, 5, 6, 6, 6, 6]
|
4149
|
-
|
4150
|
-
b = Numo::Int32.new(10).seq
|
4151
|
-
# => Numo::Int32#shape=[10]
|
4152
|
-
# [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
4153
|
-
|
4154
|
-
b.clip([3,4,1,1,1,4,4,4,4,4], 8)
|
4155
|
-
# => Numo::Int32#shape=[10]
|
4156
|
-
# [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]
|
4157
|
-
*/
|
4158
3924
|
static VALUE sfloat_clip(VALUE self, VALUE min, VALUE max) {
|
4159
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {cT, 0}, {cT, 0}};
|
4160
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4161
|
-
ndfunc_t ndf_min = {iter_sfloat_clip_min, STRIDE_LOOP, 2, 1, ain, aout};
|
4162
|
-
ndfunc_t ndf_max = {iter_sfloat_clip_max, STRIDE_LOOP, 2, 1, ain, aout};
|
4163
|
-
ndfunc_t ndf_both = {iter_sfloat_clip, STRIDE_LOOP, 3, 1, ain, aout};
|
3925
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { cT, 0 }, { cT, 0 } };
|
3926
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3927
|
+
ndfunc_t ndf_min = { iter_sfloat_clip_min, STRIDE_LOOP, 2, 1, ain, aout };
|
3928
|
+
ndfunc_t ndf_max = { iter_sfloat_clip_max, STRIDE_LOOP, 2, 1, ain, aout };
|
3929
|
+
ndfunc_t ndf_both = { iter_sfloat_clip, STRIDE_LOOP, 3, 1, ain, aout };
|
4164
3930
|
|
4165
3931
|
if (RTEST(min)) {
|
4166
3932
|
if (RTEST(max)) {
|
@@ -4206,15 +3972,10 @@ static void iter_sfloat_isnan(na_loop_t* const lp) {
|
|
4206
3972
|
}
|
4207
3973
|
}
|
4208
3974
|
|
4209
|
-
/*
|
4210
|
-
Condition of isnan.
|
4211
|
-
@overload isnan
|
4212
|
-
@return [Numo::Bit] Condition of isnan.
|
4213
|
-
*/
|
4214
3975
|
static VALUE sfloat_isnan(VALUE self) {
|
4215
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
4216
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
4217
|
-
ndfunc_t ndf = {iter_sfloat_isnan, FULL_LOOP, 1, 1, ain, aout};
|
3976
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3977
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3978
|
+
ndfunc_t ndf = { iter_sfloat_isnan, FULL_LOOP, 1, 1, ain, aout };
|
4218
3979
|
|
4219
3980
|
return na_ndloop(&ndf, 1, self);
|
4220
3981
|
}
|
@@ -4248,15 +4009,10 @@ static void iter_sfloat_isinf(na_loop_t* const lp) {
|
|
4248
4009
|
}
|
4249
4010
|
}
|
4250
4011
|
|
4251
|
-
/*
|
4252
|
-
Condition of isinf.
|
4253
|
-
@overload isinf
|
4254
|
-
@return [Numo::Bit] Condition of isinf.
|
4255
|
-
*/
|
4256
4012
|
static VALUE sfloat_isinf(VALUE self) {
|
4257
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
4258
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
4259
|
-
ndfunc_t ndf = {iter_sfloat_isinf, FULL_LOOP, 1, 1, ain, aout};
|
4013
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4014
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
4015
|
+
ndfunc_t ndf = { iter_sfloat_isinf, FULL_LOOP, 1, 1, ain, aout };
|
4260
4016
|
|
4261
4017
|
return na_ndloop(&ndf, 1, self);
|
4262
4018
|
}
|
@@ -4290,15 +4046,10 @@ static void iter_sfloat_isposinf(na_loop_t* const lp) {
|
|
4290
4046
|
}
|
4291
4047
|
}
|
4292
4048
|
|
4293
|
-
/*
|
4294
|
-
Condition of isposinf.
|
4295
|
-
@overload isposinf
|
4296
|
-
@return [Numo::Bit] Condition of isposinf.
|
4297
|
-
*/
|
4298
4049
|
static VALUE sfloat_isposinf(VALUE self) {
|
4299
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
4300
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
4301
|
-
ndfunc_t ndf = {iter_sfloat_isposinf, FULL_LOOP, 1, 1, ain, aout};
|
4050
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4051
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
4052
|
+
ndfunc_t ndf = { iter_sfloat_isposinf, FULL_LOOP, 1, 1, ain, aout };
|
4302
4053
|
|
4303
4054
|
return na_ndloop(&ndf, 1, self);
|
4304
4055
|
}
|
@@ -4332,15 +4083,10 @@ static void iter_sfloat_isneginf(na_loop_t* const lp) {
|
|
4332
4083
|
}
|
4333
4084
|
}
|
4334
4085
|
|
4335
|
-
/*
|
4336
|
-
Condition of isneginf.
|
4337
|
-
@overload isneginf
|
4338
|
-
@return [Numo::Bit] Condition of isneginf.
|
4339
|
-
*/
|
4340
4086
|
static VALUE sfloat_isneginf(VALUE self) {
|
4341
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
4342
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
4343
|
-
ndfunc_t ndf = {iter_sfloat_isneginf, FULL_LOOP, 1, 1, ain, aout};
|
4087
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4088
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
4089
|
+
ndfunc_t ndf = { iter_sfloat_isneginf, FULL_LOOP, 1, 1, ain, aout };
|
4344
4090
|
|
4345
4091
|
return na_ndloop(&ndf, 1, self);
|
4346
4092
|
}
|
@@ -4374,15 +4120,10 @@ static void iter_sfloat_isfinite(na_loop_t* const lp) {
|
|
4374
4120
|
}
|
4375
4121
|
}
|
4376
4122
|
|
4377
|
-
/*
|
4378
|
-
Condition of isfinite.
|
4379
|
-
@overload isfinite
|
4380
|
-
@return [Numo::Bit] Condition of isfinite.
|
4381
|
-
*/
|
4382
4123
|
static VALUE sfloat_isfinite(VALUE self) {
|
4383
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
4384
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
4385
|
-
ndfunc_t ndf = {iter_sfloat_isfinite, FULL_LOOP, 1, 1, ain, aout};
|
4124
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4125
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
4126
|
+
ndfunc_t ndf = { iter_sfloat_isfinite, FULL_LOOP, 1, 1, ain, aout };
|
4386
4127
|
|
4387
4128
|
return na_ndloop(&ndf, 1, self);
|
4388
4129
|
}
|
@@ -4410,19 +4151,11 @@ static void iter_sfloat_sum_nan(na_loop_t* const lp) {
|
|
4410
4151
|
*(dtype*)p2 = f_sum_nan(n, p1, s1);
|
4411
4152
|
}
|
4412
4153
|
|
4413
|
-
/*
|
4414
|
-
sum of self.
|
4415
|
-
@overload sum(axis:nil, keepdims:false, nan:false)
|
4416
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
4417
|
-
@param [Numeric,Array,Range] axis Performs sum along the axis.
|
4418
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
4419
|
-
@return [Numo::SFloat] returns result of sum.
|
4420
|
-
*/
|
4421
4154
|
static VALUE sfloat_sum(int argc, VALUE* argv, VALUE self) {
|
4422
4155
|
VALUE v, reduce;
|
4423
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4424
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4425
|
-
ndfunc_t ndf = {iter_sfloat_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
4156
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4157
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4158
|
+
ndfunc_t ndf = { iter_sfloat_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4426
4159
|
|
4427
4160
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_sum_nan);
|
4428
4161
|
|
@@ -4454,19 +4187,11 @@ static void iter_sfloat_prod_nan(na_loop_t* const lp) {
|
|
4454
4187
|
*(dtype*)p2 = f_prod_nan(n, p1, s1);
|
4455
4188
|
}
|
4456
4189
|
|
4457
|
-
/*
|
4458
|
-
prod of self.
|
4459
|
-
@overload prod(axis:nil, keepdims:false, nan:false)
|
4460
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
4461
|
-
@param [Numeric,Array,Range] axis Performs prod along the axis.
|
4462
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
4463
|
-
@return [Numo::SFloat] returns result of prod.
|
4464
|
-
*/
|
4465
4190
|
static VALUE sfloat_prod(int argc, VALUE* argv, VALUE self) {
|
4466
4191
|
VALUE v, reduce;
|
4467
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4468
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4469
|
-
ndfunc_t ndf = {iter_sfloat_prod, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
4192
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4193
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4194
|
+
ndfunc_t ndf = { iter_sfloat_prod, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4470
4195
|
|
4471
4196
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_prod_nan);
|
4472
4197
|
|
@@ -4475,182 +4200,6 @@ static VALUE sfloat_prod(int argc, VALUE* argv, VALUE self) {
|
|
4475
4200
|
return sfloat_extract(v);
|
4476
4201
|
}
|
4477
4202
|
|
4478
|
-
static void iter_sfloat_mean(na_loop_t* const lp) {
|
4479
|
-
size_t n;
|
4480
|
-
char *p1, *p2;
|
4481
|
-
ssize_t s1;
|
4482
|
-
|
4483
|
-
INIT_COUNTER(lp, n);
|
4484
|
-
INIT_PTR(lp, 0, p1, s1);
|
4485
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4486
|
-
|
4487
|
-
*(dtype*)p2 = f_mean(n, p1, s1);
|
4488
|
-
}
|
4489
|
-
static void iter_sfloat_mean_nan(na_loop_t* const lp) {
|
4490
|
-
size_t n;
|
4491
|
-
char *p1, *p2;
|
4492
|
-
ssize_t s1;
|
4493
|
-
|
4494
|
-
INIT_COUNTER(lp, n);
|
4495
|
-
INIT_PTR(lp, 0, p1, s1);
|
4496
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4497
|
-
|
4498
|
-
*(dtype*)p2 = f_mean_nan(n, p1, s1);
|
4499
|
-
}
|
4500
|
-
|
4501
|
-
/*
|
4502
|
-
mean of self.
|
4503
|
-
@overload mean(axis:nil, keepdims:false, nan:false)
|
4504
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
4505
|
-
@param [Numeric,Array,Range] axis Performs mean along the axis.
|
4506
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
4507
|
-
@return [Numo::SFloat] returns result of mean.
|
4508
|
-
*/
|
4509
|
-
static VALUE sfloat_mean(int argc, VALUE* argv, VALUE self) {
|
4510
|
-
VALUE v, reduce;
|
4511
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4512
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4513
|
-
ndfunc_t ndf = {iter_sfloat_mean, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
4514
|
-
|
4515
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_mean_nan);
|
4516
|
-
|
4517
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4518
|
-
|
4519
|
-
return sfloat_extract(v);
|
4520
|
-
}
|
4521
|
-
|
4522
|
-
static void iter_sfloat_stddev(na_loop_t* const lp) {
|
4523
|
-
size_t n;
|
4524
|
-
char *p1, *p2;
|
4525
|
-
ssize_t s1;
|
4526
|
-
|
4527
|
-
INIT_COUNTER(lp, n);
|
4528
|
-
INIT_PTR(lp, 0, p1, s1);
|
4529
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4530
|
-
|
4531
|
-
*(rtype*)p2 = f_stddev(n, p1, s1);
|
4532
|
-
}
|
4533
|
-
static void iter_sfloat_stddev_nan(na_loop_t* const lp) {
|
4534
|
-
size_t n;
|
4535
|
-
char *p1, *p2;
|
4536
|
-
ssize_t s1;
|
4537
|
-
|
4538
|
-
INIT_COUNTER(lp, n);
|
4539
|
-
INIT_PTR(lp, 0, p1, s1);
|
4540
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4541
|
-
|
4542
|
-
*(rtype*)p2 = f_stddev_nan(n, p1, s1);
|
4543
|
-
}
|
4544
|
-
|
4545
|
-
/*
|
4546
|
-
stddev of self.
|
4547
|
-
@overload stddev(axis:nil, keepdims:false, nan:false)
|
4548
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
4549
|
-
@param [Numeric,Array,Range] axis Performs stddev along the axis.
|
4550
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
4551
|
-
@return [Numo::SFloat] returns result of stddev.
|
4552
|
-
*/
|
4553
|
-
static VALUE sfloat_stddev(int argc, VALUE* argv, VALUE self) {
|
4554
|
-
VALUE v, reduce;
|
4555
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4556
|
-
ndfunc_arg_out_t aout[1] = {{cRT, 0}};
|
4557
|
-
ndfunc_t ndf = {iter_sfloat_stddev, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
4558
|
-
|
4559
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_stddev_nan);
|
4560
|
-
|
4561
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4562
|
-
|
4563
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
4564
|
-
}
|
4565
|
-
|
4566
|
-
static void iter_sfloat_var(na_loop_t* const lp) {
|
4567
|
-
size_t n;
|
4568
|
-
char *p1, *p2;
|
4569
|
-
ssize_t s1;
|
4570
|
-
|
4571
|
-
INIT_COUNTER(lp, n);
|
4572
|
-
INIT_PTR(lp, 0, p1, s1);
|
4573
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4574
|
-
|
4575
|
-
*(rtype*)p2 = f_var(n, p1, s1);
|
4576
|
-
}
|
4577
|
-
static void iter_sfloat_var_nan(na_loop_t* const lp) {
|
4578
|
-
size_t n;
|
4579
|
-
char *p1, *p2;
|
4580
|
-
ssize_t s1;
|
4581
|
-
|
4582
|
-
INIT_COUNTER(lp, n);
|
4583
|
-
INIT_PTR(lp, 0, p1, s1);
|
4584
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4585
|
-
|
4586
|
-
*(rtype*)p2 = f_var_nan(n, p1, s1);
|
4587
|
-
}
|
4588
|
-
|
4589
|
-
/*
|
4590
|
-
var of self.
|
4591
|
-
@overload var(axis:nil, keepdims:false, nan:false)
|
4592
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
4593
|
-
@param [Numeric,Array,Range] axis Performs var along the axis.
|
4594
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
4595
|
-
@return [Numo::SFloat] returns result of var.
|
4596
|
-
*/
|
4597
|
-
static VALUE sfloat_var(int argc, VALUE* argv, VALUE self) {
|
4598
|
-
VALUE v, reduce;
|
4599
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4600
|
-
ndfunc_arg_out_t aout[1] = {{cRT, 0}};
|
4601
|
-
ndfunc_t ndf = {iter_sfloat_var, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
4602
|
-
|
4603
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_var_nan);
|
4604
|
-
|
4605
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4606
|
-
|
4607
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
4608
|
-
}
|
4609
|
-
|
4610
|
-
static void iter_sfloat_rms(na_loop_t* const lp) {
|
4611
|
-
size_t n;
|
4612
|
-
char *p1, *p2;
|
4613
|
-
ssize_t s1;
|
4614
|
-
|
4615
|
-
INIT_COUNTER(lp, n);
|
4616
|
-
INIT_PTR(lp, 0, p1, s1);
|
4617
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4618
|
-
|
4619
|
-
*(rtype*)p2 = f_rms(n, p1, s1);
|
4620
|
-
}
|
4621
|
-
static void iter_sfloat_rms_nan(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_rms_nan(n, p1, s1);
|
4631
|
-
}
|
4632
|
-
|
4633
|
-
/*
|
4634
|
-
rms of self.
|
4635
|
-
@overload rms(axis:nil, keepdims:false, nan:false)
|
4636
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
4637
|
-
@param [Numeric,Array,Range] axis Performs rms along the axis.
|
4638
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
4639
|
-
@return [Numo::SFloat] returns result of rms.
|
4640
|
-
*/
|
4641
|
-
static VALUE sfloat_rms(int argc, VALUE* argv, VALUE self) {
|
4642
|
-
VALUE v, reduce;
|
4643
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4644
|
-
ndfunc_arg_out_t aout[1] = {{cRT, 0}};
|
4645
|
-
ndfunc_t ndf = {iter_sfloat_rms, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
4646
|
-
|
4647
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_rms_nan);
|
4648
|
-
|
4649
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4650
|
-
|
4651
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
4652
|
-
}
|
4653
|
-
|
4654
4203
|
static void iter_sfloat_min(na_loop_t* const lp) {
|
4655
4204
|
size_t n;
|
4656
4205
|
char *p1, *p2;
|
@@ -4674,19 +4223,11 @@ static void iter_sfloat_min_nan(na_loop_t* const lp) {
|
|
4674
4223
|
*(dtype*)p2 = f_min_nan(n, p1, s1);
|
4675
4224
|
}
|
4676
4225
|
|
4677
|
-
/*
|
4678
|
-
min of self.
|
4679
|
-
@overload min(axis:nil, keepdims:false, nan:false)
|
4680
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
4681
|
-
@param [Numeric,Array,Range] axis Performs min along the axis.
|
4682
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
4683
|
-
@return [Numo::SFloat] returns result of min.
|
4684
|
-
*/
|
4685
4226
|
static VALUE sfloat_min(int argc, VALUE* argv, VALUE self) {
|
4686
4227
|
VALUE v, reduce;
|
4687
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4688
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4689
|
-
ndfunc_t ndf = {iter_sfloat_min, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
4228
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4229
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4230
|
+
ndfunc_t ndf = { iter_sfloat_min, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4690
4231
|
|
4691
4232
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_min_nan);
|
4692
4233
|
|
@@ -4718,19 +4259,11 @@ static void iter_sfloat_max_nan(na_loop_t* const lp) {
|
|
4718
4259
|
*(dtype*)p2 = f_max_nan(n, p1, s1);
|
4719
4260
|
}
|
4720
4261
|
|
4721
|
-
/*
|
4722
|
-
max of self.
|
4723
|
-
@overload max(axis:nil, keepdims:false, nan:false)
|
4724
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
4725
|
-
@param [Numeric,Array,Range] axis Performs max along the axis.
|
4726
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
4727
|
-
@return [Numo::SFloat] returns result of max.
|
4728
|
-
*/
|
4729
4262
|
static VALUE sfloat_max(int argc, VALUE* argv, VALUE self) {
|
4730
4263
|
VALUE v, reduce;
|
4731
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4732
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4733
|
-
ndfunc_t ndf = {iter_sfloat_max, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
4264
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4265
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4266
|
+
ndfunc_t ndf = { iter_sfloat_max, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4734
4267
|
|
4735
4268
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_max_nan);
|
4736
4269
|
|
@@ -4762,19 +4295,11 @@ static void iter_sfloat_ptp_nan(na_loop_t* const lp) {
|
|
4762
4295
|
*(dtype*)p2 = f_ptp_nan(n, p1, s1);
|
4763
4296
|
}
|
4764
4297
|
|
4765
|
-
/*
|
4766
|
-
ptp of self.
|
4767
|
-
@overload ptp(axis:nil, keepdims:false, nan:false)
|
4768
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
4769
|
-
@param [Numeric,Array,Range] axis Performs ptp along the axis.
|
4770
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
4771
|
-
@return [Numo::SFloat] returns result of ptp.
|
4772
|
-
*/
|
4773
4298
|
static VALUE sfloat_ptp(int argc, VALUE* argv, VALUE self) {
|
4774
4299
|
VALUE v, reduce;
|
4775
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4776
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4777
|
-
ndfunc_t ndf = {iter_sfloat_ptp, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
4300
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4301
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4302
|
+
ndfunc_t ndf = { iter_sfloat_ptp, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4778
4303
|
|
4779
4304
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_ptp_nan);
|
4780
4305
|
|
@@ -4851,31 +4376,12 @@ static void iter_sfloat_max_index_index32_nan(na_loop_t* const lp) {
|
|
4851
4376
|
}
|
4852
4377
|
#undef idx_t
|
4853
4378
|
|
4854
|
-
/*
|
4855
|
-
Index of the maximum value.
|
4856
|
-
@overload max_index(axis:nil, nan:false)
|
4857
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
4858
|
-
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **flat 1-d indices**.
|
4859
|
-
@return [Integer,Numo::Int] returns result indices.
|
4860
|
-
@see #argmax
|
4861
|
-
@see #max
|
4862
|
-
|
4863
|
-
@example
|
4864
|
-
a = Numo::NArray[3,4,1,2]
|
4865
|
-
a.max_index #=> 1
|
4866
|
-
|
4867
|
-
b = Numo::NArray[[3,4,1],[2,0,5]]
|
4868
|
-
b.max_index #=> 5
|
4869
|
-
b.max_index(axis:1) #=> [1, 5]
|
4870
|
-
b.max_index(axis:0) #=> [0, 1, 5]
|
4871
|
-
b[b.max_index(axis:0)] #=> [3, 4, 5]
|
4872
|
-
*/
|
4873
4379
|
static VALUE sfloat_max_index(int argc, VALUE* argv, VALUE self) {
|
4874
4380
|
narray_t* na;
|
4875
4381
|
VALUE idx, reduce;
|
4876
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {Qnil, 0}, {sym_reduce, 0}};
|
4877
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
4878
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout};
|
4382
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { Qnil, 0 }, { sym_reduce, 0 } };
|
4383
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
4384
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout };
|
4879
4385
|
|
4880
4386
|
GetNArray(self, na);
|
4881
4387
|
if (na->ndim == 0) {
|
@@ -4968,31 +4474,12 @@ static void iter_sfloat_min_index_index32_nan(na_loop_t* const lp) {
|
|
4968
4474
|
}
|
4969
4475
|
#undef idx_t
|
4970
4476
|
|
4971
|
-
/*
|
4972
|
-
Index of the minimum value.
|
4973
|
-
@overload min_index(axis:nil, nan:false)
|
4974
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
4975
|
-
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **flat 1-d indices**.
|
4976
|
-
@return [Integer,Numo::Int] returns result indices.
|
4977
|
-
@see #argmin
|
4978
|
-
@see #min
|
4979
|
-
|
4980
|
-
@example
|
4981
|
-
a = Numo::NArray[3,4,1,2]
|
4982
|
-
a.min_index #=> 2
|
4983
|
-
|
4984
|
-
b = Numo::NArray[[3,4,1],[2,0,5]]
|
4985
|
-
b.min_index #=> 4
|
4986
|
-
b.min_index(axis:1) #=> [2, 4]
|
4987
|
-
b.min_index(axis:0) #=> [3, 4, 2]
|
4988
|
-
b[b.min_index(axis:0)] #=> [2, 0, 1]
|
4989
|
-
*/
|
4990
4477
|
static VALUE sfloat_min_index(int argc, VALUE* argv, VALUE self) {
|
4991
4478
|
narray_t* na;
|
4992
4479
|
VALUE idx, reduce;
|
4993
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {Qnil, 0}, {sym_reduce, 0}};
|
4994
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
4995
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout};
|
4480
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { Qnil, 0 }, { sym_reduce, 0 } };
|
4481
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
4482
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 3, 1, ain, aout };
|
4996
4483
|
|
4997
4484
|
GetNArray(self, na);
|
4998
4485
|
if (na->ndim == 0) {
|
@@ -5081,31 +4568,12 @@ static void iter_sfloat_argmax_arg32_nan(na_loop_t* const lp) {
|
|
5081
4568
|
}
|
5082
4569
|
#undef idx_t
|
5083
4570
|
|
5084
|
-
/*
|
5085
|
-
Index of the maximum value.
|
5086
|
-
@overload argmax(axis:nil, nan:false)
|
5087
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
5088
|
-
@param [Numeric,Array,Range] axis Finds maximum values along the axis and returns **indices along the axis**.
|
5089
|
-
@return [Integer,Numo::Int] returns the result indices.
|
5090
|
-
@see #max_index
|
5091
|
-
@see #max
|
5092
|
-
|
5093
|
-
@example
|
5094
|
-
a = Numo::NArray[3,4,1,2]
|
5095
|
-
a.argmax #=> 1
|
5096
|
-
|
5097
|
-
b = Numo::NArray[[3,4,1],[2,0,5]]
|
5098
|
-
b.argmax #=> 5
|
5099
|
-
b.argmax(axis:1) #=> [1, 2]
|
5100
|
-
b.argmax(axis:0) #=> [0, 0, 1]
|
5101
|
-
b.at(b.argmax(axis:0), 0..-1) #=> [3, 4, 5]
|
5102
|
-
*/
|
5103
4571
|
static VALUE sfloat_argmax(int argc, VALUE* argv, VALUE self) {
|
5104
4572
|
narray_t* na;
|
5105
4573
|
VALUE reduce;
|
5106
|
-
ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_reduce, 0}};
|
5107
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
5108
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout};
|
4574
|
+
ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } };
|
4575
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
4576
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout };
|
5109
4577
|
|
5110
4578
|
GetNArray(self, na);
|
5111
4579
|
if (na->ndim == 0) {
|
@@ -5191,31 +4659,12 @@ static void iter_sfloat_argmin_arg32_nan(na_loop_t* const lp) {
|
|
5191
4659
|
}
|
5192
4660
|
#undef idx_t
|
5193
4661
|
|
5194
|
-
/*
|
5195
|
-
Index of the minimum value.
|
5196
|
-
@overload argmin(axis:nil, nan:false)
|
5197
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN posision if exist).
|
5198
|
-
@param [Numeric,Array,Range] axis Finds minimum values along the axis and returns **indices along the axis**.
|
5199
|
-
@return [Integer,Numo::Int] returns the result indices.
|
5200
|
-
@see #min_index
|
5201
|
-
@see #min
|
5202
|
-
|
5203
|
-
@example
|
5204
|
-
a = Numo::NArray[3,4,1,2]
|
5205
|
-
a.argmin #=> 2
|
5206
|
-
|
5207
|
-
b = Numo::NArray[[3,4,1],[2,0,5]]
|
5208
|
-
b.argmin #=> 4
|
5209
|
-
b.argmin(axis:1) #=> [2, 1]
|
5210
|
-
b.argmin(axis:0) #=> [1, 1, 0]
|
5211
|
-
b.at(b.argmin(axis:0), 0..-1) #=> [2, 0, 1]
|
5212
|
-
*/
|
5213
4662
|
static VALUE sfloat_argmin(int argc, VALUE* argv, VALUE self) {
|
5214
4663
|
narray_t* na;
|
5215
4664
|
VALUE reduce;
|
5216
|
-
ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_reduce, 0}};
|
5217
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
5218
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout};
|
4665
|
+
ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_reduce, 0 } };
|
4666
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
4667
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 1, ain, aout };
|
5219
4668
|
|
5220
4669
|
GetNArray(self, na);
|
5221
4670
|
if (na->ndim == 0) {
|
@@ -5266,35 +4715,19 @@ static void iter_sfloat_minmax_nan(na_loop_t* const lp) {
|
|
5266
4715
|
*(dtype*)(lp->args[2].ptr + lp->args[2].iter[0].pos) = xmax;
|
5267
4716
|
}
|
5268
4717
|
|
5269
|
-
/*
|
5270
|
-
minmax of self.
|
5271
|
-
@overload minmax(axis:nil, keepdims:false, nan:false)
|
5272
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
5273
|
-
@param [Numeric,Array,Range] axis Finds min-max along the axis.
|
5274
|
-
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
|
5275
|
-
@return [Numo::SFloat,Numo::SFloat] min and max of self.
|
5276
|
-
*/
|
5277
4718
|
static VALUE sfloat_minmax(int argc, VALUE* argv, VALUE self) {
|
5278
4719
|
VALUE reduce;
|
5279
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
5280
|
-
ndfunc_arg_out_t aout[2] = {{cT, 0}, {cT, 0}};
|
5281
|
-
ndfunc_t ndf = {
|
4720
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4721
|
+
ndfunc_arg_out_t aout[2] = { { cT, 0 }, { cT, 0 } };
|
4722
|
+
ndfunc_t ndf = {
|
4723
|
+
iter_sfloat_minmax, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_EXTRACT, 2, 2, ain, aout
|
4724
|
+
};
|
5282
4725
|
|
5283
4726
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_minmax_nan);
|
5284
4727
|
|
5285
4728
|
return na_ndloop(&ndf, 2, self, reduce);
|
5286
4729
|
}
|
5287
4730
|
|
5288
|
-
/*
|
5289
|
-
Element-wise maximum of two arrays.
|
5290
|
-
|
5291
|
-
@overload maximum(a1, a2, nan:false)
|
5292
|
-
@param [Numo::NArray,Numeric] a1 The array to be compared.
|
5293
|
-
@param [Numo::NArray,Numeric] a2 The array to be compared.
|
5294
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
5295
|
-
@return [Numo::SFloat]
|
5296
|
-
*/
|
5297
|
-
|
5298
4731
|
static void iter_sfloat_s_maximum(na_loop_t* const lp) {
|
5299
4732
|
size_t i, n;
|
5300
4733
|
char *p1, *p2, *p3;
|
@@ -5337,13 +4770,13 @@ static void iter_sfloat_s_maximum_nan(na_loop_t* const lp) {
|
|
5337
4770
|
static VALUE sfloat_s_maximum(int argc, VALUE* argv, VALUE mod) {
|
5338
4771
|
VALUE a1 = Qnil;
|
5339
4772
|
VALUE a2 = Qnil;
|
5340
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
5341
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5342
|
-
ndfunc_t ndf = {iter_sfloat_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout};
|
4773
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
4774
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4775
|
+
ndfunc_t ndf = { iter_sfloat_s_maximum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
|
5343
4776
|
|
5344
4777
|
VALUE kw_hash = Qnil;
|
5345
|
-
ID kw_table[1] = {id_nan};
|
5346
|
-
VALUE opts[1] = {Qundef};
|
4778
|
+
ID kw_table[1] = { id_nan };
|
4779
|
+
VALUE opts[1] = { Qundef };
|
5347
4780
|
|
5348
4781
|
rb_scan_args(argc, argv, "20:", &a1, &a2, &kw_hash);
|
5349
4782
|
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
|
@@ -5354,16 +4787,6 @@ static VALUE sfloat_s_maximum(int argc, VALUE* argv, VALUE mod) {
|
|
5354
4787
|
return na_ndloop(&ndf, 2, a1, a2);
|
5355
4788
|
}
|
5356
4789
|
|
5357
|
-
/*
|
5358
|
-
Element-wise minimum of two arrays.
|
5359
|
-
|
5360
|
-
@overload minimum(a1, a2, nan:false)
|
5361
|
-
@param [Numo::NArray,Numeric] a1 The array to be compared.
|
5362
|
-
@param [Numo::NArray,Numeric] a2 The array to be compared.
|
5363
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
5364
|
-
@return [Numo::SFloat]
|
5365
|
-
*/
|
5366
|
-
|
5367
4790
|
static void iter_sfloat_s_minimum(na_loop_t* const lp) {
|
5368
4791
|
size_t i, n;
|
5369
4792
|
char *p1, *p2, *p3;
|
@@ -5406,13 +4829,13 @@ static void iter_sfloat_s_minimum_nan(na_loop_t* const lp) {
|
|
5406
4829
|
static VALUE sfloat_s_minimum(int argc, VALUE* argv, VALUE mod) {
|
5407
4830
|
VALUE a1 = Qnil;
|
5408
4831
|
VALUE a2 = Qnil;
|
5409
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
5410
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5411
|
-
ndfunc_t ndf = {iter_sfloat_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout};
|
4832
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
4833
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4834
|
+
ndfunc_t ndf = { iter_sfloat_s_minimum, STRIDE_LOOP_NIP, 2, 1, ain, aout };
|
5412
4835
|
|
5413
4836
|
VALUE kw_hash = Qnil;
|
5414
|
-
ID kw_table[1] = {id_nan};
|
5415
|
-
VALUE opts[1] = {Qundef};
|
4837
|
+
ID kw_table[1] = { id_nan };
|
4838
|
+
VALUE opts[1] = { Qundef };
|
5416
4839
|
|
5417
4840
|
rb_scan_args(argc, argv, "20:", &a1, &a2, &kw_hash);
|
5418
4841
|
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
|
@@ -5432,16 +4855,13 @@ static void iter_sfloat_cumsum(na_loop_t* const lp) {
|
|
5432
4855
|
INIT_COUNTER(lp, i);
|
5433
4856
|
INIT_PTR(lp, 0, p1, s1);
|
5434
4857
|
INIT_PTR(lp, 1, p2, s2);
|
5435
|
-
// printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
|
5436
4858
|
|
5437
4859
|
GET_DATA_STRIDE(p1, s1, dtype, x);
|
5438
4860
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
5439
|
-
// printf("i=%lu x=%f\n",i,x);
|
5440
4861
|
for (i--; i--;) {
|
5441
4862
|
GET_DATA_STRIDE(p1, s1, dtype, y);
|
5442
4863
|
m_cumsum(x, y);
|
5443
4864
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
5444
|
-
// printf("i=%lu x=%f\n",i,x);
|
5445
4865
|
}
|
5446
4866
|
}
|
5447
4867
|
static void iter_sfloat_cumsum_nan(na_loop_t* const lp) {
|
@@ -5453,31 +4873,23 @@ static void iter_sfloat_cumsum_nan(na_loop_t* const lp) {
|
|
5453
4873
|
INIT_COUNTER(lp, i);
|
5454
4874
|
INIT_PTR(lp, 0, p1, s1);
|
5455
4875
|
INIT_PTR(lp, 1, p2, s2);
|
5456
|
-
// printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
|
5457
4876
|
|
5458
4877
|
GET_DATA_STRIDE(p1, s1, dtype, x);
|
5459
4878
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
5460
|
-
// printf("i=%lu x=%f\n",i,x);
|
5461
4879
|
for (i--; i--;) {
|
5462
4880
|
GET_DATA_STRIDE(p1, s1, dtype, y);
|
5463
4881
|
m_cumsum_nan(x, y);
|
5464
4882
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
5465
|
-
// printf("i=%lu x=%f\n",i,x);
|
5466
4883
|
}
|
5467
4884
|
}
|
5468
4885
|
|
5469
|
-
/*
|
5470
|
-
cumsum of self.
|
5471
|
-
@overload cumsum(axis:nil, nan:false)
|
5472
|
-
@param [Numeric,Array,Range] axis Performs cumsum along the axis.
|
5473
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
5474
|
-
@return [Numo::SFloat] cumsum of self.
|
5475
|
-
*/
|
5476
4886
|
static VALUE sfloat_cumsum(int argc, VALUE* argv, VALUE self) {
|
5477
4887
|
VALUE reduce;
|
5478
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
5479
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5480
|
-
ndfunc_t ndf = {
|
4888
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4889
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4890
|
+
ndfunc_t ndf = {
|
4891
|
+
iter_sfloat_cumsum, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout
|
4892
|
+
};
|
5481
4893
|
|
5482
4894
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_cumsum_nan);
|
5483
4895
|
|
@@ -5493,16 +4905,13 @@ static void iter_sfloat_cumprod(na_loop_t* const lp) {
|
|
5493
4905
|
INIT_COUNTER(lp, i);
|
5494
4906
|
INIT_PTR(lp, 0, p1, s1);
|
5495
4907
|
INIT_PTR(lp, 1, p2, s2);
|
5496
|
-
// printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
|
5497
4908
|
|
5498
4909
|
GET_DATA_STRIDE(p1, s1, dtype, x);
|
5499
4910
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
5500
|
-
// printf("i=%lu x=%f\n",i,x);
|
5501
4911
|
for (i--; i--;) {
|
5502
4912
|
GET_DATA_STRIDE(p1, s1, dtype, y);
|
5503
4913
|
m_cumprod(x, y);
|
5504
4914
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
5505
|
-
// printf("i=%lu x=%f\n",i,x);
|
5506
4915
|
}
|
5507
4916
|
}
|
5508
4917
|
static void iter_sfloat_cumprod_nan(na_loop_t* const lp) {
|
@@ -5514,31 +4923,23 @@ static void iter_sfloat_cumprod_nan(na_loop_t* const lp) {
|
|
5514
4923
|
INIT_COUNTER(lp, i);
|
5515
4924
|
INIT_PTR(lp, 0, p1, s1);
|
5516
4925
|
INIT_PTR(lp, 1, p2, s2);
|
5517
|
-
// printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
|
5518
4926
|
|
5519
4927
|
GET_DATA_STRIDE(p1, s1, dtype, x);
|
5520
4928
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
5521
|
-
// printf("i=%lu x=%f\n",i,x);
|
5522
4929
|
for (i--; i--;) {
|
5523
4930
|
GET_DATA_STRIDE(p1, s1, dtype, y);
|
5524
4931
|
m_cumprod_nan(x, y);
|
5525
4932
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
5526
|
-
// printf("i=%lu x=%f\n",i,x);
|
5527
4933
|
}
|
5528
4934
|
}
|
5529
4935
|
|
5530
|
-
/*
|
5531
|
-
cumprod of self.
|
5532
|
-
@overload cumprod(axis:nil, nan:false)
|
5533
|
-
@param [Numeric,Array,Range] axis Performs cumprod along the axis.
|
5534
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
5535
|
-
@return [Numo::SFloat] cumprod of self.
|
5536
|
-
*/
|
5537
4936
|
static VALUE sfloat_cumprod(int argc, VALUE* argv, VALUE self) {
|
5538
4937
|
VALUE reduce;
|
5539
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
5540
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5541
|
-
ndfunc_t ndf = {
|
4938
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4939
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4940
|
+
ndfunc_t ndf = {
|
4941
|
+
iter_sfloat_cumprod, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout
|
4942
|
+
};
|
5542
4943
|
|
5543
4944
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_sfloat_cumprod_nan);
|
5544
4945
|
|
@@ -5618,9 +5019,9 @@ static void iter_sfloat_mulsum_nan(na_loop_t* const lp) {
|
|
5618
5019
|
static VALUE sfloat_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
5619
5020
|
VALUE v, reduce;
|
5620
5021
|
VALUE naryv[2];
|
5621
|
-
ndfunc_arg_in_t ain[4] = {{cT, 0}, {cT, 0}, {sym_reduce, 0}, {sym_init, 0}};
|
5622
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5623
|
-
ndfunc_t ndf = {iter_sfloat_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout};
|
5022
|
+
ndfunc_arg_in_t ain[4] = { { cT, 0 }, { cT, 0 }, { sym_reduce, 0 }, { sym_init, 0 } };
|
5023
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5024
|
+
ndfunc_t ndf = { iter_sfloat_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout };
|
5624
5025
|
|
5625
5026
|
if (argc < 1) {
|
5626
5027
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for >=1)", argc);
|
@@ -5636,16 +5037,6 @@ static VALUE sfloat_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
|
5636
5037
|
return sfloat_extract(v);
|
5637
5038
|
}
|
5638
5039
|
|
5639
|
-
/*
|
5640
|
-
Binary mulsum.
|
5641
|
-
|
5642
|
-
@overload mulsum(other, axis:nil, keepdims:false, nan:false)
|
5643
|
-
@param [Numo::NArray,Numeric] other
|
5644
|
-
@param [Numeric,Array,Range] axis Performs mulsum along the axis.
|
5645
|
-
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array as dimensions with size one.
|
5646
|
-
@param [TrueClass] nan (keyword) If true, apply NaN-aware algorithm (avoid NaN if exists).
|
5647
|
-
@return [Numo::NArray] mulsum of self and other.
|
5648
|
-
*/
|
5649
5040
|
static VALUE sfloat_mulsum(int argc, VALUE* argv, VALUE self) {
|
5650
5041
|
//
|
5651
5042
|
VALUE klass, v;
|
@@ -5708,28 +5099,11 @@ static void iter_sfloat_seq(na_loop_t* const lp) {
|
|
5708
5099
|
g->count = c;
|
5709
5100
|
}
|
5710
5101
|
|
5711
|
-
/*
|
5712
|
-
Set linear sequence of numbers to self. The sequence is obtained from
|
5713
|
-
beg+i*step
|
5714
|
-
where i is 1-dimensional index.
|
5715
|
-
@overload seq([beg,[step]])
|
5716
|
-
@param [Numeric] beg beginning of sequence. (default=0)
|
5717
|
-
@param [Numeric] step step of sequence. (default=1)
|
5718
|
-
@return [Numo::SFloat] self.
|
5719
|
-
@example
|
5720
|
-
Numo::DFloat.new(6).seq(1,-0.2)
|
5721
|
-
# => Numo::DFloat#shape=[6]
|
5722
|
-
# [1, 0.8, 0.6, 0.4, 0.2, 0]
|
5723
|
-
|
5724
|
-
Numo::DComplex.new(6).seq(1,-0.2+0.2i)
|
5725
|
-
# => Numo::DComplex#shape=[6]
|
5726
|
-
# [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
5727
|
-
*/
|
5728
5102
|
static VALUE sfloat_seq(int argc, VALUE* args, VALUE self) {
|
5729
5103
|
seq_opt_t* g;
|
5730
5104
|
VALUE vbeg = Qnil, vstep = Qnil;
|
5731
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
|
5732
|
-
ndfunc_t ndf = {iter_sfloat_seq, FULL_LOOP, 1, 0, ain, 0};
|
5105
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
5106
|
+
ndfunc_t ndf = { iter_sfloat_seq, FULL_LOOP, 1, 0, ain, 0 };
|
5733
5107
|
|
5734
5108
|
g = ALLOCA_N(seq_opt_t, 1);
|
5735
5109
|
g->beg = m_zero;
|
@@ -5787,32 +5161,11 @@ static void iter_sfloat_logseq(na_loop_t* const lp) {
|
|
5787
5161
|
g->count = c;
|
5788
5162
|
}
|
5789
5163
|
|
5790
|
-
/*
|
5791
|
-
Set logarithmic sequence of numbers to self. The sequence is obtained from
|
5792
|
-
`base**(beg+i*step)`
|
5793
|
-
where i is 1-dimensional index.
|
5794
|
-
Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
|
5795
|
-
|
5796
|
-
@overload logseq(beg,step,[base])
|
5797
|
-
@param [Numeric] beg The beginning of sequence.
|
5798
|
-
@param [Numeric] step The step of sequence.
|
5799
|
-
@param [Numeric] base The base of log space. (default=10)
|
5800
|
-
@return [Numo::SFloat] self.
|
5801
|
-
|
5802
|
-
@example
|
5803
|
-
Numo::DFloat.new(5).logseq(4,-1,2)
|
5804
|
-
# => Numo::DFloat#shape=[5]
|
5805
|
-
# [16, 8, 4, 2, 1]
|
5806
|
-
|
5807
|
-
Numo::DComplex.new(5).logseq(0,1i*Math::PI/3,Math::E)
|
5808
|
-
# => Numo::DComplex#shape=[5]
|
5809
|
-
# [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
|
5810
|
-
*/
|
5811
5164
|
static VALUE sfloat_logseq(int argc, VALUE* args, VALUE self) {
|
5812
5165
|
logseq_opt_t* g;
|
5813
5166
|
VALUE vbeg, vstep, vbase;
|
5814
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
|
5815
|
-
ndfunc_t ndf = {iter_sfloat_logseq, FULL_LOOP, 1, 0, ain, 0};
|
5167
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
5168
|
+
ndfunc_t ndf = { iter_sfloat_logseq, FULL_LOOP, 1, 0, ain, 0 };
|
5816
5169
|
|
5817
5170
|
g = ALLOCA_N(logseq_opt_t, 1);
|
5818
5171
|
rb_scan_args(argc, args, "21", &vbeg, &vstep, &vbase);
|
@@ -5856,18 +5209,9 @@ static void iter_sfloat_eye(na_loop_t* const lp) {
|
|
5856
5209
|
}
|
5857
5210
|
}
|
5858
5211
|
|
5859
|
-
/*
|
5860
|
-
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
|
5861
|
-
@overload eye([element,offset])
|
5862
|
-
@param [Numeric] element Diagonal element to be stored. Default is 1.
|
5863
|
-
@param [Integer] offset Diagonal offset from the main diagonal. The
|
5864
|
-
default is 0. k>0 for diagonals above the main diagonal, and k<0
|
5865
|
-
for diagonals below the main diagonal.
|
5866
|
-
@return [Numo::SFloat] eye of self.
|
5867
|
-
*/
|
5868
5212
|
static VALUE sfloat_eye(int argc, VALUE* argv, VALUE self) {
|
5869
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 2}};
|
5870
|
-
ndfunc_t ndf = {iter_sfloat_eye, NO_LOOP, 1, 0, ain, 0};
|
5213
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
|
5214
|
+
ndfunc_t ndf = { iter_sfloat_eye, NO_LOOP, 1, 0, ain, 0 };
|
5871
5215
|
ssize_t kofs;
|
5872
5216
|
dtype data;
|
5873
5217
|
char* g;
|
@@ -5897,17 +5241,21 @@ static VALUE sfloat_eye(int argc, VALUE* argv, VALUE self) {
|
|
5897
5241
|
// Diagonal offset from the main diagonal.
|
5898
5242
|
if (kofs >= 0) {
|
5899
5243
|
if ((size_t)(kofs) >= na->shape[nd - 1]) {
|
5900
|
-
rb_raise(
|
5901
|
-
|
5902
|
-
|
5903
|
-
|
5244
|
+
rb_raise(
|
5245
|
+
rb_eArgError,
|
5246
|
+
"invalid diagonal offset(%" SZF "d) for "
|
5247
|
+
"last dimension size(%" SZF "d)",
|
5248
|
+
kofs, na->shape[nd - 1]
|
5249
|
+
);
|
5904
5250
|
}
|
5905
5251
|
} else {
|
5906
5252
|
if ((size_t)(-kofs) >= na->shape[nd - 2]) {
|
5907
|
-
rb_raise(
|
5908
|
-
|
5909
|
-
|
5910
|
-
|
5253
|
+
rb_raise(
|
5254
|
+
rb_eArgError,
|
5255
|
+
"invalid diagonal offset(%" SZF "d) for "
|
5256
|
+
"last-1 dimension size(%" SZF "d)",
|
5257
|
+
kofs, na->shape[nd - 2]
|
5258
|
+
);
|
5911
5259
|
}
|
5912
5260
|
}
|
5913
5261
|
|
@@ -5953,31 +5301,12 @@ static void iter_sfloat_rand(na_loop_t* const lp) {
|
|
5953
5301
|
}
|
5954
5302
|
}
|
5955
5303
|
|
5956
|
-
/*
|
5957
|
-
Generate uniformly distributed random numbers on self narray.
|
5958
|
-
@overload rand([[low],high])
|
5959
|
-
@param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
5960
|
-
@param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for complex types)
|
5961
|
-
@return [Numo::SFloat] self.
|
5962
|
-
@example
|
5963
|
-
Numo::DFloat.new(6).rand
|
5964
|
-
# => Numo::DFloat#shape=[6]
|
5965
|
-
# [0.0617545, 0.373067, 0.794815, 0.201042, 0.116041, 0.344032]
|
5966
|
-
|
5967
|
-
Numo::DComplex.new(6).rand(5+5i)
|
5968
|
-
# => Numo::DComplex#shape=[6]
|
5969
|
-
# [2.69974+3.68908i, 0.825443+0.254414i, 0.540323+0.34354i, 4.52061+2.39322i, ...]
|
5970
|
-
|
5971
|
-
Numo::Int32.new(6).rand(2,5)
|
5972
|
-
# => Numo::Int32#shape=[6]
|
5973
|
-
# [4, 3, 3, 2, 4, 2]
|
5974
|
-
*/
|
5975
5304
|
static VALUE sfloat_rand(int argc, VALUE* args, VALUE self) {
|
5976
5305
|
rand_opt_t g;
|
5977
5306
|
VALUE v1 = Qnil, v2 = Qnil;
|
5978
5307
|
dtype high;
|
5979
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
|
5980
|
-
ndfunc_t ndf = {iter_sfloat_rand, FULL_LOOP, 1, 0, ain, 0};
|
5308
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
5309
|
+
ndfunc_t ndf = { iter_sfloat_rand, FULL_LOOP, 1, 0, ain, 0 };
|
5981
5310
|
|
5982
5311
|
rb_scan_args(argc, args, "02", &v1, &v2);
|
5983
5312
|
if (v2 == Qnil) {
|
@@ -6051,42 +5380,12 @@ static void iter_sfloat_rand_norm(na_loop_t* const lp) {
|
|
6051
5380
|
}
|
6052
5381
|
}
|
6053
5382
|
|
6054
|
-
/*
|
6055
|
-
Generates random numbers from the normal distribution on self narray
|
6056
|
-
using Box-Muller Transformation.
|
6057
|
-
@overload rand_norm([mu,[sigma]])
|
6058
|
-
@param [Numeric] mu mean of normal distribution. (default=0)
|
6059
|
-
@param [Numeric] sigma standard deviation of normal distribution. (default=1)
|
6060
|
-
@return [Numo::SFloat] self.
|
6061
|
-
@example
|
6062
|
-
Numo::DFloat.new(5,5).rand_norm
|
6063
|
-
# => Numo::DFloat#shape=[5,5]
|
6064
|
-
# [[-0.581255, -0.168354, 0.586895, -0.595142, -0.802802],
|
6065
|
-
# [-0.326106, 0.282922, 1.68427, 0.918499, -0.0485384],
|
6066
|
-
# [-0.464453, -0.992194, 0.413794, -0.60717, -0.699695],
|
6067
|
-
# [-1.64168, 0.48676, -0.875871, -1.43275, 0.812172],
|
6068
|
-
# [-0.209975, -0.103612, -0.878617, -1.42495, 1.0968]]
|
6069
|
-
|
6070
|
-
Numo::DFloat.new(5,5).rand_norm(10,0.1)
|
6071
|
-
# => Numo::DFloat#shape=[5,5]
|
6072
|
-
# [[9.9019, 9.90339, 10.0826, 9.98384, 9.72861],
|
6073
|
-
# [9.81507, 10.0272, 9.91445, 10.0568, 9.88923],
|
6074
|
-
# [10.0234, 9.97874, 9.96011, 9.9006, 9.99964],
|
6075
|
-
# [10.0186, 9.94598, 9.92236, 9.99811, 9.97003],
|
6076
|
-
# [9.79266, 9.95044, 9.95212, 9.93692, 10.2027]]
|
6077
|
-
|
6078
|
-
Numo::DComplex.new(3,3).rand_norm(5+5i)
|
6079
|
-
# => Numo::DComplex#shape=[3,3]
|
6080
|
-
# [[5.84303+4.40052i, 4.00984+6.08982i, 5.10979+5.13215i],
|
6081
|
-
# [4.26477+3.99655i, 4.90052+5.00763i, 4.46607+2.3444i],
|
6082
|
-
# [4.5528+7.11003i, 5.62117+6.69094i, 5.05443+5.35133i]]
|
6083
|
-
*/
|
6084
5383
|
static VALUE sfloat_rand_norm(int argc, VALUE* args, VALUE self) {
|
6085
5384
|
int n;
|
6086
5385
|
randn_opt_t g;
|
6087
5386
|
VALUE v1 = Qnil, v2 = Qnil;
|
6088
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
|
6089
|
-
ndfunc_t ndf = {iter_sfloat_rand_norm, FULL_LOOP, 1, 0, ain, 0};
|
5387
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
5388
|
+
ndfunc_t ndf = { iter_sfloat_rand_norm, FULL_LOOP, 1, 0, ain, 0 };
|
6090
5389
|
|
6091
5390
|
n = rb_scan_args(argc, args, "02", &v1, &v2);
|
6092
5391
|
if (n == 0) {
|
@@ -6119,19 +5418,12 @@ static void iter_sfloat_poly(na_loop_t* const lp) {
|
|
6119
5418
|
*(dtype*)(lp->args[i].ptr + lp->args[i].iter[0].pos) = y;
|
6120
5419
|
}
|
6121
5420
|
|
6122
|
-
/*
|
6123
|
-
Calculate polynomial.
|
6124
|
-
`x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
|
6125
|
-
@overload poly a0, a1, ..., an
|
6126
|
-
@param [Numo::NArray,Numeric] a0,a1,...,an
|
6127
|
-
@return [Numo::SFloat]
|
6128
|
-
*/
|
6129
5421
|
static VALUE sfloat_poly(VALUE self, VALUE args) {
|
6130
5422
|
int argc, i;
|
6131
5423
|
VALUE* argv;
|
6132
5424
|
volatile VALUE v, a;
|
6133
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
6134
|
-
ndfunc_t ndf = {iter_sfloat_poly, NO_LOOP, 0, 1, 0, aout};
|
5425
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5426
|
+
ndfunc_t ndf = { iter_sfloat_poly, NO_LOOP, 0, 1, 0, aout };
|
6135
5427
|
|
6136
5428
|
argc = (int)RARRAY_LEN(args);
|
6137
5429
|
ndf.nin = argc + 1;
|
@@ -6211,23 +5503,28 @@ static VALUE sfloat_poly(VALUE self, VALUE args) {
|
|
6211
5503
|
* We have modified their original by adding a check for already-sorted input,
|
6212
5504
|
* which seems to be a win per discussions on pgsql-hackers around 2006-03-21.
|
6213
5505
|
*/
|
6214
|
-
#define swapcode(TYPE, parmi, parmj, n)
|
6215
|
-
do {
|
6216
|
-
size_t i = (n) / sizeof(TYPE);
|
6217
|
-
TYPE* pi = (TYPE*)(void*)(parmi);
|
6218
|
-
TYPE* pj = (TYPE*)(void*)(parmj);
|
6219
|
-
do {
|
6220
|
-
TYPE t = *pi;
|
6221
|
-
*pi++ = *pj;
|
6222
|
-
*pj++ = t;
|
6223
|
-
} while (--i > 0);
|
5506
|
+
#define swapcode(TYPE, parmi, parmj, n) \
|
5507
|
+
do { \
|
5508
|
+
size_t i = (n) / sizeof(TYPE); \
|
5509
|
+
TYPE* pi = (TYPE*)(void*)(parmi); \
|
5510
|
+
TYPE* pj = (TYPE*)(void*)(parmj); \
|
5511
|
+
do { \
|
5512
|
+
TYPE t = *pi; \
|
5513
|
+
*pi++ = *pj; \
|
5514
|
+
*pj++ = t; \
|
5515
|
+
} while (--i > 0); \
|
6224
5516
|
} while (0)
|
6225
5517
|
|
6226
5518
|
#ifdef HAVE_STDINT_H
|
6227
|
-
#define SWAPINIT(a, es)
|
5519
|
+
#define SWAPINIT(a, es) \
|
5520
|
+
swaptype = (uintptr_t)(a) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
5521
|
+
: (es) == sizeof(long) ? 0 \
|
5522
|
+
: 1;
|
6228
5523
|
#else
|
6229
|
-
#define SWAPINIT(a, es)
|
6230
|
-
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2
|
5524
|
+
#define SWAPINIT(a, es) \
|
5525
|
+
swaptype = ((char*)(a) - (char*)0) % sizeof(long) || (es) % sizeof(long) ? 2 \
|
5526
|
+
: (es) == sizeof(long) ? 0 \
|
5527
|
+
: 1;
|
6231
5528
|
#endif
|
6232
5529
|
|
6233
5530
|
static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
|
@@ -6237,19 +5534,20 @@ static inline void swapfunc(char* a, char* b, size_t n, int swaptype) {
|
|
6237
5534
|
swapcode(char, a, b, n);
|
6238
5535
|
}
|
6239
5536
|
|
6240
|
-
#define swap(a, b)
|
6241
|
-
if (swaptype == 0) {
|
6242
|
-
long t = *(long*)(void*)(a);
|
6243
|
-
*(long*)(void*)(a) = *(long*)(void*)(b);
|
6244
|
-
*(long*)(void*)(b) = t;
|
6245
|
-
} else
|
5537
|
+
#define swap(a, b) \
|
5538
|
+
if (swaptype == 0) { \
|
5539
|
+
long t = *(long*)(void*)(a); \
|
5540
|
+
*(long*)(void*)(a) = *(long*)(void*)(b); \
|
5541
|
+
*(long*)(void*)(b) = t; \
|
5542
|
+
} else \
|
6246
5543
|
swapfunc(a, b, es, swaptype)
|
6247
5544
|
|
6248
|
-
#define vecswap(a, b, n)
|
5545
|
+
#define vecswap(a, b, n) \
|
6249
5546
|
if ((n) > 0) swapfunc((a), (b), (size_t)(n), swaptype)
|
6250
5547
|
|
6251
|
-
#define med3(a, b, c, _cmp)
|
6252
|
-
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a))
|
5548
|
+
#define med3(a, b, c, _cmp) \
|
5549
|
+
(cmpgt(b, a) ? (cmpgt(c, b) ? b : (cmpgt(c, a) ? c : a)) \
|
5550
|
+
: (cmpgt(b, c) ? b : (cmpgt(c, a) ? a : c)))
|
6253
5551
|
#endif
|
6254
5552
|
|
6255
5553
|
#undef qsort_dtype
|
@@ -6478,19 +5776,10 @@ static void iter_sfloat_sort_prnan(na_loop_t* const lp) {
|
|
6478
5776
|
sfloat_qsort_prnan(ptr, n, step);
|
6479
5777
|
}
|
6480
5778
|
|
6481
|
-
/*
|
6482
|
-
sort of self.
|
6483
|
-
@overload sort(axis:nil, nan:false)
|
6484
|
-
@param [TrueClass] nan If true, propagete NaN. If false, ignore NaN.
|
6485
|
-
@param [Numeric,Array,Range] axis Performs sort along the axis.
|
6486
|
-
@return [Numo::SFloat] returns result of sort.
|
6487
|
-
@example
|
6488
|
-
Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
|
6489
|
-
*/
|
6490
5779
|
static VALUE sfloat_sort(int argc, VALUE* argv, VALUE self) {
|
6491
5780
|
VALUE reduce;
|
6492
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_reduce, 0}};
|
6493
|
-
ndfunc_t ndf = {0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 0, ain, 0};
|
5781
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
|
5782
|
+
ndfunc_t ndf = { 0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 0, ain, 0 };
|
6494
5783
|
|
6495
5784
|
if (!TEST_INPLACE(self)) {
|
6496
5785
|
self = na_copy(self);
|
@@ -6595,7 +5884,8 @@ loop:
|
|
6595
5884
|
pm = med3(pl, pm, pn, cmp);
|
6596
5885
|
}
|
6597
5886
|
swap(a, pm);
|
6598
|
-
for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc;
|
5887
|
+
for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc;
|
5888
|
+
pb += es, pc -= es) {
|
6599
5889
|
while (pb <= pc && (r = cmp(pb, a)) <= 0) {
|
6600
5890
|
if (r == 0) {
|
6601
5891
|
swap(pa, pb);
|
@@ -6720,7 +6010,8 @@ loop:
|
|
6720
6010
|
pm = med3(pl, pm, pn, cmp);
|
6721
6011
|
}
|
6722
6012
|
swap(a, pm);
|
6723
|
-
for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc;
|
6013
|
+
for (pa = pb = (char*)a + es, pc = pd = (char*)a + (n - 1) * es; pb <= pc;
|
6014
|
+
pb += es, pc -= es) {
|
6724
6015
|
while (pb <= pc && (r = cmp(pb, a)) <= 0) {
|
6725
6016
|
if (r == 0) {
|
6726
6017
|
swap(pa, pb);
|
@@ -6767,7 +6058,6 @@ static void sfloat_index64_qsort_ignan(na_loop_t* const lp) {
|
|
6767
6058
|
|
6768
6059
|
ptr = (char**)(lp->opt_ptr);
|
6769
6060
|
|
6770
|
-
// printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
|
6771
6061
|
// o_ptr=%lx,o_step=%ld)\n",(size_t)ptr,(size_t)d_ptr,(ssize_t)d_step,(size_t)i_ptr,(ssize_t)i_step,(size_t)o_ptr,(ssize_t)o_step);
|
6772
6062
|
|
6773
6063
|
if (n == 1) {
|
@@ -6777,21 +6067,17 @@ static void sfloat_index64_qsort_ignan(na_loop_t* const lp) {
|
|
6777
6067
|
|
6778
6068
|
for (i = 0; i < n; i++) {
|
6779
6069
|
ptr[i] = d_ptr + d_step * i;
|
6780
|
-
// printf("(%ld,%.3f)",i,*(double*)ptr[i]);
|
6781
6070
|
}
|
6782
6071
|
|
6783
6072
|
sfloat_index_qsort_ignan(ptr, n, sizeof(dtype*));
|
6784
6073
|
|
6785
6074
|
// d_ptr = lp->args[0].ptr;
|
6786
|
-
// printf("(d_ptr=%lx)\n",(size_t)d_ptr);
|
6787
6075
|
|
6788
6076
|
for (i = 0; i < n; i++) {
|
6789
6077
|
idx = (ptr[i] - d_ptr) / d_step;
|
6790
6078
|
*(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
|
6791
|
-
// printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
|
6792
6079
|
o_ptr += o_step;
|
6793
6080
|
}
|
6794
|
-
// printf("\n");
|
6795
6081
|
}
|
6796
6082
|
#undef idx_t
|
6797
6083
|
|
@@ -6809,7 +6095,6 @@ static void sfloat_index32_qsort_ignan(na_loop_t* const lp) {
|
|
6809
6095
|
|
6810
6096
|
ptr = (char**)(lp->opt_ptr);
|
6811
6097
|
|
6812
|
-
// printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
|
6813
6098
|
// o_ptr=%lx,o_step=%ld)\n",(size_t)ptr,(size_t)d_ptr,(ssize_t)d_step,(size_t)i_ptr,(ssize_t)i_step,(size_t)o_ptr,(ssize_t)o_step);
|
6814
6099
|
|
6815
6100
|
if (n == 1) {
|
@@ -6819,21 +6104,17 @@ static void sfloat_index32_qsort_ignan(na_loop_t* const lp) {
|
|
6819
6104
|
|
6820
6105
|
for (i = 0; i < n; i++) {
|
6821
6106
|
ptr[i] = d_ptr + d_step * i;
|
6822
|
-
// printf("(%ld,%.3f)",i,*(double*)ptr[i]);
|
6823
6107
|
}
|
6824
6108
|
|
6825
6109
|
sfloat_index_qsort_ignan(ptr, n, sizeof(dtype*));
|
6826
6110
|
|
6827
6111
|
// d_ptr = lp->args[0].ptr;
|
6828
|
-
// printf("(d_ptr=%lx)\n",(size_t)d_ptr);
|
6829
6112
|
|
6830
6113
|
for (i = 0; i < n; i++) {
|
6831
6114
|
idx = (ptr[i] - d_ptr) / d_step;
|
6832
6115
|
*(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
|
6833
|
-
// printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
|
6834
6116
|
o_ptr += o_step;
|
6835
6117
|
}
|
6836
|
-
// printf("\n");
|
6837
6118
|
}
|
6838
6119
|
#undef idx_t
|
6839
6120
|
|
@@ -6851,7 +6132,6 @@ static void sfloat_index64_qsort_prnan(na_loop_t* const lp) {
|
|
6851
6132
|
|
6852
6133
|
ptr = (char**)(lp->opt_ptr);
|
6853
6134
|
|
6854
|
-
// printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
|
6855
6135
|
// o_ptr=%lx,o_step=%ld)\n",(size_t)ptr,(size_t)d_ptr,(ssize_t)d_step,(size_t)i_ptr,(ssize_t)i_step,(size_t)o_ptr,(ssize_t)o_step);
|
6856
6136
|
|
6857
6137
|
if (n == 1) {
|
@@ -6861,21 +6141,17 @@ static void sfloat_index64_qsort_prnan(na_loop_t* const lp) {
|
|
6861
6141
|
|
6862
6142
|
for (i = 0; i < n; i++) {
|
6863
6143
|
ptr[i] = d_ptr + d_step * i;
|
6864
|
-
// printf("(%ld,%.3f)",i,*(double*)ptr[i]);
|
6865
6144
|
}
|
6866
6145
|
|
6867
6146
|
sfloat_index_qsort_prnan(ptr, n, sizeof(dtype*));
|
6868
6147
|
|
6869
6148
|
// d_ptr = lp->args[0].ptr;
|
6870
|
-
// printf("(d_ptr=%lx)\n",(size_t)d_ptr);
|
6871
6149
|
|
6872
6150
|
for (i = 0; i < n; i++) {
|
6873
6151
|
idx = (ptr[i] - d_ptr) / d_step;
|
6874
6152
|
*(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
|
6875
|
-
// printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
|
6876
6153
|
o_ptr += o_step;
|
6877
6154
|
}
|
6878
|
-
// printf("\n");
|
6879
6155
|
}
|
6880
6156
|
#undef idx_t
|
6881
6157
|
|
@@ -6893,7 +6169,6 @@ static void sfloat_index32_qsort_prnan(na_loop_t* const lp) {
|
|
6893
6169
|
|
6894
6170
|
ptr = (char**)(lp->opt_ptr);
|
6895
6171
|
|
6896
|
-
// printf("(ptr=%lx, d_ptr=%lx,d_step=%ld, i_ptr=%lx,i_step=%ld,
|
6897
6172
|
// o_ptr=%lx,o_step=%ld)\n",(size_t)ptr,(size_t)d_ptr,(ssize_t)d_step,(size_t)i_ptr,(ssize_t)i_step,(size_t)o_ptr,(ssize_t)o_step);
|
6898
6173
|
|
6899
6174
|
if (n == 1) {
|
@@ -6903,41 +6178,28 @@ static void sfloat_index32_qsort_prnan(na_loop_t* const lp) {
|
|
6903
6178
|
|
6904
6179
|
for (i = 0; i < n; i++) {
|
6905
6180
|
ptr[i] = d_ptr + d_step * i;
|
6906
|
-
// printf("(%ld,%.3f)",i,*(double*)ptr[i]);
|
6907
6181
|
}
|
6908
6182
|
|
6909
6183
|
sfloat_index_qsort_prnan(ptr, n, sizeof(dtype*));
|
6910
6184
|
|
6911
6185
|
// d_ptr = lp->args[0].ptr;
|
6912
|
-
// printf("(d_ptr=%lx)\n",(size_t)d_ptr);
|
6913
6186
|
|
6914
6187
|
for (i = 0; i < n; i++) {
|
6915
6188
|
idx = (ptr[i] - d_ptr) / d_step;
|
6916
6189
|
*(idx_t*)o_ptr = *(idx_t*)(i_ptr + i_step * idx);
|
6917
|
-
// printf("(idx[%ld]=%ld,%d)",i,idx,*(idx_t*)o_ptr);
|
6918
6190
|
o_ptr += o_step;
|
6919
6191
|
}
|
6920
|
-
// printf("\n");
|
6921
6192
|
}
|
6922
6193
|
#undef idx_t
|
6923
6194
|
|
6924
|
-
/*
|
6925
|
-
sort_index. Returns an index array of sort result.
|
6926
|
-
@overload sort_index(axis:nil, nan:false)
|
6927
|
-
@param [TrueClass] nan If true, propagete NaN. If false, ignore NaN.
|
6928
|
-
@param [Numeric,Array,Range] axis Performs sort_index along the axis.
|
6929
|
-
@return [Integer,Numo::Int] returns result index of sort_index.
|
6930
|
-
@example
|
6931
|
-
Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
|
6932
|
-
*/
|
6933
6195
|
static VALUE sfloat_sort_index(int argc, VALUE* argv, VALUE self) {
|
6934
6196
|
size_t size;
|
6935
6197
|
narray_t* na;
|
6936
6198
|
VALUE idx, tmp, reduce, res;
|
6937
6199
|
char* buf;
|
6938
|
-
ndfunc_arg_in_t ain[3] = {{cT, 0}, {0, 0}, {sym_reduce, 0}};
|
6939
|
-
ndfunc_arg_out_t aout[1] = {{0, 0, 0}};
|
6940
|
-
ndfunc_t ndf = {0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_CUM, 3, 1, ain, aout};
|
6200
|
+
ndfunc_arg_in_t ain[3] = { { cT, 0 }, { 0, 0 }, { sym_reduce, 0 } };
|
6201
|
+
ndfunc_arg_out_t aout[1] = { { 0, 0, 0 } };
|
6202
|
+
ndfunc_t ndf = { 0, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE | NDF_CUM, 3, 1, ain, aout };
|
6941
6203
|
|
6942
6204
|
GetNArray(self, na);
|
6943
6205
|
if (na->ndim == 0) {
|
@@ -7015,20 +6277,11 @@ static void iter_sfloat_median_prnan(na_loop_t* const lp) {
|
|
7015
6277
|
}
|
7016
6278
|
}
|
7017
6279
|
|
7018
|
-
/*
|
7019
|
-
median of self.
|
7020
|
-
@overload median(axis:nil, keepdims:false, nan:false)
|
7021
|
-
@param [TrueClass] nan (keyword) If true, propagete NaN. If false, ignore NaN.
|
7022
|
-
@param [Numeric,Array,Range] axis Finds median along the axis.
|
7023
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
7024
|
-
@return [Numo::SFloat] returns median of self.
|
7025
|
-
*/
|
7026
|
-
|
7027
6280
|
static VALUE sfloat_median(int argc, VALUE* argv, VALUE self) {
|
7028
6281
|
VALUE v, reduce;
|
7029
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_reduce, 0}};
|
7030
|
-
ndfunc_arg_out_t aout[1] = {{INT2FIX(0), 0}};
|
7031
|
-
ndfunc_t ndf = {0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
6282
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_reduce, 0 } };
|
6283
|
+
ndfunc_arg_out_t aout[1] = { { INT2FIX(0), 0 } };
|
6284
|
+
ndfunc_t ndf = { 0, NDF_HAS_LOOP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
7032
6285
|
|
7033
6286
|
self = na_copy(self); // as temporary buffer
|
7034
6287
|
|
@@ -7039,10 +6292,6 @@ static VALUE sfloat_median(int argc, VALUE* argv, VALUE self) {
|
|
7039
6292
|
return sfloat_extract(v);
|
7040
6293
|
}
|
7041
6294
|
|
7042
|
-
/*
|
7043
|
-
module definition: Numo::SFloat::NMath
|
7044
|
-
*/
|
7045
|
-
|
7046
6295
|
VALUE mTM;
|
7047
6296
|
|
7048
6297
|
static void iter_sfloat_math_s_sqrt(na_loop_t* const lp) {
|
@@ -7093,9 +6342,12 @@ static void iter_sfloat_math_s_sqrt(na_loop_t* const lp) {
|
|
7093
6342
|
#ifdef __SSE2__
|
7094
6343
|
//
|
7095
6344
|
// Check number of elements. & Check same alignment.
|
7096
|
-
if ((n >= num_pack) &&
|
6345
|
+
if ((n >= num_pack) &&
|
6346
|
+
is_same_aligned2(&((dtype*)p1)[i], &((dtype*)p2)[i], SIMD_ALIGNMENT_SIZE)) {
|
7097
6347
|
// Calculate up to the position just before the start of SIMD computation.
|
7098
|
-
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
6348
|
+
cnt = get_count_of_elements_not_aligned_to_simd_size(
|
6349
|
+
&((dtype*)p1)[i], SIMD_ALIGNMENT_SIZE, sizeof(dtype)
|
6350
|
+
);
|
7099
6351
|
#endif
|
7100
6352
|
#ifdef __SSE2__
|
7101
6353
|
for (i = 0; i < cnt; i++) {
|
@@ -7157,16 +6409,10 @@ static void iter_sfloat_math_s_sqrt(na_loop_t* const lp) {
|
|
7157
6409
|
}
|
7158
6410
|
}
|
7159
6411
|
|
7160
|
-
/*
|
7161
|
-
Calculate sqrt(x).
|
7162
|
-
@overload sqrt(x)
|
7163
|
-
@param [Numo::NArray,Numeric] x input value
|
7164
|
-
@return [Numo::SFloat] result of sqrt(x).
|
7165
|
-
*/
|
7166
6412
|
static VALUE sfloat_math_s_sqrt(VALUE mod, VALUE a1) {
|
7167
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
7168
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
7169
|
-
ndfunc_t ndf = {iter_sfloat_math_s_sqrt, FULL_LOOP, 1, 1, ain, aout};
|
6413
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
6414
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
6415
|
+
ndfunc_t ndf = { iter_sfloat_math_s_sqrt, FULL_LOOP, 1, 1, ain, aout };
|
7170
6416
|
|
7171
6417
|
return na_ndloop(&ndf, 1, a1);
|
7172
6418
|
}
|
@@ -7235,16 +6481,10 @@ static void iter_sfloat_math_s_cbrt(na_loop_t* const lp) {
|
|
7235
6481
|
}
|
7236
6482
|
}
|
7237
6483
|
|
7238
|
-
/*
|
7239
|
-
Calculate cbrt(x).
|
7240
|
-
@overload cbrt(x)
|
7241
|
-
@param [Numo::NArray,Numeric] x input value
|
7242
|
-
@return [Numo::SFloat] result of cbrt(x).
|
7243
|
-
*/
|
7244
6484
|
static VALUE sfloat_math_s_cbrt(VALUE mod, VALUE a1) {
|
7245
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
7246
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
7247
|
-
ndfunc_t ndf = {iter_sfloat_math_s_cbrt, FULL_LOOP, 1, 1, ain, aout};
|
6485
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
6486
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
6487
|
+
ndfunc_t ndf = { iter_sfloat_math_s_cbrt, FULL_LOOP, 1, 1, ain, aout };
|
7248
6488
|
|
7249
6489
|
return na_ndloop(&ndf, 1, a1);
|
7250
6490
|
}
|
@@ -7313,16 +6553,10 @@ static void iter_sfloat_math_s_log(na_loop_t* const lp) {
|
|
7313
6553
|
}
|
7314
6554
|
}
|
7315
6555
|
|
7316
|
-
/*
|
7317
|
-
Calculate log(x).
|
7318
|
-
@overload log(x)
|
7319
|
-
@param [Numo::NArray,Numeric] x input value
|
7320
|
-
@return [Numo::SFloat] result of log(x).
|
7321
|
-
*/
|
7322
6556
|
static VALUE sfloat_math_s_log(VALUE mod, VALUE a1) {
|
7323
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
7324
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
7325
|
-
ndfunc_t ndf = {iter_sfloat_math_s_log, FULL_LOOP, 1, 1, ain, aout};
|
6557
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
6558
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
6559
|
+
ndfunc_t ndf = { iter_sfloat_math_s_log, FULL_LOOP, 1, 1, ain, aout };
|
7326
6560
|
|
7327
6561
|
return na_ndloop(&ndf, 1, a1);
|
7328
6562
|
}
|
@@ -7391,16 +6625,10 @@ static void iter_sfloat_math_s_log2(na_loop_t* const lp) {
|
|
7391
6625
|
}
|
7392
6626
|
}
|
7393
6627
|
|
7394
|
-
/*
|
7395
|
-
Calculate log2(x).
|
7396
|
-
@overload log2(x)
|
7397
|
-
@param [Numo::NArray,Numeric] x input value
|
7398
|
-
@return [Numo::SFloat] result of log2(x).
|
7399
|
-
*/
|
7400
6628
|
static VALUE sfloat_math_s_log2(VALUE mod, VALUE a1) {
|
7401
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
7402
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
7403
|
-
ndfunc_t ndf = {iter_sfloat_math_s_log2, FULL_LOOP, 1, 1, ain, aout};
|
6629
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
6630
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
6631
|
+
ndfunc_t ndf = { iter_sfloat_math_s_log2, FULL_LOOP, 1, 1, ain, aout };
|
7404
6632
|
|
7405
6633
|
return na_ndloop(&ndf, 1, a1);
|
7406
6634
|
}
|
@@ -7469,16 +6697,10 @@ static void iter_sfloat_math_s_log10(na_loop_t* const lp) {
|
|
7469
6697
|
}
|
7470
6698
|
}
|
7471
6699
|
|
7472
|
-
/*
|
7473
|
-
Calculate log10(x).
|
7474
|
-
@overload log10(x)
|
7475
|
-
@param [Numo::NArray,Numeric] x input value
|
7476
|
-
@return [Numo::SFloat] result of log10(x).
|
7477
|
-
*/
|
7478
6700
|
static VALUE sfloat_math_s_log10(VALUE mod, VALUE a1) {
|
7479
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
7480
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
7481
|
-
ndfunc_t ndf = {iter_sfloat_math_s_log10, FULL_LOOP, 1, 1, ain, aout};
|
6701
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
6702
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
6703
|
+
ndfunc_t ndf = { iter_sfloat_math_s_log10, FULL_LOOP, 1, 1, ain, aout };
|
7482
6704
|
|
7483
6705
|
return na_ndloop(&ndf, 1, a1);
|
7484
6706
|
}
|
@@ -7547,16 +6769,10 @@ static void iter_sfloat_math_s_exp(na_loop_t* const lp) {
|
|
7547
6769
|
}
|
7548
6770
|
}
|
7549
6771
|
|
7550
|
-
/*
|
7551
|
-
Calculate exp(x).
|
7552
|
-
@overload exp(x)
|
7553
|
-
@param [Numo::NArray,Numeric] x input value
|
7554
|
-
@return [Numo::SFloat] result of exp(x).
|
7555
|
-
*/
|
7556
6772
|
static VALUE sfloat_math_s_exp(VALUE mod, VALUE a1) {
|
7557
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
7558
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
7559
|
-
ndfunc_t ndf = {iter_sfloat_math_s_exp, FULL_LOOP, 1, 1, ain, aout};
|
6773
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
6774
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
6775
|
+
ndfunc_t ndf = { iter_sfloat_math_s_exp, FULL_LOOP, 1, 1, ain, aout };
|
7560
6776
|
|
7561
6777
|
return na_ndloop(&ndf, 1, a1);
|
7562
6778
|
}
|
@@ -7625,16 +6841,10 @@ static void iter_sfloat_math_s_exp2(na_loop_t* const lp) {
|
|
7625
6841
|
}
|
7626
6842
|
}
|
7627
6843
|
|
7628
|
-
/*
|
7629
|
-
Calculate exp2(x).
|
7630
|
-
@overload exp2(x)
|
7631
|
-
@param [Numo::NArray,Numeric] x input value
|
7632
|
-
@return [Numo::SFloat] result of exp2(x).
|
7633
|
-
*/
|
7634
6844
|
static VALUE sfloat_math_s_exp2(VALUE mod, VALUE a1) {
|
7635
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
7636
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
7637
|
-
ndfunc_t ndf = {iter_sfloat_math_s_exp2, FULL_LOOP, 1, 1, ain, aout};
|
6845
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
6846
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
6847
|
+
ndfunc_t ndf = { iter_sfloat_math_s_exp2, FULL_LOOP, 1, 1, ain, aout };
|
7638
6848
|
|
7639
6849
|
return na_ndloop(&ndf, 1, a1);
|
7640
6850
|
}
|
@@ -7703,16 +6913,10 @@ static void iter_sfloat_math_s_exp10(na_loop_t* const lp) {
|
|
7703
6913
|
}
|
7704
6914
|
}
|
7705
6915
|
|
7706
|
-
/*
|
7707
|
-
Calculate exp10(x).
|
7708
|
-
@overload exp10(x)
|
7709
|
-
@param [Numo::NArray,Numeric] x input value
|
7710
|
-
@return [Numo::SFloat] result of exp10(x).
|
7711
|
-
*/
|
7712
6916
|
static VALUE sfloat_math_s_exp10(VALUE mod, VALUE a1) {
|
7713
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
7714
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
7715
|
-
ndfunc_t ndf = {iter_sfloat_math_s_exp10, FULL_LOOP, 1, 1, ain, aout};
|
6917
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
6918
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
6919
|
+
ndfunc_t ndf = { iter_sfloat_math_s_exp10, FULL_LOOP, 1, 1, ain, aout };
|
7716
6920
|
|
7717
6921
|
return na_ndloop(&ndf, 1, a1);
|
7718
6922
|
}
|
@@ -7781,16 +6985,10 @@ static void iter_sfloat_math_s_sin(na_loop_t* const lp) {
|
|
7781
6985
|
}
|
7782
6986
|
}
|
7783
6987
|
|
7784
|
-
/*
|
7785
|
-
Calculate sin(x).
|
7786
|
-
@overload sin(x)
|
7787
|
-
@param [Numo::NArray,Numeric] x input value
|
7788
|
-
@return [Numo::SFloat] result of sin(x).
|
7789
|
-
*/
|
7790
6988
|
static VALUE sfloat_math_s_sin(VALUE mod, VALUE a1) {
|
7791
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
7792
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
7793
|
-
ndfunc_t ndf = {iter_sfloat_math_s_sin, FULL_LOOP, 1, 1, ain, aout};
|
6989
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
6990
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
6991
|
+
ndfunc_t ndf = { iter_sfloat_math_s_sin, FULL_LOOP, 1, 1, ain, aout };
|
7794
6992
|
|
7795
6993
|
return na_ndloop(&ndf, 1, a1);
|
7796
6994
|
}
|
@@ -7859,16 +7057,10 @@ static void iter_sfloat_math_s_cos(na_loop_t* const lp) {
|
|
7859
7057
|
}
|
7860
7058
|
}
|
7861
7059
|
|
7862
|
-
/*
|
7863
|
-
Calculate cos(x).
|
7864
|
-
@overload cos(x)
|
7865
|
-
@param [Numo::NArray,Numeric] x input value
|
7866
|
-
@return [Numo::SFloat] result of cos(x).
|
7867
|
-
*/
|
7868
7060
|
static VALUE sfloat_math_s_cos(VALUE mod, VALUE a1) {
|
7869
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
7870
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
7871
|
-
ndfunc_t ndf = {iter_sfloat_math_s_cos, FULL_LOOP, 1, 1, ain, aout};
|
7061
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7062
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7063
|
+
ndfunc_t ndf = { iter_sfloat_math_s_cos, FULL_LOOP, 1, 1, ain, aout };
|
7872
7064
|
|
7873
7065
|
return na_ndloop(&ndf, 1, a1);
|
7874
7066
|
}
|
@@ -7937,16 +7129,10 @@ static void iter_sfloat_math_s_tan(na_loop_t* const lp) {
|
|
7937
7129
|
}
|
7938
7130
|
}
|
7939
7131
|
|
7940
|
-
/*
|
7941
|
-
Calculate tan(x).
|
7942
|
-
@overload tan(x)
|
7943
|
-
@param [Numo::NArray,Numeric] x input value
|
7944
|
-
@return [Numo::SFloat] result of tan(x).
|
7945
|
-
*/
|
7946
7132
|
static VALUE sfloat_math_s_tan(VALUE mod, VALUE a1) {
|
7947
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
7948
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
7949
|
-
ndfunc_t ndf = {iter_sfloat_math_s_tan, FULL_LOOP, 1, 1, ain, aout};
|
7133
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7134
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7135
|
+
ndfunc_t ndf = { iter_sfloat_math_s_tan, FULL_LOOP, 1, 1, ain, aout };
|
7950
7136
|
|
7951
7137
|
return na_ndloop(&ndf, 1, a1);
|
7952
7138
|
}
|
@@ -8015,16 +7201,10 @@ static void iter_sfloat_math_s_asin(na_loop_t* const lp) {
|
|
8015
7201
|
}
|
8016
7202
|
}
|
8017
7203
|
|
8018
|
-
/*
|
8019
|
-
Calculate asin(x).
|
8020
|
-
@overload asin(x)
|
8021
|
-
@param [Numo::NArray,Numeric] x input value
|
8022
|
-
@return [Numo::SFloat] result of asin(x).
|
8023
|
-
*/
|
8024
7204
|
static VALUE sfloat_math_s_asin(VALUE mod, VALUE a1) {
|
8025
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
8026
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
8027
|
-
ndfunc_t ndf = {iter_sfloat_math_s_asin, FULL_LOOP, 1, 1, ain, aout};
|
7205
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7206
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7207
|
+
ndfunc_t ndf = { iter_sfloat_math_s_asin, FULL_LOOP, 1, 1, ain, aout };
|
8028
7208
|
|
8029
7209
|
return na_ndloop(&ndf, 1, a1);
|
8030
7210
|
}
|
@@ -8093,16 +7273,10 @@ static void iter_sfloat_math_s_acos(na_loop_t* const lp) {
|
|
8093
7273
|
}
|
8094
7274
|
}
|
8095
7275
|
|
8096
|
-
/*
|
8097
|
-
Calculate acos(x).
|
8098
|
-
@overload acos(x)
|
8099
|
-
@param [Numo::NArray,Numeric] x input value
|
8100
|
-
@return [Numo::SFloat] result of acos(x).
|
8101
|
-
*/
|
8102
7276
|
static VALUE sfloat_math_s_acos(VALUE mod, VALUE a1) {
|
8103
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
8104
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
8105
|
-
ndfunc_t ndf = {iter_sfloat_math_s_acos, FULL_LOOP, 1, 1, ain, aout};
|
7277
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7278
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7279
|
+
ndfunc_t ndf = { iter_sfloat_math_s_acos, FULL_LOOP, 1, 1, ain, aout };
|
8106
7280
|
|
8107
7281
|
return na_ndloop(&ndf, 1, a1);
|
8108
7282
|
}
|
@@ -8171,16 +7345,10 @@ static void iter_sfloat_math_s_atan(na_loop_t* const lp) {
|
|
8171
7345
|
}
|
8172
7346
|
}
|
8173
7347
|
|
8174
|
-
/*
|
8175
|
-
Calculate atan(x).
|
8176
|
-
@overload atan(x)
|
8177
|
-
@param [Numo::NArray,Numeric] x input value
|
8178
|
-
@return [Numo::SFloat] result of atan(x).
|
8179
|
-
*/
|
8180
7348
|
static VALUE sfloat_math_s_atan(VALUE mod, VALUE a1) {
|
8181
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
8182
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
8183
|
-
ndfunc_t ndf = {iter_sfloat_math_s_atan, FULL_LOOP, 1, 1, ain, aout};
|
7349
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7350
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7351
|
+
ndfunc_t ndf = { iter_sfloat_math_s_atan, FULL_LOOP, 1, 1, ain, aout };
|
8184
7352
|
|
8185
7353
|
return na_ndloop(&ndf, 1, a1);
|
8186
7354
|
}
|
@@ -8249,16 +7417,10 @@ static void iter_sfloat_math_s_sinh(na_loop_t* const lp) {
|
|
8249
7417
|
}
|
8250
7418
|
}
|
8251
7419
|
|
8252
|
-
/*
|
8253
|
-
Calculate sinh(x).
|
8254
|
-
@overload sinh(x)
|
8255
|
-
@param [Numo::NArray,Numeric] x input value
|
8256
|
-
@return [Numo::SFloat] result of sinh(x).
|
8257
|
-
*/
|
8258
7420
|
static VALUE sfloat_math_s_sinh(VALUE mod, VALUE a1) {
|
8259
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
8260
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
8261
|
-
ndfunc_t ndf = {iter_sfloat_math_s_sinh, FULL_LOOP, 1, 1, ain, aout};
|
7421
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7422
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7423
|
+
ndfunc_t ndf = { iter_sfloat_math_s_sinh, FULL_LOOP, 1, 1, ain, aout };
|
8262
7424
|
|
8263
7425
|
return na_ndloop(&ndf, 1, a1);
|
8264
7426
|
}
|
@@ -8327,16 +7489,10 @@ static void iter_sfloat_math_s_cosh(na_loop_t* const lp) {
|
|
8327
7489
|
}
|
8328
7490
|
}
|
8329
7491
|
|
8330
|
-
/*
|
8331
|
-
Calculate cosh(x).
|
8332
|
-
@overload cosh(x)
|
8333
|
-
@param [Numo::NArray,Numeric] x input value
|
8334
|
-
@return [Numo::SFloat] result of cosh(x).
|
8335
|
-
*/
|
8336
7492
|
static VALUE sfloat_math_s_cosh(VALUE mod, VALUE a1) {
|
8337
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
8338
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
8339
|
-
ndfunc_t ndf = {iter_sfloat_math_s_cosh, FULL_LOOP, 1, 1, ain, aout};
|
7493
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7494
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7495
|
+
ndfunc_t ndf = { iter_sfloat_math_s_cosh, FULL_LOOP, 1, 1, ain, aout };
|
8340
7496
|
|
8341
7497
|
return na_ndloop(&ndf, 1, a1);
|
8342
7498
|
}
|
@@ -8405,16 +7561,10 @@ static void iter_sfloat_math_s_tanh(na_loop_t* const lp) {
|
|
8405
7561
|
}
|
8406
7562
|
}
|
8407
7563
|
|
8408
|
-
/*
|
8409
|
-
Calculate tanh(x).
|
8410
|
-
@overload tanh(x)
|
8411
|
-
@param [Numo::NArray,Numeric] x input value
|
8412
|
-
@return [Numo::SFloat] result of tanh(x).
|
8413
|
-
*/
|
8414
7564
|
static VALUE sfloat_math_s_tanh(VALUE mod, VALUE a1) {
|
8415
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
8416
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
8417
|
-
ndfunc_t ndf = {iter_sfloat_math_s_tanh, FULL_LOOP, 1, 1, ain, aout};
|
7565
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7566
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7567
|
+
ndfunc_t ndf = { iter_sfloat_math_s_tanh, FULL_LOOP, 1, 1, ain, aout };
|
8418
7568
|
|
8419
7569
|
return na_ndloop(&ndf, 1, a1);
|
8420
7570
|
}
|
@@ -8483,16 +7633,10 @@ static void iter_sfloat_math_s_asinh(na_loop_t* const lp) {
|
|
8483
7633
|
}
|
8484
7634
|
}
|
8485
7635
|
|
8486
|
-
/*
|
8487
|
-
Calculate asinh(x).
|
8488
|
-
@overload asinh(x)
|
8489
|
-
@param [Numo::NArray,Numeric] x input value
|
8490
|
-
@return [Numo::SFloat] result of asinh(x).
|
8491
|
-
*/
|
8492
7636
|
static VALUE sfloat_math_s_asinh(VALUE mod, VALUE a1) {
|
8493
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
8494
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
8495
|
-
ndfunc_t ndf = {iter_sfloat_math_s_asinh, FULL_LOOP, 1, 1, ain, aout};
|
7637
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7638
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7639
|
+
ndfunc_t ndf = { iter_sfloat_math_s_asinh, FULL_LOOP, 1, 1, ain, aout };
|
8496
7640
|
|
8497
7641
|
return na_ndloop(&ndf, 1, a1);
|
8498
7642
|
}
|
@@ -8561,16 +7705,10 @@ static void iter_sfloat_math_s_acosh(na_loop_t* const lp) {
|
|
8561
7705
|
}
|
8562
7706
|
}
|
8563
7707
|
|
8564
|
-
/*
|
8565
|
-
Calculate acosh(x).
|
8566
|
-
@overload acosh(x)
|
8567
|
-
@param [Numo::NArray,Numeric] x input value
|
8568
|
-
@return [Numo::SFloat] result of acosh(x).
|
8569
|
-
*/
|
8570
7708
|
static VALUE sfloat_math_s_acosh(VALUE mod, VALUE a1) {
|
8571
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
8572
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
8573
|
-
ndfunc_t ndf = {iter_sfloat_math_s_acosh, FULL_LOOP, 1, 1, ain, aout};
|
7709
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7710
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7711
|
+
ndfunc_t ndf = { iter_sfloat_math_s_acosh, FULL_LOOP, 1, 1, ain, aout };
|
8574
7712
|
|
8575
7713
|
return na_ndloop(&ndf, 1, a1);
|
8576
7714
|
}
|
@@ -8639,16 +7777,10 @@ static void iter_sfloat_math_s_atanh(na_loop_t* const lp) {
|
|
8639
7777
|
}
|
8640
7778
|
}
|
8641
7779
|
|
8642
|
-
/*
|
8643
|
-
Calculate atanh(x).
|
8644
|
-
@overload atanh(x)
|
8645
|
-
@param [Numo::NArray,Numeric] x input value
|
8646
|
-
@return [Numo::SFloat] result of atanh(x).
|
8647
|
-
*/
|
8648
7780
|
static VALUE sfloat_math_s_atanh(VALUE mod, VALUE a1) {
|
8649
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
8650
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
8651
|
-
ndfunc_t ndf = {iter_sfloat_math_s_atanh, FULL_LOOP, 1, 1, ain, aout};
|
7781
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7782
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7783
|
+
ndfunc_t ndf = { iter_sfloat_math_s_atanh, FULL_LOOP, 1, 1, ain, aout };
|
8652
7784
|
|
8653
7785
|
return na_ndloop(&ndf, 1, a1);
|
8654
7786
|
}
|
@@ -8717,16 +7849,10 @@ static void iter_sfloat_math_s_sinc(na_loop_t* const lp) {
|
|
8717
7849
|
}
|
8718
7850
|
}
|
8719
7851
|
|
8720
|
-
/*
|
8721
|
-
Calculate sinc(x).
|
8722
|
-
@overload sinc(x)
|
8723
|
-
@param [Numo::NArray,Numeric] x input value
|
8724
|
-
@return [Numo::SFloat] result of sinc(x).
|
8725
|
-
*/
|
8726
7852
|
static VALUE sfloat_math_s_sinc(VALUE mod, VALUE a1) {
|
8727
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
8728
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
8729
|
-
ndfunc_t ndf = {iter_sfloat_math_s_sinc, FULL_LOOP, 1, 1, ain, aout};
|
7853
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7854
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7855
|
+
ndfunc_t ndf = { iter_sfloat_math_s_sinc, FULL_LOOP, 1, 1, ain, aout };
|
8730
7856
|
|
8731
7857
|
return na_ndloop(&ndf, 1, a1);
|
8732
7858
|
}
|
@@ -8748,17 +7874,10 @@ static void iter_sfloat_math_s_atan2(na_loop_t* const lp) {
|
|
8748
7874
|
}
|
8749
7875
|
}
|
8750
7876
|
|
8751
|
-
/*
|
8752
|
-
Calculate atan2(a1,a2).
|
8753
|
-
@overload atan2(a1,a2)
|
8754
|
-
@param [Numo::NArray,Numeric] a1 first value
|
8755
|
-
@param [Numo::NArray,Numeric] a2 second value
|
8756
|
-
@return [Numo::SFloat] atan2(a1,a2).
|
8757
|
-
*/
|
8758
7877
|
static VALUE sfloat_math_s_atan2(VALUE mod, VALUE a1, VALUE a2) {
|
8759
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
8760
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
8761
|
-
ndfunc_t ndf = {iter_sfloat_math_s_atan2, STRIDE_LOOP, 2, 1, ain, aout};
|
7878
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
7879
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7880
|
+
ndfunc_t ndf = { iter_sfloat_math_s_atan2, STRIDE_LOOP, 2, 1, ain, aout };
|
8762
7881
|
return na_ndloop(&ndf, 2, a1, a2);
|
8763
7882
|
}
|
8764
7883
|
|
@@ -8779,17 +7898,10 @@ static void iter_sfloat_math_s_hypot(na_loop_t* const lp) {
|
|
8779
7898
|
}
|
8780
7899
|
}
|
8781
7900
|
|
8782
|
-
/*
|
8783
|
-
Calculate hypot(a1,a2).
|
8784
|
-
@overload hypot(a1,a2)
|
8785
|
-
@param [Numo::NArray,Numeric] a1 first value
|
8786
|
-
@param [Numo::NArray,Numeric] a2 second value
|
8787
|
-
@return [Numo::SFloat] hypot(a1,a2).
|
8788
|
-
*/
|
8789
7901
|
static VALUE sfloat_math_s_hypot(VALUE mod, VALUE a1, VALUE a2) {
|
8790
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
8791
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
8792
|
-
ndfunc_t ndf = {iter_sfloat_math_s_hypot, STRIDE_LOOP, 2, 1, ain, aout};
|
7902
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
7903
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7904
|
+
ndfunc_t ndf = { iter_sfloat_math_s_hypot, STRIDE_LOOP, 2, 1, ain, aout };
|
8793
7905
|
return na_ndloop(&ndf, 2, a1, a2);
|
8794
7906
|
}
|
8795
7907
|
|
@@ -8857,16 +7969,10 @@ static void iter_sfloat_math_s_erf(na_loop_t* const lp) {
|
|
8857
7969
|
}
|
8858
7970
|
}
|
8859
7971
|
|
8860
|
-
/*
|
8861
|
-
Calculate erf(x).
|
8862
|
-
@overload erf(x)
|
8863
|
-
@param [Numo::NArray,Numeric] x input value
|
8864
|
-
@return [Numo::SFloat] result of erf(x).
|
8865
|
-
*/
|
8866
7972
|
static VALUE sfloat_math_s_erf(VALUE mod, VALUE a1) {
|
8867
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
8868
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
8869
|
-
ndfunc_t ndf = {iter_sfloat_math_s_erf, FULL_LOOP, 1, 1, ain, aout};
|
7973
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
7974
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
7975
|
+
ndfunc_t ndf = { iter_sfloat_math_s_erf, FULL_LOOP, 1, 1, ain, aout };
|
8870
7976
|
|
8871
7977
|
return na_ndloop(&ndf, 1, a1);
|
8872
7978
|
}
|
@@ -8935,16 +8041,10 @@ static void iter_sfloat_math_s_erfc(na_loop_t* const lp) {
|
|
8935
8041
|
}
|
8936
8042
|
}
|
8937
8043
|
|
8938
|
-
/*
|
8939
|
-
Calculate erfc(x).
|
8940
|
-
@overload erfc(x)
|
8941
|
-
@param [Numo::NArray,Numeric] x input value
|
8942
|
-
@return [Numo::SFloat] result of erfc(x).
|
8943
|
-
*/
|
8944
8044
|
static VALUE sfloat_math_s_erfc(VALUE mod, VALUE a1) {
|
8945
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
8946
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
8947
|
-
ndfunc_t ndf = {iter_sfloat_math_s_erfc, FULL_LOOP, 1, 1, ain, aout};
|
8045
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8046
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
8047
|
+
ndfunc_t ndf = { iter_sfloat_math_s_erfc, FULL_LOOP, 1, 1, ain, aout };
|
8948
8048
|
|
8949
8049
|
return na_ndloop(&ndf, 1, a1);
|
8950
8050
|
}
|
@@ -9013,16 +8113,10 @@ static void iter_sfloat_math_s_log1p(na_loop_t* const lp) {
|
|
9013
8113
|
}
|
9014
8114
|
}
|
9015
8115
|
|
9016
|
-
/*
|
9017
|
-
Calculate log1p(x).
|
9018
|
-
@overload log1p(x)
|
9019
|
-
@param [Numo::NArray,Numeric] x input value
|
9020
|
-
@return [Numo::SFloat] result of log1p(x).
|
9021
|
-
*/
|
9022
8116
|
static VALUE sfloat_math_s_log1p(VALUE mod, VALUE a1) {
|
9023
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
9024
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
9025
|
-
ndfunc_t ndf = {iter_sfloat_math_s_log1p, FULL_LOOP, 1, 1, ain, aout};
|
8117
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8118
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
8119
|
+
ndfunc_t ndf = { iter_sfloat_math_s_log1p, FULL_LOOP, 1, 1, ain, aout };
|
9026
8120
|
|
9027
8121
|
return na_ndloop(&ndf, 1, a1);
|
9028
8122
|
}
|
@@ -9091,16 +8185,10 @@ static void iter_sfloat_math_s_expm1(na_loop_t* const lp) {
|
|
9091
8185
|
}
|
9092
8186
|
}
|
9093
8187
|
|
9094
|
-
/*
|
9095
|
-
Calculate expm1(x).
|
9096
|
-
@overload expm1(x)
|
9097
|
-
@param [Numo::NArray,Numeric] x input value
|
9098
|
-
@return [Numo::SFloat] result of expm1(x).
|
9099
|
-
*/
|
9100
8188
|
static VALUE sfloat_math_s_expm1(VALUE mod, VALUE a1) {
|
9101
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
9102
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
9103
|
-
ndfunc_t ndf = {iter_sfloat_math_s_expm1, FULL_LOOP, 1, 1, ain, aout};
|
8189
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8190
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
8191
|
+
ndfunc_t ndf = { iter_sfloat_math_s_expm1, FULL_LOOP, 1, 1, ain, aout };
|
9104
8192
|
|
9105
8193
|
return na_ndloop(&ndf, 1, a1);
|
9106
8194
|
}
|
@@ -9122,17 +8210,10 @@ static void iter_sfloat_math_s_ldexp(na_loop_t* const lp) {
|
|
9122
8210
|
}
|
9123
8211
|
}
|
9124
8212
|
|
9125
|
-
/*
|
9126
|
-
Calculate ldexp(a1,a2).
|
9127
|
-
@overload ldexp(a1,a2)
|
9128
|
-
@param [Numo::NArray,Numeric] a1 first value
|
9129
|
-
@param [Numo::NArray,Numeric] a2 second value
|
9130
|
-
@return [Numo::SFloat] ldexp(a1,a2).
|
9131
|
-
*/
|
9132
8213
|
static VALUE sfloat_math_s_ldexp(VALUE mod, VALUE a1, VALUE a2) {
|
9133
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
9134
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
9135
|
-
ndfunc_t ndf = {iter_sfloat_math_s_ldexp, STRIDE_LOOP, 2, 1, ain, aout};
|
8214
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
8215
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
8216
|
+
ndfunc_t ndf = { iter_sfloat_math_s_ldexp, STRIDE_LOOP, 2, 1, ain, aout };
|
9136
8217
|
return na_ndloop(&ndf, 2, a1, a2);
|
9137
8218
|
}
|
9138
8219
|
|
@@ -9154,19 +8235,10 @@ static void iter_sfloat_math_s_frexp(na_loop_t* const lp) {
|
|
9154
8235
|
}
|
9155
8236
|
}
|
9156
8237
|
|
9157
|
-
/*
|
9158
|
-
split the number x into a normalized fraction and an exponent.
|
9159
|
-
Returns [mantissa, exponent], where x = mantissa * 2**exponent.
|
9160
|
-
|
9161
|
-
@overload frexp(x)
|
9162
|
-
@param [Numo::NArray,Numeric] x
|
9163
|
-
@return [Numo::SFloat,Numo::Int32] mantissa and exponent.
|
9164
|
-
|
9165
|
-
*/
|
9166
8238
|
static VALUE sfloat_math_s_frexp(VALUE mod, VALUE a1) {
|
9167
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
9168
|
-
ndfunc_arg_out_t aout[2] = {{cT, 0}, {numo_cInt32, 0}};
|
9169
|
-
ndfunc_t ndf = {iter_sfloat_math_s_frexp, STRIDE_LOOP, 1, 2, ain, aout};
|
8239
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
8240
|
+
ndfunc_arg_out_t aout[2] = { { cT, 0 }, { numo_cInt32, 0 } };
|
8241
|
+
ndfunc_t ndf = { iter_sfloat_math_s_frexp, STRIDE_LOOP, 1, 2, ain, aout };
|
9170
8242
|
return na_ndloop(&ndf, 1, a1);
|
9171
8243
|
}
|
9172
8244
|
|
@@ -9190,16 +8262,18 @@ void Init_numo_sfloat(void) {
|
|
9190
8262
|
id_nearly_eq = rb_intern("nearly_eq");
|
9191
8263
|
id_to_a = rb_intern("to_a");
|
9192
8264
|
|
9193
|
-
|
9194
|
-
|
9195
|
-
|
9196
|
-
|
8265
|
+
/**
|
8266
|
+
* Document-class: Numo::SFloat
|
8267
|
+
*
|
8268
|
+
* Single precision floating point number (32-bit float) N-dimensional array class.
|
8269
|
+
*/
|
9197
8270
|
cT = rb_define_class_under(mNumo, "SFloat", cNArray);
|
9198
8271
|
|
9199
8272
|
// alias of SFloat
|
9200
8273
|
rb_define_const(mNumo, "Float32", numo_cSFloat);
|
9201
8274
|
|
9202
8275
|
hCast = rb_hash_new();
|
8276
|
+
/* Upcasting rules of SFloat. */
|
9203
8277
|
rb_define_const(cT, "UPCAST", hCast);
|
9204
8278
|
rb_hash_aset(hCast, rb_cArray, cT);
|
9205
8279
|
|
@@ -9226,147 +8300,995 @@ void Init_numo_sfloat(void) {
|
|
9226
8300
|
rb_hash_aset(hCast, numo_cUInt8, numo_cSFloat);
|
9227
8301
|
rb_obj_freeze(hCast);
|
9228
8302
|
|
9229
|
-
|
8303
|
+
/* Element size of SFloat in bits. */
|
9230
8304
|
rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
|
9231
|
-
|
8305
|
+
/* Element size of SFloat in bytes. */
|
9232
8306
|
rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
|
9233
|
-
|
8307
|
+
/* Stride size of contiguous SFloat array. */
|
9234
8308
|
rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
|
9235
|
-
|
8309
|
+
/* Machine epsilon of SFloat */
|
9236
8310
|
rb_define_const(cT, "EPSILON", M_EPSILON);
|
9237
|
-
|
8311
|
+
/* The largest respresentable value of SFloat */
|
9238
8312
|
rb_define_const(cT, "MAX", M_MAX);
|
9239
|
-
|
8313
|
+
/* The smallest respresentable value of SFloat */
|
9240
8314
|
rb_define_const(cT, "MIN", M_MIN);
|
9241
8315
|
rb_define_alloc_func(cT, sfloat_s_alloc_func);
|
9242
8316
|
rb_define_method(cT, "allocate", sfloat_allocate, 0);
|
8317
|
+
/**
|
8318
|
+
* Extract an element only if self is a dimensionless NArray.
|
8319
|
+
* @overload extract
|
8320
|
+
* @return [Numeric,Numo::NArray] Extract element value as Ruby Object
|
8321
|
+
* if self is a dimensionless NArray, otherwise returns self.
|
8322
|
+
*/
|
9243
8323
|
rb_define_method(cT, "extract", sfloat_extract, 0);
|
9244
|
-
|
8324
|
+
/**
|
8325
|
+
* Store elements to Numo::SFloat from other.
|
8326
|
+
* @overload store(other)
|
8327
|
+
* @param [Object] other
|
8328
|
+
* @return [Numo::SFloat] self
|
8329
|
+
*/
|
9245
8330
|
rb_define_method(cT, "store", sfloat_store, 1);
|
9246
|
-
|
8331
|
+
/**
|
8332
|
+
* Cast object to Numo::SFloat.
|
8333
|
+
* @overload cast(array)
|
8334
|
+
* @param [Numeric,Array] elements
|
8335
|
+
* @param [Array] array
|
8336
|
+
* @return [Numo::SFloat]
|
8337
|
+
*/
|
9247
8338
|
rb_define_singleton_method(cT, "cast", sfloat_s_cast, 1);
|
8339
|
+
/**
|
8340
|
+
* Cast object to Numo::SFloat.
|
8341
|
+
* @overload [](elements)
|
8342
|
+
* @param [Numeric,Array] elements
|
8343
|
+
* @param [Array] array
|
8344
|
+
* @return [Numo::SFloat]
|
8345
|
+
*/
|
8346
|
+
rb_define_singleton_method(cT, "[]", sfloat_s_cast, -2);
|
8347
|
+
/**
|
8348
|
+
* Multi-dimensional element reference.
|
8349
|
+
* @overload [](dim0,...,dimL)
|
8350
|
+
* @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,Boolean,Symbol]
|
8351
|
+
* dim0,...,dimL multi-dimensional indices.
|
8352
|
+
* @return [Numeric,Numo::SFloat] an element or NArray view.
|
8353
|
+
* @see Numo::NArray#[]
|
8354
|
+
* @see #[]=
|
8355
|
+
*/
|
9248
8356
|
rb_define_method(cT, "[]", sfloat_aref, -1);
|
8357
|
+
/**
|
8358
|
+
* Multi-dimensional element assignment.
|
8359
|
+
* @overload []=(dim0,...,dimL,val)
|
8360
|
+
* @param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,Boolean,Symbol]
|
8361
|
+
* dim0,...,dimL multi-dimensional indices.
|
8362
|
+
* @param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
|
8363
|
+
* @return [Numeric,Numo::NArray,Array] returns `val` (last argument).
|
8364
|
+
* @see Numo::NArray#[]=
|
8365
|
+
* @see #[]
|
8366
|
+
*/
|
9249
8367
|
rb_define_method(cT, "[]=", sfloat_aset, -1);
|
8368
|
+
/**
|
8369
|
+
* Return NArray with cast to the type of self.
|
8370
|
+
* @overload coerce_cast(type)
|
8371
|
+
* @return [nil]
|
8372
|
+
*/
|
9250
8373
|
rb_define_method(cT, "coerce_cast", sfloat_coerce_cast, 1);
|
8374
|
+
/**
|
8375
|
+
* Convert self to Array.
|
8376
|
+
* @overload to_a
|
8377
|
+
* @return [Array]
|
8378
|
+
*/
|
9251
8379
|
rb_define_method(cT, "to_a", sfloat_to_a, 0);
|
8380
|
+
/**
|
8381
|
+
* Fill elements with other.
|
8382
|
+
* @overload fill other
|
8383
|
+
* @param [Numeric] other
|
8384
|
+
* @return [Numo::SFloat] self.
|
8385
|
+
*/
|
9252
8386
|
rb_define_method(cT, "fill", sfloat_fill, 1);
|
8387
|
+
/**
|
8388
|
+
* Format elements into strings.
|
8389
|
+
* @overload format format
|
8390
|
+
* @param [String] format
|
8391
|
+
* @return [Numo::RObject] array of formatted strings.
|
8392
|
+
*/
|
9253
8393
|
rb_define_method(cT, "format", sfloat_format, -1);
|
8394
|
+
/**
|
8395
|
+
* Format elements into strings.
|
8396
|
+
* @overload format_to_a format
|
8397
|
+
* @param [String] format
|
8398
|
+
* @return [Array] array of formatted strings.
|
8399
|
+
*/
|
9254
8400
|
rb_define_method(cT, "format_to_a", sfloat_format_to_a, -1);
|
8401
|
+
/**
|
8402
|
+
* Returns a string containing a human-readable representation of NArray.
|
8403
|
+
* @overload inspect
|
8404
|
+
* @return [String]
|
8405
|
+
*/
|
9255
8406
|
rb_define_method(cT, "inspect", sfloat_inspect, 0);
|
8407
|
+
/**
|
8408
|
+
* Calls the given block once for each element in self, passing that element as a parameter.
|
8409
|
+
* For a block `{|x| ... }`,
|
8410
|
+
* @overload each
|
8411
|
+
* @return [Numo::NArray] self
|
8412
|
+
* @yieldparam [Numeric] x an element of NArray.
|
8413
|
+
* @see #each_with_index
|
8414
|
+
* @see #map
|
8415
|
+
*/
|
9256
8416
|
rb_define_method(cT, "each", sfloat_each, 0);
|
8417
|
+
/**
|
8418
|
+
* Unary map.
|
8419
|
+
* @overload map
|
8420
|
+
* @return [Numo::SFloat] map of self.
|
8421
|
+
*/
|
9257
8422
|
rb_define_method(cT, "map", sfloat_map, 0);
|
8423
|
+
/**
|
8424
|
+
* Invokes the given block once for each element of self, passing that element and
|
8425
|
+
* indices along each axis as parameters. For a block `{|x,i,j,...| ... }`,
|
8426
|
+
* @overload each_with_index
|
8427
|
+
* @yieldparam [Numeric] x an element
|
8428
|
+
* @yieldparam [Integer] i,j,... multitimensional indices
|
8429
|
+
* @return [Numo::NArray] self
|
8430
|
+
* @see #each
|
8431
|
+
* @see #map_with_index
|
8432
|
+
*/
|
9258
8433
|
rb_define_method(cT, "each_with_index", sfloat_each_with_index, 0);
|
8434
|
+
/**
|
8435
|
+
* Invokes the given block once for each element of self,
|
8436
|
+
* passing that element and indices along each axis as parameters.
|
8437
|
+
* Creates a new NArray containing the values returned by the block.
|
8438
|
+
* Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
|
8439
|
+
* For a block `{|x,i,j,...| ... }`,
|
8440
|
+
* @overload map_with_index
|
8441
|
+
* @yieldparam [Numeric] x an element
|
8442
|
+
* @yieldparam [Integer] i,j,... multitimensional indices
|
8443
|
+
* @return [Numo::NArray] mapped array
|
8444
|
+
* @see #map
|
8445
|
+
* @see #each_with_index
|
8446
|
+
*/
|
9259
8447
|
rb_define_method(cT, "map_with_index", sfloat_map_with_index, 0);
|
8448
|
+
/**
|
8449
|
+
* abs of self.
|
8450
|
+
* @overload abs
|
8451
|
+
* @return [Numo::SFloat] abs of self.
|
8452
|
+
*/
|
9260
8453
|
rb_define_method(cT, "abs", sfloat_abs, 0);
|
8454
|
+
/**
|
8455
|
+
* Binary add.
|
8456
|
+
* @overload + other
|
8457
|
+
* @param [Numo::NArray,Numeric] other
|
8458
|
+
* @return [Numo::NArray] self + other
|
8459
|
+
*/
|
9261
8460
|
rb_define_method(cT, "+", sfloat_add, 1);
|
8461
|
+
/**
|
8462
|
+
* Binary sub.
|
8463
|
+
* @overload - other
|
8464
|
+
* @param [Numo::NArray,Numeric] other
|
8465
|
+
* @return [Numo::NArray] self - other
|
8466
|
+
*/
|
9262
8467
|
rb_define_method(cT, "-", sfloat_sub, 1);
|
8468
|
+
/**
|
8469
|
+
* Binary mul.
|
8470
|
+
* @overload * other
|
8471
|
+
* @param [Numo::NArray,Numeric] other
|
8472
|
+
* @return [Numo::NArray] self * other
|
8473
|
+
*/
|
9263
8474
|
rb_define_method(cT, "*", sfloat_mul, 1);
|
8475
|
+
/**
|
8476
|
+
* Binary div.
|
8477
|
+
* @overload / other
|
8478
|
+
* @param [Numo::NArray,Numeric] other
|
8479
|
+
* @return [Numo::NArray] self / other
|
8480
|
+
*/
|
9264
8481
|
rb_define_method(cT, "/", sfloat_div, 1);
|
8482
|
+
/**
|
8483
|
+
* Binary mod.
|
8484
|
+
* @overload % other
|
8485
|
+
* @param [Numo::NArray,Numeric] other
|
8486
|
+
* @return [Numo::NArray] self % other
|
8487
|
+
*/
|
9265
8488
|
rb_define_method(cT, "%", sfloat_mod, 1);
|
8489
|
+
/**
|
8490
|
+
* Binary divmod.
|
8491
|
+
* @overload divmod other
|
8492
|
+
* @param [Numo::NArray,Numeric] other
|
8493
|
+
* @return [Numo::NArray] divmod of self and other.
|
8494
|
+
*/
|
9266
8495
|
rb_define_method(cT, "divmod", sfloat_divmod, 1);
|
8496
|
+
/**
|
8497
|
+
* Binary power.
|
8498
|
+
* @overload ** other
|
8499
|
+
* @param [Numo::NArray,Numeric] other
|
8500
|
+
* @return [Numo::NArray] self to the other-th power.
|
8501
|
+
*/
|
9267
8502
|
rb_define_method(cT, "**", sfloat_pow, 1);
|
9268
8503
|
rb_define_alias(cT, "pow", "**");
|
8504
|
+
/**
|
8505
|
+
* Unary minus.
|
8506
|
+
* @overload -@
|
8507
|
+
* @return [Numo::SFloat] minus of self.
|
8508
|
+
*/
|
9269
8509
|
rb_define_method(cT, "-@", sfloat_minus, 0);
|
8510
|
+
/**
|
8511
|
+
* Unary reciprocal.
|
8512
|
+
* @overload reciprocal
|
8513
|
+
* @return [Numo::SFloat] reciprocal of self.
|
8514
|
+
*/
|
9270
8515
|
rb_define_method(cT, "reciprocal", sfloat_reciprocal, 0);
|
8516
|
+
/**
|
8517
|
+
* Unary sign.
|
8518
|
+
* @overload sign
|
8519
|
+
* @return [Numo::SFloat] sign of self.
|
8520
|
+
*/
|
9271
8521
|
rb_define_method(cT, "sign", sfloat_sign, 0);
|
8522
|
+
/**
|
8523
|
+
* Unary square.
|
8524
|
+
* @overload square
|
8525
|
+
* @return [Numo::SFloat] square of self.
|
8526
|
+
*/
|
9272
8527
|
rb_define_method(cT, "square", sfloat_square, 0);
|
9273
8528
|
rb_define_alias(cT, "conj", "view");
|
9274
8529
|
rb_define_alias(cT, "im", "view");
|
9275
8530
|
rb_define_alias(cT, "conjugate", "conj");
|
8531
|
+
/**
|
8532
|
+
* Comparison eq other.
|
8533
|
+
* @overload eq other
|
8534
|
+
* @param [Numo::NArray,Numeric] other
|
8535
|
+
* @return [Numo::Bit] result of self eq other.
|
8536
|
+
*/
|
9276
8537
|
rb_define_method(cT, "eq", sfloat_eq, 1);
|
8538
|
+
/**
|
8539
|
+
* Comparison ne other.
|
8540
|
+
* @overload ne other
|
8541
|
+
* @param [Numo::NArray,Numeric] other
|
8542
|
+
* @return [Numo::Bit] result of self ne other.
|
8543
|
+
*/
|
9277
8544
|
rb_define_method(cT, "ne", sfloat_ne, 1);
|
8545
|
+
/**
|
8546
|
+
* Comparison nearly_eq other.
|
8547
|
+
* @overload nearly_eq other
|
8548
|
+
* @param [Numo::NArray,Numeric] other
|
8549
|
+
* @return [Numo::Bit] result of self nearly_eq other.
|
8550
|
+
*/
|
9278
8551
|
rb_define_method(cT, "nearly_eq", sfloat_nearly_eq, 1);
|
9279
8552
|
rb_define_alias(cT, "close_to", "nearly_eq");
|
8553
|
+
/**
|
8554
|
+
* Unary floor.
|
8555
|
+
* @overload floor
|
8556
|
+
* @return [Numo::SFloat] floor of self.
|
8557
|
+
*/
|
9280
8558
|
rb_define_method(cT, "floor", sfloat_floor, 0);
|
8559
|
+
/**
|
8560
|
+
* Unary round.
|
8561
|
+
* @overload round
|
8562
|
+
* @return [Numo::SFloat] round of self.
|
8563
|
+
*/
|
9281
8564
|
rb_define_method(cT, "round", sfloat_round, 0);
|
8565
|
+
/**
|
8566
|
+
* Unary ceil.
|
8567
|
+
* @overload ceil
|
8568
|
+
* @return [Numo::SFloat] ceil of self.
|
8569
|
+
*/
|
9282
8570
|
rb_define_method(cT, "ceil", sfloat_ceil, 0);
|
8571
|
+
/**
|
8572
|
+
* Unary trunc.
|
8573
|
+
* @overload trunc
|
8574
|
+
* @return [Numo::SFloat] trunc of self.
|
8575
|
+
*/
|
9283
8576
|
rb_define_method(cT, "trunc", sfloat_trunc, 0);
|
8577
|
+
/**
|
8578
|
+
* Unary rint.
|
8579
|
+
* @overload rint
|
8580
|
+
* @return [Numo::SFloat] rint of self.
|
8581
|
+
*/
|
9284
8582
|
rb_define_method(cT, "rint", sfloat_rint, 0);
|
8583
|
+
/**
|
8584
|
+
* Binary copysign.
|
8585
|
+
* @overload copysign other
|
8586
|
+
* @param [Numo::NArray,Numeric] other
|
8587
|
+
* @return [Numo::NArray] self copysign other
|
8588
|
+
*/
|
9285
8589
|
rb_define_method(cT, "copysign", sfloat_copysign, 1);
|
8590
|
+
/**
|
8591
|
+
* Condition of signbit.
|
8592
|
+
* @overload signbit
|
8593
|
+
* @return [Numo::Bit] Condition of signbit.
|
8594
|
+
*/
|
9286
8595
|
rb_define_method(cT, "signbit", sfloat_signbit, 0);
|
8596
|
+
/**
|
8597
|
+
* modf of self.
|
8598
|
+
* @overload modf
|
8599
|
+
* @return [Numo::SFloat] modf of self.
|
8600
|
+
*/
|
9287
8601
|
rb_define_method(cT, "modf", sfloat_modf, 0);
|
8602
|
+
/**
|
8603
|
+
* Comparison gt other.
|
8604
|
+
* @overload gt other
|
8605
|
+
* @param [Numo::NArray,Numeric] other
|
8606
|
+
* @return [Numo::Bit] result of self gt other.
|
8607
|
+
*/
|
9288
8608
|
rb_define_method(cT, "gt", sfloat_gt, 1);
|
8609
|
+
/**
|
8610
|
+
* Comparison ge other.
|
8611
|
+
* @overload ge other
|
8612
|
+
* @param [Numo::NArray,Numeric] other
|
8613
|
+
* @return [Numo::Bit] result of self ge other.
|
8614
|
+
*/
|
9289
8615
|
rb_define_method(cT, "ge", sfloat_ge, 1);
|
8616
|
+
/**
|
8617
|
+
* Comparison lt other.
|
8618
|
+
* @overload lt other
|
8619
|
+
* @param [Numo::NArray,Numeric] other
|
8620
|
+
* @return [Numo::Bit] result of self lt other.
|
8621
|
+
*/
|
9290
8622
|
rb_define_method(cT, "lt", sfloat_lt, 1);
|
8623
|
+
/**
|
8624
|
+
* Comparison le other.
|
8625
|
+
* @overload le other
|
8626
|
+
* @param [Numo::NArray,Numeric] other
|
8627
|
+
* @return [Numo::Bit] result of self le other.
|
8628
|
+
*/
|
9291
8629
|
rb_define_method(cT, "le", sfloat_le, 1);
|
9292
8630
|
rb_define_alias(cT, ">", "gt");
|
9293
8631
|
rb_define_alias(cT, ">=", "ge");
|
9294
8632
|
rb_define_alias(cT, "<", "lt");
|
9295
8633
|
rb_define_alias(cT, "<=", "le");
|
8634
|
+
/**
|
8635
|
+
* Clip array elements by [min,max].
|
8636
|
+
* If either of min or max is nil, one side is clipped.
|
8637
|
+
* @overload clip(min,max)
|
8638
|
+
* @param [Numo::NArray,Numeric] min
|
8639
|
+
* @param [Numo::NArray,Numeric] max
|
8640
|
+
* @return [Numo::NArray] result of clip.
|
8641
|
+
*
|
8642
|
+
* @example
|
8643
|
+
* a = Numo::Int32.new(10).seq
|
8644
|
+
* # => Numo::Int32#shape=[10]
|
8645
|
+
* # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
8646
|
+
*
|
8647
|
+
* a.clip(1,8)
|
8648
|
+
* # => Numo::Int32#shape=[10]
|
8649
|
+
* # [1, 1, 2, 3, 4, 5, 6, 7, 8, 8]
|
8650
|
+
*
|
8651
|
+
* a.inplace.clip(3,6)
|
8652
|
+
* a
|
8653
|
+
* # => Numo::Int32#shape=[10]
|
8654
|
+
* # [3, 3, 3, 3, 4, 5, 6, 6, 6, 6]
|
8655
|
+
*
|
8656
|
+
* b = Numo::Int32.new(10).seq
|
8657
|
+
* # => Numo::Int32#shape=[10]
|
8658
|
+
* # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
8659
|
+
*
|
8660
|
+
* b.clip([3,4,1,1,1,4,4,4,4,4], 8)
|
8661
|
+
* # => Numo::Int32#shape=[10]
|
8662
|
+
* # [3, 4, 2, 3, 4, 5, 6, 7, 8, 8]
|
8663
|
+
*/
|
9296
8664
|
rb_define_method(cT, "clip", sfloat_clip, 2);
|
8665
|
+
/**
|
8666
|
+
* Condition of isnan.
|
8667
|
+
* @overload isnan
|
8668
|
+
* @return [Numo::Bit] Condition of isnan.
|
8669
|
+
*/
|
9297
8670
|
rb_define_method(cT, "isnan", sfloat_isnan, 0);
|
8671
|
+
/**
|
8672
|
+
* Condition of isinf.
|
8673
|
+
* @overload isinf
|
8674
|
+
* @return [Numo::Bit] Condition of isinf.
|
8675
|
+
*/
|
9298
8676
|
rb_define_method(cT, "isinf", sfloat_isinf, 0);
|
8677
|
+
/**
|
8678
|
+
* Condition of isposinf.
|
8679
|
+
* @overload isposinf
|
8680
|
+
* @return [Numo::Bit] Condition of isposinf.
|
8681
|
+
*/
|
9299
8682
|
rb_define_method(cT, "isposinf", sfloat_isposinf, 0);
|
8683
|
+
/**
|
8684
|
+
* Condition of isneginf.
|
8685
|
+
* @overload isneginf
|
8686
|
+
* @return [Numo::Bit] Condition of isneginf.
|
8687
|
+
*/
|
9300
8688
|
rb_define_method(cT, "isneginf", sfloat_isneginf, 0);
|
8689
|
+
/**
|
8690
|
+
* Condition of isfinite.
|
8691
|
+
* @overload isfinite
|
8692
|
+
* @return [Numo::Bit] Condition of isfinite.
|
8693
|
+
*/
|
9301
8694
|
rb_define_method(cT, "isfinite", sfloat_isfinite, 0);
|
8695
|
+
/**
|
8696
|
+
* sum of self.
|
8697
|
+
* @overload sum(axis:nil, keepdims:false, nan:false)
|
8698
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8699
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8700
|
+
* @param [Numeric,Array,Range] axis Performs sum along the axis.
|
8701
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8702
|
+
* dimensions with size one.
|
8703
|
+
* @return [Numo::SFloat] returns result of sum.
|
8704
|
+
*/
|
9302
8705
|
rb_define_method(cT, "sum", sfloat_sum, -1);
|
8706
|
+
/**
|
8707
|
+
* prod of self.
|
8708
|
+
* @overload prod(axis:nil, keepdims:false, nan:false)
|
8709
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8710
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8711
|
+
* @param [Numeric,Array,Range] axis Performs prod along the axis.
|
8712
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8713
|
+
* dimensions with size one.
|
8714
|
+
* @return [Numo::SFloat] returns result of prod.
|
8715
|
+
*/
|
9303
8716
|
rb_define_method(cT, "prod", sfloat_prod, -1);
|
8717
|
+
/**
|
8718
|
+
* mean of self.
|
8719
|
+
* @overload mean(axis: nil, keepdims: false, nan: false)
|
8720
|
+
* @param axis [Numeric, Array, Range] Performs mean along the axis.
|
8721
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
8722
|
+
* dimensions with size one.
|
8723
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
8724
|
+
* (avoid NaN for sum/mean etc, or return NaN for min/max etc).
|
8725
|
+
* @return [Numo::SFloat] returns result of mean.
|
8726
|
+
*/
|
9304
8727
|
rb_define_method(cT, "mean", sfloat_mean, -1);
|
9305
|
-
|
8728
|
+
/**
|
8729
|
+
* var of self.
|
8730
|
+
* @overload var(axis: nil, keepdims: false, nan: false)
|
8731
|
+
* @param axis [Numeric, Array, Range] Performs var along the axis.
|
8732
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
8733
|
+
* dimensions with size one.
|
8734
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
8735
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8736
|
+
* @return [Numo::SFloat] returns result of var.
|
8737
|
+
*/
|
9306
8738
|
rb_define_method(cT, "var", sfloat_var, -1);
|
8739
|
+
/**
|
8740
|
+
* stddev of self.
|
8741
|
+
* @overload stddev(axis: nil, keepdims: false, nan: false)
|
8742
|
+
* @param axis [Numeric, Array, Range] Performs stddev along the axis.
|
8743
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
8744
|
+
* dimensions with size one.
|
8745
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
8746
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8747
|
+
* @return [Numo::SFloat] returns result of stddev.
|
8748
|
+
*/
|
8749
|
+
rb_define_method(cT, "stddev", sfloat_stddev, -1);
|
8750
|
+
/**
|
8751
|
+
* rms of self.
|
8752
|
+
* @overload rms(axis: nil, keepdims: false, nan: false)
|
8753
|
+
* @param axis [Numeric, Array, Range] Performs rms along the axis.
|
8754
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
8755
|
+
* dimensions with size one.
|
8756
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
8757
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8758
|
+
* @return [Numo::SFloat] returns result of rms.
|
8759
|
+
*/
|
9307
8760
|
rb_define_method(cT, "rms", sfloat_rms, -1);
|
8761
|
+
/**
|
8762
|
+
* min of self.
|
8763
|
+
* @overload min(axis:nil, keepdims:false, nan:false)
|
8764
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8765
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8766
|
+
* @param [Numeric,Array,Range] axis Performs min along the axis.
|
8767
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8768
|
+
* dimensions with size one.
|
8769
|
+
* @return [Numo::SFloat] returns result of min.
|
8770
|
+
*/
|
9308
8771
|
rb_define_method(cT, "min", sfloat_min, -1);
|
8772
|
+
/**
|
8773
|
+
* max of self.
|
8774
|
+
* @overload max(axis:nil, keepdims:false, nan:false)
|
8775
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8776
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8777
|
+
* @param [Numeric,Array,Range] axis Performs max along the axis.
|
8778
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8779
|
+
* dimensions with size one.
|
8780
|
+
* @return [Numo::SFloat] returns result of max.
|
8781
|
+
*/
|
9309
8782
|
rb_define_method(cT, "max", sfloat_max, -1);
|
8783
|
+
/**
|
8784
|
+
* ptp of self.
|
8785
|
+
* @overload ptp(axis:nil, keepdims:false, nan:false)
|
8786
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8787
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
8788
|
+
* @param [Numeric,Array,Range] axis Performs ptp along the axis.
|
8789
|
+
* @param [Boolean] keepdims If true, the reduced axes are left in the result array as
|
8790
|
+
* dimensions with size one.
|
8791
|
+
* @return [Numo::SFloat] returns result of ptp.
|
8792
|
+
*/
|
9310
8793
|
rb_define_method(cT, "ptp", sfloat_ptp, -1);
|
8794
|
+
/**
|
8795
|
+
* Index of the maximum value.
|
8796
|
+
* @overload max_index(axis:nil, nan:false)
|
8797
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8798
|
+
* (return NaN posision if exist).
|
8799
|
+
* @param [Numeric,Array,Range] axis Finds maximum values along the axis
|
8800
|
+
* and returns **flat 1-d indices**.
|
8801
|
+
* @return [Integer,Numo::Int] returns result indices.
|
8802
|
+
* @see #argmax
|
8803
|
+
* @see #max
|
8804
|
+
*
|
8805
|
+
* @example
|
8806
|
+
* a = Numo::NArray[3,4,1,2]
|
8807
|
+
* a.max_index #=> 1
|
8808
|
+
*
|
8809
|
+
* b = Numo::NArray[[3,4,1],[2,0,5]]
|
8810
|
+
* b.max_index #=> 5
|
8811
|
+
* b.max_index(axis:1) #=> [1, 5]
|
8812
|
+
* b.max_index(axis:0) #=> [0, 1, 5]
|
8813
|
+
* b[b.max_index(axis:0)] #=> [3, 4, 5]
|
8814
|
+
*/
|
9311
8815
|
rb_define_method(cT, "max_index", sfloat_max_index, -1);
|
8816
|
+
/**
|
8817
|
+
* Index of the minimum value.
|
8818
|
+
* @overload min_index(axis:nil, nan:false)
|
8819
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8820
|
+
* (return NaN posision if exist).
|
8821
|
+
* @param [Numeric,Array,Range] axis Finds minimum values along the axis
|
8822
|
+
* and returns **flat 1-d indices**.
|
8823
|
+
* @return [Integer,Numo::Int] returns result indices.
|
8824
|
+
* @see #argmin
|
8825
|
+
* @see #min
|
8826
|
+
*
|
8827
|
+
* @example
|
8828
|
+
* a = Numo::NArray[3,4,1,2]
|
8829
|
+
* a.min_index #=> 2
|
8830
|
+
*
|
8831
|
+
* b = Numo::NArray[[3,4,1],[2,0,5]]
|
8832
|
+
* b.min_index #=> 4
|
8833
|
+
* b.min_index(axis:1) #=> [2, 4]
|
8834
|
+
* b.min_index(axis:0) #=> [3, 4, 2]
|
8835
|
+
* b[b.min_index(axis:0)] #=> [2, 0, 1]
|
8836
|
+
*/
|
9312
8837
|
rb_define_method(cT, "min_index", sfloat_min_index, -1);
|
8838
|
+
/**
|
8839
|
+
* Index of the maximum value.
|
8840
|
+
* @overload argmax(axis:nil, nan:false)
|
8841
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8842
|
+
* (return NaN posision if exist).
|
8843
|
+
* @param [Numeric,Array,Range] axis Finds maximum values along the axis
|
8844
|
+
* and returns **indices along the axis**.
|
8845
|
+
* @return [Integer,Numo::Int] returns the result indices.
|
8846
|
+
* @see #max_index
|
8847
|
+
* @see #max
|
8848
|
+
*
|
8849
|
+
* @example
|
8850
|
+
* a = Numo::NArray[3,4,1,2]
|
8851
|
+
* a.argmax #=> 1
|
8852
|
+
*
|
8853
|
+
* b = Numo::NArray[[3,4,1],[2,0,5]]
|
8854
|
+
* b.argmax #=> 5
|
8855
|
+
* b.argmax(axis:1) #=> [1, 2]
|
8856
|
+
* b.argmax(axis:0) #=> [0, 0, 1]
|
8857
|
+
* b.at(b.argmax(axis:0), 0..-1) #=> [3, 4, 5]
|
8858
|
+
*/
|
9313
8859
|
rb_define_method(cT, "argmax", sfloat_argmax, -1);
|
8860
|
+
/**
|
8861
|
+
* Index of the minimum value.
|
8862
|
+
* @overload argmin(axis:nil, nan:false)
|
8863
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm
|
8864
|
+
* (return NaN posision if exist).
|
8865
|
+
* @param [Numeric,Array,Range] axis Finds minimum values along the axis
|
8866
|
+
* and returns **indices along the axis**.
|
8867
|
+
* @return [Integer,Numo::Int] returns the result indices.
|
8868
|
+
* @see #min_index
|
8869
|
+
* @see #min
|
8870
|
+
*
|
8871
|
+
* @example
|
8872
|
+
* a = Numo::NArray[3,4,1,2]
|
8873
|
+
* a.argmin #=> 2
|
8874
|
+
*
|
8875
|
+
* b = Numo::NArray[[3,4,1],[2,0,5]]
|
8876
|
+
* b.argmin #=> 4
|
8877
|
+
* b.argmin(axis:1) #=> [2, 1]
|
8878
|
+
* b.argmin(axis:0) #=> [1, 1, 0]
|
8879
|
+
* b.at(b.argmin(axis:0), 0..-1) #=> [2, 0, 1]
|
8880
|
+
*/
|
9314
8881
|
rb_define_method(cT, "argmin", sfloat_argmin, -1);
|
8882
|
+
/**
|
8883
|
+
* minmax of self.
|
8884
|
+
* @overload minmax(axis:nil, keepdims:false, nan:false)
|
8885
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
8886
|
+
* @param [Numeric,Array,Range] axis Finds min-max along the axis.
|
8887
|
+
* @param [Boolean] keepdims (keyword) If true, the reduced axes are left
|
8888
|
+
* in the result array as dimensions with size one.
|
8889
|
+
* @return [Numo::SFloat,Numo::SFloat] min and max of self.
|
8890
|
+
*/
|
9315
8891
|
rb_define_method(cT, "minmax", sfloat_minmax, -1);
|
8892
|
+
/**
|
8893
|
+
* Element-wise maximum of two arrays.
|
8894
|
+
* @overload maximum(a1, a2, nan:false)
|
8895
|
+
* @param [Numo::NArray,Numeric] a1 The array to be compared.
|
8896
|
+
* @param [Numo::NArray,Numeric] a2 The array to be compared.
|
8897
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
8898
|
+
* @return [Numo::SFloat]
|
8899
|
+
*/
|
9316
8900
|
rb_define_module_function(cT, "maximum", sfloat_s_maximum, -1);
|
8901
|
+
/**
|
8902
|
+
* Element-wise minimum of two arrays.
|
8903
|
+
* @overload minimum(a1, a2, nan:false)
|
8904
|
+
* @param [Numo::NArray,Numeric] a1 The array to be compared.
|
8905
|
+
* @param [Numo::NArray,Numeric] a2 The array to be compared.
|
8906
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (return NaN if exist).
|
8907
|
+
* @return [Numo::SFloat]
|
8908
|
+
*/
|
9317
8909
|
rb_define_module_function(cT, "minimum", sfloat_s_minimum, -1);
|
8910
|
+
/**
|
8911
|
+
* cumsum of self.
|
8912
|
+
* @overload cumsum(axis:nil, nan:false)
|
8913
|
+
* @param [Numeric,Array,Range] axis Performs cumsum along the axis.
|
8914
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
8915
|
+
* @return [Numo::SFloat] cumsum of self.
|
8916
|
+
*/
|
9318
8917
|
rb_define_method(cT, "cumsum", sfloat_cumsum, -1);
|
8918
|
+
/**
|
8919
|
+
* cumprod of self.
|
8920
|
+
* @overload cumprod(axis:nil, nan:false)
|
8921
|
+
* @param [Numeric,Array,Range] axis Performs cumprod along the axis.
|
8922
|
+
* @param [Boolean] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
8923
|
+
* @return [Numo::SFloat] cumprod of self.
|
8924
|
+
*/
|
9319
8925
|
rb_define_method(cT, "cumprod", sfloat_cumprod, -1);
|
8926
|
+
/**
|
8927
|
+
* Binary mulsum.
|
8928
|
+
* @overload mulsum(other, axis:nil, keepdims:false, nan:false)
|
8929
|
+
* @param [Numo::NArray,Numeric] other
|
8930
|
+
* @param [Numeric,Array,Range] axis Performs mulsum along the axis.
|
8931
|
+
* @param [Boolean] keepdims (keyword) If true, the reduced axes are left
|
8932
|
+
* in the result array as dimensions with size one.
|
8933
|
+
* @param [Boolean] nan (keyword) If true, apply NaN-aware algorithm
|
8934
|
+
* (avoid NaN if exists).
|
8935
|
+
* @return [Numo::NArray] mulsum of self and other.
|
8936
|
+
*/
|
9320
8937
|
rb_define_method(cT, "mulsum", sfloat_mulsum, -1);
|
8938
|
+
/**
|
8939
|
+
* Set linear sequence of numbers to self. The sequence is obtained from
|
8940
|
+
* beg+i*step
|
8941
|
+
* where i is 1-dimensional index.
|
8942
|
+
* @overload seq([beg,[step]])
|
8943
|
+
* @param [Numeric] beg beginning of sequence. (default=0)
|
8944
|
+
* @param [Numeric] step step of sequence. (default=1)
|
8945
|
+
* @return [Numo::SFloat] self.
|
8946
|
+
* @example
|
8947
|
+
* Numo::DFloat.new(6).seq(1,-0.2)
|
8948
|
+
* # => Numo::DFloat#shape=[6]
|
8949
|
+
* # [1, 0.8, 0.6, 0.4, 0.2, 0]
|
8950
|
+
*
|
8951
|
+
* Numo::DComplex.new(6).seq(1,-0.2+0.2i)
|
8952
|
+
* # => Numo::DComplex#shape=[6]
|
8953
|
+
* # [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
8954
|
+
*/
|
9321
8955
|
rb_define_method(cT, "seq", sfloat_seq, -1);
|
8956
|
+
/**
|
8957
|
+
* Set logarithmic sequence of numbers to self. The sequence is obtained from
|
8958
|
+
* `base**(beg+i*step)`
|
8959
|
+
* where i is 1-dimensional index.
|
8960
|
+
* Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
|
8961
|
+
*
|
8962
|
+
* @overload logseq(beg,step,[base])
|
8963
|
+
* @param [Numeric] beg The beginning of sequence.
|
8964
|
+
* @param [Numeric] step The step of sequence.
|
8965
|
+
* @param [Numeric] base The base of log space. (default=10)
|
8966
|
+
* @return [Numo::SFloat] self.
|
8967
|
+
*
|
8968
|
+
* @example
|
8969
|
+
* Numo::DFloat.new(5).logseq(4,-1,2)
|
8970
|
+
* # => Numo::DFloat#shape=[5]
|
8971
|
+
* # [16, 8, 4, 2, 1]
|
8972
|
+
*
|
8973
|
+
* Numo::DComplex.new(5).logseq(0,1i*Math::PI/3,Math::E)
|
8974
|
+
* # => Numo::DComplex#shape=[5]
|
8975
|
+
* # [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
|
8976
|
+
*/
|
9322
8977
|
rb_define_method(cT, "logseq", sfloat_logseq, -1);
|
8978
|
+
/**
|
8979
|
+
* Eye: Set a value to diagonal components, set 0 to non-diagonal components.
|
8980
|
+
* @overload eye([element,offset])
|
8981
|
+
* @param [Numeric] element Diagonal element to be stored. Default is 1.
|
8982
|
+
* @param [Integer] offset Diagonal offset from the main diagonal.
|
8983
|
+
* The default is 0. k>0 for diagonals above the main diagonal,
|
8984
|
+
* and k<0 for diagonals below the main diagonal.
|
8985
|
+
* @return [Numo::SFloat] eye of self.
|
8986
|
+
*/
|
9323
8987
|
rb_define_method(cT, "eye", sfloat_eye, -1);
|
9324
8988
|
rb_define_alias(cT, "indgen", "seq");
|
8989
|
+
/**
|
8990
|
+
* Generate uniformly distributed random numbers on self narray.
|
8991
|
+
* @overload rand([[low],high])
|
8992
|
+
* @param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
8993
|
+
* @param [Numeric] high upper exclusive boundary of random numbers.
|
8994
|
+
* (default=1 or 1+1i for complex types)
|
8995
|
+
* @return [Numo::SFloat] self.
|
8996
|
+
* @example
|
8997
|
+
* Numo::DFloat.new(6).rand
|
8998
|
+
* # => Numo::DFloat#shape=[6]
|
8999
|
+
* # [0.0617545, 0.373067, 0.794815, 0.201042, 0.116041, 0.344032]
|
9000
|
+
*
|
9001
|
+
* Numo::DComplex.new(6).rand(5+5i)
|
9002
|
+
* # => Numo::DComplex#shape=[6]
|
9003
|
+
* # [2.69974+3.68908i, 0.825443+0.254414i, 0.540323+0.34354i, 4.52061+2.39322i, ...]
|
9004
|
+
*
|
9005
|
+
* Numo::Int32.new(6).rand(2,5)
|
9006
|
+
* # => Numo::Int32#shape=[6]
|
9007
|
+
* # [4, 3, 3, 2, 4, 2]
|
9008
|
+
*/
|
9325
9009
|
rb_define_method(cT, "rand", sfloat_rand, -1);
|
9010
|
+
/**
|
9011
|
+
* Generates random numbers from the normal distribution on self narray
|
9012
|
+
* using Box-Muller Transformation.
|
9013
|
+
* @overload rand_norm([mu,[sigma]])
|
9014
|
+
* @param [Numeric] mu mean of normal distribution. (default=0)
|
9015
|
+
* @param [Numeric] sigma standard deviation of normal distribution. (default=1)
|
9016
|
+
* @return [Numo::SFloat] self.
|
9017
|
+
* @example
|
9018
|
+
* Numo::DFloat.new(5,5).rand_norm
|
9019
|
+
* # => Numo::DFloat#shape=[5,5]
|
9020
|
+
* # [[-0.581255, -0.168354, 0.586895, -0.595142, -0.802802],
|
9021
|
+
* # [-0.326106, 0.282922, 1.68427, 0.918499, -0.0485384],
|
9022
|
+
* # [-0.464453, -0.992194, 0.413794, -0.60717, -0.699695],
|
9023
|
+
* # [-1.64168, 0.48676, -0.875871, -1.43275, 0.812172],
|
9024
|
+
* # [-0.209975, -0.103612, -0.878617, -1.42495, 1.0968]]
|
9025
|
+
*
|
9026
|
+
* Numo::DFloat.new(5,5).rand_norm(10,0.1)
|
9027
|
+
* # => Numo::DFloat#shape=[5,5]
|
9028
|
+
* # [[9.9019, 9.90339, 10.0826, 9.98384, 9.72861],
|
9029
|
+
* # [9.81507, 10.0272, 9.91445, 10.0568, 9.88923],
|
9030
|
+
* # [10.0234, 9.97874, 9.96011, 9.9006, 9.99964],
|
9031
|
+
* # [10.0186, 9.94598, 9.92236, 9.99811, 9.97003],
|
9032
|
+
* # [9.79266, 9.95044, 9.95212, 9.93692, 10.2027]]
|
9033
|
+
*
|
9034
|
+
* Numo::DComplex.new(3,3).rand_norm(5+5i)
|
9035
|
+
* # => Numo::DComplex#shape=[3,3]
|
9036
|
+
* # [[5.84303+4.40052i, 4.00984+6.08982i, 5.10979+5.13215i],
|
9037
|
+
* # [4.26477+3.99655i, 4.90052+5.00763i, 4.46607+2.3444i],
|
9038
|
+
* # [4.5528+7.11003i, 5.62117+6.69094i, 5.05443+5.35133i]]
|
9039
|
+
*/
|
9326
9040
|
rb_define_method(cT, "rand_norm", sfloat_rand_norm, -1);
|
9041
|
+
/**
|
9042
|
+
* Calculate polynomial.
|
9043
|
+
* `x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
|
9044
|
+
* @overload poly a0, a1, ..., an
|
9045
|
+
* @param [Numo::NArray,Numeric] a0,a1,...,an
|
9046
|
+
* @return [Numo::SFloat]
|
9047
|
+
*/
|
9327
9048
|
rb_define_method(cT, "poly", sfloat_poly, -2);
|
9328
|
-
|
9049
|
+
/**
|
9050
|
+
* sort of self.
|
9051
|
+
* @overload sort(axis:nil, nan:false)
|
9052
|
+
* @param [Boolean] nan If true, propagete NaN. If false, ignore NaN.
|
9053
|
+
* @param [Numeric,Array,Range] axis Performs sort along the axis.
|
9054
|
+
* @return [Numo::SFloat] returns result of sort.
|
9055
|
+
* @example
|
9056
|
+
* Numo::DFloat[3,4,1,2].sort #=> Numo::DFloat[1,2,3,4]
|
9057
|
+
*/
|
9329
9058
|
rb_define_method(cT, "sort", sfloat_sort, -1);
|
9330
|
-
|
9059
|
+
/**
|
9060
|
+
* sort_index. Returns an index array of sort result.
|
9061
|
+
* @overload sort_index(axis:nil, nan:false)
|
9062
|
+
* @param [Boolean] nan If true, propagete NaN. If false, ignore NaN.
|
9063
|
+
* @param [Numeric,Array,Range] axis Performs sort_index along the axis.
|
9064
|
+
* @return [Integer,Numo::Int] returns result index of sort_index.
|
9065
|
+
* @example
|
9066
|
+
* Numo::NArray[3,4,1,2].sort_index #=> Numo::Int32[2,3,0,1]
|
9067
|
+
*/
|
9331
9068
|
rb_define_method(cT, "sort_index", sfloat_sort_index, -1);
|
9069
|
+
/**
|
9070
|
+
* median of self.
|
9071
|
+
* @overload median(axis:nil, keepdims:false, nan:false)
|
9072
|
+
* @param [Boolean] nan (keyword) If true, propagete NaN. If false, ignore NaN.
|
9073
|
+
* @param [Numeric,Array,Range] axis Finds median along the axis.
|
9074
|
+
* @param [Boolean] keepdims If true, the reduced axes are left
|
9075
|
+
* in the result array as dimensions with size one.
|
9076
|
+
* @return [Numo::SFloat] returns median of self.
|
9077
|
+
*/
|
9332
9078
|
rb_define_method(cT, "median", sfloat_median, -1);
|
9333
|
-
rb_define_singleton_method(cT, "[]", sfloat_s_cast, -2);
|
9334
|
-
|
9335
|
-
/*
|
9336
|
-
Document-module: Numo::SFloat::NMath
|
9337
|
-
|
9338
|
-
*/
|
9339
9079
|
|
9080
|
+
/**
|
9081
|
+
* Document-module: Numo::SFloat::Math
|
9082
|
+
*
|
9083
|
+
* This module contains mathematical functions for Numo::SFloat.
|
9084
|
+
*/
|
9340
9085
|
mTM = rb_define_module_under(cT, "Math");
|
9341
|
-
|
9086
|
+
/**
|
9087
|
+
* Calculate sqrt(x).
|
9088
|
+
* @overload sqrt(x)
|
9089
|
+
* @param [Numo::NArray,Numeric] x input value
|
9090
|
+
* @return [Numo::SFloat] result of sqrt(x).
|
9091
|
+
*/
|
9342
9092
|
rb_define_module_function(mTM, "sqrt", sfloat_math_s_sqrt, 1);
|
9093
|
+
/**
|
9094
|
+
* Calculate cbrt(x).
|
9095
|
+
* @overload cbrt(x)
|
9096
|
+
* @param [Numo::NArray,Numeric] x input value
|
9097
|
+
* @return [Numo::SFloat] result of cbrt(x).
|
9098
|
+
*/
|
9343
9099
|
rb_define_module_function(mTM, "cbrt", sfloat_math_s_cbrt, 1);
|
9100
|
+
/**
|
9101
|
+
* Calculate log(x).
|
9102
|
+
* @overload log(x)
|
9103
|
+
* @param [Numo::NArray,Numeric] x input value
|
9104
|
+
* @return [Numo::SFloat] result of log(x).
|
9105
|
+
*/
|
9344
9106
|
rb_define_module_function(mTM, "log", sfloat_math_s_log, 1);
|
9107
|
+
/**
|
9108
|
+
* Calculate log2(x).
|
9109
|
+
* @overload log2(x)
|
9110
|
+
* @param [Numo::NArray,Numeric] x input value
|
9111
|
+
* @return [Numo::SFloat] result of log2(x).
|
9112
|
+
*/
|
9345
9113
|
rb_define_module_function(mTM, "log2", sfloat_math_s_log2, 1);
|
9114
|
+
/**
|
9115
|
+
* Calculate log10(x).
|
9116
|
+
* @overload log10(x)
|
9117
|
+
* @param [Numo::NArray,Numeric] x input value
|
9118
|
+
* @return [Numo::SFloat] result of log10(x).
|
9119
|
+
*/
|
9346
9120
|
rb_define_module_function(mTM, "log10", sfloat_math_s_log10, 1);
|
9121
|
+
/**
|
9122
|
+
* Calculate exp(x).
|
9123
|
+
* @overload exp(x)
|
9124
|
+
* @param [Numo::NArray,Numeric] x input value
|
9125
|
+
* @return [Numo::SFloat] result of exp(x).
|
9126
|
+
*/
|
9347
9127
|
rb_define_module_function(mTM, "exp", sfloat_math_s_exp, 1);
|
9128
|
+
/**
|
9129
|
+
* Calculate exp2(x).
|
9130
|
+
* @overload exp2(x)
|
9131
|
+
* @param [Numo::NArray,Numeric] x input value
|
9132
|
+
* @return [Numo::SFloat] result of exp2(x).
|
9133
|
+
*/
|
9348
9134
|
rb_define_module_function(mTM, "exp2", sfloat_math_s_exp2, 1);
|
9135
|
+
/**
|
9136
|
+
* Calculate exp10(x).
|
9137
|
+
* @overload exp10(x)
|
9138
|
+
* @param [Numo::NArray,Numeric] x input value
|
9139
|
+
* @return [Numo::SFloat] result of exp10(x).
|
9140
|
+
*/
|
9349
9141
|
rb_define_module_function(mTM, "exp10", sfloat_math_s_exp10, 1);
|
9142
|
+
/**
|
9143
|
+
* Calculate sin(x).
|
9144
|
+
* @overload sin(x)
|
9145
|
+
* @param [Numo::NArray,Numeric] x input value
|
9146
|
+
* @return [Numo::SFloat] result of sin(x).
|
9147
|
+
*/
|
9350
9148
|
rb_define_module_function(mTM, "sin", sfloat_math_s_sin, 1);
|
9149
|
+
/**
|
9150
|
+
* Calculate cos(x).
|
9151
|
+
* @overload cos(x)
|
9152
|
+
* @param [Numo::NArray,Numeric] x input value
|
9153
|
+
* @return [Numo::SFloat] result of cos(x).
|
9154
|
+
*/
|
9351
9155
|
rb_define_module_function(mTM, "cos", sfloat_math_s_cos, 1);
|
9156
|
+
/**
|
9157
|
+
* Calculate tan(x).
|
9158
|
+
* @overload tan(x)
|
9159
|
+
* @param [Numo::NArray,Numeric] x input value
|
9160
|
+
* @return [Numo::SFloat] result of tan(x).
|
9161
|
+
*/
|
9352
9162
|
rb_define_module_function(mTM, "tan", sfloat_math_s_tan, 1);
|
9163
|
+
/**
|
9164
|
+
* Calculate asin(x).
|
9165
|
+
* @overload asin(x)
|
9166
|
+
* @param [Numo::NArray,Numeric] x input value
|
9167
|
+
* @return [Numo::SFloat] result of asin(x).
|
9168
|
+
*/
|
9353
9169
|
rb_define_module_function(mTM, "asin", sfloat_math_s_asin, 1);
|
9170
|
+
/**
|
9171
|
+
* Calculate acos(x).
|
9172
|
+
* @overload acos(x)
|
9173
|
+
* @param [Numo::NArray,Numeric] x input value
|
9174
|
+
* @return [Numo::SFloat] result of acos(x).
|
9175
|
+
*/
|
9354
9176
|
rb_define_module_function(mTM, "acos", sfloat_math_s_acos, 1);
|
9177
|
+
/**
|
9178
|
+
* Calculate atan(x).
|
9179
|
+
* @overload atan(x)
|
9180
|
+
* @param [Numo::NArray,Numeric] x input value
|
9181
|
+
* @return [Numo::SFloat] result of atan(x).
|
9182
|
+
*/
|
9355
9183
|
rb_define_module_function(mTM, "atan", sfloat_math_s_atan, 1);
|
9184
|
+
/**
|
9185
|
+
* Calculate sinh(x).
|
9186
|
+
* @overload sinh(x)
|
9187
|
+
* @param [Numo::NArray,Numeric] x input value
|
9188
|
+
* @return [Numo::SFloat] result of sinh(x).
|
9189
|
+
*/
|
9356
9190
|
rb_define_module_function(mTM, "sinh", sfloat_math_s_sinh, 1);
|
9191
|
+
/**
|
9192
|
+
* Calculate cosh(x).
|
9193
|
+
* @overload cosh(x)
|
9194
|
+
* @param [Numo::NArray,Numeric] x input value
|
9195
|
+
* @return [Numo::SFloat] result of cosh(x).
|
9196
|
+
*/
|
9357
9197
|
rb_define_module_function(mTM, "cosh", sfloat_math_s_cosh, 1);
|
9198
|
+
/**
|
9199
|
+
* Calculate tanh(x).
|
9200
|
+
* @overload tanh(x)
|
9201
|
+
* @param [Numo::NArray,Numeric] x input value
|
9202
|
+
* @return [Numo::SFloat] result of tanh(x).
|
9203
|
+
*/
|
9358
9204
|
rb_define_module_function(mTM, "tanh", sfloat_math_s_tanh, 1);
|
9205
|
+
/**
|
9206
|
+
* Calculate asinh(x).
|
9207
|
+
* @overload asinh(x)
|
9208
|
+
* @param [Numo::NArray,Numeric] x input value
|
9209
|
+
* @return [Numo::SFloat] result of asinh(x).
|
9210
|
+
*/
|
9359
9211
|
rb_define_module_function(mTM, "asinh", sfloat_math_s_asinh, 1);
|
9212
|
+
/**
|
9213
|
+
* Calculate acosh(x).
|
9214
|
+
* @overload acosh(x)
|
9215
|
+
* @param [Numo::NArray,Numeric] x input value
|
9216
|
+
* @return [Numo::SFloat] result of acosh(x).
|
9217
|
+
*/
|
9360
9218
|
rb_define_module_function(mTM, "acosh", sfloat_math_s_acosh, 1);
|
9219
|
+
/**
|
9220
|
+
* Calculate atanh(x).
|
9221
|
+
* @overload atanh(x)
|
9222
|
+
* @param [Numo::NArray,Numeric] x input value
|
9223
|
+
* @return [Numo::SFloat] result of atanh(x).
|
9224
|
+
*/
|
9361
9225
|
rb_define_module_function(mTM, "atanh", sfloat_math_s_atanh, 1);
|
9226
|
+
/**
|
9227
|
+
* Calculate sinc(x).
|
9228
|
+
* @overload sinc(x)
|
9229
|
+
* @param [Numo::NArray,Numeric] x input value
|
9230
|
+
* @return [Numo::SFloat] result of sinc(x).
|
9231
|
+
*/
|
9362
9232
|
rb_define_module_function(mTM, "sinc", sfloat_math_s_sinc, 1);
|
9233
|
+
/**
|
9234
|
+
* Calculate atan2(a1,a2).
|
9235
|
+
* @overload atan2(a1,a2)
|
9236
|
+
* @param [Numo::NArray,Numeric] a1 first value
|
9237
|
+
* @param [Numo::NArray,Numeric] a2 second value
|
9238
|
+
* @return [Numo::SFloat] atan2(a1,a2).
|
9239
|
+
*/
|
9363
9240
|
rb_define_module_function(mTM, "atan2", sfloat_math_s_atan2, 2);
|
9241
|
+
/**
|
9242
|
+
* Calculate hypot(a1,a2).
|
9243
|
+
* @overload hypot(a1,a2)
|
9244
|
+
* @param [Numo::NArray,Numeric] a1 first value
|
9245
|
+
* @param [Numo::NArray,Numeric] a2 second value
|
9246
|
+
* @return [Numo::SFloat] hypot(a1,a2).
|
9247
|
+
*/
|
9364
9248
|
rb_define_module_function(mTM, "hypot", sfloat_math_s_hypot, 2);
|
9249
|
+
/**
|
9250
|
+
* Calculate erf(x).
|
9251
|
+
* @overload erf(x)
|
9252
|
+
* @param [Numo::NArray,Numeric] x input value
|
9253
|
+
* @return [Numo::SFloat] result of erf(x).
|
9254
|
+
*/
|
9365
9255
|
rb_define_module_function(mTM, "erf", sfloat_math_s_erf, 1);
|
9256
|
+
/**
|
9257
|
+
* Calculate erfc(x).
|
9258
|
+
* @overload erfc(x)
|
9259
|
+
* @param [Numo::NArray,Numeric] x input value
|
9260
|
+
* @return [Numo::SFloat] result of erfc(x).
|
9261
|
+
*/
|
9366
9262
|
rb_define_module_function(mTM, "erfc", sfloat_math_s_erfc, 1);
|
9263
|
+
/**
|
9264
|
+
* Calculate log1p(x).
|
9265
|
+
* @overload log1p(x)
|
9266
|
+
* @param [Numo::NArray,Numeric] x input value
|
9267
|
+
* @return [Numo::SFloat] result of log1p(x).
|
9268
|
+
*/
|
9367
9269
|
rb_define_module_function(mTM, "log1p", sfloat_math_s_log1p, 1);
|
9270
|
+
/**
|
9271
|
+
* Calculate expm1(x).
|
9272
|
+
* @overload expm1(x)
|
9273
|
+
* @param [Numo::NArray,Numeric] x input value
|
9274
|
+
* @return [Numo::SFloat] result of expm1(x).
|
9275
|
+
*/
|
9368
9276
|
rb_define_module_function(mTM, "expm1", sfloat_math_s_expm1, 1);
|
9277
|
+
/**
|
9278
|
+
* Calculate ldexp(a1,a2).
|
9279
|
+
* @overload ldexp(a1,a2)
|
9280
|
+
* @param [Numo::NArray,Numeric] a1 first value
|
9281
|
+
* @param [Numo::NArray,Numeric] a2 second value
|
9282
|
+
* @return [Numo::SFloat] ldexp(a1,a2).
|
9283
|
+
*/
|
9369
9284
|
rb_define_module_function(mTM, "ldexp", sfloat_math_s_ldexp, 2);
|
9285
|
+
/**
|
9286
|
+
* split the number x into a normalized fraction and an exponent.
|
9287
|
+
* Returns [mantissa, exponent], where x = mantissa * 2**exponent.
|
9288
|
+
* @overload frexp(x)
|
9289
|
+
* @param [Numo::NArray,Numeric] x
|
9290
|
+
* @return [Numo::SFloat,Numo::Int32] mantissa and exponent.
|
9291
|
+
*/
|
9370
9292
|
rb_define_module_function(mTM, "frexp", sfloat_math_s_frexp, 1);
|
9371
9293
|
|
9372
9294
|
// how to do this?
|