numo-narray-alt 0.9.11 → 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 (91) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -1
  3. data/README.md +7 -0
  4. data/ext/numo/narray/numo/narray.h +2 -2
  5. data/ext/numo/narray/numo/types/robj_macro.h +1 -1
  6. data/ext/numo/narray/src/mh/bincount.h +233 -0
  7. data/ext/numo/narray/src/mh/bit/and.h +225 -0
  8. data/ext/numo/narray/src/mh/bit/left_shift.h +225 -0
  9. data/ext/numo/narray/src/mh/bit/not.h +173 -0
  10. data/ext/numo/narray/src/mh/bit/or.h +225 -0
  11. data/ext/numo/narray/src/mh/bit/right_shift.h +225 -0
  12. data/ext/numo/narray/src/mh/bit/xor.h +225 -0
  13. data/ext/numo/narray/src/mh/coerce_cast.h +9 -0
  14. data/ext/numo/narray/src/mh/comp/binary_func.h +37 -0
  15. data/ext/numo/narray/src/mh/comp/eq.h +26 -0
  16. data/ext/numo/narray/src/mh/comp/ge.h +26 -0
  17. data/ext/numo/narray/src/mh/comp/gt.h +26 -0
  18. data/ext/numo/narray/src/mh/comp/le.h +26 -0
  19. data/ext/numo/narray/src/mh/comp/lt.h +26 -0
  20. data/ext/numo/narray/src/mh/comp/ne.h +26 -0
  21. data/ext/numo/narray/src/mh/comp/nearly_eq.h +26 -0
  22. data/ext/numo/narray/src/mh/divmod.h +142 -0
  23. data/ext/numo/narray/src/mh/eye.h +1 -1
  24. data/ext/numo/narray/src/mh/fill.h +94 -0
  25. data/ext/numo/narray/src/mh/format.h +108 -0
  26. data/ext/numo/narray/src/mh/format_to_a.h +89 -0
  27. data/ext/numo/narray/src/mh/inspect.h +33 -0
  28. data/ext/numo/narray/src/mh/isfinite.h +42 -0
  29. data/ext/numo/narray/src/mh/isinf.h +42 -0
  30. data/ext/numo/narray/src/mh/isnan.h +42 -0
  31. data/ext/numo/narray/src/mh/isneginf.h +42 -0
  32. data/ext/numo/narray/src/mh/isposinf.h +42 -0
  33. data/ext/numo/narray/src/mh/math/acos.h +2 -2
  34. data/ext/numo/narray/src/mh/math/acosh.h +2 -2
  35. data/ext/numo/narray/src/mh/math/asin.h +2 -2
  36. data/ext/numo/narray/src/mh/math/asinh.h +2 -2
  37. data/ext/numo/narray/src/mh/math/atan.h +2 -2
  38. data/ext/numo/narray/src/mh/math/atan2.h +3 -3
  39. data/ext/numo/narray/src/mh/math/atanh.h +2 -2
  40. data/ext/numo/narray/src/mh/math/cbrt.h +2 -2
  41. data/ext/numo/narray/src/mh/math/cos.h +2 -2
  42. data/ext/numo/narray/src/mh/math/cosh.h +2 -2
  43. data/ext/numo/narray/src/mh/math/erf.h +2 -2
  44. data/ext/numo/narray/src/mh/math/erfc.h +2 -2
  45. data/ext/numo/narray/src/mh/math/exp.h +2 -2
  46. data/ext/numo/narray/src/mh/math/exp10.h +2 -2
  47. data/ext/numo/narray/src/mh/math/exp2.h +2 -2
  48. data/ext/numo/narray/src/mh/math/expm1.h +2 -2
  49. data/ext/numo/narray/src/mh/math/frexp.h +3 -3
  50. data/ext/numo/narray/src/mh/math/hypot.h +3 -3
  51. data/ext/numo/narray/src/mh/math/ldexp.h +3 -3
  52. data/ext/numo/narray/src/mh/math/log.h +2 -2
  53. data/ext/numo/narray/src/mh/math/log10.h +2 -2
  54. data/ext/numo/narray/src/mh/math/log1p.h +2 -2
  55. data/ext/numo/narray/src/mh/math/log2.h +2 -2
  56. data/ext/numo/narray/src/mh/math/sin.h +2 -2
  57. data/ext/numo/narray/src/mh/math/sinc.h +2 -2
  58. data/ext/numo/narray/src/mh/math/sinh.h +2 -2
  59. data/ext/numo/narray/src/mh/math/sqrt.h +8 -8
  60. data/ext/numo/narray/src/mh/math/tan.h +2 -2
  61. data/ext/numo/narray/src/mh/math/tanh.h +2 -2
  62. data/ext/numo/narray/src/mh/math/unary_func.h +3 -3
  63. data/ext/numo/narray/src/mh/op/add.h +78 -0
  64. data/ext/numo/narray/src/mh/op/binary_func.h +423 -0
  65. data/ext/numo/narray/src/mh/op/div.h +118 -0
  66. data/ext/numo/narray/src/mh/op/mod.h +108 -0
  67. data/ext/numo/narray/src/mh/op/mul.h +78 -0
  68. data/ext/numo/narray/src/mh/op/sub.h +78 -0
  69. data/ext/numo/narray/src/mh/rand.h +2 -2
  70. data/ext/numo/narray/src/mh/round/ceil.h +11 -0
  71. data/ext/numo/narray/src/mh/round/floor.h +11 -0
  72. data/ext/numo/narray/src/mh/round/rint.h +9 -0
  73. data/ext/numo/narray/src/mh/round/round.h +11 -0
  74. data/ext/numo/narray/src/mh/round/trunc.h +11 -0
  75. data/ext/numo/narray/src/mh/round/unary_func.h +127 -0
  76. data/ext/numo/narray/src/mh/to_a.h +78 -0
  77. data/ext/numo/narray/src/t_bit.c +45 -234
  78. data/ext/numo/narray/src/t_dcomplex.c +584 -1809
  79. data/ext/numo/narray/src/t_dfloat.c +429 -2432
  80. data/ext/numo/narray/src/t_int16.c +481 -2283
  81. data/ext/numo/narray/src/t_int32.c +481 -2283
  82. data/ext/numo/narray/src/t_int64.c +481 -2283
  83. data/ext/numo/narray/src/t_int8.c +408 -1873
  84. data/ext/numo/narray/src/t_robject.c +448 -1977
  85. data/ext/numo/narray/src/t_scomplex.c +584 -1809
  86. data/ext/numo/narray/src/t_sfloat.c +429 -2434
  87. data/ext/numo/narray/src/t_uint16.c +480 -2278
  88. data/ext/numo/narray/src/t_uint32.c +480 -2278
  89. data/ext/numo/narray/src/t_uint64.c +480 -2278
  90. data/ext/numo/narray/src/t_uint8.c +407 -1868
  91. metadata +41 -2
@@ -0,0 +1,94 @@
1
+ #ifndef NUMO_NARRAY_MH_FILL_H
2
+ #define NUMO_NARRAY_MH_FILL_H 1
3
+
4
+ #define DEF_NARRAY_FILL_METHOD_FUNC(tDType) \
5
+ static void iter_##tDType##_fill(na_loop_t* const lp) { \
6
+ size_t n; \
7
+ char* p1; \
8
+ ssize_t s1; \
9
+ size_t* idx1; \
10
+ VALUE x = lp->option; \
11
+ tDType y; \
12
+ \
13
+ INIT_COUNTER(lp, n); \
14
+ INIT_PTR_IDX(lp, 0, p1, s1, idx1); \
15
+ y = m_num_to_data(x); \
16
+ \
17
+ if (idx1) { \
18
+ for (size_t i = 0; i < n; i++) { \
19
+ SET_DATA_INDEX(p1, idx1, tDType, y); \
20
+ } \
21
+ } else { \
22
+ for (size_t i = 0; i < n; i++) { \
23
+ SET_DATA_STRIDE(p1, s1, tDType, y); \
24
+ } \
25
+ } \
26
+ } \
27
+ \
28
+ static VALUE tDType##_fill(VALUE self, VALUE val) { \
29
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } }; \
30
+ ndfunc_t ndf = { iter_##tDType##_fill, FULL_LOOP, 2, 0, ain, 0 }; \
31
+ na_ndloop(&ndf, 2, self, val); \
32
+ return self; \
33
+ }
34
+
35
+ #define DEF_NARRAY_BIT_FILL_METHOD_FUNC() \
36
+ static void iter_bit_fill(na_loop_t* const lp) { \
37
+ size_t n; \
38
+ size_t p3; \
39
+ ssize_t s3; \
40
+ size_t* idx3; \
41
+ int len; \
42
+ BIT_DIGIT* a3; \
43
+ BIT_DIGIT y; \
44
+ VALUE x = lp->option; \
45
+ \
46
+ if (x == INT2FIX(0) || x == Qfalse) { \
47
+ y = 0; \
48
+ } else if (x == INT2FIX(1) || x == Qtrue) { \
49
+ y = ~(BIT_DIGIT)0; \
50
+ } else { \
51
+ rb_raise(rb_eArgError, "invalid value for Bit"); \
52
+ } \
53
+ \
54
+ INIT_COUNTER(lp, n); \
55
+ INIT_PTR_BIT_IDX(lp, 0, a3, p3, s3, idx3); \
56
+ if (idx3) { \
57
+ y = y & 1; \
58
+ for (size_t i = 0; i < n; i++) { \
59
+ STORE_BIT(a3, p3 + *idx3, y); \
60
+ idx3++; \
61
+ } \
62
+ } else if (s3 != 1) { \
63
+ y = y & 1; \
64
+ for (size_t i = 0; i < n; i++) { \
65
+ STORE_BIT(a3, p3, y); \
66
+ p3 += s3; \
67
+ } \
68
+ } else { \
69
+ if (p3 > 0 || n < NB) { \
70
+ len = (int)(NB - p3); \
71
+ if ((int)n < len) { \
72
+ len = (int)n; \
73
+ } \
74
+ *a3 = (y & (SLB(len) << p3)) | (*a3 & ~(SLB(len) << p3)); \
75
+ a3++; \
76
+ n -= len; \
77
+ } \
78
+ for (; n >= NB; n -= NB) { \
79
+ *(a3++) = y; \
80
+ } \
81
+ if (n > 0) { \
82
+ *a3 = (y & SLB(n)) | (*a3 & BALL << n); \
83
+ } \
84
+ } \
85
+ } \
86
+ \
87
+ static VALUE bit_fill(VALUE self, VALUE val) { \
88
+ ndfunc_arg_in_t ain[2] = { { OVERWRITE, 0 }, { sym_option } }; \
89
+ ndfunc_t ndf = { iter_bit_fill, FULL_LOOP, 2, 0, ain, 0 }; \
90
+ na_ndloop(&ndf, 2, self, val); \
91
+ return self; \
92
+ }
93
+
94
+ #endif /* NUMO_NARRAY_MH_FILL_H */
@@ -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 */
@@ -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 */