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
@@ -32,14 +32,21 @@ static ID id_to_a;
|
|
32
32
|
|
33
33
|
#include <numo/types/scomplex.h>
|
34
34
|
|
35
|
-
VALUE cT;
|
36
|
-
extern VALUE cRT;
|
37
|
-
|
38
35
|
/*
|
39
36
|
class definition: Numo::SComplex
|
40
37
|
*/
|
41
|
-
|
42
38
|
VALUE cT;
|
39
|
+
extern VALUE cRT;
|
40
|
+
|
41
|
+
#include "mh/mean.h"
|
42
|
+
#include "mh/var.h"
|
43
|
+
#include "mh/stddev.h"
|
44
|
+
#include "mh/rms.h"
|
45
|
+
|
46
|
+
DEF_NARRAY_FLT_MEAN_METHOD_FUNC(scomplex, scomplex, numo_cSComplex, numo_cSComplex)
|
47
|
+
DEF_NARRAY_FLT_VAR_METHOD_FUNC(scomplex, float, numo_cSComplex, numo_cSFloat)
|
48
|
+
DEF_NARRAY_FLT_STDDEV_METHOD_FUNC(scomplex, float, numo_cSComplex, numo_cSFloat)
|
49
|
+
DEF_NARRAY_FLT_RMS_METHOD_FUNC(scomplex, float, numo_cSComplex, numo_cSFloat)
|
43
50
|
|
44
51
|
static VALUE scomplex_store(VALUE, VALUE);
|
45
52
|
|
@@ -147,9 +154,9 @@ static VALUE scomplex_allocate(VALUE self) {
|
|
147
154
|
/*
|
148
155
|
Extract an element only if self is a dimensionless NArray.
|
149
156
|
@overload extract
|
150
|
-
|
151
|
-
|
152
|
-
|
157
|
+
@return [Numeric,Numo::NArray]
|
158
|
+
--- Extract element value as Ruby Object if self is a dimensionless NArray,
|
159
|
+
otherwise returns self.
|
153
160
|
*/
|
154
161
|
static VALUE scomplex_extract(VALUE self) {
|
155
162
|
volatile VALUE v;
|
@@ -233,8 +240,8 @@ static void iter_scomplex_store_bit(na_loop_t* const lp) {
|
|
233
240
|
}
|
234
241
|
|
235
242
|
static VALUE scomplex_store_bit(VALUE self, VALUE obj) {
|
236
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
237
|
-
ndfunc_t ndf = {iter_scomplex_store_bit, FULL_LOOP, 2, 0, ain, 0};
|
243
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
244
|
+
ndfunc_t ndf = { iter_scomplex_store_bit, FULL_LOOP, 2, 0, ain, 0 };
|
238
245
|
|
239
246
|
na_ndloop(&ndf, 2, self, obj);
|
240
247
|
return self;
|
@@ -282,8 +289,8 @@ static void iter_scomplex_store_dcomplex(na_loop_t* const lp) {
|
|
282
289
|
}
|
283
290
|
|
284
291
|
static VALUE scomplex_store_dcomplex(VALUE self, VALUE obj) {
|
285
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
286
|
-
ndfunc_t ndf = {iter_scomplex_store_dcomplex, FULL_LOOP, 2, 0, ain, 0};
|
292
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
293
|
+
ndfunc_t ndf = { iter_scomplex_store_dcomplex, FULL_LOOP, 2, 0, ain, 0 };
|
287
294
|
|
288
295
|
na_ndloop(&ndf, 2, self, obj);
|
289
296
|
return self;
|
@@ -331,8 +338,8 @@ static void iter_scomplex_store_scomplex(na_loop_t* const lp) {
|
|
331
338
|
}
|
332
339
|
|
333
340
|
static VALUE scomplex_store_scomplex(VALUE self, VALUE obj) {
|
334
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
335
|
-
ndfunc_t ndf = {iter_scomplex_store_scomplex, FULL_LOOP, 2, 0, ain, 0};
|
341
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
342
|
+
ndfunc_t ndf = { iter_scomplex_store_scomplex, FULL_LOOP, 2, 0, ain, 0 };
|
336
343
|
|
337
344
|
na_ndloop(&ndf, 2, self, obj);
|
338
345
|
return self;
|
@@ -380,8 +387,8 @@ static void iter_scomplex_store_dfloat(na_loop_t* const lp) {
|
|
380
387
|
}
|
381
388
|
|
382
389
|
static VALUE scomplex_store_dfloat(VALUE self, VALUE obj) {
|
383
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
384
|
-
ndfunc_t ndf = {iter_scomplex_store_dfloat, FULL_LOOP, 2, 0, ain, 0};
|
390
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
391
|
+
ndfunc_t ndf = { iter_scomplex_store_dfloat, FULL_LOOP, 2, 0, ain, 0 };
|
385
392
|
|
386
393
|
na_ndloop(&ndf, 2, self, obj);
|
387
394
|
return self;
|
@@ -429,8 +436,8 @@ static void iter_scomplex_store_sfloat(na_loop_t* const lp) {
|
|
429
436
|
}
|
430
437
|
|
431
438
|
static VALUE scomplex_store_sfloat(VALUE self, VALUE obj) {
|
432
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
433
|
-
ndfunc_t ndf = {iter_scomplex_store_sfloat, FULL_LOOP, 2, 0, ain, 0};
|
439
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
440
|
+
ndfunc_t ndf = { iter_scomplex_store_sfloat, FULL_LOOP, 2, 0, ain, 0 };
|
434
441
|
|
435
442
|
na_ndloop(&ndf, 2, self, obj);
|
436
443
|
return self;
|
@@ -478,8 +485,8 @@ static void iter_scomplex_store_int64(na_loop_t* const lp) {
|
|
478
485
|
}
|
479
486
|
|
480
487
|
static VALUE scomplex_store_int64(VALUE self, VALUE obj) {
|
481
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
482
|
-
ndfunc_t ndf = {iter_scomplex_store_int64, FULL_LOOP, 2, 0, ain, 0};
|
488
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
489
|
+
ndfunc_t ndf = { iter_scomplex_store_int64, FULL_LOOP, 2, 0, ain, 0 };
|
483
490
|
|
484
491
|
na_ndloop(&ndf, 2, self, obj);
|
485
492
|
return self;
|
@@ -527,8 +534,8 @@ static void iter_scomplex_store_int32(na_loop_t* const lp) {
|
|
527
534
|
}
|
528
535
|
|
529
536
|
static VALUE scomplex_store_int32(VALUE self, VALUE obj) {
|
530
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
531
|
-
ndfunc_t ndf = {iter_scomplex_store_int32, FULL_LOOP, 2, 0, ain, 0};
|
537
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
538
|
+
ndfunc_t ndf = { iter_scomplex_store_int32, FULL_LOOP, 2, 0, ain, 0 };
|
532
539
|
|
533
540
|
na_ndloop(&ndf, 2, self, obj);
|
534
541
|
return self;
|
@@ -576,8 +583,8 @@ static void iter_scomplex_store_int16(na_loop_t* const lp) {
|
|
576
583
|
}
|
577
584
|
|
578
585
|
static VALUE scomplex_store_int16(VALUE self, VALUE obj) {
|
579
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
580
|
-
ndfunc_t ndf = {iter_scomplex_store_int16, FULL_LOOP, 2, 0, ain, 0};
|
586
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
587
|
+
ndfunc_t ndf = { iter_scomplex_store_int16, FULL_LOOP, 2, 0, ain, 0 };
|
581
588
|
|
582
589
|
na_ndloop(&ndf, 2, self, obj);
|
583
590
|
return self;
|
@@ -625,8 +632,8 @@ static void iter_scomplex_store_int8(na_loop_t* const lp) {
|
|
625
632
|
}
|
626
633
|
|
627
634
|
static VALUE scomplex_store_int8(VALUE self, VALUE obj) {
|
628
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
629
|
-
ndfunc_t ndf = {iter_scomplex_store_int8, FULL_LOOP, 2, 0, ain, 0};
|
635
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
636
|
+
ndfunc_t ndf = { iter_scomplex_store_int8, FULL_LOOP, 2, 0, ain, 0 };
|
630
637
|
|
631
638
|
na_ndloop(&ndf, 2, self, obj);
|
632
639
|
return self;
|
@@ -674,8 +681,8 @@ static void iter_scomplex_store_uint64(na_loop_t* const lp) {
|
|
674
681
|
}
|
675
682
|
|
676
683
|
static VALUE scomplex_store_uint64(VALUE self, VALUE obj) {
|
677
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
678
|
-
ndfunc_t ndf = {iter_scomplex_store_uint64, FULL_LOOP, 2, 0, ain, 0};
|
684
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
685
|
+
ndfunc_t ndf = { iter_scomplex_store_uint64, FULL_LOOP, 2, 0, ain, 0 };
|
679
686
|
|
680
687
|
na_ndloop(&ndf, 2, self, obj);
|
681
688
|
return self;
|
@@ -723,8 +730,8 @@ static void iter_scomplex_store_uint32(na_loop_t* const lp) {
|
|
723
730
|
}
|
724
731
|
|
725
732
|
static VALUE scomplex_store_uint32(VALUE self, VALUE obj) {
|
726
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
727
|
-
ndfunc_t ndf = {iter_scomplex_store_uint32, FULL_LOOP, 2, 0, ain, 0};
|
733
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
734
|
+
ndfunc_t ndf = { iter_scomplex_store_uint32, FULL_LOOP, 2, 0, ain, 0 };
|
728
735
|
|
729
736
|
na_ndloop(&ndf, 2, self, obj);
|
730
737
|
return self;
|
@@ -772,8 +779,8 @@ static void iter_scomplex_store_uint16(na_loop_t* const lp) {
|
|
772
779
|
}
|
773
780
|
|
774
781
|
static VALUE scomplex_store_uint16(VALUE self, VALUE obj) {
|
775
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
776
|
-
ndfunc_t ndf = {iter_scomplex_store_uint16, FULL_LOOP, 2, 0, ain, 0};
|
782
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
783
|
+
ndfunc_t ndf = { iter_scomplex_store_uint16, FULL_LOOP, 2, 0, ain, 0 };
|
777
784
|
|
778
785
|
na_ndloop(&ndf, 2, self, obj);
|
779
786
|
return self;
|
@@ -821,8 +828,8 @@ static void iter_scomplex_store_uint8(na_loop_t* const lp) {
|
|
821
828
|
}
|
822
829
|
|
823
830
|
static VALUE scomplex_store_uint8(VALUE self, VALUE obj) {
|
824
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
825
|
-
ndfunc_t ndf = {iter_scomplex_store_uint8, FULL_LOOP, 2, 0, ain, 0};
|
831
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
832
|
+
ndfunc_t ndf = { iter_scomplex_store_uint8, FULL_LOOP, 2, 0, ain, 0 };
|
826
833
|
|
827
834
|
na_ndloop(&ndf, 2, self, obj);
|
828
835
|
return self;
|
@@ -870,8 +877,8 @@ static void iter_scomplex_store_robject(na_loop_t* const lp) {
|
|
870
877
|
}
|
871
878
|
|
872
879
|
static VALUE scomplex_store_robject(VALUE self, VALUE obj) {
|
873
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {Qnil, 0}};
|
874
|
-
ndfunc_t ndf = {iter_scomplex_store_robject, FULL_LOOP, 2, 0, ain, 0};
|
880
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { Qnil, 0 } };
|
881
|
+
ndfunc_t ndf = { iter_scomplex_store_robject, FULL_LOOP, 2, 0, ain, 0 };
|
875
882
|
|
876
883
|
na_ndloop(&ndf, 2, self, obj);
|
877
884
|
return self;
|
@@ -979,8 +986,8 @@ loop_end:
|
|
979
986
|
}
|
980
987
|
|
981
988
|
static VALUE scomplex_store_array(VALUE self, VALUE rary) {
|
982
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {rb_cArray, 0}};
|
983
|
-
ndfunc_t ndf = {iter_scomplex_store_array, FULL_LOOP, 2, 0, ain, 0};
|
989
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { rb_cArray, 0 } };
|
990
|
+
ndfunc_t ndf = { iter_scomplex_store_array, FULL_LOOP, 2, 0, ain, 0 };
|
984
991
|
|
985
992
|
na_ndloop_store_rarray(&ndf, self, rary);
|
986
993
|
return self;
|
@@ -989,8 +996,8 @@ static VALUE scomplex_store_array(VALUE self, VALUE rary) {
|
|
989
996
|
/*
|
990
997
|
Store elements to Numo::SComplex from other.
|
991
998
|
@overload store(other)
|
992
|
-
|
993
|
-
|
999
|
+
@param [Object] other
|
1000
|
+
@return [Numo::SComplex] self
|
994
1001
|
*/
|
995
1002
|
static VALUE scomplex_store(VALUE self, VALUE obj) {
|
996
1003
|
VALUE r, klass;
|
@@ -1085,8 +1092,10 @@ static VALUE scomplex_store(VALUE self, VALUE obj) {
|
|
1085
1092
|
}
|
1086
1093
|
}
|
1087
1094
|
|
1088
|
-
rb_raise(
|
1089
|
-
|
1095
|
+
rb_raise(
|
1096
|
+
nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
|
1097
|
+
rb_class2name(rb_obj_class(self))
|
1098
|
+
);
|
1090
1099
|
|
1091
1100
|
return self;
|
1092
1101
|
}
|
@@ -1196,7 +1205,10 @@ static dtype scomplex_extract_data(VALUE obj) {
|
|
1196
1205
|
return scomplex_extract_data(r);
|
1197
1206
|
}
|
1198
1207
|
|
1199
|
-
rb_raise(
|
1208
|
+
rb_raise(
|
1209
|
+
nary_eCastError, "unknown conversion from %s to %s", rb_class2name(rb_obj_class(obj)),
|
1210
|
+
rb_class2name(cT)
|
1211
|
+
);
|
1200
1212
|
}
|
1201
1213
|
if (TYPE(obj) == T_ARRAY) {
|
1202
1214
|
if (RARRAY_LEN(obj) != 1) {
|
@@ -1223,9 +1235,9 @@ static VALUE scomplex_cast_array(VALUE rary) {
|
|
1223
1235
|
Cast object to Numo::SComplex.
|
1224
1236
|
@overload [](elements)
|
1225
1237
|
@overload cast(array)
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1238
|
+
@param [Numeric,Array] elements
|
1239
|
+
@param [Array] array
|
1240
|
+
@return [Numo::SComplex]
|
1229
1241
|
*/
|
1230
1242
|
static VALUE scomplex_s_cast(VALUE type, VALUE obj) {
|
1231
1243
|
VALUE v;
|
@@ -1265,11 +1277,11 @@ static VALUE scomplex_s_cast(VALUE type, VALUE obj) {
|
|
1265
1277
|
/*
|
1266
1278
|
Multi-dimensional element reference.
|
1267
1279
|
@overload [](dim0,...,dimL)
|
1268
|
-
|
1269
|
-
indices.
|
1270
|
-
|
1271
|
-
|
1272
|
-
|
1280
|
+
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
|
1281
|
+
dim0,...,dimL multi-dimensional indices.
|
1282
|
+
@return [Numeric,Numo::SComplex] an element or NArray view.
|
1283
|
+
@see Numo::NArray#[]
|
1284
|
+
@see #[]=
|
1273
1285
|
*/
|
1274
1286
|
static VALUE scomplex_aref(int argc, VALUE* argv, VALUE self) {
|
1275
1287
|
int nd;
|
@@ -1288,10 +1300,10 @@ static VALUE scomplex_aref(int argc, VALUE* argv, VALUE self) {
|
|
1288
1300
|
/*
|
1289
1301
|
Multi-dimensional element assignment.
|
1290
1302
|
@overload []=(dim0,...,dimL,val)
|
1291
|
-
|
1292
|
-
indices.
|
1293
|
-
|
1294
|
-
|
1303
|
+
@param [Numeric,Range,Array,Numo::Int32,Numo::Int64,Numo::Bit,TrueClass,FalseClass,Symbol]
|
1304
|
+
dim0,...,dimL multi-dimensional indices.
|
1305
|
+
@param [Numeric,Numo::NArray,Array] val Value(s) to be set to self.
|
1306
|
+
@return [Numeric,Numo::NArray,Array] returns `val` (last argument).
|
1295
1307
|
@see Numo::NArray#[]=
|
1296
1308
|
@see #[]
|
1297
1309
|
*/
|
@@ -1322,7 +1334,7 @@ static VALUE scomplex_aset(int argc, VALUE* argv, VALUE self) {
|
|
1322
1334
|
/*
|
1323
1335
|
return NArray with cast to the type of self.
|
1324
1336
|
@overload coerce_cast(type)
|
1325
|
-
|
1337
|
+
@return [nil]
|
1326
1338
|
*/
|
1327
1339
|
static VALUE scomplex_coerce_cast(VALUE self, VALUE type) {
|
1328
1340
|
return Qnil;
|
@@ -1357,12 +1369,12 @@ static void iter_scomplex_to_a(na_loop_t* const lp) {
|
|
1357
1369
|
/*
|
1358
1370
|
Convert self to Array.
|
1359
1371
|
@overload to_a
|
1360
|
-
|
1372
|
+
@return [Array]
|
1361
1373
|
*/
|
1362
1374
|
static VALUE scomplex_to_a(VALUE self) {
|
1363
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
|
1364
|
-
ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
|
1365
|
-
ndfunc_t ndf = {iter_scomplex_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
|
1375
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
|
1376
|
+
ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
|
1377
|
+
ndfunc_t ndf = { iter_scomplex_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
|
1366
1378
|
return na_ndloop_cast_narray_to_rarray(&ndf, self, Qnil);
|
1367
1379
|
}
|
1368
1380
|
|
@@ -1390,12 +1402,12 @@ static void iter_scomplex_fill(na_loop_t* const lp) {
|
|
1390
1402
|
/*
|
1391
1403
|
Fill elements with other.
|
1392
1404
|
@overload fill other
|
1393
|
-
|
1394
|
-
|
1405
|
+
@param [Numeric] other
|
1406
|
+
@return [Numo::SComplex] self.
|
1395
1407
|
*/
|
1396
1408
|
static VALUE scomplex_fill(VALUE self, VALUE val) {
|
1397
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {sym_option}};
|
1398
|
-
ndfunc_t ndf = {iter_scomplex_fill, FULL_LOOP, 2, 0, ain, 0};
|
1409
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } };
|
1410
|
+
ndfunc_t ndf = { iter_scomplex_fill, FULL_LOOP, 2, 0, ain, 0 };
|
1399
1411
|
|
1400
1412
|
na_ndloop(&ndf, 2, self, val);
|
1401
1413
|
return self;
|
@@ -1444,15 +1456,15 @@ static void iter_scomplex_format(na_loop_t* const lp) {
|
|
1444
1456
|
/*
|
1445
1457
|
Format elements into strings.
|
1446
1458
|
@overload format format
|
1447
|
-
|
1448
|
-
|
1459
|
+
@param [String] format
|
1460
|
+
@return [Numo::RObject] array of formatted strings.
|
1449
1461
|
*/
|
1450
1462
|
static VALUE scomplex_format(int argc, VALUE* argv, VALUE self) {
|
1451
1463
|
VALUE fmt = Qnil;
|
1452
1464
|
|
1453
|
-
ndfunc_arg_in_t ain[2] = {{Qnil, 0}, {sym_option}};
|
1454
|
-
ndfunc_arg_out_t aout[1] = {{numo_cRObject, 0}};
|
1455
|
-
ndfunc_t ndf = {iter_scomplex_format, FULL_LOOP_NIP, 2, 1, ain, aout};
|
1465
|
+
ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_option } };
|
1466
|
+
ndfunc_arg_out_t aout[1] = { { numo_cRObject, 0 } };
|
1467
|
+
ndfunc_t ndf = { iter_scomplex_format, FULL_LOOP_NIP, 2, 1, ain, aout };
|
1456
1468
|
|
1457
1469
|
rb_scan_args(argc, argv, "01", &fmt);
|
1458
1470
|
return na_ndloop(&ndf, 2, self, fmt);
|
@@ -1491,14 +1503,14 @@ static void iter_scomplex_format_to_a(na_loop_t* const lp) {
|
|
1491
1503
|
/*
|
1492
1504
|
Format elements into strings.
|
1493
1505
|
@overload format_to_a format
|
1494
|
-
|
1495
|
-
|
1506
|
+
@param [String] format
|
1507
|
+
@return [Array] array of formatted strings.
|
1496
1508
|
*/
|
1497
1509
|
static VALUE scomplex_format_to_a(int argc, VALUE* argv, VALUE self) {
|
1498
1510
|
VALUE fmt = Qnil;
|
1499
|
-
ndfunc_arg_in_t ain[3] = {{Qnil, 0}, {sym_loop_opt}, {sym_option}};
|
1500
|
-
ndfunc_arg_out_t aout[1] = {{rb_cArray, 0}}; // dummy?
|
1501
|
-
ndfunc_t ndf = {iter_scomplex_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout};
|
1511
|
+
ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } };
|
1512
|
+
ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; // dummy?
|
1513
|
+
ndfunc_t ndf = { iter_scomplex_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout };
|
1502
1514
|
|
1503
1515
|
rb_scan_args(argc, argv, "01", &fmt);
|
1504
1516
|
return na_ndloop_cast_narray_to_rarray(&ndf, self, fmt);
|
@@ -1511,7 +1523,7 @@ static VALUE iter_scomplex_inspect(char* ptr, size_t pos, VALUE fmt) {
|
|
1511
1523
|
/*
|
1512
1524
|
Returns a string containing a human-readable representation of NArray.
|
1513
1525
|
@overload inspect
|
1514
|
-
|
1526
|
+
@return [String]
|
1515
1527
|
*/
|
1516
1528
|
static VALUE scomplex_inspect(VALUE ary) {
|
1517
1529
|
return na_ndloop_inspect(ary, iter_scomplex_inspect, Qnil);
|
@@ -1545,15 +1557,15 @@ static void iter_scomplex_each(na_loop_t* const lp) {
|
|
1545
1557
|
Calls the given block once for each element in self,
|
1546
1558
|
passing that element as a parameter.
|
1547
1559
|
@overload each
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1560
|
+
@return [Numo::NArray] self
|
1561
|
+
For a block `{|x| ... }`,
|
1562
|
+
@yieldparam [Numeric] x an element of NArray.
|
1551
1563
|
@see #each_with_index
|
1552
1564
|
@see #map
|
1553
1565
|
*/
|
1554
1566
|
static VALUE scomplex_each(VALUE self) {
|
1555
|
-
ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
|
1556
|
-
ndfunc_t ndf = {iter_scomplex_each, FULL_LOOP_NIP, 1, 0, ain, 0};
|
1567
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1568
|
+
ndfunc_t ndf = { iter_scomplex_each, FULL_LOOP_NIP, 1, 0, ain, 0 };
|
1557
1569
|
|
1558
1570
|
na_ndloop(&ndf, 1, self);
|
1559
1571
|
return self;
|
@@ -1624,12 +1636,12 @@ static void iter_scomplex_map(na_loop_t* const lp) {
|
|
1624
1636
|
/*
|
1625
1637
|
Unary map.
|
1626
1638
|
@overload map
|
1627
|
-
|
1639
|
+
@return [Numo::SComplex] map of self.
|
1628
1640
|
*/
|
1629
1641
|
static VALUE scomplex_map(VALUE self) {
|
1630
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
1631
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1632
|
-
ndfunc_t ndf = {iter_scomplex_map, FULL_LOOP, 1, 1, ain, aout};
|
1642
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
1643
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1644
|
+
ndfunc_t ndf = { iter_scomplex_map, FULL_LOOP, 1, 1, ain, aout };
|
1633
1645
|
|
1634
1646
|
return na_ndloop(&ndf, 1, self);
|
1635
1647
|
}
|
@@ -1683,16 +1695,16 @@ static void iter_scomplex_each_with_index(na_loop_t* const lp) {
|
|
1683
1695
|
Invokes the given block once for each element of self,
|
1684
1696
|
passing that element and indices along each axis as parameters.
|
1685
1697
|
@overload each_with_index
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1698
|
+
For a block `{|x,i,j,...| ... }`,
|
1699
|
+
@yieldparam [Numeric] x an element
|
1700
|
+
@yieldparam [Integer] i,j,... multitimensional indices
|
1701
|
+
@return [Numo::NArray] self
|
1690
1702
|
@see #each
|
1691
1703
|
@see #map_with_index
|
1692
1704
|
*/
|
1693
1705
|
static VALUE scomplex_each_with_index(VALUE self) {
|
1694
|
-
ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
|
1695
|
-
ndfunc_t ndf = {iter_scomplex_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0};
|
1706
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1707
|
+
ndfunc_t ndf = { iter_scomplex_each_with_index, FULL_LOOP_NIP, 1, 0, ain, 0 };
|
1696
1708
|
|
1697
1709
|
na_ndloop_with_index(&ndf, 1, self);
|
1698
1710
|
return self;
|
@@ -1774,17 +1786,17 @@ static void iter_scomplex_map_with_index(na_loop_t* const lp) {
|
|
1774
1786
|
Creates a new NArray containing the values returned by the block.
|
1775
1787
|
Inplace option is allowed, i.e., `nary.inplace.map` overwrites `nary`.
|
1776
1788
|
@overload map_with_index
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
1780
|
-
|
1789
|
+
For a block `{|x,i,j,...| ... }`,
|
1790
|
+
@yieldparam [Numeric] x an element
|
1791
|
+
@yieldparam [Integer] i,j,... multitimensional indices
|
1792
|
+
@return [Numo::NArray] mapped array
|
1781
1793
|
@see #map
|
1782
1794
|
@see #each_with_index
|
1783
1795
|
*/
|
1784
1796
|
static VALUE scomplex_map_with_index(VALUE self) {
|
1785
|
-
ndfunc_arg_in_t ain[1] = {{Qnil, 0}};
|
1786
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1787
|
-
ndfunc_t ndf = {iter_scomplex_map_with_index, FULL_LOOP, 1, 1, ain, aout};
|
1797
|
+
ndfunc_arg_in_t ain[1] = { { Qnil, 0 } };
|
1798
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1799
|
+
ndfunc_t ndf = { iter_scomplex_map_with_index, FULL_LOOP, 1, 1, ain, aout };
|
1788
1800
|
|
1789
1801
|
return na_ndloop_with_index(&ndf, 1, self);
|
1790
1802
|
}
|
@@ -1833,17 +1845,17 @@ static void iter_scomplex_abs(na_loop_t* const lp) {
|
|
1833
1845
|
/*
|
1834
1846
|
abs of self.
|
1835
1847
|
@overload abs
|
1836
|
-
|
1848
|
+
@return [Numo::SFloat] abs of self.
|
1837
1849
|
*/
|
1838
1850
|
static VALUE scomplex_abs(VALUE self) {
|
1839
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
1840
|
-
ndfunc_arg_out_t aout[1] = {{cRT, 0}};
|
1841
|
-
ndfunc_t ndf = {iter_scomplex_abs, FULL_LOOP, 1, 1, ain, aout};
|
1851
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
1852
|
+
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
1853
|
+
ndfunc_t ndf = { iter_scomplex_abs, FULL_LOOP, 1, 1, ain, aout };
|
1842
1854
|
|
1843
1855
|
return na_ndloop(&ndf, 1, self);
|
1844
1856
|
}
|
1845
1857
|
|
1846
|
-
#define check_intdivzero(y)
|
1858
|
+
#define check_intdivzero(y) \
|
1847
1859
|
{}
|
1848
1860
|
|
1849
1861
|
static void iter_scomplex_add(na_loop_t* const lp) {
|
@@ -1858,7 +1870,8 @@ static void iter_scomplex_add(na_loop_t* const lp) {
|
|
1858
1870
|
INIT_PTR(lp, 2, p3, s3);
|
1859
1871
|
|
1860
1872
|
//
|
1861
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
1873
|
+
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
1874
|
+
is_aligned(p3, sizeof(dtype))) {
|
1862
1875
|
|
1863
1876
|
if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
|
1864
1877
|
if (p1 == p3) { // inplace case
|
@@ -1875,7 +1888,8 @@ static void iter_scomplex_add(na_loop_t* const lp) {
|
|
1875
1888
|
return;
|
1876
1889
|
}
|
1877
1890
|
|
1878
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
1891
|
+
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
1892
|
+
is_aligned_step(s3, sizeof(dtype))) {
|
1879
1893
|
//
|
1880
1894
|
|
1881
1895
|
if (s2 == 0) { // Broadcasting from scalar value.
|
@@ -1933,9 +1947,9 @@ static void iter_scomplex_add(na_loop_t* const lp) {
|
|
1933
1947
|
#undef check_intdivzero
|
1934
1948
|
|
1935
1949
|
static VALUE scomplex_add_self(VALUE self, VALUE other) {
|
1936
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
1937
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
1938
|
-
ndfunc_t ndf = {iter_scomplex_add, STRIDE_LOOP, 2, 1, ain, aout};
|
1950
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
1951
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
1952
|
+
ndfunc_t ndf = { iter_scomplex_add, STRIDE_LOOP, 2, 1, ain, aout };
|
1939
1953
|
|
1940
1954
|
return na_ndloop(&ndf, 2, self, other);
|
1941
1955
|
}
|
@@ -1943,8 +1957,8 @@ static VALUE scomplex_add_self(VALUE self, VALUE other) {
|
|
1943
1957
|
/*
|
1944
1958
|
Binary add.
|
1945
1959
|
@overload + other
|
1946
|
-
|
1947
|
-
|
1960
|
+
@param [Numo::NArray,Numeric] other
|
1961
|
+
@return [Numo::NArray] self + other
|
1948
1962
|
*/
|
1949
1963
|
static VALUE scomplex_add(VALUE self, VALUE other) {
|
1950
1964
|
|
@@ -1959,7 +1973,7 @@ static VALUE scomplex_add(VALUE self, VALUE other) {
|
|
1959
1973
|
}
|
1960
1974
|
}
|
1961
1975
|
|
1962
|
-
#define check_intdivzero(y)
|
1976
|
+
#define check_intdivzero(y) \
|
1963
1977
|
{}
|
1964
1978
|
|
1965
1979
|
static void iter_scomplex_sub(na_loop_t* const lp) {
|
@@ -1974,7 +1988,8 @@ static void iter_scomplex_sub(na_loop_t* const lp) {
|
|
1974
1988
|
INIT_PTR(lp, 2, p3, s3);
|
1975
1989
|
|
1976
1990
|
//
|
1977
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
1991
|
+
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
1992
|
+
is_aligned(p3, sizeof(dtype))) {
|
1978
1993
|
|
1979
1994
|
if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
|
1980
1995
|
if (p1 == p3) { // inplace case
|
@@ -1991,7 +2006,8 @@ static void iter_scomplex_sub(na_loop_t* const lp) {
|
|
1991
2006
|
return;
|
1992
2007
|
}
|
1993
2008
|
|
1994
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
2009
|
+
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
2010
|
+
is_aligned_step(s3, sizeof(dtype))) {
|
1995
2011
|
//
|
1996
2012
|
|
1997
2013
|
if (s2 == 0) { // Broadcasting from scalar value.
|
@@ -2049,9 +2065,9 @@ static void iter_scomplex_sub(na_loop_t* const lp) {
|
|
2049
2065
|
#undef check_intdivzero
|
2050
2066
|
|
2051
2067
|
static VALUE scomplex_sub_self(VALUE self, VALUE other) {
|
2052
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2053
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2054
|
-
ndfunc_t ndf = {iter_scomplex_sub, STRIDE_LOOP, 2, 1, ain, aout};
|
2068
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2069
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2070
|
+
ndfunc_t ndf = { iter_scomplex_sub, STRIDE_LOOP, 2, 1, ain, aout };
|
2055
2071
|
|
2056
2072
|
return na_ndloop(&ndf, 2, self, other);
|
2057
2073
|
}
|
@@ -2059,8 +2075,8 @@ static VALUE scomplex_sub_self(VALUE self, VALUE other) {
|
|
2059
2075
|
/*
|
2060
2076
|
Binary sub.
|
2061
2077
|
@overload - other
|
2062
|
-
|
2063
|
-
|
2078
|
+
@param [Numo::NArray,Numeric] other
|
2079
|
+
@return [Numo::NArray] self - other
|
2064
2080
|
*/
|
2065
2081
|
static VALUE scomplex_sub(VALUE self, VALUE other) {
|
2066
2082
|
|
@@ -2075,7 +2091,7 @@ static VALUE scomplex_sub(VALUE self, VALUE other) {
|
|
2075
2091
|
}
|
2076
2092
|
}
|
2077
2093
|
|
2078
|
-
#define check_intdivzero(y)
|
2094
|
+
#define check_intdivzero(y) \
|
2079
2095
|
{}
|
2080
2096
|
|
2081
2097
|
static void iter_scomplex_mul(na_loop_t* const lp) {
|
@@ -2090,7 +2106,8 @@ static void iter_scomplex_mul(na_loop_t* const lp) {
|
|
2090
2106
|
INIT_PTR(lp, 2, p3, s3);
|
2091
2107
|
|
2092
2108
|
//
|
2093
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
2109
|
+
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
2110
|
+
is_aligned(p3, sizeof(dtype))) {
|
2094
2111
|
|
2095
2112
|
if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
|
2096
2113
|
if (p1 == p3) { // inplace case
|
@@ -2107,7 +2124,8 @@ static void iter_scomplex_mul(na_loop_t* const lp) {
|
|
2107
2124
|
return;
|
2108
2125
|
}
|
2109
2126
|
|
2110
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
2127
|
+
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
2128
|
+
is_aligned_step(s3, sizeof(dtype))) {
|
2111
2129
|
//
|
2112
2130
|
|
2113
2131
|
if (s2 == 0) { // Broadcasting from scalar value.
|
@@ -2165,9 +2183,9 @@ static void iter_scomplex_mul(na_loop_t* const lp) {
|
|
2165
2183
|
#undef check_intdivzero
|
2166
2184
|
|
2167
2185
|
static VALUE scomplex_mul_self(VALUE self, VALUE other) {
|
2168
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2169
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2170
|
-
ndfunc_t ndf = {iter_scomplex_mul, STRIDE_LOOP, 2, 1, ain, aout};
|
2186
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2187
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2188
|
+
ndfunc_t ndf = { iter_scomplex_mul, STRIDE_LOOP, 2, 1, ain, aout };
|
2171
2189
|
|
2172
2190
|
return na_ndloop(&ndf, 2, self, other);
|
2173
2191
|
}
|
@@ -2175,8 +2193,8 @@ static VALUE scomplex_mul_self(VALUE self, VALUE other) {
|
|
2175
2193
|
/*
|
2176
2194
|
Binary mul.
|
2177
2195
|
@overload * other
|
2178
|
-
|
2179
|
-
|
2196
|
+
@param [Numo::NArray,Numeric] other
|
2197
|
+
@return [Numo::NArray] self * other
|
2180
2198
|
*/
|
2181
2199
|
static VALUE scomplex_mul(VALUE self, VALUE other) {
|
2182
2200
|
|
@@ -2191,7 +2209,7 @@ static VALUE scomplex_mul(VALUE self, VALUE other) {
|
|
2191
2209
|
}
|
2192
2210
|
}
|
2193
2211
|
|
2194
|
-
#define check_intdivzero(y)
|
2212
|
+
#define check_intdivzero(y) \
|
2195
2213
|
{}
|
2196
2214
|
|
2197
2215
|
static void iter_scomplex_div(na_loop_t* const lp) {
|
@@ -2206,7 +2224,8 @@ static void iter_scomplex_div(na_loop_t* const lp) {
|
|
2206
2224
|
INIT_PTR(lp, 2, p3, s3);
|
2207
2225
|
|
2208
2226
|
//
|
2209
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
2227
|
+
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
2228
|
+
is_aligned(p3, sizeof(dtype))) {
|
2210
2229
|
|
2211
2230
|
if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
|
2212
2231
|
if (p1 == p3) { // inplace case
|
@@ -2223,7 +2242,8 @@ static void iter_scomplex_div(na_loop_t* const lp) {
|
|
2223
2242
|
return;
|
2224
2243
|
}
|
2225
2244
|
|
2226
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
2245
|
+
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
2246
|
+
is_aligned_step(s3, sizeof(dtype))) {
|
2227
2247
|
//
|
2228
2248
|
|
2229
2249
|
if (s2 == 0) { // Broadcasting from scalar value.
|
@@ -2281,9 +2301,9 @@ static void iter_scomplex_div(na_loop_t* const lp) {
|
|
2281
2301
|
#undef check_intdivzero
|
2282
2302
|
|
2283
2303
|
static VALUE scomplex_div_self(VALUE self, VALUE other) {
|
2284
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2285
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2286
|
-
ndfunc_t ndf = {iter_scomplex_div, STRIDE_LOOP, 2, 1, ain, aout};
|
2304
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2305
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2306
|
+
ndfunc_t ndf = { iter_scomplex_div, STRIDE_LOOP, 2, 1, ain, aout };
|
2287
2307
|
|
2288
2308
|
return na_ndloop(&ndf, 2, self, other);
|
2289
2309
|
}
|
@@ -2291,8 +2311,8 @@ static VALUE scomplex_div_self(VALUE self, VALUE other) {
|
|
2291
2311
|
/*
|
2292
2312
|
Binary div.
|
2293
2313
|
@overload / other
|
2294
|
-
|
2295
|
-
|
2314
|
+
@param [Numo::NArray,Numeric] other
|
2315
|
+
@return [Numo::NArray] self / other
|
2296
2316
|
*/
|
2297
2317
|
static VALUE scomplex_div(VALUE self, VALUE other) {
|
2298
2318
|
|
@@ -2343,11 +2363,11 @@ static void iter_scomplex_pow_int32(na_loop_t* const lp) {
|
|
2343
2363
|
}
|
2344
2364
|
|
2345
2365
|
static VALUE scomplex_pow_self(VALUE self, VALUE other) {
|
2346
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
2347
|
-
ndfunc_arg_in_t ain_i[2] = {{cT, 0}, {numo_cInt32, 0}};
|
2348
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2349
|
-
ndfunc_t ndf = {iter_scomplex_pow, STRIDE_LOOP, 2, 1, ain, aout};
|
2350
|
-
ndfunc_t ndf_i = {iter_scomplex_pow_int32, STRIDE_LOOP, 2, 1, ain_i, aout};
|
2366
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
2367
|
+
ndfunc_arg_in_t ain_i[2] = { { cT, 0 }, { numo_cInt32, 0 } };
|
2368
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2369
|
+
ndfunc_t ndf = { iter_scomplex_pow, STRIDE_LOOP, 2, 1, ain, aout };
|
2370
|
+
ndfunc_t ndf_i = { iter_scomplex_pow_int32, STRIDE_LOOP, 2, 1, ain_i, aout };
|
2351
2371
|
|
2352
2372
|
// fixme : use na.integer?
|
2353
2373
|
if (FIXNUM_P(other) || rb_obj_is_kind_of(other, numo_cInt32)) {
|
@@ -2360,8 +2380,8 @@ static VALUE scomplex_pow_self(VALUE self, VALUE other) {
|
|
2360
2380
|
/*
|
2361
2381
|
Binary power.
|
2362
2382
|
@overload ** other
|
2363
|
-
|
2364
|
-
|
2383
|
+
@param [Numo::NArray,Numeric] other
|
2384
|
+
@return [Numo::NArray] self to the other-th power.
|
2365
2385
|
*/
|
2366
2386
|
static VALUE scomplex_pow(VALUE self, VALUE other) {
|
2367
2387
|
|
@@ -2440,12 +2460,12 @@ static void iter_scomplex_minus(na_loop_t* const lp) {
|
|
2440
2460
|
/*
|
2441
2461
|
Unary minus.
|
2442
2462
|
@overload -@
|
2443
|
-
|
2463
|
+
@return [Numo::SComplex] minus of self.
|
2444
2464
|
*/
|
2445
2465
|
static VALUE scomplex_minus(VALUE self) {
|
2446
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2447
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2448
|
-
ndfunc_t ndf = {iter_scomplex_minus, FULL_LOOP, 1, 1, ain, aout};
|
2466
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2467
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2468
|
+
ndfunc_t ndf = { iter_scomplex_minus, FULL_LOOP, 1, 1, ain, aout };
|
2449
2469
|
|
2450
2470
|
return na_ndloop(&ndf, 1, self);
|
2451
2471
|
}
|
@@ -2515,12 +2535,12 @@ static void iter_scomplex_reciprocal(na_loop_t* const lp) {
|
|
2515
2535
|
/*
|
2516
2536
|
Unary reciprocal.
|
2517
2537
|
@overload reciprocal
|
2518
|
-
|
2538
|
+
@return [Numo::SComplex] reciprocal of self.
|
2519
2539
|
*/
|
2520
2540
|
static VALUE scomplex_reciprocal(VALUE self) {
|
2521
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2522
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2523
|
-
ndfunc_t ndf = {iter_scomplex_reciprocal, FULL_LOOP, 1, 1, ain, aout};
|
2541
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2542
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2543
|
+
ndfunc_t ndf = { iter_scomplex_reciprocal, FULL_LOOP, 1, 1, ain, aout };
|
2524
2544
|
|
2525
2545
|
return na_ndloop(&ndf, 1, self);
|
2526
2546
|
}
|
@@ -2590,12 +2610,12 @@ static void iter_scomplex_sign(na_loop_t* const lp) {
|
|
2590
2610
|
/*
|
2591
2611
|
Unary sign.
|
2592
2612
|
@overload sign
|
2593
|
-
|
2613
|
+
@return [Numo::SComplex] sign of self.
|
2594
2614
|
*/
|
2595
2615
|
static VALUE scomplex_sign(VALUE self) {
|
2596
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2597
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2598
|
-
ndfunc_t ndf = {iter_scomplex_sign, FULL_LOOP, 1, 1, ain, aout};
|
2616
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2617
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2618
|
+
ndfunc_t ndf = { iter_scomplex_sign, FULL_LOOP, 1, 1, ain, aout };
|
2599
2619
|
|
2600
2620
|
return na_ndloop(&ndf, 1, self);
|
2601
2621
|
}
|
@@ -2665,12 +2685,12 @@ static void iter_scomplex_square(na_loop_t* const lp) {
|
|
2665
2685
|
/*
|
2666
2686
|
Unary square.
|
2667
2687
|
@overload square
|
2668
|
-
|
2688
|
+
@return [Numo::SComplex] square of self.
|
2669
2689
|
*/
|
2670
2690
|
static VALUE scomplex_square(VALUE self) {
|
2671
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2672
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2673
|
-
ndfunc_t ndf = {iter_scomplex_square, FULL_LOOP, 1, 1, ain, aout};
|
2691
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2692
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2693
|
+
ndfunc_t ndf = { iter_scomplex_square, FULL_LOOP, 1, 1, ain, aout };
|
2674
2694
|
|
2675
2695
|
return na_ndloop(&ndf, 1, self);
|
2676
2696
|
}
|
@@ -2740,12 +2760,12 @@ static void iter_scomplex_conj(na_loop_t* const lp) {
|
|
2740
2760
|
/*
|
2741
2761
|
Unary conj.
|
2742
2762
|
@overload conj
|
2743
|
-
|
2763
|
+
@return [Numo::SComplex] conj of self.
|
2744
2764
|
*/
|
2745
2765
|
static VALUE scomplex_conj(VALUE self) {
|
2746
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2747
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2748
|
-
ndfunc_t ndf = {iter_scomplex_conj, FULL_LOOP, 1, 1, ain, aout};
|
2766
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2767
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2768
|
+
ndfunc_t ndf = { iter_scomplex_conj, FULL_LOOP, 1, 1, ain, aout };
|
2749
2769
|
|
2750
2770
|
return na_ndloop(&ndf, 1, self);
|
2751
2771
|
}
|
@@ -2815,12 +2835,12 @@ static void iter_scomplex_im(na_loop_t* const lp) {
|
|
2815
2835
|
/*
|
2816
2836
|
Unary im.
|
2817
2837
|
@overload im
|
2818
|
-
|
2838
|
+
@return [Numo::SComplex] im of self.
|
2819
2839
|
*/
|
2820
2840
|
static VALUE scomplex_im(VALUE self) {
|
2821
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2822
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
2823
|
-
ndfunc_t ndf = {iter_scomplex_im, FULL_LOOP, 1, 1, ain, aout};
|
2841
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2842
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
2843
|
+
ndfunc_t ndf = { iter_scomplex_im, FULL_LOOP, 1, 1, ain, aout };
|
2824
2844
|
|
2825
2845
|
return na_ndloop(&ndf, 1, self);
|
2826
2846
|
}
|
@@ -2869,12 +2889,12 @@ static void iter_scomplex_real(na_loop_t* const lp) {
|
|
2869
2889
|
/*
|
2870
2890
|
real of self.
|
2871
2891
|
@overload real
|
2872
|
-
|
2892
|
+
@return [Numo::SFloat] real of self.
|
2873
2893
|
*/
|
2874
2894
|
static VALUE scomplex_real(VALUE self) {
|
2875
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2876
|
-
ndfunc_arg_out_t aout[1] = {{cRT, 0}};
|
2877
|
-
ndfunc_t ndf = {iter_scomplex_real, FULL_LOOP, 1, 1, ain, aout};
|
2895
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2896
|
+
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
2897
|
+
ndfunc_t ndf = { iter_scomplex_real, FULL_LOOP, 1, 1, ain, aout };
|
2878
2898
|
|
2879
2899
|
return na_ndloop(&ndf, 1, self);
|
2880
2900
|
}
|
@@ -2923,12 +2943,12 @@ static void iter_scomplex_imag(na_loop_t* const lp) {
|
|
2923
2943
|
/*
|
2924
2944
|
imag of self.
|
2925
2945
|
@overload imag
|
2926
|
-
|
2946
|
+
@return [Numo::SFloat] imag of self.
|
2927
2947
|
*/
|
2928
2948
|
static VALUE scomplex_imag(VALUE self) {
|
2929
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2930
|
-
ndfunc_arg_out_t aout[1] = {{cRT, 0}};
|
2931
|
-
ndfunc_t ndf = {iter_scomplex_imag, FULL_LOOP, 1, 1, ain, aout};
|
2949
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
2950
|
+
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
2951
|
+
ndfunc_t ndf = { iter_scomplex_imag, FULL_LOOP, 1, 1, ain, aout };
|
2932
2952
|
|
2933
2953
|
return na_ndloop(&ndf, 1, self);
|
2934
2954
|
}
|
@@ -2977,12 +2997,12 @@ static void iter_scomplex_arg(na_loop_t* const lp) {
|
|
2977
2997
|
/*
|
2978
2998
|
arg of self.
|
2979
2999
|
@overload arg
|
2980
|
-
|
3000
|
+
@return [Numo::SFloat] arg of self.
|
2981
3001
|
*/
|
2982
3002
|
static VALUE scomplex_arg(VALUE self) {
|
2983
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
2984
|
-
ndfunc_arg_out_t aout[1] = {{cRT, 0}};
|
2985
|
-
ndfunc_t ndf = {iter_scomplex_arg, FULL_LOOP, 1, 1, ain, aout};
|
3003
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3004
|
+
ndfunc_arg_out_t aout[1] = { { cRT, 0 } };
|
3005
|
+
ndfunc_t ndf = { iter_scomplex_arg, FULL_LOOP, 1, 1, ain, aout };
|
2986
3006
|
|
2987
3007
|
return na_ndloop(&ndf, 1, self);
|
2988
3008
|
}
|
@@ -3033,8 +3053,8 @@ static void iter_scomplex_set_imag(na_loop_t* const lp) {
|
|
3033
3053
|
}
|
3034
3054
|
|
3035
3055
|
static VALUE scomplex_set_imag(VALUE self, VALUE a1) {
|
3036
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {cRT, 0}};
|
3037
|
-
ndfunc_t ndf = {iter_scomplex_set_imag, FULL_LOOP, 2, 0, ain, 0};
|
3056
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { cRT, 0 } };
|
3057
|
+
ndfunc_t ndf = { iter_scomplex_set_imag, FULL_LOOP, 2, 0, ain, 0 };
|
3038
3058
|
|
3039
3059
|
na_ndloop(&ndf, 2, self, a1);
|
3040
3060
|
return a1;
|
@@ -3086,8 +3106,8 @@ static void iter_scomplex_set_real(na_loop_t* const lp) {
|
|
3086
3106
|
}
|
3087
3107
|
|
3088
3108
|
static VALUE scomplex_set_real(VALUE self, VALUE a1) {
|
3089
|
-
ndfunc_arg_in_t ain[2] = {{OVERWRITE, 0}, {cRT, 0}};
|
3090
|
-
ndfunc_t ndf = {iter_scomplex_set_real, FULL_LOOP, 2, 0, ain, 0};
|
3109
|
+
ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { cRT, 0 } };
|
3110
|
+
ndfunc_t ndf = { iter_scomplex_set_real, FULL_LOOP, 2, 0, ain, 0 };
|
3091
3111
|
|
3092
3112
|
na_ndloop(&ndf, 2, self, a1);
|
3093
3113
|
return a1;
|
@@ -3115,9 +3135,9 @@ static void iter_scomplex_eq(na_loop_t* const lp) {
|
|
3115
3135
|
}
|
3116
3136
|
|
3117
3137
|
static VALUE scomplex_eq_self(VALUE self, VALUE other) {
|
3118
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3119
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3120
|
-
ndfunc_t ndf = {iter_scomplex_eq, STRIDE_LOOP, 2, 1, ain, aout};
|
3138
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3139
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3140
|
+
ndfunc_t ndf = { iter_scomplex_eq, STRIDE_LOOP, 2, 1, ain, aout };
|
3121
3141
|
|
3122
3142
|
return na_ndloop(&ndf, 2, self, other);
|
3123
3143
|
}
|
@@ -3125,8 +3145,8 @@ static VALUE scomplex_eq_self(VALUE self, VALUE other) {
|
|
3125
3145
|
/*
|
3126
3146
|
Comparison eq other.
|
3127
3147
|
@overload eq other
|
3128
|
-
|
3129
|
-
|
3148
|
+
@param [Numo::NArray,Numeric] other
|
3149
|
+
@return [Numo::Bit] result of self eq other.
|
3130
3150
|
*/
|
3131
3151
|
static VALUE scomplex_eq(VALUE self, VALUE other) {
|
3132
3152
|
|
@@ -3162,9 +3182,9 @@ static void iter_scomplex_ne(na_loop_t* const lp) {
|
|
3162
3182
|
}
|
3163
3183
|
|
3164
3184
|
static VALUE scomplex_ne_self(VALUE self, VALUE other) {
|
3165
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3166
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3167
|
-
ndfunc_t ndf = {iter_scomplex_ne, STRIDE_LOOP, 2, 1, ain, aout};
|
3185
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3186
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3187
|
+
ndfunc_t ndf = { iter_scomplex_ne, STRIDE_LOOP, 2, 1, ain, aout };
|
3168
3188
|
|
3169
3189
|
return na_ndloop(&ndf, 2, self, other);
|
3170
3190
|
}
|
@@ -3172,8 +3192,8 @@ static VALUE scomplex_ne_self(VALUE self, VALUE other) {
|
|
3172
3192
|
/*
|
3173
3193
|
Comparison ne other.
|
3174
3194
|
@overload ne other
|
3175
|
-
|
3176
|
-
|
3195
|
+
@param [Numo::NArray,Numeric] other
|
3196
|
+
@return [Numo::Bit] result of self ne other.
|
3177
3197
|
*/
|
3178
3198
|
static VALUE scomplex_ne(VALUE self, VALUE other) {
|
3179
3199
|
|
@@ -3209,9 +3229,9 @@ static void iter_scomplex_nearly_eq(na_loop_t* const lp) {
|
|
3209
3229
|
}
|
3210
3230
|
|
3211
3231
|
static VALUE scomplex_nearly_eq_self(VALUE self, VALUE other) {
|
3212
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3213
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3214
|
-
ndfunc_t ndf = {iter_scomplex_nearly_eq, STRIDE_LOOP, 2, 1, ain, aout};
|
3232
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3233
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3234
|
+
ndfunc_t ndf = { iter_scomplex_nearly_eq, STRIDE_LOOP, 2, 1, ain, aout };
|
3215
3235
|
|
3216
3236
|
return na_ndloop(&ndf, 2, self, other);
|
3217
3237
|
}
|
@@ -3219,8 +3239,8 @@ static VALUE scomplex_nearly_eq_self(VALUE self, VALUE other) {
|
|
3219
3239
|
/*
|
3220
3240
|
Comparison nearly_eq other.
|
3221
3241
|
@overload nearly_eq other
|
3222
|
-
|
3223
|
-
|
3242
|
+
@param [Numo::NArray,Numeric] other
|
3243
|
+
@return [Numo::Bit] result of self nearly_eq other.
|
3224
3244
|
*/
|
3225
3245
|
static VALUE scomplex_nearly_eq(VALUE self, VALUE other) {
|
3226
3246
|
|
@@ -3299,12 +3319,12 @@ static void iter_scomplex_floor(na_loop_t* const lp) {
|
|
3299
3319
|
/*
|
3300
3320
|
Unary floor.
|
3301
3321
|
@overload floor
|
3302
|
-
|
3322
|
+
@return [Numo::SComplex] floor of self.
|
3303
3323
|
*/
|
3304
3324
|
static VALUE scomplex_floor(VALUE self) {
|
3305
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3306
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3307
|
-
ndfunc_t ndf = {iter_scomplex_floor, FULL_LOOP, 1, 1, ain, aout};
|
3325
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3326
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3327
|
+
ndfunc_t ndf = { iter_scomplex_floor, FULL_LOOP, 1, 1, ain, aout };
|
3308
3328
|
|
3309
3329
|
return na_ndloop(&ndf, 1, self);
|
3310
3330
|
}
|
@@ -3374,12 +3394,12 @@ static void iter_scomplex_round(na_loop_t* const lp) {
|
|
3374
3394
|
/*
|
3375
3395
|
Unary round.
|
3376
3396
|
@overload round
|
3377
|
-
|
3397
|
+
@return [Numo::SComplex] round of self.
|
3378
3398
|
*/
|
3379
3399
|
static VALUE scomplex_round(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_scomplex_round, FULL_LOOP, 1, 1, ain, aout};
|
3400
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3401
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3402
|
+
ndfunc_t ndf = { iter_scomplex_round, FULL_LOOP, 1, 1, ain, aout };
|
3383
3403
|
|
3384
3404
|
return na_ndloop(&ndf, 1, self);
|
3385
3405
|
}
|
@@ -3449,12 +3469,12 @@ static void iter_scomplex_ceil(na_loop_t* const lp) {
|
|
3449
3469
|
/*
|
3450
3470
|
Unary ceil.
|
3451
3471
|
@overload ceil
|
3452
|
-
|
3472
|
+
@return [Numo::SComplex] ceil of self.
|
3453
3473
|
*/
|
3454
3474
|
static VALUE scomplex_ceil(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_scomplex_ceil, FULL_LOOP, 1, 1, ain, aout};
|
3475
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3476
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3477
|
+
ndfunc_t ndf = { iter_scomplex_ceil, FULL_LOOP, 1, 1, ain, aout };
|
3458
3478
|
|
3459
3479
|
return na_ndloop(&ndf, 1, self);
|
3460
3480
|
}
|
@@ -3524,12 +3544,12 @@ static void iter_scomplex_trunc(na_loop_t* const lp) {
|
|
3524
3544
|
/*
|
3525
3545
|
Unary trunc.
|
3526
3546
|
@overload trunc
|
3527
|
-
|
3547
|
+
@return [Numo::SComplex] trunc of self.
|
3528
3548
|
*/
|
3529
3549
|
static VALUE scomplex_trunc(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_scomplex_trunc, FULL_LOOP, 1, 1, ain, aout};
|
3550
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3551
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3552
|
+
ndfunc_t ndf = { iter_scomplex_trunc, FULL_LOOP, 1, 1, ain, aout };
|
3533
3553
|
|
3534
3554
|
return na_ndloop(&ndf, 1, self);
|
3535
3555
|
}
|
@@ -3599,17 +3619,17 @@ static void iter_scomplex_rint(na_loop_t* const lp) {
|
|
3599
3619
|
/*
|
3600
3620
|
Unary rint.
|
3601
3621
|
@overload rint
|
3602
|
-
|
3622
|
+
@return [Numo::SComplex] rint of self.
|
3603
3623
|
*/
|
3604
3624
|
static VALUE scomplex_rint(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_scomplex_rint, FULL_LOOP, 1, 1, ain, aout};
|
3625
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3626
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3627
|
+
ndfunc_t ndf = { iter_scomplex_rint, FULL_LOOP, 1, 1, ain, aout };
|
3608
3628
|
|
3609
3629
|
return na_ndloop(&ndf, 1, self);
|
3610
3630
|
}
|
3611
3631
|
|
3612
|
-
#define check_intdivzero(y)
|
3632
|
+
#define check_intdivzero(y) \
|
3613
3633
|
{}
|
3614
3634
|
|
3615
3635
|
static void iter_scomplex_copysign(na_loop_t* const lp) {
|
@@ -3624,7 +3644,8 @@ static void iter_scomplex_copysign(na_loop_t* const lp) {
|
|
3624
3644
|
INIT_PTR(lp, 2, p3, s3);
|
3625
3645
|
|
3626
3646
|
//
|
3627
|
-
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
3647
|
+
if (is_aligned(p1, sizeof(dtype)) && is_aligned(p2, sizeof(dtype)) &&
|
3648
|
+
is_aligned(p3, sizeof(dtype))) {
|
3628
3649
|
|
3629
3650
|
if (s1 == sizeof(dtype) && s2 == sizeof(dtype) && s3 == sizeof(dtype)) {
|
3630
3651
|
if (p1 == p3) { // inplace case
|
@@ -3641,7 +3662,8 @@ static void iter_scomplex_copysign(na_loop_t* const lp) {
|
|
3641
3662
|
return;
|
3642
3663
|
}
|
3643
3664
|
|
3644
|
-
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
3665
|
+
if (is_aligned_step(s1, sizeof(dtype)) && is_aligned_step(s2, sizeof(dtype)) &&
|
3666
|
+
is_aligned_step(s3, sizeof(dtype))) {
|
3645
3667
|
//
|
3646
3668
|
|
3647
3669
|
if (s2 == 0) { // Broadcasting from scalar value.
|
@@ -3699,9 +3721,9 @@ static void iter_scomplex_copysign(na_loop_t* const lp) {
|
|
3699
3721
|
#undef check_intdivzero
|
3700
3722
|
|
3701
3723
|
static VALUE scomplex_copysign_self(VALUE self, VALUE other) {
|
3702
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {cT, 0}};
|
3703
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3704
|
-
ndfunc_t ndf = {iter_scomplex_copysign, STRIDE_LOOP, 2, 1, ain, aout};
|
3724
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { cT, 0 } };
|
3725
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3726
|
+
ndfunc_t ndf = { iter_scomplex_copysign, STRIDE_LOOP, 2, 1, ain, aout };
|
3705
3727
|
|
3706
3728
|
return na_ndloop(&ndf, 2, self, other);
|
3707
3729
|
}
|
@@ -3709,8 +3731,8 @@ static VALUE scomplex_copysign_self(VALUE self, VALUE other) {
|
|
3709
3731
|
/*
|
3710
3732
|
Binary copysign.
|
3711
3733
|
@overload copysign other
|
3712
|
-
|
3713
|
-
|
3734
|
+
@param [Numo::NArray,Numeric] other
|
3735
|
+
@return [Numo::NArray] self copysign other
|
3714
3736
|
*/
|
3715
3737
|
static VALUE scomplex_copysign(VALUE self, VALUE other) {
|
3716
3738
|
|
@@ -3757,12 +3779,12 @@ static void iter_scomplex_isnan(na_loop_t* const lp) {
|
|
3757
3779
|
/*
|
3758
3780
|
Condition of isnan.
|
3759
3781
|
@overload isnan
|
3760
|
-
|
3782
|
+
@return [Numo::Bit] Condition of isnan.
|
3761
3783
|
*/
|
3762
3784
|
static VALUE scomplex_isnan(VALUE self) {
|
3763
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3764
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3765
|
-
ndfunc_t ndf = {iter_scomplex_isnan, FULL_LOOP, 1, 1, ain, aout};
|
3785
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3786
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3787
|
+
ndfunc_t ndf = { iter_scomplex_isnan, FULL_LOOP, 1, 1, ain, aout };
|
3766
3788
|
|
3767
3789
|
return na_ndloop(&ndf, 1, self);
|
3768
3790
|
}
|
@@ -3799,12 +3821,12 @@ static void iter_scomplex_isinf(na_loop_t* const lp) {
|
|
3799
3821
|
/*
|
3800
3822
|
Condition of isinf.
|
3801
3823
|
@overload isinf
|
3802
|
-
|
3824
|
+
@return [Numo::Bit] Condition of isinf.
|
3803
3825
|
*/
|
3804
3826
|
static VALUE scomplex_isinf(VALUE self) {
|
3805
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3806
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3807
|
-
ndfunc_t ndf = {iter_scomplex_isinf, FULL_LOOP, 1, 1, ain, aout};
|
3827
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3828
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3829
|
+
ndfunc_t ndf = { iter_scomplex_isinf, FULL_LOOP, 1, 1, ain, aout };
|
3808
3830
|
|
3809
3831
|
return na_ndloop(&ndf, 1, self);
|
3810
3832
|
}
|
@@ -3841,12 +3863,12 @@ static void iter_scomplex_isposinf(na_loop_t* const lp) {
|
|
3841
3863
|
/*
|
3842
3864
|
Condition of isposinf.
|
3843
3865
|
@overload isposinf
|
3844
|
-
|
3866
|
+
@return [Numo::Bit] Condition of isposinf.
|
3845
3867
|
*/
|
3846
3868
|
static VALUE scomplex_isposinf(VALUE self) {
|
3847
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3848
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3849
|
-
ndfunc_t ndf = {iter_scomplex_isposinf, FULL_LOOP, 1, 1, ain, aout};
|
3869
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3870
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3871
|
+
ndfunc_t ndf = { iter_scomplex_isposinf, FULL_LOOP, 1, 1, ain, aout };
|
3850
3872
|
|
3851
3873
|
return na_ndloop(&ndf, 1, self);
|
3852
3874
|
}
|
@@ -3883,12 +3905,12 @@ static void iter_scomplex_isneginf(na_loop_t* const lp) {
|
|
3883
3905
|
/*
|
3884
3906
|
Condition of isneginf.
|
3885
3907
|
@overload isneginf
|
3886
|
-
|
3908
|
+
@return [Numo::Bit] Condition of isneginf.
|
3887
3909
|
*/
|
3888
3910
|
static VALUE scomplex_isneginf(VALUE self) {
|
3889
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3890
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3891
|
-
ndfunc_t ndf = {iter_scomplex_isneginf, FULL_LOOP, 1, 1, ain, aout};
|
3911
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3912
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3913
|
+
ndfunc_t ndf = { iter_scomplex_isneginf, FULL_LOOP, 1, 1, ain, aout };
|
3892
3914
|
|
3893
3915
|
return na_ndloop(&ndf, 1, self);
|
3894
3916
|
}
|
@@ -3925,12 +3947,12 @@ static void iter_scomplex_isfinite(na_loop_t* const lp) {
|
|
3925
3947
|
/*
|
3926
3948
|
Condition of isfinite.
|
3927
3949
|
@overload isfinite
|
3928
|
-
|
3950
|
+
@return [Numo::Bit] Condition of isfinite.
|
3929
3951
|
*/
|
3930
3952
|
static VALUE scomplex_isfinite(VALUE self) {
|
3931
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
3932
|
-
ndfunc_arg_out_t aout[1] = {{numo_cBit, 0}};
|
3933
|
-
ndfunc_t ndf = {iter_scomplex_isfinite, FULL_LOOP, 1, 1, ain, aout};
|
3953
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
3954
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } };
|
3955
|
+
ndfunc_t ndf = { iter_scomplex_isfinite, FULL_LOOP, 1, 1, ain, aout };
|
3934
3956
|
|
3935
3957
|
return na_ndloop(&ndf, 1, self);
|
3936
3958
|
}
|
@@ -3961,16 +3983,18 @@ static void iter_scomplex_sum_nan(na_loop_t* const lp) {
|
|
3961
3983
|
/*
|
3962
3984
|
sum of self.
|
3963
3985
|
@overload sum(axis:nil, keepdims:false, nan:false)
|
3964
|
-
|
3965
|
-
|
3966
|
-
|
3967
|
-
|
3986
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
3987
|
+
return NaN for min/max etc).
|
3988
|
+
@param [Numeric,Array,Range] axis Performs sum along the axis.
|
3989
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
3990
|
+
dimensions with size one.
|
3991
|
+
@return [Numo::SComplex] returns result of sum.
|
3968
3992
|
*/
|
3969
3993
|
static VALUE scomplex_sum(int argc, VALUE* argv, VALUE self) {
|
3970
3994
|
VALUE v, reduce;
|
3971
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
3972
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
3973
|
-
ndfunc_t ndf = {iter_scomplex_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
3995
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
3996
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
3997
|
+
ndfunc_t ndf = { iter_scomplex_sum, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
3974
3998
|
|
3975
3999
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_scomplex_sum_nan);
|
3976
4000
|
|
@@ -4005,16 +4029,18 @@ static void iter_scomplex_prod_nan(na_loop_t* const lp) {
|
|
4005
4029
|
/*
|
4006
4030
|
prod of self.
|
4007
4031
|
@overload prod(axis:nil, keepdims:false, nan:false)
|
4008
|
-
|
4009
|
-
|
4010
|
-
|
4011
|
-
|
4032
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or,
|
4033
|
+
return NaN for min/max etc).
|
4034
|
+
@param [Numeric,Array,Range] axis Performs prod along the axis.
|
4035
|
+
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as
|
4036
|
+
dimensions with size one.
|
4037
|
+
@return [Numo::SComplex] returns result of prod.
|
4012
4038
|
*/
|
4013
4039
|
static VALUE scomplex_prod(int argc, VALUE* argv, VALUE self) {
|
4014
4040
|
VALUE v, reduce;
|
4015
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4016
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4017
|
-
ndfunc_t ndf = {iter_scomplex_prod, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
4041
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4042
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4043
|
+
ndfunc_t ndf = { iter_scomplex_prod, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout };
|
4018
4044
|
|
4019
4045
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_scomplex_prod_nan);
|
4020
4046
|
|
@@ -4023,182 +4049,6 @@ static VALUE scomplex_prod(int argc, VALUE* argv, VALUE self) {
|
|
4023
4049
|
return scomplex_extract(v);
|
4024
4050
|
}
|
4025
4051
|
|
4026
|
-
static void iter_scomplex_mean(na_loop_t* const lp) {
|
4027
|
-
size_t n;
|
4028
|
-
char *p1, *p2;
|
4029
|
-
ssize_t s1;
|
4030
|
-
|
4031
|
-
INIT_COUNTER(lp, n);
|
4032
|
-
INIT_PTR(lp, 0, p1, s1);
|
4033
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4034
|
-
|
4035
|
-
*(dtype*)p2 = f_mean(n, p1, s1);
|
4036
|
-
}
|
4037
|
-
static void iter_scomplex_mean_nan(na_loop_t* const lp) {
|
4038
|
-
size_t n;
|
4039
|
-
char *p1, *p2;
|
4040
|
-
ssize_t s1;
|
4041
|
-
|
4042
|
-
INIT_COUNTER(lp, n);
|
4043
|
-
INIT_PTR(lp, 0, p1, s1);
|
4044
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4045
|
-
|
4046
|
-
*(dtype*)p2 = f_mean_nan(n, p1, s1);
|
4047
|
-
}
|
4048
|
-
|
4049
|
-
/*
|
4050
|
-
mean of self.
|
4051
|
-
@overload mean(axis:nil, keepdims:false, nan:false)
|
4052
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
4053
|
-
@param [Numeric,Array,Range] axis Performs mean along the axis.
|
4054
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
4055
|
-
@return [Numo::SComplex] returns result of mean.
|
4056
|
-
*/
|
4057
|
-
static VALUE scomplex_mean(int argc, VALUE* argv, VALUE self) {
|
4058
|
-
VALUE v, reduce;
|
4059
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4060
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4061
|
-
ndfunc_t ndf = {iter_scomplex_mean, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
4062
|
-
|
4063
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_scomplex_mean_nan);
|
4064
|
-
|
4065
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4066
|
-
|
4067
|
-
return scomplex_extract(v);
|
4068
|
-
}
|
4069
|
-
|
4070
|
-
static void iter_scomplex_stddev(na_loop_t* const lp) {
|
4071
|
-
size_t n;
|
4072
|
-
char *p1, *p2;
|
4073
|
-
ssize_t s1;
|
4074
|
-
|
4075
|
-
INIT_COUNTER(lp, n);
|
4076
|
-
INIT_PTR(lp, 0, p1, s1);
|
4077
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4078
|
-
|
4079
|
-
*(rtype*)p2 = f_stddev(n, p1, s1);
|
4080
|
-
}
|
4081
|
-
static void iter_scomplex_stddev_nan(na_loop_t* const lp) {
|
4082
|
-
size_t n;
|
4083
|
-
char *p1, *p2;
|
4084
|
-
ssize_t s1;
|
4085
|
-
|
4086
|
-
INIT_COUNTER(lp, n);
|
4087
|
-
INIT_PTR(lp, 0, p1, s1);
|
4088
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4089
|
-
|
4090
|
-
*(rtype*)p2 = f_stddev_nan(n, p1, s1);
|
4091
|
-
}
|
4092
|
-
|
4093
|
-
/*
|
4094
|
-
stddev of self.
|
4095
|
-
@overload stddev(axis:nil, keepdims:false, nan:false)
|
4096
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
4097
|
-
@param [Numeric,Array,Range] axis Performs stddev along the axis.
|
4098
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
4099
|
-
@return [Numo::SComplex] returns result of stddev.
|
4100
|
-
*/
|
4101
|
-
static VALUE scomplex_stddev(int argc, VALUE* argv, VALUE self) {
|
4102
|
-
VALUE v, reduce;
|
4103
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4104
|
-
ndfunc_arg_out_t aout[1] = {{cRT, 0}};
|
4105
|
-
ndfunc_t ndf = {iter_scomplex_stddev, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
4106
|
-
|
4107
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_scomplex_stddev_nan);
|
4108
|
-
|
4109
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4110
|
-
|
4111
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
4112
|
-
}
|
4113
|
-
|
4114
|
-
static void iter_scomplex_var(na_loop_t* const lp) {
|
4115
|
-
size_t n;
|
4116
|
-
char *p1, *p2;
|
4117
|
-
ssize_t s1;
|
4118
|
-
|
4119
|
-
INIT_COUNTER(lp, n);
|
4120
|
-
INIT_PTR(lp, 0, p1, s1);
|
4121
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4122
|
-
|
4123
|
-
*(rtype*)p2 = f_var(n, p1, s1);
|
4124
|
-
}
|
4125
|
-
static void iter_scomplex_var_nan(na_loop_t* const lp) {
|
4126
|
-
size_t n;
|
4127
|
-
char *p1, *p2;
|
4128
|
-
ssize_t s1;
|
4129
|
-
|
4130
|
-
INIT_COUNTER(lp, n);
|
4131
|
-
INIT_PTR(lp, 0, p1, s1);
|
4132
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4133
|
-
|
4134
|
-
*(rtype*)p2 = f_var_nan(n, p1, s1);
|
4135
|
-
}
|
4136
|
-
|
4137
|
-
/*
|
4138
|
-
var of self.
|
4139
|
-
@overload var(axis:nil, keepdims:false, nan:false)
|
4140
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
4141
|
-
@param [Numeric,Array,Range] axis Performs var along the axis.
|
4142
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
4143
|
-
@return [Numo::SComplex] returns result of var.
|
4144
|
-
*/
|
4145
|
-
static VALUE scomplex_var(int argc, VALUE* argv, VALUE self) {
|
4146
|
-
VALUE v, reduce;
|
4147
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4148
|
-
ndfunc_arg_out_t aout[1] = {{cRT, 0}};
|
4149
|
-
ndfunc_t ndf = {iter_scomplex_var, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
4150
|
-
|
4151
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_scomplex_var_nan);
|
4152
|
-
|
4153
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4154
|
-
|
4155
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
4156
|
-
}
|
4157
|
-
|
4158
|
-
static void iter_scomplex_rms(na_loop_t* const lp) {
|
4159
|
-
size_t n;
|
4160
|
-
char *p1, *p2;
|
4161
|
-
ssize_t s1;
|
4162
|
-
|
4163
|
-
INIT_COUNTER(lp, n);
|
4164
|
-
INIT_PTR(lp, 0, p1, s1);
|
4165
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4166
|
-
|
4167
|
-
*(rtype*)p2 = f_rms(n, p1, s1);
|
4168
|
-
}
|
4169
|
-
static void iter_scomplex_rms_nan(na_loop_t* const lp) {
|
4170
|
-
size_t n;
|
4171
|
-
char *p1, *p2;
|
4172
|
-
ssize_t s1;
|
4173
|
-
|
4174
|
-
INIT_COUNTER(lp, n);
|
4175
|
-
INIT_PTR(lp, 0, p1, s1);
|
4176
|
-
p2 = lp->args[1].ptr + lp->args[1].iter[0].pos;
|
4177
|
-
|
4178
|
-
*(rtype*)p2 = f_rms_nan(n, p1, s1);
|
4179
|
-
}
|
4180
|
-
|
4181
|
-
/*
|
4182
|
-
rms of self.
|
4183
|
-
@overload rms(axis:nil, keepdims:false, nan:false)
|
4184
|
-
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
4185
|
-
@param [Numeric,Array,Range] axis Performs rms along the axis.
|
4186
|
-
@param [TrueClass] keepdims If true, the reduced axes are left in the result array as dimensions with size one.
|
4187
|
-
@return [Numo::SComplex] returns result of rms.
|
4188
|
-
*/
|
4189
|
-
static VALUE scomplex_rms(int argc, VALUE* argv, VALUE self) {
|
4190
|
-
VALUE v, reduce;
|
4191
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4192
|
-
ndfunc_arg_out_t aout[1] = {{cRT, 0}};
|
4193
|
-
ndfunc_t ndf = {iter_scomplex_rms, STRIDE_LOOP_NIP | NDF_FLAT_REDUCE, 2, 1, ain, aout};
|
4194
|
-
|
4195
|
-
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_scomplex_rms_nan);
|
4196
|
-
|
4197
|
-
v = na_ndloop(&ndf, 2, self, reduce);
|
4198
|
-
|
4199
|
-
return rb_funcall(v, rb_intern("extract"), 0);
|
4200
|
-
}
|
4201
|
-
|
4202
4052
|
static void iter_scomplex_cumsum(na_loop_t* const lp) {
|
4203
4053
|
size_t i;
|
4204
4054
|
char *p1, *p2;
|
@@ -4208,16 +4058,13 @@ static void iter_scomplex_cumsum(na_loop_t* const lp) {
|
|
4208
4058
|
INIT_COUNTER(lp, i);
|
4209
4059
|
INIT_PTR(lp, 0, p1, s1);
|
4210
4060
|
INIT_PTR(lp, 1, p2, s2);
|
4211
|
-
// printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
|
4212
4061
|
|
4213
4062
|
GET_DATA_STRIDE(p1, s1, dtype, x);
|
4214
4063
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4215
|
-
// printf("i=%lu x=%f\n",i,x);
|
4216
4064
|
for (i--; i--;) {
|
4217
4065
|
GET_DATA_STRIDE(p1, s1, dtype, y);
|
4218
4066
|
m_cumsum(x, y);
|
4219
4067
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4220
|
-
// printf("i=%lu x=%f\n",i,x);
|
4221
4068
|
}
|
4222
4069
|
}
|
4223
4070
|
static void iter_scomplex_cumsum_nan(na_loop_t* const lp) {
|
@@ -4229,31 +4076,30 @@ static void iter_scomplex_cumsum_nan(na_loop_t* const lp) {
|
|
4229
4076
|
INIT_COUNTER(lp, i);
|
4230
4077
|
INIT_PTR(lp, 0, p1, s1);
|
4231
4078
|
INIT_PTR(lp, 1, p2, s2);
|
4232
|
-
// printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
|
4233
4079
|
|
4234
4080
|
GET_DATA_STRIDE(p1, s1, dtype, x);
|
4235
4081
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4236
|
-
// printf("i=%lu x=%f\n",i,x);
|
4237
4082
|
for (i--; i--;) {
|
4238
4083
|
GET_DATA_STRIDE(p1, s1, dtype, y);
|
4239
4084
|
m_cumsum_nan(x, y);
|
4240
4085
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4241
|
-
// printf("i=%lu x=%f\n",i,x);
|
4242
4086
|
}
|
4243
4087
|
}
|
4244
4088
|
|
4245
4089
|
/*
|
4246
4090
|
cumsum of self.
|
4247
4091
|
@overload cumsum(axis:nil, nan:false)
|
4248
|
-
|
4249
|
-
|
4250
|
-
|
4092
|
+
@param [Numeric,Array,Range] axis Performs cumsum along the axis.
|
4093
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
4094
|
+
@return [Numo::SComplex] cumsum of self.
|
4251
4095
|
*/
|
4252
4096
|
static VALUE scomplex_cumsum(int argc, VALUE* argv, VALUE self) {
|
4253
4097
|
VALUE reduce;
|
4254
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4255
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4256
|
-
ndfunc_t ndf = {
|
4098
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4099
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4100
|
+
ndfunc_t ndf = {
|
4101
|
+
iter_scomplex_cumsum, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout
|
4102
|
+
};
|
4257
4103
|
|
4258
4104
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_scomplex_cumsum_nan);
|
4259
4105
|
|
@@ -4269,16 +4115,13 @@ static void iter_scomplex_cumprod(na_loop_t* const lp) {
|
|
4269
4115
|
INIT_COUNTER(lp, i);
|
4270
4116
|
INIT_PTR(lp, 0, p1, s1);
|
4271
4117
|
INIT_PTR(lp, 1, p2, s2);
|
4272
|
-
// printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
|
4273
4118
|
|
4274
4119
|
GET_DATA_STRIDE(p1, s1, dtype, x);
|
4275
4120
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4276
|
-
// printf("i=%lu x=%f\n",i,x);
|
4277
4121
|
for (i--; i--;) {
|
4278
4122
|
GET_DATA_STRIDE(p1, s1, dtype, y);
|
4279
4123
|
m_cumprod(x, y);
|
4280
4124
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4281
|
-
// printf("i=%lu x=%f\n",i,x);
|
4282
4125
|
}
|
4283
4126
|
}
|
4284
4127
|
static void iter_scomplex_cumprod_nan(na_loop_t* const lp) {
|
@@ -4290,31 +4133,30 @@ static void iter_scomplex_cumprod_nan(na_loop_t* const lp) {
|
|
4290
4133
|
INIT_COUNTER(lp, i);
|
4291
4134
|
INIT_PTR(lp, 0, p1, s1);
|
4292
4135
|
INIT_PTR(lp, 1, p2, s2);
|
4293
|
-
// printf("i=%lu p1=%lx s1=%lu p2=%lx s2=%lu\n",i,(size_t)p1,s1,(size_t)p2,s2);
|
4294
4136
|
|
4295
4137
|
GET_DATA_STRIDE(p1, s1, dtype, x);
|
4296
4138
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4297
|
-
// printf("i=%lu x=%f\n",i,x);
|
4298
4139
|
for (i--; i--;) {
|
4299
4140
|
GET_DATA_STRIDE(p1, s1, dtype, y);
|
4300
4141
|
m_cumprod_nan(x, y);
|
4301
4142
|
SET_DATA_STRIDE(p2, s2, dtype, x);
|
4302
|
-
// printf("i=%lu x=%f\n",i,x);
|
4303
4143
|
}
|
4304
4144
|
}
|
4305
4145
|
|
4306
4146
|
/*
|
4307
4147
|
cumprod of self.
|
4308
4148
|
@overload cumprod(axis:nil, nan:false)
|
4309
|
-
|
4310
|
-
|
4311
|
-
|
4149
|
+
@param [Numeric,Array,Range] axis Performs cumprod along the axis.
|
4150
|
+
@param [TrueClass] nan If true, apply NaN-aware algorithm (avoid NaN if exists).
|
4151
|
+
@return [Numo::SComplex] cumprod of self.
|
4312
4152
|
*/
|
4313
4153
|
static VALUE scomplex_cumprod(int argc, VALUE* argv, VALUE self) {
|
4314
4154
|
VALUE reduce;
|
4315
|
-
ndfunc_arg_in_t ain[2] = {{cT, 0}, {sym_reduce, 0}};
|
4316
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4317
|
-
ndfunc_t ndf = {
|
4155
|
+
ndfunc_arg_in_t ain[2] = { { cT, 0 }, { sym_reduce, 0 } };
|
4156
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4157
|
+
ndfunc_t ndf = {
|
4158
|
+
iter_scomplex_cumprod, STRIDE_LOOP | NDF_FLAT_REDUCE | NDF_CUM, 2, 1, ain, aout
|
4159
|
+
};
|
4318
4160
|
|
4319
4161
|
reduce = na_reduce_dimension(argc, argv, 1, &self, &ndf, iter_scomplex_cumprod_nan);
|
4320
4162
|
|
@@ -4394,9 +4236,9 @@ static void iter_scomplex_mulsum_nan(na_loop_t* const lp) {
|
|
4394
4236
|
static VALUE scomplex_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
4395
4237
|
VALUE v, reduce;
|
4396
4238
|
VALUE naryv[2];
|
4397
|
-
ndfunc_arg_in_t ain[4] = {{cT, 0}, {cT, 0}, {sym_reduce, 0}, {sym_init, 0}};
|
4398
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4399
|
-
ndfunc_t ndf = {iter_scomplex_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout};
|
4239
|
+
ndfunc_arg_in_t ain[4] = { { cT, 0 }, { cT, 0 }, { sym_reduce, 0 }, { sym_init, 0 } };
|
4240
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4241
|
+
ndfunc_t ndf = { iter_scomplex_mulsum, STRIDE_LOOP_NIP, 4, 1, ain, aout };
|
4400
4242
|
|
4401
4243
|
if (argc < 1) {
|
4402
4244
|
rb_raise(rb_eArgError, "wrong number of arguments (%d for >=1)", argc);
|
@@ -4416,11 +4258,12 @@ static VALUE scomplex_mulsum_self(int argc, VALUE* argv, VALUE self) {
|
|
4416
4258
|
Binary mulsum.
|
4417
4259
|
|
4418
4260
|
@overload mulsum(other, axis:nil, keepdims:false, nan:false)
|
4419
|
-
|
4420
|
-
|
4421
|
-
|
4422
|
-
|
4423
|
-
|
4261
|
+
@param [Numo::NArray,Numeric] other
|
4262
|
+
@param [Numeric,Array,Range] axis Performs mulsum along the axis.
|
4263
|
+
@param [TrueClass] keepdims (keyword) If true, the reduced axes are left in the result array
|
4264
|
+
as dimensions with size one.
|
4265
|
+
@param [TrueClass] nan (keyword) If true, apply NaN-aware algorithm (avoid NaN if exists).
|
4266
|
+
@return [Numo::NArray] mulsum of self and other.
|
4424
4267
|
*/
|
4425
4268
|
static VALUE scomplex_mulsum(int argc, VALUE* argv, VALUE self) {
|
4426
4269
|
//
|
@@ -4489,9 +4332,9 @@ static void iter_scomplex_seq(na_loop_t* const lp) {
|
|
4489
4332
|
beg+i*step
|
4490
4333
|
where i is 1-dimensional index.
|
4491
4334
|
@overload seq([beg,[step]])
|
4492
|
-
|
4493
|
-
|
4494
|
-
|
4335
|
+
@param [Numeric] beg beginning of sequence. (default=0)
|
4336
|
+
@param [Numeric] step step of sequence. (default=1)
|
4337
|
+
@return [Numo::SComplex] self.
|
4495
4338
|
@example
|
4496
4339
|
Numo::DFloat.new(6).seq(1,-0.2)
|
4497
4340
|
# => Numo::DFloat#shape=[6]
|
@@ -4501,17 +4344,17 @@ static void iter_scomplex_seq(na_loop_t* const lp) {
|
|
4501
4344
|
# => Numo::DComplex#shape=[6]
|
4502
4345
|
# [1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
4503
4346
|
*/
|
4504
|
-
static VALUE scomplex_seq(int argc, VALUE*
|
4347
|
+
static VALUE scomplex_seq(int argc, VALUE* argv, VALUE self) {
|
4505
4348
|
seq_opt_t* g;
|
4506
4349
|
VALUE vbeg = Qnil, vstep = Qnil;
|
4507
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
|
4508
|
-
ndfunc_t ndf = {iter_scomplex_seq, FULL_LOOP, 1, 0, ain, 0};
|
4350
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
4351
|
+
ndfunc_t ndf = { iter_scomplex_seq, FULL_LOOP, 1, 0, ain, 0 };
|
4509
4352
|
|
4510
4353
|
g = ALLOCA_N(seq_opt_t, 1);
|
4511
4354
|
g->beg = m_zero;
|
4512
4355
|
g->step = m_one;
|
4513
4356
|
g->count = 0;
|
4514
|
-
rb_scan_args(argc,
|
4357
|
+
rb_scan_args(argc, argv, "02", &vbeg, &vstep);
|
4515
4358
|
if (vbeg != Qnil) {
|
4516
4359
|
g->beg = m_num_to_data(vbeg);
|
4517
4360
|
}
|
@@ -4570,10 +4413,10 @@ static void iter_scomplex_logseq(na_loop_t* const lp) {
|
|
4570
4413
|
Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
|
4571
4414
|
|
4572
4415
|
@overload logseq(beg,step,[base])
|
4573
|
-
|
4574
|
-
|
4575
|
-
|
4576
|
-
|
4416
|
+
@param [Numeric] beg The beginning of sequence.
|
4417
|
+
@param [Numeric] step The step of sequence.
|
4418
|
+
@param [Numeric] base The base of log space. (default=10)
|
4419
|
+
@return [Numo::SComplex] self.
|
4577
4420
|
|
4578
4421
|
@example
|
4579
4422
|
Numo::DFloat.new(5).logseq(4,-1,2)
|
@@ -4584,14 +4427,14 @@ static void iter_scomplex_logseq(na_loop_t* const lp) {
|
|
4584
4427
|
# => Numo::DComplex#shape=[5]
|
4585
4428
|
# [1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
|
4586
4429
|
*/
|
4587
|
-
static VALUE scomplex_logseq(int argc, VALUE*
|
4430
|
+
static VALUE scomplex_logseq(int argc, VALUE* argv, VALUE self) {
|
4588
4431
|
logseq_opt_t* g;
|
4589
4432
|
VALUE vbeg, vstep, vbase;
|
4590
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
|
4591
|
-
ndfunc_t ndf = {iter_scomplex_logseq, FULL_LOOP, 1, 0, ain, 0};
|
4433
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
4434
|
+
ndfunc_t ndf = { iter_scomplex_logseq, FULL_LOOP, 1, 0, ain, 0 };
|
4592
4435
|
|
4593
4436
|
g = ALLOCA_N(logseq_opt_t, 1);
|
4594
|
-
rb_scan_args(argc,
|
4437
|
+
rb_scan_args(argc, argv, "21", &vbeg, &vstep, &vbase);
|
4595
4438
|
g->beg = m_num_to_data(vbeg);
|
4596
4439
|
g->step = m_num_to_data(vstep);
|
4597
4440
|
if (vbase == Qnil) {
|
@@ -4635,15 +4478,15 @@ static void iter_scomplex_eye(na_loop_t* const lp) {
|
|
4635
4478
|
/*
|
4636
4479
|
Eye: Set a value to diagonal components, set 0 to non-diagonal components.
|
4637
4480
|
@overload eye([element,offset])
|
4638
|
-
|
4639
|
-
|
4640
|
-
|
4641
|
-
|
4642
|
-
|
4481
|
+
@param [Numeric] element Diagonal element to be stored. Default is 1.
|
4482
|
+
@param [Integer] offset Diagonal offset from the main diagonal. The
|
4483
|
+
default is 0. k>0 for diagonals above the main diagonal, and k<0
|
4484
|
+
for diagonals below the main diagonal.
|
4485
|
+
@return [Numo::SComplex] eye of self.
|
4643
4486
|
*/
|
4644
4487
|
static VALUE scomplex_eye(int argc, VALUE* argv, VALUE self) {
|
4645
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 2}};
|
4646
|
-
ndfunc_t ndf = {iter_scomplex_eye, NO_LOOP, 1, 0, ain, 0};
|
4488
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 2 } };
|
4489
|
+
ndfunc_t ndf = { iter_scomplex_eye, NO_LOOP, 1, 0, ain, 0 };
|
4647
4490
|
ssize_t kofs;
|
4648
4491
|
dtype data;
|
4649
4492
|
char* g;
|
@@ -4673,17 +4516,21 @@ static VALUE scomplex_eye(int argc, VALUE* argv, VALUE self) {
|
|
4673
4516
|
// Diagonal offset from the main diagonal.
|
4674
4517
|
if (kofs >= 0) {
|
4675
4518
|
if ((size_t)(kofs) >= na->shape[nd - 1]) {
|
4676
|
-
rb_raise(
|
4677
|
-
|
4678
|
-
|
4679
|
-
|
4519
|
+
rb_raise(
|
4520
|
+
rb_eArgError,
|
4521
|
+
"invalid diagonal offset(%" SZF "d) for "
|
4522
|
+
"last dimension size(%" SZF "d)",
|
4523
|
+
kofs, na->shape[nd - 1]
|
4524
|
+
);
|
4680
4525
|
}
|
4681
4526
|
} else {
|
4682
4527
|
if ((size_t)(-kofs) >= na->shape[nd - 2]) {
|
4683
|
-
rb_raise(
|
4684
|
-
|
4685
|
-
|
4686
|
-
|
4528
|
+
rb_raise(
|
4529
|
+
rb_eArgError,
|
4530
|
+
"invalid diagonal offset(%" SZF "d) for "
|
4531
|
+
"last-1 dimension size(%" SZF "d)",
|
4532
|
+
kofs, na->shape[nd - 2]
|
4533
|
+
);
|
4687
4534
|
}
|
4688
4535
|
}
|
4689
4536
|
|
@@ -4732,9 +4579,10 @@ static void iter_scomplex_rand(na_loop_t* const lp) {
|
|
4732
4579
|
/*
|
4733
4580
|
Generate uniformly distributed random numbers on self narray.
|
4734
4581
|
@overload rand([[low],high])
|
4735
|
-
|
4736
|
-
|
4737
|
-
|
4582
|
+
@param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
4583
|
+
@param [Numeric] high upper exclusive boundary of random numbers. (default=1 or 1+1i for
|
4584
|
+
complex types)
|
4585
|
+
@return [Numo::SComplex] self.
|
4738
4586
|
@example
|
4739
4587
|
Numo::DFloat.new(6).rand
|
4740
4588
|
# => Numo::DFloat#shape=[6]
|
@@ -4748,14 +4596,14 @@ static void iter_scomplex_rand(na_loop_t* const lp) {
|
|
4748
4596
|
# => Numo::Int32#shape=[6]
|
4749
4597
|
# [4, 3, 3, 2, 4, 2]
|
4750
4598
|
*/
|
4751
|
-
static VALUE scomplex_rand(int argc, VALUE*
|
4599
|
+
static VALUE scomplex_rand(int argc, VALUE* argv, VALUE self) {
|
4752
4600
|
rand_opt_t g;
|
4753
4601
|
VALUE v1 = Qnil, v2 = Qnil;
|
4754
4602
|
dtype high;
|
4755
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
|
4756
|
-
ndfunc_t ndf = {iter_scomplex_rand, FULL_LOOP, 1, 0, ain, 0};
|
4603
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
4604
|
+
ndfunc_t ndf = { iter_scomplex_rand, FULL_LOOP, 1, 0, ain, 0 };
|
4757
4605
|
|
4758
|
-
rb_scan_args(argc,
|
4606
|
+
rb_scan_args(argc, argv, "02", &v1, &v2);
|
4759
4607
|
if (v2 == Qnil) {
|
4760
4608
|
g.low = m_zero;
|
4761
4609
|
if (v1 == Qnil) {
|
@@ -4820,41 +4668,20 @@ static void iter_scomplex_rand_norm(na_loop_t* const lp) {
|
|
4820
4668
|
/*
|
4821
4669
|
Generates random numbers from the normal distribution on self narray
|
4822
4670
|
using Box-Muller Transformation.
|
4671
|
+
|
4823
4672
|
@overload rand_norm([mu,[sigma]])
|
4824
|
-
|
4825
|
-
|
4826
|
-
|
4827
|
-
@example
|
4828
|
-
Numo::DFloat.new(5,5).rand_norm
|
4829
|
-
# => Numo::DFloat#shape=[5,5]
|
4830
|
-
# [[-0.581255, -0.168354, 0.586895, -0.595142, -0.802802],
|
4831
|
-
# [-0.326106, 0.282922, 1.68427, 0.918499, -0.0485384],
|
4832
|
-
# [-0.464453, -0.992194, 0.413794, -0.60717, -0.699695],
|
4833
|
-
# [-1.64168, 0.48676, -0.875871, -1.43275, 0.812172],
|
4834
|
-
# [-0.209975, -0.103612, -0.878617, -1.42495, 1.0968]]
|
4835
|
-
|
4836
|
-
Numo::DFloat.new(5,5).rand_norm(10,0.1)
|
4837
|
-
# => Numo::DFloat#shape=[5,5]
|
4838
|
-
# [[9.9019, 9.90339, 10.0826, 9.98384, 9.72861],
|
4839
|
-
# [9.81507, 10.0272, 9.91445, 10.0568, 9.88923],
|
4840
|
-
# [10.0234, 9.97874, 9.96011, 9.9006, 9.99964],
|
4841
|
-
# [10.0186, 9.94598, 9.92236, 9.99811, 9.97003],
|
4842
|
-
# [9.79266, 9.95044, 9.95212, 9.93692, 10.2027]]
|
4843
|
-
|
4844
|
-
Numo::DComplex.new(3,3).rand_norm(5+5i)
|
4845
|
-
# => Numo::DComplex#shape=[3,3]
|
4846
|
-
# [[5.84303+4.40052i, 4.00984+6.08982i, 5.10979+5.13215i],
|
4847
|
-
# [4.26477+3.99655i, 4.90052+5.00763i, 4.46607+2.3444i],
|
4848
|
-
# [4.5528+7.11003i, 5.62117+6.69094i, 5.05443+5.35133i]]
|
4673
|
+
@param [Numeric] mu mean of normal distribution. (default=0)
|
4674
|
+
@param [Numeric] sigma standard deviation of normal distribution. (default=1)
|
4675
|
+
@return [Numo::SComplex] self.
|
4849
4676
|
*/
|
4850
|
-
static VALUE scomplex_rand_norm(int argc, VALUE*
|
4677
|
+
static VALUE scomplex_rand_norm(int argc, VALUE* argv, VALUE self) {
|
4851
4678
|
int n;
|
4852
4679
|
randn_opt_t g;
|
4853
4680
|
VALUE v1 = Qnil, v2 = Qnil;
|
4854
|
-
ndfunc_arg_in_t ain[1] = {{OVERWRITE, 0}};
|
4855
|
-
ndfunc_t ndf = {iter_scomplex_rand_norm, FULL_LOOP, 1, 0, ain, 0};
|
4681
|
+
ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } };
|
4682
|
+
ndfunc_t ndf = { iter_scomplex_rand_norm, FULL_LOOP, 1, 0, ain, 0 };
|
4856
4683
|
|
4857
|
-
n = rb_scan_args(argc,
|
4684
|
+
n = rb_scan_args(argc, argv, "02", &v1, &v2);
|
4858
4685
|
if (n == 0) {
|
4859
4686
|
g.mu = m_zero;
|
4860
4687
|
} else {
|
@@ -4889,15 +4716,15 @@ static void iter_scomplex_poly(na_loop_t* const lp) {
|
|
4889
4716
|
Calculate polynomial.
|
4890
4717
|
`x.poly(a0,a1,a2,...,an) = a0 + a1*x + a2*x**2 + ... + an*x**n`
|
4891
4718
|
@overload poly a0, a1, ..., an
|
4892
|
-
|
4893
|
-
|
4719
|
+
@param [Numo::NArray,Numeric] a0,a1,...,an
|
4720
|
+
@return [Numo::SComplex]
|
4894
4721
|
*/
|
4895
4722
|
static VALUE scomplex_poly(VALUE self, VALUE args) {
|
4896
4723
|
int argc, i;
|
4897
4724
|
VALUE* argv;
|
4898
4725
|
volatile VALUE v, a;
|
4899
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4900
|
-
ndfunc_t ndf = {iter_scomplex_poly, NO_LOOP, 0, 1, 0, aout};
|
4726
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4727
|
+
ndfunc_t ndf = { iter_scomplex_poly, NO_LOOP, 0, 1, 0, aout };
|
4901
4728
|
|
4902
4729
|
argc = (int)RARRAY_LEN(args);
|
4903
4730
|
ndf.nin = argc + 1;
|
@@ -4915,10 +4742,6 @@ static VALUE scomplex_poly(VALUE self, VALUE args) {
|
|
4915
4742
|
return scomplex_extract(v);
|
4916
4743
|
}
|
4917
4744
|
|
4918
|
-
/*
|
4919
|
-
module definition: Numo::SComplex::NMath
|
4920
|
-
*/
|
4921
|
-
|
4922
4745
|
VALUE mTM;
|
4923
4746
|
|
4924
4747
|
static void iter_scomplex_math_s_sqrt(na_loop_t* const lp) {
|
@@ -4988,13 +4811,13 @@ static void iter_scomplex_math_s_sqrt(na_loop_t* const lp) {
|
|
4988
4811
|
/*
|
4989
4812
|
Calculate sqrt(x).
|
4990
4813
|
@overload sqrt(x)
|
4991
|
-
|
4992
|
-
|
4814
|
+
@param [Numo::NArray,Numeric] x input value
|
4815
|
+
@return [Numo::SComplex] result of sqrt(x).
|
4993
4816
|
*/
|
4994
4817
|
static VALUE scomplex_math_s_sqrt(VALUE mod, VALUE a1) {
|
4995
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
4996
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
4997
|
-
ndfunc_t ndf = {iter_scomplex_math_s_sqrt, FULL_LOOP, 1, 1, ain, aout};
|
4818
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4819
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4820
|
+
ndfunc_t ndf = { iter_scomplex_math_s_sqrt, FULL_LOOP, 1, 1, ain, aout };
|
4998
4821
|
|
4999
4822
|
return na_ndloop(&ndf, 1, a1);
|
5000
4823
|
}
|
@@ -5066,13 +4889,13 @@ static void iter_scomplex_math_s_cbrt(na_loop_t* const lp) {
|
|
5066
4889
|
/*
|
5067
4890
|
Calculate cbrt(x).
|
5068
4891
|
@overload cbrt(x)
|
5069
|
-
|
5070
|
-
|
4892
|
+
@param [Numo::NArray,Numeric] x input value
|
4893
|
+
@return [Numo::SComplex] result of cbrt(x).
|
5071
4894
|
*/
|
5072
4895
|
static VALUE scomplex_math_s_cbrt(VALUE mod, VALUE a1) {
|
5073
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
5074
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5075
|
-
ndfunc_t ndf = {iter_scomplex_math_s_cbrt, FULL_LOOP, 1, 1, ain, aout};
|
4896
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4897
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4898
|
+
ndfunc_t ndf = { iter_scomplex_math_s_cbrt, FULL_LOOP, 1, 1, ain, aout };
|
5076
4899
|
|
5077
4900
|
return na_ndloop(&ndf, 1, a1);
|
5078
4901
|
}
|
@@ -5144,13 +4967,13 @@ static void iter_scomplex_math_s_log(na_loop_t* const lp) {
|
|
5144
4967
|
/*
|
5145
4968
|
Calculate log(x).
|
5146
4969
|
@overload log(x)
|
5147
|
-
|
5148
|
-
|
4970
|
+
@param [Numo::NArray,Numeric] x input value
|
4971
|
+
@return [Numo::SComplex] result of log(x).
|
5149
4972
|
*/
|
5150
4973
|
static VALUE scomplex_math_s_log(VALUE mod, VALUE a1) {
|
5151
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
5152
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5153
|
-
ndfunc_t ndf = {iter_scomplex_math_s_log, FULL_LOOP, 1, 1, ain, aout};
|
4974
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
4975
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
4976
|
+
ndfunc_t ndf = { iter_scomplex_math_s_log, FULL_LOOP, 1, 1, ain, aout };
|
5154
4977
|
|
5155
4978
|
return na_ndloop(&ndf, 1, a1);
|
5156
4979
|
}
|
@@ -5222,13 +5045,13 @@ static void iter_scomplex_math_s_log2(na_loop_t* const lp) {
|
|
5222
5045
|
/*
|
5223
5046
|
Calculate log2(x).
|
5224
5047
|
@overload log2(x)
|
5225
|
-
|
5226
|
-
|
5048
|
+
@param [Numo::NArray,Numeric] x input value
|
5049
|
+
@return [Numo::SComplex] result of log2(x).
|
5227
5050
|
*/
|
5228
5051
|
static VALUE scomplex_math_s_log2(VALUE mod, VALUE a1) {
|
5229
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
5230
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5231
|
-
ndfunc_t ndf = {iter_scomplex_math_s_log2, FULL_LOOP, 1, 1, ain, aout};
|
5052
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
5053
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5054
|
+
ndfunc_t ndf = { iter_scomplex_math_s_log2, FULL_LOOP, 1, 1, ain, aout };
|
5232
5055
|
|
5233
5056
|
return na_ndloop(&ndf, 1, a1);
|
5234
5057
|
}
|
@@ -5300,13 +5123,13 @@ static void iter_scomplex_math_s_log10(na_loop_t* const lp) {
|
|
5300
5123
|
/*
|
5301
5124
|
Calculate log10(x).
|
5302
5125
|
@overload log10(x)
|
5303
|
-
|
5304
|
-
|
5126
|
+
@param [Numo::NArray,Numeric] x input value
|
5127
|
+
@return [Numo::SComplex] result of log10(x).
|
5305
5128
|
*/
|
5306
5129
|
static VALUE scomplex_math_s_log10(VALUE mod, VALUE a1) {
|
5307
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
5308
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5309
|
-
ndfunc_t ndf = {iter_scomplex_math_s_log10, FULL_LOOP, 1, 1, ain, aout};
|
5130
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
5131
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5132
|
+
ndfunc_t ndf = { iter_scomplex_math_s_log10, FULL_LOOP, 1, 1, ain, aout };
|
5310
5133
|
|
5311
5134
|
return na_ndloop(&ndf, 1, a1);
|
5312
5135
|
}
|
@@ -5378,13 +5201,13 @@ static void iter_scomplex_math_s_exp(na_loop_t* const lp) {
|
|
5378
5201
|
/*
|
5379
5202
|
Calculate exp(x).
|
5380
5203
|
@overload exp(x)
|
5381
|
-
|
5382
|
-
|
5204
|
+
@param [Numo::NArray,Numeric] x input value
|
5205
|
+
@return [Numo::SComplex] result of exp(x).
|
5383
5206
|
*/
|
5384
5207
|
static VALUE scomplex_math_s_exp(VALUE mod, VALUE a1) {
|
5385
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
5386
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5387
|
-
ndfunc_t ndf = {iter_scomplex_math_s_exp, FULL_LOOP, 1, 1, ain, aout};
|
5208
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
5209
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5210
|
+
ndfunc_t ndf = { iter_scomplex_math_s_exp, FULL_LOOP, 1, 1, ain, aout };
|
5388
5211
|
|
5389
5212
|
return na_ndloop(&ndf, 1, a1);
|
5390
5213
|
}
|
@@ -5456,13 +5279,13 @@ static void iter_scomplex_math_s_exp2(na_loop_t* const lp) {
|
|
5456
5279
|
/*
|
5457
5280
|
Calculate exp2(x).
|
5458
5281
|
@overload exp2(x)
|
5459
|
-
|
5460
|
-
|
5282
|
+
@param [Numo::NArray,Numeric] x input value
|
5283
|
+
@return [Numo::SComplex] result of exp2(x).
|
5461
5284
|
*/
|
5462
5285
|
static VALUE scomplex_math_s_exp2(VALUE mod, VALUE a1) {
|
5463
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
5464
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5465
|
-
ndfunc_t ndf = {iter_scomplex_math_s_exp2, FULL_LOOP, 1, 1, ain, aout};
|
5286
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
5287
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5288
|
+
ndfunc_t ndf = { iter_scomplex_math_s_exp2, FULL_LOOP, 1, 1, ain, aout };
|
5466
5289
|
|
5467
5290
|
return na_ndloop(&ndf, 1, a1);
|
5468
5291
|
}
|
@@ -5534,13 +5357,13 @@ static void iter_scomplex_math_s_exp10(na_loop_t* const lp) {
|
|
5534
5357
|
/*
|
5535
5358
|
Calculate exp10(x).
|
5536
5359
|
@overload exp10(x)
|
5537
|
-
|
5538
|
-
|
5360
|
+
@param [Numo::NArray,Numeric] x input value
|
5361
|
+
@return [Numo::SComplex] result of exp10(x).
|
5539
5362
|
*/
|
5540
5363
|
static VALUE scomplex_math_s_exp10(VALUE mod, VALUE a1) {
|
5541
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
5542
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5543
|
-
ndfunc_t ndf = {iter_scomplex_math_s_exp10, FULL_LOOP, 1, 1, ain, aout};
|
5364
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
5365
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5366
|
+
ndfunc_t ndf = { iter_scomplex_math_s_exp10, FULL_LOOP, 1, 1, ain, aout };
|
5544
5367
|
|
5545
5368
|
return na_ndloop(&ndf, 1, a1);
|
5546
5369
|
}
|
@@ -5612,13 +5435,13 @@ static void iter_scomplex_math_s_sin(na_loop_t* const lp) {
|
|
5612
5435
|
/*
|
5613
5436
|
Calculate sin(x).
|
5614
5437
|
@overload sin(x)
|
5615
|
-
|
5616
|
-
|
5438
|
+
@param [Numo::NArray,Numeric] x input value
|
5439
|
+
@return [Numo::SComplex] result of sin(x).
|
5617
5440
|
*/
|
5618
5441
|
static VALUE scomplex_math_s_sin(VALUE mod, VALUE a1) {
|
5619
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
5620
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5621
|
-
ndfunc_t ndf = {iter_scomplex_math_s_sin, FULL_LOOP, 1, 1, ain, aout};
|
5442
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
5443
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5444
|
+
ndfunc_t ndf = { iter_scomplex_math_s_sin, FULL_LOOP, 1, 1, ain, aout };
|
5622
5445
|
|
5623
5446
|
return na_ndloop(&ndf, 1, a1);
|
5624
5447
|
}
|
@@ -5690,13 +5513,13 @@ static void iter_scomplex_math_s_cos(na_loop_t* const lp) {
|
|
5690
5513
|
/*
|
5691
5514
|
Calculate cos(x).
|
5692
5515
|
@overload cos(x)
|
5693
|
-
|
5694
|
-
|
5516
|
+
@param [Numo::NArray,Numeric] x input value
|
5517
|
+
@return [Numo::SComplex] result of cos(x).
|
5695
5518
|
*/
|
5696
5519
|
static VALUE scomplex_math_s_cos(VALUE mod, VALUE a1) {
|
5697
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
5698
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5699
|
-
ndfunc_t ndf = {iter_scomplex_math_s_cos, FULL_LOOP, 1, 1, ain, aout};
|
5520
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
5521
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5522
|
+
ndfunc_t ndf = { iter_scomplex_math_s_cos, FULL_LOOP, 1, 1, ain, aout };
|
5700
5523
|
|
5701
5524
|
return na_ndloop(&ndf, 1, a1);
|
5702
5525
|
}
|
@@ -5768,13 +5591,13 @@ static void iter_scomplex_math_s_tan(na_loop_t* const lp) {
|
|
5768
5591
|
/*
|
5769
5592
|
Calculate tan(x).
|
5770
5593
|
@overload tan(x)
|
5771
|
-
|
5772
|
-
|
5594
|
+
@param [Numo::NArray,Numeric] x input value
|
5595
|
+
@return [Numo::SComplex] result of tan(x).
|
5773
5596
|
*/
|
5774
5597
|
static VALUE scomplex_math_s_tan(VALUE mod, VALUE a1) {
|
5775
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
5776
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5777
|
-
ndfunc_t ndf = {iter_scomplex_math_s_tan, FULL_LOOP, 1, 1, ain, aout};
|
5598
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
5599
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5600
|
+
ndfunc_t ndf = { iter_scomplex_math_s_tan, FULL_LOOP, 1, 1, ain, aout };
|
5778
5601
|
|
5779
5602
|
return na_ndloop(&ndf, 1, a1);
|
5780
5603
|
}
|
@@ -5846,13 +5669,13 @@ static void iter_scomplex_math_s_asin(na_loop_t* const lp) {
|
|
5846
5669
|
/*
|
5847
5670
|
Calculate asin(x).
|
5848
5671
|
@overload asin(x)
|
5849
|
-
|
5850
|
-
|
5672
|
+
@param [Numo::NArray,Numeric] x input value
|
5673
|
+
@return [Numo::SComplex] result of asin(x).
|
5851
5674
|
*/
|
5852
5675
|
static VALUE scomplex_math_s_asin(VALUE mod, VALUE a1) {
|
5853
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
5854
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5855
|
-
ndfunc_t ndf = {iter_scomplex_math_s_asin, FULL_LOOP, 1, 1, ain, aout};
|
5676
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
5677
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5678
|
+
ndfunc_t ndf = { iter_scomplex_math_s_asin, FULL_LOOP, 1, 1, ain, aout };
|
5856
5679
|
|
5857
5680
|
return na_ndloop(&ndf, 1, a1);
|
5858
5681
|
}
|
@@ -5924,13 +5747,13 @@ static void iter_scomplex_math_s_acos(na_loop_t* const lp) {
|
|
5924
5747
|
/*
|
5925
5748
|
Calculate acos(x).
|
5926
5749
|
@overload acos(x)
|
5927
|
-
|
5928
|
-
|
5750
|
+
@param [Numo::NArray,Numeric] x input value
|
5751
|
+
@return [Numo::SComplex] result of acos(x).
|
5929
5752
|
*/
|
5930
5753
|
static VALUE scomplex_math_s_acos(VALUE mod, VALUE a1) {
|
5931
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
5932
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
5933
|
-
ndfunc_t ndf = {iter_scomplex_math_s_acos, FULL_LOOP, 1, 1, ain, aout};
|
5754
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
5755
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5756
|
+
ndfunc_t ndf = { iter_scomplex_math_s_acos, FULL_LOOP, 1, 1, ain, aout };
|
5934
5757
|
|
5935
5758
|
return na_ndloop(&ndf, 1, a1);
|
5936
5759
|
}
|
@@ -6002,13 +5825,13 @@ static void iter_scomplex_math_s_atan(na_loop_t* const lp) {
|
|
6002
5825
|
/*
|
6003
5826
|
Calculate atan(x).
|
6004
5827
|
@overload atan(x)
|
6005
|
-
|
6006
|
-
|
5828
|
+
@param [Numo::NArray,Numeric] x input value
|
5829
|
+
@return [Numo::SComplex] result of atan(x).
|
6007
5830
|
*/
|
6008
5831
|
static VALUE scomplex_math_s_atan(VALUE mod, VALUE a1) {
|
6009
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
6010
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
6011
|
-
ndfunc_t ndf = {iter_scomplex_math_s_atan, FULL_LOOP, 1, 1, ain, aout};
|
5832
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
5833
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5834
|
+
ndfunc_t ndf = { iter_scomplex_math_s_atan, FULL_LOOP, 1, 1, ain, aout };
|
6012
5835
|
|
6013
5836
|
return na_ndloop(&ndf, 1, a1);
|
6014
5837
|
}
|
@@ -6080,13 +5903,13 @@ static void iter_scomplex_math_s_sinh(na_loop_t* const lp) {
|
|
6080
5903
|
/*
|
6081
5904
|
Calculate sinh(x).
|
6082
5905
|
@overload sinh(x)
|
6083
|
-
|
6084
|
-
|
5906
|
+
@param [Numo::NArray,Numeric] x input value
|
5907
|
+
@return [Numo::SComplex] result of sinh(x).
|
6085
5908
|
*/
|
6086
5909
|
static VALUE scomplex_math_s_sinh(VALUE mod, VALUE a1) {
|
6087
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
6088
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
6089
|
-
ndfunc_t ndf = {iter_scomplex_math_s_sinh, FULL_LOOP, 1, 1, ain, aout};
|
5910
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
5911
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5912
|
+
ndfunc_t ndf = { iter_scomplex_math_s_sinh, FULL_LOOP, 1, 1, ain, aout };
|
6090
5913
|
|
6091
5914
|
return na_ndloop(&ndf, 1, a1);
|
6092
5915
|
}
|
@@ -6158,13 +5981,13 @@ static void iter_scomplex_math_s_cosh(na_loop_t* const lp) {
|
|
6158
5981
|
/*
|
6159
5982
|
Calculate cosh(x).
|
6160
5983
|
@overload cosh(x)
|
6161
|
-
|
6162
|
-
|
5984
|
+
@param [Numo::NArray,Numeric] x input value
|
5985
|
+
@return [Numo::SComplex] result of cosh(x).
|
6163
5986
|
*/
|
6164
5987
|
static VALUE scomplex_math_s_cosh(VALUE mod, VALUE a1) {
|
6165
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
6166
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
6167
|
-
ndfunc_t ndf = {iter_scomplex_math_s_cosh, FULL_LOOP, 1, 1, ain, aout};
|
5988
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
5989
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
5990
|
+
ndfunc_t ndf = { iter_scomplex_math_s_cosh, FULL_LOOP, 1, 1, ain, aout };
|
6168
5991
|
|
6169
5992
|
return na_ndloop(&ndf, 1, a1);
|
6170
5993
|
}
|
@@ -6236,13 +6059,13 @@ static void iter_scomplex_math_s_tanh(na_loop_t* const lp) {
|
|
6236
6059
|
/*
|
6237
6060
|
Calculate tanh(x).
|
6238
6061
|
@overload tanh(x)
|
6239
|
-
|
6240
|
-
|
6062
|
+
@param [Numo::NArray,Numeric] x input value
|
6063
|
+
@return [Numo::SComplex] result of tanh(x).
|
6241
6064
|
*/
|
6242
6065
|
static VALUE scomplex_math_s_tanh(VALUE mod, VALUE a1) {
|
6243
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
6244
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
6245
|
-
ndfunc_t ndf = {iter_scomplex_math_s_tanh, FULL_LOOP, 1, 1, ain, aout};
|
6066
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
6067
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
6068
|
+
ndfunc_t ndf = { iter_scomplex_math_s_tanh, FULL_LOOP, 1, 1, ain, aout };
|
6246
6069
|
|
6247
6070
|
return na_ndloop(&ndf, 1, a1);
|
6248
6071
|
}
|
@@ -6314,13 +6137,13 @@ static void iter_scomplex_math_s_asinh(na_loop_t* const lp) {
|
|
6314
6137
|
/*
|
6315
6138
|
Calculate asinh(x).
|
6316
6139
|
@overload asinh(x)
|
6317
|
-
|
6318
|
-
|
6140
|
+
@param [Numo::NArray,Numeric] x input value
|
6141
|
+
@return [Numo::SComplex] result of asinh(x).
|
6319
6142
|
*/
|
6320
6143
|
static VALUE scomplex_math_s_asinh(VALUE mod, VALUE a1) {
|
6321
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
6322
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
6323
|
-
ndfunc_t ndf = {iter_scomplex_math_s_asinh, FULL_LOOP, 1, 1, ain, aout};
|
6144
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
6145
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
6146
|
+
ndfunc_t ndf = { iter_scomplex_math_s_asinh, FULL_LOOP, 1, 1, ain, aout };
|
6324
6147
|
|
6325
6148
|
return na_ndloop(&ndf, 1, a1);
|
6326
6149
|
}
|
@@ -6392,13 +6215,13 @@ static void iter_scomplex_math_s_acosh(na_loop_t* const lp) {
|
|
6392
6215
|
/*
|
6393
6216
|
Calculate acosh(x).
|
6394
6217
|
@overload acosh(x)
|
6395
|
-
|
6396
|
-
|
6218
|
+
@param [Numo::NArray,Numeric] x input value
|
6219
|
+
@return [Numo::SComplex] result of acosh(x).
|
6397
6220
|
*/
|
6398
6221
|
static VALUE scomplex_math_s_acosh(VALUE mod, VALUE a1) {
|
6399
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
6400
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
6401
|
-
ndfunc_t ndf = {iter_scomplex_math_s_acosh, FULL_LOOP, 1, 1, ain, aout};
|
6222
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
6223
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
6224
|
+
ndfunc_t ndf = { iter_scomplex_math_s_acosh, FULL_LOOP, 1, 1, ain, aout };
|
6402
6225
|
|
6403
6226
|
return na_ndloop(&ndf, 1, a1);
|
6404
6227
|
}
|
@@ -6470,13 +6293,13 @@ static void iter_scomplex_math_s_atanh(na_loop_t* const lp) {
|
|
6470
6293
|
/*
|
6471
6294
|
Calculate atanh(x).
|
6472
6295
|
@overload atanh(x)
|
6473
|
-
|
6474
|
-
|
6296
|
+
@param [Numo::NArray,Numeric] x input value
|
6297
|
+
@return [Numo::SComplex] result of atanh(x).
|
6475
6298
|
*/
|
6476
6299
|
static VALUE scomplex_math_s_atanh(VALUE mod, VALUE a1) {
|
6477
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
6478
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
6479
|
-
ndfunc_t ndf = {iter_scomplex_math_s_atanh, FULL_LOOP, 1, 1, ain, aout};
|
6300
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
6301
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
6302
|
+
ndfunc_t ndf = { iter_scomplex_math_s_atanh, FULL_LOOP, 1, 1, ain, aout };
|
6480
6303
|
|
6481
6304
|
return na_ndloop(&ndf, 1, a1);
|
6482
6305
|
}
|
@@ -6548,13 +6371,13 @@ static void iter_scomplex_math_s_sinc(na_loop_t* const lp) {
|
|
6548
6371
|
/*
|
6549
6372
|
Calculate sinc(x).
|
6550
6373
|
@overload sinc(x)
|
6551
|
-
|
6552
|
-
|
6374
|
+
@param [Numo::NArray,Numeric] x input value
|
6375
|
+
@return [Numo::SComplex] result of sinc(x).
|
6553
6376
|
*/
|
6554
6377
|
static VALUE scomplex_math_s_sinc(VALUE mod, VALUE a1) {
|
6555
|
-
ndfunc_arg_in_t ain[1] = {{cT, 0}};
|
6556
|
-
ndfunc_arg_out_t aout[1] = {{cT, 0}};
|
6557
|
-
ndfunc_t ndf = {iter_scomplex_math_s_sinc, FULL_LOOP, 1, 1, ain, aout};
|
6378
|
+
ndfunc_arg_in_t ain[1] = { { cT, 0 } };
|
6379
|
+
ndfunc_arg_out_t aout[1] = { { cT, 0 } };
|
6380
|
+
ndfunc_t ndf = { iter_scomplex_math_s_sinc, FULL_LOOP, 1, 1, ain, aout };
|
6558
6381
|
|
6559
6382
|
return na_ndloop(&ndf, 1, a1);
|
6560
6383
|
}
|
@@ -6575,16 +6398,18 @@ void Init_numo_scomplex(void) {
|
|
6575
6398
|
id_real = rb_intern("real");
|
6576
6399
|
id_to_a = rb_intern("to_a");
|
6577
6400
|
|
6578
|
-
|
6579
|
-
|
6580
|
-
|
6581
|
-
|
6401
|
+
/**
|
6402
|
+
* Document-class: Numo::SComplex
|
6403
|
+
*
|
6404
|
+
* Single precision floating point (32bit) complex number N-dimensional array class.
|
6405
|
+
*/
|
6582
6406
|
cT = rb_define_class_under(mNumo, "SComplex", cNArray);
|
6583
6407
|
|
6584
6408
|
// alias of SComplex
|
6585
6409
|
rb_define_const(mNumo, "Complex32", numo_cSComplex);
|
6586
6410
|
|
6587
6411
|
hCast = rb_hash_new();
|
6412
|
+
/* Upcasting rules of SComplex. */
|
6588
6413
|
rb_define_const(cT, "UPCAST", hCast);
|
6589
6414
|
rb_hash_aset(hCast, rb_cArray, cT);
|
6590
6415
|
|
@@ -6611,17 +6436,17 @@ void Init_numo_scomplex(void) {
|
|
6611
6436
|
rb_hash_aset(hCast, numo_cUInt8, numo_cSComplex);
|
6612
6437
|
rb_obj_freeze(hCast);
|
6613
6438
|
|
6614
|
-
|
6439
|
+
/* Element size of SComplex in bits. */
|
6615
6440
|
rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(sizeof(dtype) * 8));
|
6616
|
-
|
6441
|
+
/* Element size of SComplex in bytes. */
|
6617
6442
|
rb_define_const(cT, "ELEMENT_BYTE_SIZE", INT2FIX(sizeof(dtype)));
|
6618
|
-
|
6443
|
+
/* Stride size of contiguous SComplex array. */
|
6619
6444
|
rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(sizeof(dtype)));
|
6620
|
-
|
6445
|
+
/* Machine epsilon of SComplex */
|
6621
6446
|
rb_define_const(cT, "EPSILON", M_EPSILON);
|
6622
|
-
|
6447
|
+
/* The largest representable value of SComplex */
|
6623
6448
|
rb_define_const(cT, "MAX", M_MAX);
|
6624
|
-
|
6449
|
+
/* The smallest representable value of SComplex */
|
6625
6450
|
rb_define_const(cT, "MIN", M_MIN);
|
6626
6451
|
rb_define_alloc_func(cT, scomplex_s_alloc_func);
|
6627
6452
|
rb_define_method(cT, "allocate", scomplex_allocate, 0);
|
@@ -6681,9 +6506,49 @@ void Init_numo_scomplex(void) {
|
|
6681
6506
|
rb_define_method(cT, "isfinite", scomplex_isfinite, 0);
|
6682
6507
|
rb_define_method(cT, "sum", scomplex_sum, -1);
|
6683
6508
|
rb_define_method(cT, "prod", scomplex_prod, -1);
|
6509
|
+
/**
|
6510
|
+
* mean of self.
|
6511
|
+
* @overload mean(axis: nil, keepdims: false, nan: false)
|
6512
|
+
* @param axis [Numeric, Array, Range] Performs mean along the axis.
|
6513
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
6514
|
+
* dimensions with size one.
|
6515
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
6516
|
+
* (avoid NaN for sum/mean etc, or return NaN for min/max etc).
|
6517
|
+
* @return [Numo::SComplex] returns result of mean.
|
6518
|
+
*/
|
6684
6519
|
rb_define_method(cT, "mean", scomplex_mean, -1);
|
6685
|
-
|
6520
|
+
/**
|
6521
|
+
* var of self.
|
6522
|
+
* @overload var(axis: nil, keepdims: false, nan: false)
|
6523
|
+
* @param axis [Numeric,Array,Range] Performs var along the axis.
|
6524
|
+
* @param keepdims [TrueClass] If true, the reduced axes are left in the result array as
|
6525
|
+
* dimensions with size one.
|
6526
|
+
* @param nan [TrueClass] If true, apply NaN-aware algorithm
|
6527
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
6528
|
+
* @return [Numo::SFloat] returns result of var.
|
6529
|
+
*/
|
6686
6530
|
rb_define_method(cT, "var", scomplex_var, -1);
|
6531
|
+
/**
|
6532
|
+
* stddev of self.
|
6533
|
+
* @overload stddev(axis: nil, keepdims: false, nan: false)
|
6534
|
+
* @param axis [Numeric, Array, Range] Performs stddev along the axis.
|
6535
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
6536
|
+
* dimensions with size one.
|
6537
|
+
* @param nan [Bollean] If true, apply NaN-aware algorithm
|
6538
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
6539
|
+
* @return [Numo::SFloat] returns result of stddev.
|
6540
|
+
*/
|
6541
|
+
rb_define_method(cT, "stddev", scomplex_stddev, -1);
|
6542
|
+
/**
|
6543
|
+
* rms of self.
|
6544
|
+
* @overload rms(axis: nil, keepdims: false, nan: false)
|
6545
|
+
* @param axis [Numeric, Array, Range] Performs rms along the axis.
|
6546
|
+
* @param keepdims [Boolean] If true, the reduced axes are left in the result array as
|
6547
|
+
* dimensions with size one.
|
6548
|
+
* @param nan [Boolean] If true, apply NaN-aware algorithm
|
6549
|
+
* (avoid NaN for sum/mean etc, or, return NaN for min/max etc).
|
6550
|
+
* @return [Numo::SFloat] returns result of rms.
|
6551
|
+
*/
|
6687
6552
|
rb_define_method(cT, "rms", scomplex_rms, -1);
|
6688
6553
|
rb_define_method(cT, "cumsum", scomplex_cumsum, -1);
|
6689
6554
|
rb_define_method(cT, "cumprod", scomplex_cumprod, -1);
|
@@ -6697,11 +6562,11 @@ void Init_numo_scomplex(void) {
|
|
6697
6562
|
rb_define_method(cT, "poly", scomplex_poly, -2);
|
6698
6563
|
rb_define_singleton_method(cT, "[]", scomplex_s_cast, -2);
|
6699
6564
|
|
6700
|
-
|
6701
|
-
|
6702
|
-
|
6703
|
-
|
6704
|
-
|
6565
|
+
/**
|
6566
|
+
* Document-module: Numo::SComplex::Math
|
6567
|
+
*
|
6568
|
+
* This module contains mathematical functions for Numo::SComplex.
|
6569
|
+
*/
|
6705
6570
|
mTM = rb_define_module_under(cT, "Math");
|
6706
6571
|
|
6707
6572
|
rb_define_module_function(mTM, "sqrt", scomplex_math_s_sqrt, 1);
|