numo-narray-alt 0.9.10 → 0.9.12

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.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -1
  3. data/LICENSE +1 -1
  4. data/README.md +7 -0
  5. data/ext/numo/narray/numo/narray.h +2 -2
  6. data/ext/numo/narray/numo/types/robj_macro.h +1 -1
  7. data/ext/numo/narray/numo/types/robject.h +1 -1
  8. data/ext/numo/narray/src/mh/argmax.h +154 -0
  9. data/ext/numo/narray/src/mh/argmin.h +154 -0
  10. data/ext/numo/narray/src/mh/bincount.h +233 -0
  11. data/ext/numo/narray/src/mh/bit/and.h +225 -0
  12. data/ext/numo/narray/src/mh/bit/left_shift.h +225 -0
  13. data/ext/numo/narray/src/mh/bit/not.h +173 -0
  14. data/ext/numo/narray/src/mh/bit/or.h +225 -0
  15. data/ext/numo/narray/src/mh/bit/right_shift.h +225 -0
  16. data/ext/numo/narray/src/mh/bit/xor.h +225 -0
  17. data/ext/numo/narray/src/mh/clip.h +115 -0
  18. data/ext/numo/narray/src/mh/coerce_cast.h +9 -0
  19. data/ext/numo/narray/src/mh/comp/binary_func.h +37 -0
  20. data/ext/numo/narray/src/mh/comp/eq.h +26 -0
  21. data/ext/numo/narray/src/mh/comp/ge.h +26 -0
  22. data/ext/numo/narray/src/mh/comp/gt.h +26 -0
  23. data/ext/numo/narray/src/mh/comp/le.h +26 -0
  24. data/ext/numo/narray/src/mh/comp/lt.h +26 -0
  25. data/ext/numo/narray/src/mh/comp/ne.h +26 -0
  26. data/ext/numo/narray/src/mh/comp/nearly_eq.h +26 -0
  27. data/ext/numo/narray/src/mh/cumprod.h +98 -0
  28. data/ext/numo/narray/src/mh/cumsum.h +98 -0
  29. data/ext/numo/narray/src/mh/divmod.h +142 -0
  30. data/ext/numo/narray/src/mh/eye.h +82 -0
  31. data/ext/numo/narray/src/mh/fill.h +94 -0
  32. data/ext/numo/narray/src/mh/format.h +108 -0
  33. data/ext/numo/narray/src/mh/format_to_a.h +89 -0
  34. data/ext/numo/narray/src/mh/inspect.h +33 -0
  35. data/ext/numo/narray/src/mh/isfinite.h +42 -0
  36. data/ext/numo/narray/src/mh/isinf.h +42 -0
  37. data/ext/numo/narray/src/mh/isnan.h +42 -0
  38. data/ext/numo/narray/src/mh/isneginf.h +42 -0
  39. data/ext/numo/narray/src/mh/isposinf.h +42 -0
  40. data/ext/numo/narray/src/mh/logseq.h +69 -0
  41. data/ext/numo/narray/src/mh/math/acos.h +2 -2
  42. data/ext/numo/narray/src/mh/math/acosh.h +2 -2
  43. data/ext/numo/narray/src/mh/math/asin.h +2 -2
  44. data/ext/numo/narray/src/mh/math/asinh.h +2 -2
  45. data/ext/numo/narray/src/mh/math/atan.h +2 -2
  46. data/ext/numo/narray/src/mh/math/atan2.h +3 -3
  47. data/ext/numo/narray/src/mh/math/atanh.h +2 -2
  48. data/ext/numo/narray/src/mh/math/cbrt.h +2 -2
  49. data/ext/numo/narray/src/mh/math/cos.h +2 -2
  50. data/ext/numo/narray/src/mh/math/cosh.h +2 -2
  51. data/ext/numo/narray/src/mh/math/erf.h +2 -2
  52. data/ext/numo/narray/src/mh/math/erfc.h +2 -2
  53. data/ext/numo/narray/src/mh/math/exp.h +2 -2
  54. data/ext/numo/narray/src/mh/math/exp10.h +2 -2
  55. data/ext/numo/narray/src/mh/math/exp2.h +2 -2
  56. data/ext/numo/narray/src/mh/math/expm1.h +2 -2
  57. data/ext/numo/narray/src/mh/math/frexp.h +3 -3
  58. data/ext/numo/narray/src/mh/math/hypot.h +3 -3
  59. data/ext/numo/narray/src/mh/math/ldexp.h +3 -3
  60. data/ext/numo/narray/src/mh/math/log.h +2 -2
  61. data/ext/numo/narray/src/mh/math/log10.h +2 -2
  62. data/ext/numo/narray/src/mh/math/log1p.h +2 -2
  63. data/ext/numo/narray/src/mh/math/log2.h +2 -2
  64. data/ext/numo/narray/src/mh/math/sin.h +2 -2
  65. data/ext/numo/narray/src/mh/math/sinc.h +2 -2
  66. data/ext/numo/narray/src/mh/math/sinh.h +2 -2
  67. data/ext/numo/narray/src/mh/math/sqrt.h +8 -8
  68. data/ext/numo/narray/src/mh/math/tan.h +2 -2
  69. data/ext/numo/narray/src/mh/math/tanh.h +2 -2
  70. data/ext/numo/narray/src/mh/math/unary_func.h +3 -3
  71. data/ext/numo/narray/src/mh/max.h +69 -0
  72. data/ext/numo/narray/src/mh/max_index.h +184 -0
  73. data/ext/numo/narray/src/mh/maximum.h +116 -0
  74. data/ext/numo/narray/src/mh/min.h +69 -0
  75. data/ext/numo/narray/src/mh/min_index.h +184 -0
  76. data/ext/numo/narray/src/mh/minimum.h +116 -0
  77. data/ext/numo/narray/src/mh/minmax.h +77 -0
  78. data/ext/numo/narray/src/mh/mulsum.h +185 -0
  79. data/ext/numo/narray/src/mh/op/add.h +78 -0
  80. data/ext/numo/narray/src/mh/op/binary_func.h +423 -0
  81. data/ext/numo/narray/src/mh/op/div.h +118 -0
  82. data/ext/numo/narray/src/mh/op/mod.h +108 -0
  83. data/ext/numo/narray/src/mh/op/mul.h +78 -0
  84. data/ext/numo/narray/src/mh/op/sub.h +78 -0
  85. data/ext/numo/narray/src/mh/prod.h +69 -0
  86. data/ext/numo/narray/src/mh/ptp.h +69 -0
  87. data/ext/numo/narray/src/mh/rand.h +315 -0
  88. data/ext/numo/narray/src/mh/round/ceil.h +11 -0
  89. data/ext/numo/narray/src/mh/round/floor.h +11 -0
  90. data/ext/numo/narray/src/mh/round/rint.h +9 -0
  91. data/ext/numo/narray/src/mh/round/round.h +11 -0
  92. data/ext/numo/narray/src/mh/round/trunc.h +11 -0
  93. data/ext/numo/narray/src/mh/round/unary_func.h +127 -0
  94. data/ext/numo/narray/src/mh/seq.h +130 -0
  95. data/ext/numo/narray/src/mh/sum.h +69 -0
  96. data/ext/numo/narray/src/mh/to_a.h +78 -0
  97. data/ext/numo/narray/src/t_bit.c +45 -234
  98. data/ext/numo/narray/src/t_dcomplex.c +608 -2369
  99. data/ext/numo/narray/src/t_dfloat.c +485 -3736
  100. data/ext/numo/narray/src/t_int16.c +743 -3444
  101. data/ext/numo/narray/src/t_int32.c +745 -3445
  102. data/ext/numo/narray/src/t_int64.c +743 -3446
  103. data/ext/numo/narray/src/t_int8.c +678 -3040
  104. data/ext/numo/narray/src/t_robject.c +771 -3548
  105. data/ext/numo/narray/src/t_scomplex.c +607 -2368
  106. data/ext/numo/narray/src/t_sfloat.c +440 -3693
  107. data/ext/numo/narray/src/t_uint16.c +743 -3440
  108. data/ext/numo/narray/src/t_uint32.c +743 -3440
  109. data/ext/numo/narray/src/t_uint64.c +743 -3442
  110. data/ext/numo/narray/src/t_uint8.c +678 -3038
  111. data/lib/numo/narray.rb +2 -3
  112. metadata +62 -3
@@ -0,0 +1,108 @@
1
+ #ifndef NUMO_NARRAY_MH_FORMAT_H
2
+ #define NUMO_NARRAY_MH_FORMAT_H 1
3
+
4
+ #define DEF_NARRAY_FORMAT_METHOD_FUNC(tDType) \
5
+ static VALUE format_##tDType(VALUE fmt, tDType* x) { \
6
+ if (NIL_P(fmt)) { \
7
+ char s[48]; \
8
+ int n = m_sprintf(s, *x); \
9
+ return rb_str_new(s, n); \
10
+ } \
11
+ return rb_funcall(fmt, '%', 1, m_data_to_num(*x)); \
12
+ } \
13
+ \
14
+ static void iter_##tDType##_format(na_loop_t* const lp) { \
15
+ size_t n; \
16
+ char* p1; \
17
+ char* p2; \
18
+ ssize_t s1; \
19
+ ssize_t s2; \
20
+ size_t* idx1; \
21
+ tDType* x; \
22
+ VALUE y; \
23
+ VALUE fmt = lp->option; \
24
+ \
25
+ INIT_COUNTER(lp, n); \
26
+ INIT_PTR_IDX(lp, 0, p1, s1, idx1); \
27
+ INIT_PTR(lp, 1, p2, s2); \
28
+ \
29
+ if (idx1) { \
30
+ for (size_t i = 0; i < n; i++) { \
31
+ x = (tDType*)(p1 + *idx1); \
32
+ idx1++; \
33
+ y = format_##tDType(fmt, x); \
34
+ SET_DATA_STRIDE(p2, s2, VALUE, y); \
35
+ } \
36
+ } else { \
37
+ for (size_t i = 0; i < n; i++) { \
38
+ x = (tDType*)p1; \
39
+ p1 += s1; \
40
+ y = format_##tDType(fmt, x); \
41
+ SET_DATA_STRIDE(p2, s2, VALUE, y); \
42
+ } \
43
+ } \
44
+ } \
45
+ \
46
+ static VALUE tDType##_format(int argc, VALUE* argv, VALUE self) { \
47
+ VALUE fmt = Qnil; \
48
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_option } }; \
49
+ ndfunc_arg_out_t aout[1] = { { numo_cRObject, 0 } }; \
50
+ ndfunc_t ndf = { iter_##tDType##_format, FULL_LOOP_NIP, 2, 1, ain, aout }; \
51
+ rb_scan_args(argc, argv, "01", &fmt); \
52
+ return na_ndloop(&ndf, 2, self, fmt); \
53
+ }
54
+
55
+ #define DEF_NARRAY_BIT_FORMAT_METHOD_FUNC() \
56
+ static VALUE format_bit(VALUE fmt, BIT_DIGIT x) { \
57
+ if (NIL_P(fmt)) { \
58
+ char s[4]; \
59
+ int n; \
60
+ n = m_sprintf(s, x); \
61
+ return rb_str_new(s, n); \
62
+ } \
63
+ return rb_funcall(fmt, '%', 1, m_data_to_num(x)); \
64
+ } \
65
+ \
66
+ static void iter_bit_format(na_loop_t* const lp) { \
67
+ size_t n; \
68
+ BIT_DIGIT* a1; \
69
+ BIT_DIGIT x = 0; \
70
+ size_t p1; \
71
+ char* p2; \
72
+ ssize_t s1; \
73
+ ssize_t s2; \
74
+ size_t* idx1; \
75
+ VALUE y; \
76
+ VALUE fmt = lp->option; \
77
+ \
78
+ INIT_COUNTER(lp, n); \
79
+ INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1); \
80
+ INIT_PTR(lp, 1, p2, s2); \
81
+ \
82
+ if (idx1) { \
83
+ for (size_t i = 0; i < n; i++) { \
84
+ LOAD_BIT(a1, p1 + *idx1, x); \
85
+ idx1++; \
86
+ y = format_bit(fmt, x); \
87
+ SET_DATA_STRIDE(p2, s2, VALUE, y); \
88
+ } \
89
+ } else { \
90
+ for (size_t i = 0; i < n; i++) { \
91
+ LOAD_BIT(a1, p1, x); \
92
+ p1 += s1; \
93
+ y = format_bit(fmt, x); \
94
+ SET_DATA_STRIDE(p2, s2, VALUE, y); \
95
+ } \
96
+ } \
97
+ } \
98
+ \
99
+ static VALUE bit_format(int argc, VALUE* argv, VALUE self) { \
100
+ VALUE fmt = Qnil; \
101
+ ndfunc_arg_in_t ain[2] = { { Qnil, 0 }, { sym_option } }; \
102
+ ndfunc_arg_out_t aout[1] = { { numo_cRObject, 0 } }; \
103
+ ndfunc_t ndf = { iter_bit_format, FULL_LOOP_NIP, 2, 1, ain, aout }; \
104
+ rb_scan_args(argc, argv, "01", &fmt); \
105
+ return na_ndloop(&ndf, 2, self, fmt); \
106
+ }
107
+
108
+ #endif /* NUMO_NARRAY_MH_FORMAT_H */
@@ -0,0 +1,89 @@
1
+ #ifndef NUMO_NARRAY_MH_FORMAT_TO_A_H
2
+ #define NUMO_NARRAY_MH_FORMAT_TO_A_H 1
3
+
4
+ #define DEF_NARRAY_FORMAT_TO_A_METHOD_FUNC(tDType) \
5
+ static void iter_##tDType##_format_to_a(na_loop_t* const lp) { \
6
+ size_t n; \
7
+ char* p1; \
8
+ ssize_t s1; \
9
+ size_t* idx1; \
10
+ tDType* x; \
11
+ VALUE y; \
12
+ volatile VALUE a; \
13
+ VALUE fmt = lp->option; \
14
+ \
15
+ INIT_COUNTER(lp, n); \
16
+ INIT_PTR_IDX(lp, 0, p1, s1, idx1); \
17
+ \
18
+ a = rb_ary_new2(n); \
19
+ rb_ary_push(lp->args[1].value, a); \
20
+ if (idx1) { \
21
+ for (size_t i = 0; i < n; i++) { \
22
+ x = (tDType*)(p1 + *idx1); \
23
+ idx1++; \
24
+ y = format_##tDType(fmt, x); \
25
+ rb_ary_push(a, y); \
26
+ } \
27
+ } else { \
28
+ for (size_t i = 0; i < n; i++) { \
29
+ x = (tDType*)p1; \
30
+ p1 += s1; \
31
+ y = format_##tDType(fmt, x); \
32
+ rb_ary_push(a, y); \
33
+ } \
34
+ } \
35
+ } \
36
+ \
37
+ static VALUE tDType##_format_to_a(int argc, VALUE* argv, VALUE self) { \
38
+ VALUE fmt = Qnil; \
39
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } }; \
40
+ ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; \
41
+ ndfunc_t ndf = { iter_##tDType##_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout }; \
42
+ rb_scan_args(argc, argv, "01", &fmt); \
43
+ return na_ndloop_cast_narray_to_rarray(&ndf, self, fmt); \
44
+ }
45
+
46
+ #define DEF_NARRAY_BIT_FORMAT_TO_A_METHOD_FUNC() \
47
+ static void iter_bit_format_to_a(na_loop_t* const lp) { \
48
+ size_t n; \
49
+ BIT_DIGIT* a1; \
50
+ BIT_DIGIT x = 0; \
51
+ size_t p1; \
52
+ ssize_t s1; \
53
+ size_t* idx1; \
54
+ VALUE y; \
55
+ VALUE fmt = lp->option; \
56
+ volatile VALUE a; \
57
+ \
58
+ INIT_COUNTER(lp, n); \
59
+ INIT_PTR_BIT_IDX(lp, 0, a1, p1, s1, idx1); \
60
+ \
61
+ a = rb_ary_new2(n); \
62
+ rb_ary_push(lp->args[1].value, a); \
63
+ if (idx1) { \
64
+ for (size_t i = 0; i < n; i++) { \
65
+ LOAD_BIT(a1, p1 + *idx1, x); \
66
+ idx1++; \
67
+ y = format_bit(fmt, x); \
68
+ rb_ary_push(a, y); \
69
+ } \
70
+ } else { \
71
+ for (size_t i = 0; i < n; i++) { \
72
+ LOAD_BIT(a1, p1, x); \
73
+ p1 += s1; \
74
+ y = format_bit(fmt, x); \
75
+ rb_ary_push(a, y); \
76
+ } \
77
+ } \
78
+ } \
79
+ \
80
+ static VALUE bit_format_to_a(int argc, VALUE* argv, VALUE self) { \
81
+ VALUE fmt = Qnil; \
82
+ ndfunc_arg_in_t ain[3] = { { Qnil, 0 }, { sym_loop_opt }, { sym_option } }; \
83
+ ndfunc_arg_out_t aout[1] = { { rb_cArray, 0 } }; \
84
+ ndfunc_t ndf = { iter_bit_format_to_a, FULL_LOOP_NIP, 3, 1, ain, aout }; \
85
+ rb_scan_args(argc, argv, "01", &fmt); \
86
+ return na_ndloop_cast_narray_to_rarray(&ndf, self, fmt); \
87
+ }
88
+
89
+ #endif /* NUMO_NARRAY_MH_FORMAT_TO_A_H */
@@ -0,0 +1,33 @@
1
+ #ifndef NUMO_NARRAY_MH_INSPECT_H
2
+ #define NUMO_NARRAY_MH_INSPECT_H 1
3
+
4
+ #define DEF_NARRAY_INSPECT_METHOD_FUNC(tDType) \
5
+ static VALUE iter_##tDType##_inspect(char* ptr, size_t pos, VALUE fmt) { \
6
+ return format_##tDType(fmt, (tDType*)(ptr + pos)); \
7
+ } \
8
+ \
9
+ static VALUE tDType##_inspect(VALUE ary) { \
10
+ return na_ndloop_inspect(ary, iter_##tDType##_inspect, Qnil); \
11
+ }
12
+
13
+ #define DEF_NARRAY_ROBJ_INSPECT_METHOD_FUNC() \
14
+ static VALUE iter_robject_inspect(char* ptr, size_t pos, VALUE fmt) { \
15
+ return rb_inspect(*(VALUE*)(ptr + pos)); \
16
+ } \
17
+ \
18
+ static VALUE robject_inspect(VALUE ary) { \
19
+ return na_ndloop_inspect(ary, iter_robject_inspect, Qnil); \
20
+ }
21
+
22
+ #define DEF_NARRAY_BIT_INSPECT_METHOD_FUNC() \
23
+ static VALUE iter_bit_inspect(char* ptr, size_t pos, VALUE fmt) { \
24
+ BIT_DIGIT x; \
25
+ LOAD_BIT(ptr, pos, x); \
26
+ return format_bit(fmt, x); \
27
+ } \
28
+ \
29
+ static VALUE bit_inspect(VALUE ary) { \
30
+ return na_ndloop_inspect(ary, iter_bit_inspect, Qnil); \
31
+ }
32
+
33
+ #endif /* NUMO_NARRAY_MH_INSPECT_H */
@@ -0,0 +1,42 @@
1
+ #ifndef NUMO_NARRAY_MH_ISFINITE_H
2
+ #define NUMO_NARRAY_MH_ISFINITE_H 1
3
+
4
+ #define DEF_NARRAY_FLT_ISFINITE_METHOD_FUNC(tDType, tNAryClass) \
5
+ static void iter_##tDType##_isfinite(na_loop_t* const lp) { \
6
+ size_t n; \
7
+ char* p1; \
8
+ BIT_DIGIT* a2; \
9
+ size_t p2; \
10
+ ssize_t s1; \
11
+ ssize_t s2; \
12
+ size_t* idx1; \
13
+ tDType x; \
14
+ BIT_DIGIT b; \
15
+ INIT_COUNTER(lp, n); \
16
+ INIT_PTR_IDX(lp, 0, p1, s1, idx1); \
17
+ INIT_PTR_BIT(lp, 1, a2, p2, s2); \
18
+ if (idx1) { \
19
+ for (size_t i = 0; i < n; i++) { \
20
+ GET_DATA_INDEX(p1, idx1, tDType, x); \
21
+ b = (m_isfinite(x)) ? 1 : 0; \
22
+ STORE_BIT(a2, p2, b); \
23
+ p2 += s2; \
24
+ } \
25
+ } else { \
26
+ for (size_t i = 0; i < n; i++) { \
27
+ GET_DATA_STRIDE(p1, s1, tDType, x); \
28
+ b = (m_isfinite(x)) ? 1 : 0; \
29
+ STORE_BIT(a2, p2, b); \
30
+ p2 += s2; \
31
+ } \
32
+ } \
33
+ } \
34
+ \
35
+ static VALUE tDType##_isfinite(VALUE self) { \
36
+ ndfunc_arg_in_t ain[1] = { { tNAryClass, 0 } }; \
37
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } }; \
38
+ ndfunc_t ndf = { iter_##tDType##_isfinite, FULL_LOOP, 1, 1, ain, aout }; \
39
+ return na_ndloop(&ndf, 1, self); \
40
+ }
41
+
42
+ #endif /* NUMO_NARRAY_MH_ISFINITE_H */
@@ -0,0 +1,42 @@
1
+ #ifndef NUMO_NARRAY_MH_ISINF_H
2
+ #define NUMO_NARRAY_MH_ISINF_H 1
3
+
4
+ #define DEF_NARRAY_FLT_ISINF_METHOD_FUNC(tDType, tNAryClass) \
5
+ static void iter_##tDType##_isinf(na_loop_t* const lp) { \
6
+ size_t n; \
7
+ char* p1; \
8
+ BIT_DIGIT* a2; \
9
+ size_t p2; \
10
+ ssize_t s1; \
11
+ ssize_t s2; \
12
+ size_t* idx1; \
13
+ tDType x; \
14
+ BIT_DIGIT b; \
15
+ INIT_COUNTER(lp, n); \
16
+ INIT_PTR_IDX(lp, 0, p1, s1, idx1); \
17
+ INIT_PTR_BIT(lp, 1, a2, p2, s2); \
18
+ if (idx1) { \
19
+ for (size_t i = 0; i < n; i++) { \
20
+ GET_DATA_INDEX(p1, idx1, tDType, x); \
21
+ b = (m_isinf(x)) ? 1 : 0; \
22
+ STORE_BIT(a2, p2, b); \
23
+ p2 += s2; \
24
+ } \
25
+ } else { \
26
+ for (size_t i = 0; i < n; i++) { \
27
+ GET_DATA_STRIDE(p1, s1, tDType, x); \
28
+ b = (m_isinf(x)) ? 1 : 0; \
29
+ STORE_BIT(a2, p2, b); \
30
+ p2 += s2; \
31
+ } \
32
+ } \
33
+ } \
34
+ \
35
+ static VALUE tDType##_isinf(VALUE self) { \
36
+ ndfunc_arg_in_t ain[1] = { { tNAryClass, 0 } }; \
37
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } }; \
38
+ ndfunc_t ndf = { iter_##tDType##_isinf, FULL_LOOP, 1, 1, ain, aout }; \
39
+ return na_ndloop(&ndf, 1, self); \
40
+ }
41
+
42
+ #endif /* NUMO_NARRAY_MH_ISINF_H */
@@ -0,0 +1,42 @@
1
+ #ifndef NUMO_NARRAY_MH_ISNAN_H
2
+ #define NUMO_NARRAY_MH_ISNAN_H 1
3
+
4
+ #define DEF_NARRAY_FLT_ISNAN_METHOD_FUNC(tDType, tNAryClass) \
5
+ static void iter_##tDType##_isnan(na_loop_t* const lp) { \
6
+ size_t n; \
7
+ char* p1; \
8
+ BIT_DIGIT* a2; \
9
+ size_t p2; \
10
+ ssize_t s1; \
11
+ ssize_t s2; \
12
+ size_t* idx1; \
13
+ tDType x; \
14
+ BIT_DIGIT b; \
15
+ INIT_COUNTER(lp, n); \
16
+ INIT_PTR_IDX(lp, 0, p1, s1, idx1); \
17
+ INIT_PTR_BIT(lp, 1, a2, p2, s2); \
18
+ if (idx1) { \
19
+ for (size_t i = 0; i < n; i++) { \
20
+ GET_DATA_INDEX(p1, idx1, tDType, x); \
21
+ b = (m_isnan(x)) ? 1 : 0; \
22
+ STORE_BIT(a2, p2, b); \
23
+ p2 += s2; \
24
+ } \
25
+ } else { \
26
+ for (size_t i = 0; i < n; i++) { \
27
+ GET_DATA_STRIDE(p1, s1, tDType, x); \
28
+ b = (m_isnan(x)) ? 1 : 0; \
29
+ STORE_BIT(a2, p2, b); \
30
+ p2 += s2; \
31
+ } \
32
+ } \
33
+ } \
34
+ \
35
+ static VALUE tDType##_isnan(VALUE self) { \
36
+ ndfunc_arg_in_t ain[1] = { { tNAryClass, 0 } }; \
37
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } }; \
38
+ ndfunc_t ndf = { iter_##tDType##_isnan, FULL_LOOP, 1, 1, ain, aout }; \
39
+ return na_ndloop(&ndf, 1, self); \
40
+ }
41
+
42
+ #endif /* NUMO_NARRAY_MH_ISNAN_H */
@@ -0,0 +1,42 @@
1
+ #ifndef NUMO_NARRAY_MH_ISNEGINF_H
2
+ #define NUMO_NARRAY_MH_ISNEGINF_H 1
3
+
4
+ #define DEF_NARRAY_FLT_ISNEGINF_METHOD_FUNC(tDType, tNAryClass) \
5
+ static void iter_##tDType##_isneginf(na_loop_t* const lp) { \
6
+ size_t n; \
7
+ char* p1; \
8
+ BIT_DIGIT* a2; \
9
+ size_t p2; \
10
+ ssize_t s1; \
11
+ ssize_t s2; \
12
+ size_t* idx1; \
13
+ tDType x; \
14
+ BIT_DIGIT b; \
15
+ INIT_COUNTER(lp, n); \
16
+ INIT_PTR_IDX(lp, 0, p1, s1, idx1); \
17
+ INIT_PTR_BIT(lp, 1, a2, p2, s2); \
18
+ if (idx1) { \
19
+ for (size_t i = 0; i < n; i++) { \
20
+ GET_DATA_INDEX(p1, idx1, tDType, x); \
21
+ b = (m_isneginf(x)) ? 1 : 0; \
22
+ STORE_BIT(a2, p2, b); \
23
+ p2 += s2; \
24
+ } \
25
+ } else { \
26
+ for (size_t i = 0; i < n; i++) { \
27
+ GET_DATA_STRIDE(p1, s1, tDType, x); \
28
+ b = (m_isneginf(x)) ? 1 : 0; \
29
+ STORE_BIT(a2, p2, b); \
30
+ p2 += s2; \
31
+ } \
32
+ } \
33
+ } \
34
+ \
35
+ static VALUE tDType##_isneginf(VALUE self) { \
36
+ ndfunc_arg_in_t ain[1] = { { tNAryClass, 0 } }; \
37
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } }; \
38
+ ndfunc_t ndf = { iter_##tDType##_isneginf, FULL_LOOP, 1, 1, ain, aout }; \
39
+ return na_ndloop(&ndf, 1, self); \
40
+ }
41
+
42
+ #endif /* NUMO_NARRAY_MH_ISNEGINF_H */
@@ -0,0 +1,42 @@
1
+ #ifndef NUMO_NARRAY_MH_ISPOSINF_H
2
+ #define NUMO_NARRAY_MH_ISPOSINF_H 1
3
+
4
+ #define DEF_NARRAY_FLT_ISPOSINF_METHOD_FUNC(tDType, tNAryClass) \
5
+ static void iter_##tDType##_isposinf(na_loop_t* const lp) { \
6
+ size_t n; \
7
+ char* p1; \
8
+ BIT_DIGIT* a2; \
9
+ size_t p2; \
10
+ ssize_t s1; \
11
+ ssize_t s2; \
12
+ size_t* idx1; \
13
+ tDType x; \
14
+ BIT_DIGIT b; \
15
+ INIT_COUNTER(lp, n); \
16
+ INIT_PTR_IDX(lp, 0, p1, s1, idx1); \
17
+ INIT_PTR_BIT(lp, 1, a2, p2, s2); \
18
+ if (idx1) { \
19
+ for (size_t i = 0; i < n; i++) { \
20
+ GET_DATA_INDEX(p1, idx1, tDType, x); \
21
+ b = (m_isposinf(x)) ? 1 : 0; \
22
+ STORE_BIT(a2, p2, b); \
23
+ p2 += s2; \
24
+ } \
25
+ } else { \
26
+ for (size_t i = 0; i < n; i++) { \
27
+ GET_DATA_STRIDE(p1, s1, tDType, x); \
28
+ b = (m_isposinf(x)) ? 1 : 0; \
29
+ STORE_BIT(a2, p2, b); \
30
+ p2 += s2; \
31
+ } \
32
+ } \
33
+ } \
34
+ \
35
+ static VALUE tDType##_isposinf(VALUE self) { \
36
+ ndfunc_arg_in_t ain[1] = { { tNAryClass, 0 } }; \
37
+ ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } }; \
38
+ ndfunc_t ndf = { iter_##tDType##_isposinf, FULL_LOOP, 1, 1, ain, aout }; \
39
+ return na_ndloop(&ndf, 1, self); \
40
+ }
41
+
42
+ #endif /* NUMO_NARRAY_MH_ISPOSINF_H */
@@ -0,0 +1,69 @@
1
+ #ifndef NUMO_NARRAY_MH_LOGSEQ_H
2
+ #define NUMO_NARRAY_MH_LOGSEQ_H 1
3
+
4
+ #define DEF_NARRAY_FLT_LOGSEQ_METHOD_FUNC(tDType) \
5
+ typedef struct { \
6
+ tDType beg; \
7
+ tDType step; \
8
+ tDType base; \
9
+ double count; \
10
+ } logseq_opt_t; \
11
+ \
12
+ static void iter_##tDType##_logseq(na_loop_t* const lp) { \
13
+ size_t n; \
14
+ char* p1; \
15
+ ssize_t s1; \
16
+ size_t* idx1; \
17
+ tDType x; \
18
+ tDType beg; \
19
+ tDType step; \
20
+ tDType base; \
21
+ double c; \
22
+ logseq_opt_t* g; \
23
+ \
24
+ INIT_COUNTER(lp, n); \
25
+ INIT_PTR_IDX(lp, 0, p1, s1, idx1); \
26
+ g = (logseq_opt_t*)(lp->opt_ptr); \
27
+ beg = g->beg; \
28
+ step = g->step; \
29
+ base = g->base; \
30
+ c = g->count; \
31
+ if (idx1) { \
32
+ for (size_t i = 0; i < n; i++) { \
33
+ x = f_seq(beg, step, c++); \
34
+ *(tDType*)(p1 + *idx1) = m_pow(base, x); \
35
+ idx1++; \
36
+ } \
37
+ } else { \
38
+ for (size_t i = 0; i < n; i++) { \
39
+ x = f_seq(beg, step, c++); \
40
+ *(tDType*)(p1) = m_pow(base, x); \
41
+ p1 += s1; \
42
+ } \
43
+ } \
44
+ g->count = c; \
45
+ } \
46
+ \
47
+ static VALUE tDType##_logseq(int argc, VALUE* argv, VALUE self) { \
48
+ logseq_opt_t* g; \
49
+ VALUE vbeg; \
50
+ VALUE vstep; \
51
+ VALUE vbase = Qnil; \
52
+ ndfunc_arg_in_t ain[1] = { { OVERWRITE, 0 } }; \
53
+ ndfunc_t ndf = { iter_##tDType##_logseq, FULL_LOOP, 1, 0, ain, 0 }; \
54
+ \
55
+ g = ALLOCA_N(logseq_opt_t, 1); \
56
+ rb_scan_args(argc, argv, "21", &vbeg, &vstep, &vbase); \
57
+ g->beg = m_num_to_data(vbeg); \
58
+ g->step = m_num_to_data(vstep); \
59
+ g->count = 0; \
60
+ if (vbase == Qnil) { \
61
+ g->base = m_from_real(10); \
62
+ } else { \
63
+ g->base = m_num_to_data(vbase); \
64
+ } \
65
+ na_ndloop3(&ndf, g, 1, self); \
66
+ return self; \
67
+ }
68
+
69
+ #endif /* NUMO_NARRAY_MH_LOGSEQ_H */
@@ -3,7 +3,7 @@
3
3
 
4
4
  #include "unary_func.h"
5
5
 
6
- #define DEF_NARRAY_FLT_ACOS_METHOD_FUNC(tDType, tNAryType) \
7
- DEF_NARRAY_FLT_UNARY_MATH_METHOD_FUNC(acos, tDType, tNAryType)
6
+ #define DEF_NARRAY_FLT_ACOS_METHOD_FUNC(tDType, tNAryClass) \
7
+ DEF_NARRAY_FLT_UNARY_MATH_METHOD_FUNC(acos, tDType, tNAryClass)
8
8
 
9
9
  #endif /* NUMO_NARRAY_MH_MATH_ACOS_H */
@@ -3,7 +3,7 @@
3
3
 
4
4
  #include "unary_func.h"
5
5
 
6
- #define DEF_NARRAY_FLT_ACOSH_METHOD_FUNC(tDType, tNAryType) \
7
- DEF_NARRAY_FLT_UNARY_MATH_METHOD_FUNC(acosh, tDType, tNAryType)
6
+ #define DEF_NARRAY_FLT_ACOSH_METHOD_FUNC(tDType, tNAryClass) \
7
+ DEF_NARRAY_FLT_UNARY_MATH_METHOD_FUNC(acosh, tDType, tNAryClass)
8
8
 
9
9
  #endif /* NUMO_NARRAY_MH_MATH_ACOSH_H */
@@ -3,7 +3,7 @@
3
3
 
4
4
  #include "unary_func.h"
5
5
 
6
- #define DEF_NARRAY_FLT_ASIN_METHOD_FUNC(tDType, tNAryType) \
7
- DEF_NARRAY_FLT_UNARY_MATH_METHOD_FUNC(asin, tDType, tNAryType)
6
+ #define DEF_NARRAY_FLT_ASIN_METHOD_FUNC(tDType, tNAryClass) \
7
+ DEF_NARRAY_FLT_UNARY_MATH_METHOD_FUNC(asin, tDType, tNAryClass)
8
8
 
9
9
  #endif /* NUMO_NARRAY_MH_MATH_ASIN_H */
@@ -3,7 +3,7 @@
3
3
 
4
4
  #include "unary_func.h"
5
5
 
6
- #define DEF_NARRAY_FLT_ASINH_METHOD_FUNC(tDType, tNAryType) \
7
- DEF_NARRAY_FLT_UNARY_MATH_METHOD_FUNC(asinh, tDType, tNAryType)
6
+ #define DEF_NARRAY_FLT_ASINH_METHOD_FUNC(tDType, tNAryClass) \
7
+ DEF_NARRAY_FLT_UNARY_MATH_METHOD_FUNC(asinh, tDType, tNAryClass)
8
8
 
9
9
  #endif /* NUMO_NARRAY_MH_MATH_ASINH_H */
@@ -3,7 +3,7 @@
3
3
 
4
4
  #include "unary_func.h"
5
5
 
6
- #define DEF_NARRAY_FLT_ATAN_METHOD_FUNC(tDType, tNAryType) \
7
- DEF_NARRAY_FLT_UNARY_MATH_METHOD_FUNC(atan, tDType, tNAryType)
6
+ #define DEF_NARRAY_FLT_ATAN_METHOD_FUNC(tDType, tNAryClass) \
7
+ DEF_NARRAY_FLT_UNARY_MATH_METHOD_FUNC(atan, tDType, tNAryClass)
8
8
 
9
9
  #endif /* NUMO_NARRAY_MH_MATH_ATAN_H */
@@ -1,7 +1,7 @@
1
1
  #ifndef NUMO_NARRAY_MH_MATH_ATAN2_H
2
2
  #define NUMO_NARRAY_MH_MATH_ATAN2_H 1
3
3
 
4
- #define DEF_NARRAY_FLT_ATAN2_METHOD_FUNC(tDType, tNAryType) \
4
+ #define DEF_NARRAY_FLT_ATAN2_METHOD_FUNC(tDType, tNAryClass) \
5
5
  static void iter_##tDType##_math_s_atan2(na_loop_t* const lp) { \
6
6
  size_t n; \
7
7
  char *p1, *p2, *p3; \
@@ -20,8 +20,8 @@
20
20
  } \
21
21
  \
22
22
  static VALUE tDType##_math_s_atan2(VALUE mod, VALUE a1, VALUE a2) { \
23
- ndfunc_arg_in_t ain[2] = { { tNAryType, 0 }, { tNAryType, 0 } }; \
24
- ndfunc_arg_out_t aout[1] = { { tNAryType, 0 } }; \
23
+ ndfunc_arg_in_t ain[2] = { { tNAryClass, 0 }, { tNAryClass, 0 } }; \
24
+ ndfunc_arg_out_t aout[1] = { { tNAryClass, 0 } }; \
25
25
  ndfunc_t ndf = { iter_##tDType##_math_s_atan2, STRIDE_LOOP, 2, 1, ain, aout }; \
26
26
  return na_ndloop(&ndf, 2, a1, a2); \
27
27
  }
@@ -3,7 +3,7 @@
3
3
 
4
4
  #include "unary_func.h"
5
5
 
6
- #define DEF_NARRAY_FLT_ATANH_METHOD_FUNC(tDType, tNAryType) \
7
- DEF_NARRAY_FLT_UNARY_MATH_METHOD_FUNC(atanh, tDType, tNAryType)
6
+ #define DEF_NARRAY_FLT_ATANH_METHOD_FUNC(tDType, tNAryClass) \
7
+ DEF_NARRAY_FLT_UNARY_MATH_METHOD_FUNC(atanh, tDType, tNAryClass)
8
8
 
9
9
  #endif /* NUMO_NARRAY_MH_MATH_ATANH_H */