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.
- checksums.yaml +4 -4
- data/Gemfile +0 -1
- data/README.md +7 -0
- data/ext/numo/narray/numo/narray.h +2 -2
- data/ext/numo/narray/numo/types/robj_macro.h +1 -1
- data/ext/numo/narray/src/mh/bincount.h +233 -0
- data/ext/numo/narray/src/mh/bit/and.h +225 -0
- data/ext/numo/narray/src/mh/bit/left_shift.h +225 -0
- data/ext/numo/narray/src/mh/bit/not.h +173 -0
- data/ext/numo/narray/src/mh/bit/or.h +225 -0
- data/ext/numo/narray/src/mh/bit/right_shift.h +225 -0
- data/ext/numo/narray/src/mh/bit/xor.h +225 -0
- data/ext/numo/narray/src/mh/coerce_cast.h +9 -0
- data/ext/numo/narray/src/mh/comp/binary_func.h +37 -0
- data/ext/numo/narray/src/mh/comp/eq.h +26 -0
- data/ext/numo/narray/src/mh/comp/ge.h +26 -0
- data/ext/numo/narray/src/mh/comp/gt.h +26 -0
- data/ext/numo/narray/src/mh/comp/le.h +26 -0
- data/ext/numo/narray/src/mh/comp/lt.h +26 -0
- data/ext/numo/narray/src/mh/comp/ne.h +26 -0
- data/ext/numo/narray/src/mh/comp/nearly_eq.h +26 -0
- data/ext/numo/narray/src/mh/divmod.h +142 -0
- data/ext/numo/narray/src/mh/eye.h +1 -1
- data/ext/numo/narray/src/mh/fill.h +94 -0
- data/ext/numo/narray/src/mh/format.h +108 -0
- data/ext/numo/narray/src/mh/format_to_a.h +89 -0
- data/ext/numo/narray/src/mh/inspect.h +33 -0
- data/ext/numo/narray/src/mh/isfinite.h +42 -0
- data/ext/numo/narray/src/mh/isinf.h +42 -0
- data/ext/numo/narray/src/mh/isnan.h +42 -0
- data/ext/numo/narray/src/mh/isneginf.h +42 -0
- data/ext/numo/narray/src/mh/isposinf.h +42 -0
- data/ext/numo/narray/src/mh/math/acos.h +2 -2
- data/ext/numo/narray/src/mh/math/acosh.h +2 -2
- data/ext/numo/narray/src/mh/math/asin.h +2 -2
- data/ext/numo/narray/src/mh/math/asinh.h +2 -2
- data/ext/numo/narray/src/mh/math/atan.h +2 -2
- data/ext/numo/narray/src/mh/math/atan2.h +3 -3
- data/ext/numo/narray/src/mh/math/atanh.h +2 -2
- data/ext/numo/narray/src/mh/math/cbrt.h +2 -2
- data/ext/numo/narray/src/mh/math/cos.h +2 -2
- data/ext/numo/narray/src/mh/math/cosh.h +2 -2
- data/ext/numo/narray/src/mh/math/erf.h +2 -2
- data/ext/numo/narray/src/mh/math/erfc.h +2 -2
- data/ext/numo/narray/src/mh/math/exp.h +2 -2
- data/ext/numo/narray/src/mh/math/exp10.h +2 -2
- data/ext/numo/narray/src/mh/math/exp2.h +2 -2
- data/ext/numo/narray/src/mh/math/expm1.h +2 -2
- data/ext/numo/narray/src/mh/math/frexp.h +3 -3
- data/ext/numo/narray/src/mh/math/hypot.h +3 -3
- data/ext/numo/narray/src/mh/math/ldexp.h +3 -3
- data/ext/numo/narray/src/mh/math/log.h +2 -2
- data/ext/numo/narray/src/mh/math/log10.h +2 -2
- data/ext/numo/narray/src/mh/math/log1p.h +2 -2
- data/ext/numo/narray/src/mh/math/log2.h +2 -2
- data/ext/numo/narray/src/mh/math/sin.h +2 -2
- data/ext/numo/narray/src/mh/math/sinc.h +2 -2
- data/ext/numo/narray/src/mh/math/sinh.h +2 -2
- data/ext/numo/narray/src/mh/math/sqrt.h +8 -8
- data/ext/numo/narray/src/mh/math/tan.h +2 -2
- data/ext/numo/narray/src/mh/math/tanh.h +2 -2
- data/ext/numo/narray/src/mh/math/unary_func.h +3 -3
- data/ext/numo/narray/src/mh/op/add.h +78 -0
- data/ext/numo/narray/src/mh/op/binary_func.h +423 -0
- data/ext/numo/narray/src/mh/op/div.h +118 -0
- data/ext/numo/narray/src/mh/op/mod.h +108 -0
- data/ext/numo/narray/src/mh/op/mul.h +78 -0
- data/ext/numo/narray/src/mh/op/sub.h +78 -0
- data/ext/numo/narray/src/mh/rand.h +2 -2
- data/ext/numo/narray/src/mh/round/ceil.h +11 -0
- data/ext/numo/narray/src/mh/round/floor.h +11 -0
- data/ext/numo/narray/src/mh/round/rint.h +9 -0
- data/ext/numo/narray/src/mh/round/round.h +11 -0
- data/ext/numo/narray/src/mh/round/trunc.h +11 -0
- data/ext/numo/narray/src/mh/round/unary_func.h +127 -0
- data/ext/numo/narray/src/mh/to_a.h +78 -0
- data/ext/numo/narray/src/t_bit.c +45 -234
- data/ext/numo/narray/src/t_dcomplex.c +584 -1809
- data/ext/numo/narray/src/t_dfloat.c +429 -2432
- data/ext/numo/narray/src/t_int16.c +481 -2283
- data/ext/numo/narray/src/t_int32.c +481 -2283
- data/ext/numo/narray/src/t_int64.c +481 -2283
- data/ext/numo/narray/src/t_int8.c +408 -1873
- data/ext/numo/narray/src/t_robject.c +448 -1977
- data/ext/numo/narray/src/t_scomplex.c +584 -1809
- data/ext/numo/narray/src/t_sfloat.c +429 -2434
- data/ext/numo/narray/src/t_uint16.c +480 -2278
- data/ext/numo/narray/src/t_uint32.c +480 -2278
- data/ext/numo/narray/src/t_uint64.c +480 -2278
- data/ext/numo/narray/src/t_uint8.c +407 -1868
- metadata +41 -2
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
#ifndef NUMO_NARRAY_MH_BIT_LEFT_SHIFT_H
|
|
2
|
+
#define NUMO_NARRAY_MH_BIT_LEFT_SHIFT_H 1
|
|
3
|
+
|
|
4
|
+
#define DEF_NARRAY_INT_LEFT_SHIFT_METHOD_FUNC(tDType, tNAryClass) \
|
|
5
|
+
static void iter_##tDType##_left_shift(na_loop_t* const lp) { \
|
|
6
|
+
size_t n; \
|
|
7
|
+
char* p1; \
|
|
8
|
+
char* p2; \
|
|
9
|
+
char* p3; \
|
|
10
|
+
ssize_t s1; \
|
|
11
|
+
ssize_t s2; \
|
|
12
|
+
ssize_t s3; \
|
|
13
|
+
INIT_COUNTER(lp, n); \
|
|
14
|
+
INIT_PTR(lp, 0, p1, s1); \
|
|
15
|
+
INIT_PTR(lp, 1, p2, s2); \
|
|
16
|
+
INIT_PTR(lp, 2, p3, s3); \
|
|
17
|
+
if (is_aligned(p1, sizeof(tDType)) && is_aligned(p2, sizeof(tDType)) && \
|
|
18
|
+
is_aligned(p3, sizeof(tDType))) { \
|
|
19
|
+
if (s1 == sizeof(tDType) && s2 == sizeof(tDType) && s3 == sizeof(tDType)) { \
|
|
20
|
+
if (p1 == p3) { \
|
|
21
|
+
for (size_t i = 0; i < n; i++) { \
|
|
22
|
+
((tDType*)p1)[i] = m_left_shift(((tDType*)p1)[i], ((tDType*)p2)[i]); \
|
|
23
|
+
} \
|
|
24
|
+
} else { \
|
|
25
|
+
for (size_t i = 0; i < n; i++) { \
|
|
26
|
+
((tDType*)p3)[i] = m_left_shift(((tDType*)p1)[i], ((tDType*)p2)[i]); \
|
|
27
|
+
} \
|
|
28
|
+
} \
|
|
29
|
+
return; \
|
|
30
|
+
} \
|
|
31
|
+
if (is_aligned_step(s1, sizeof(tDType)) && is_aligned_step(s2, sizeof(tDType)) && \
|
|
32
|
+
is_aligned_step(s3, sizeof(tDType))) { \
|
|
33
|
+
if (s2 == 0) { \
|
|
34
|
+
const tDType v2 = *(tDType*)p2; \
|
|
35
|
+
if (s1 == sizeof(tDType) && s3 == sizeof(tDType)) { \
|
|
36
|
+
if (p1 == p3) { \
|
|
37
|
+
for (size_t i = 0; i < n; i++) { \
|
|
38
|
+
((tDType*)p1)[i] = m_left_shift(((tDType*)p1)[i], v2); \
|
|
39
|
+
} \
|
|
40
|
+
} else { \
|
|
41
|
+
for (size_t i = 0; i < n; i++) { \
|
|
42
|
+
((tDType*)p3)[i] = m_left_shift(((tDType*)p1)[i], v2); \
|
|
43
|
+
} \
|
|
44
|
+
} \
|
|
45
|
+
} else { \
|
|
46
|
+
for (size_t i = 0; i < n; i++) { \
|
|
47
|
+
*(tDType*)p3 = m_left_shift(*(tDType*)p1, v2); \
|
|
48
|
+
p1 += s1; \
|
|
49
|
+
p3 += s3; \
|
|
50
|
+
} \
|
|
51
|
+
} \
|
|
52
|
+
} else { \
|
|
53
|
+
if (p1 == p3) { \
|
|
54
|
+
for (size_t i = 0; i < n; i++) { \
|
|
55
|
+
*(tDType*)p1 = m_left_shift(*(tDType*)p1, *(tDType*)p2); \
|
|
56
|
+
p1 += s1; \
|
|
57
|
+
p2 += s2; \
|
|
58
|
+
} \
|
|
59
|
+
} else { \
|
|
60
|
+
for (size_t i = 0; i < n; i++) { \
|
|
61
|
+
*(tDType*)p3 = m_left_shift(*(tDType*)p1, *(tDType*)p2); \
|
|
62
|
+
p1 += s1; \
|
|
63
|
+
p2 += s2; \
|
|
64
|
+
p3 += s3; \
|
|
65
|
+
} \
|
|
66
|
+
} \
|
|
67
|
+
} \
|
|
68
|
+
return; \
|
|
69
|
+
} \
|
|
70
|
+
} \
|
|
71
|
+
for (size_t i = 0; i < n; i++) { \
|
|
72
|
+
tDType x; \
|
|
73
|
+
tDType y; \
|
|
74
|
+
tDType z; \
|
|
75
|
+
GET_DATA_STRIDE(p1, s1, tDType, x); \
|
|
76
|
+
GET_DATA_STRIDE(p2, s2, tDType, y); \
|
|
77
|
+
z = m_left_shift(x, y); \
|
|
78
|
+
SET_DATA_STRIDE(p3, s3, tDType, z); \
|
|
79
|
+
} \
|
|
80
|
+
} \
|
|
81
|
+
\
|
|
82
|
+
static VALUE tDType##_left_shift_self(VALUE self, VALUE other) { \
|
|
83
|
+
ndfunc_arg_in_t ain[2] = { { tNAryClass, 0 }, { tNAryClass, 0 } }; \
|
|
84
|
+
ndfunc_arg_out_t aout[1] = { { tNAryClass, 0 } }; \
|
|
85
|
+
ndfunc_t ndf = { iter_##tDType##_left_shift, STRIDE_LOOP, 2, 1, ain, aout }; \
|
|
86
|
+
return na_ndloop(&ndf, 2, self, other); \
|
|
87
|
+
} \
|
|
88
|
+
\
|
|
89
|
+
static VALUE tDType##_left_shift(VALUE self, VALUE other) { \
|
|
90
|
+
VALUE klass = na_upcast(rb_obj_class(self), rb_obj_class(other)); \
|
|
91
|
+
if (klass == tNAryClass) { \
|
|
92
|
+
return tDType##_left_shift_self(self, other); \
|
|
93
|
+
} \
|
|
94
|
+
VALUE v = rb_funcall(klass, id_cast, 1, self); \
|
|
95
|
+
return rb_funcall(v, id_left_shift, 1, other); \
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#define DEF_NARRAY_INT8_LEFT_SHIFT_METHOD_FUNC(tDType, tNAryClass) \
|
|
99
|
+
static void iter_##tDType##_left_shift(na_loop_t* const lp) { \
|
|
100
|
+
size_t n; \
|
|
101
|
+
char* p1; \
|
|
102
|
+
char* p2; \
|
|
103
|
+
char* p3; \
|
|
104
|
+
ssize_t s1; \
|
|
105
|
+
ssize_t s2; \
|
|
106
|
+
ssize_t s3; \
|
|
107
|
+
INIT_COUNTER(lp, n); \
|
|
108
|
+
INIT_PTR(lp, 0, p1, s1); \
|
|
109
|
+
INIT_PTR(lp, 1, p2, s2); \
|
|
110
|
+
INIT_PTR(lp, 2, p3, s3); \
|
|
111
|
+
if (s2 == 0) { \
|
|
112
|
+
const tDType v2 = *(tDType*)p2; \
|
|
113
|
+
if (s1 == sizeof(tDType) && s3 == sizeof(tDType)) { \
|
|
114
|
+
if (p1 == p3) { \
|
|
115
|
+
for (size_t i = 0; i < n; i++) { \
|
|
116
|
+
((tDType*)p1)[i] = m_left_shift(((tDType*)p1)[i], v2); \
|
|
117
|
+
} \
|
|
118
|
+
} else { \
|
|
119
|
+
for (size_t i = 0; i < n; i++) { \
|
|
120
|
+
((tDType*)p3)[i] = m_left_shift(((tDType*)p1)[i], v2); \
|
|
121
|
+
} \
|
|
122
|
+
} \
|
|
123
|
+
} else { \
|
|
124
|
+
for (size_t i = 0; i < n; i++) { \
|
|
125
|
+
*(tDType*)p3 = m_left_shift(*(tDType*)p1, v2); \
|
|
126
|
+
p1 += s1; \
|
|
127
|
+
p3 += s3; \
|
|
128
|
+
} \
|
|
129
|
+
} \
|
|
130
|
+
} else { \
|
|
131
|
+
if (p1 == p3) { \
|
|
132
|
+
for (size_t i = 0; i < n; i++) { \
|
|
133
|
+
*(tDType*)p1 = m_left_shift(*(tDType*)p1, *(tDType*)p2); \
|
|
134
|
+
p1 += s1; \
|
|
135
|
+
p2 += s2; \
|
|
136
|
+
} \
|
|
137
|
+
} else { \
|
|
138
|
+
for (size_t i = 0; i < n; i++) { \
|
|
139
|
+
*(tDType*)p3 = m_left_shift(*(tDType*)p1, *(tDType*)p2); \
|
|
140
|
+
p1 += s1; \
|
|
141
|
+
p2 += s2; \
|
|
142
|
+
p3 += s3; \
|
|
143
|
+
} \
|
|
144
|
+
} \
|
|
145
|
+
} \
|
|
146
|
+
} \
|
|
147
|
+
\
|
|
148
|
+
static VALUE tDType##_left_shift_self(VALUE self, VALUE other) { \
|
|
149
|
+
ndfunc_arg_in_t ain[2] = { { tNAryClass, 0 }, { tNAryClass, 0 } }; \
|
|
150
|
+
ndfunc_arg_out_t aout[1] = { { tNAryClass, 0 } }; \
|
|
151
|
+
ndfunc_t ndf = { iter_##tDType##_left_shift, STRIDE_LOOP, 2, 1, ain, aout }; \
|
|
152
|
+
return na_ndloop(&ndf, 2, self, other); \
|
|
153
|
+
} \
|
|
154
|
+
\
|
|
155
|
+
static VALUE tDType##_left_shift(VALUE self, VALUE other) { \
|
|
156
|
+
VALUE klass = na_upcast(rb_obj_class(self), rb_obj_class(other)); \
|
|
157
|
+
if (klass == tNAryClass) { \
|
|
158
|
+
return tDType##_left_shift_self(self, other); \
|
|
159
|
+
} \
|
|
160
|
+
VALUE v = rb_funcall(klass, id_cast, 1, self); \
|
|
161
|
+
return rb_funcall(v, id_left_shift, 1, other); \
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
#define DEF_NARRAY_ROBJ_LEFT_SHIFT_METHOD_FUNC() \
|
|
165
|
+
static void iter_robject_left_shift(na_loop_t* const lp) { \
|
|
166
|
+
size_t n; \
|
|
167
|
+
char* p1; \
|
|
168
|
+
char* p2; \
|
|
169
|
+
char* p3; \
|
|
170
|
+
ssize_t s1; \
|
|
171
|
+
ssize_t s2; \
|
|
172
|
+
ssize_t s3; \
|
|
173
|
+
INIT_COUNTER(lp, n); \
|
|
174
|
+
INIT_PTR(lp, 0, p1, s1); \
|
|
175
|
+
INIT_PTR(lp, 1, p2, s2); \
|
|
176
|
+
INIT_PTR(lp, 2, p3, s3); \
|
|
177
|
+
if (s2 == 0) { \
|
|
178
|
+
const robject v2 = *(robject*)p2; \
|
|
179
|
+
if (s1 == sizeof(robject) && s3 == sizeof(robject)) { \
|
|
180
|
+
if (p1 == p3) { \
|
|
181
|
+
for (size_t i = 0; i < n; i++) { \
|
|
182
|
+
((robject*)p1)[i] = m_left_shift(((robject*)p1)[i], v2); \
|
|
183
|
+
} \
|
|
184
|
+
} else { \
|
|
185
|
+
for (size_t i = 0; i < n; i++) { \
|
|
186
|
+
((robject*)p3)[i] = m_left_shift(((robject*)p1)[i], v2); \
|
|
187
|
+
} \
|
|
188
|
+
} \
|
|
189
|
+
} else { \
|
|
190
|
+
for (size_t i = 0; i < n; i++) { \
|
|
191
|
+
*(robject*)p3 = m_left_shift(*(robject*)p1, v2); \
|
|
192
|
+
p1 += s1; \
|
|
193
|
+
p3 += s3; \
|
|
194
|
+
} \
|
|
195
|
+
} \
|
|
196
|
+
} else { \
|
|
197
|
+
if (p1 == p3) { \
|
|
198
|
+
for (size_t i = 0; i < n; i++) { \
|
|
199
|
+
*(robject*)p1 = m_left_shift(*(robject*)p1, *(robject*)p2); \
|
|
200
|
+
p1 += s1; \
|
|
201
|
+
p2 += s2; \
|
|
202
|
+
} \
|
|
203
|
+
} else { \
|
|
204
|
+
for (size_t i = 0; i < n; i++) { \
|
|
205
|
+
*(robject*)p3 = m_left_shift(*(robject*)p1, *(robject*)p2); \
|
|
206
|
+
p1 += s1; \
|
|
207
|
+
p2 += s2; \
|
|
208
|
+
p3 += s3; \
|
|
209
|
+
} \
|
|
210
|
+
} \
|
|
211
|
+
} \
|
|
212
|
+
} \
|
|
213
|
+
\
|
|
214
|
+
static VALUE robject_left_shift_self(VALUE self, VALUE other) { \
|
|
215
|
+
ndfunc_arg_in_t ain[2] = { { numo_cRObject, 0 }, { numo_cRObject, 0 } }; \
|
|
216
|
+
ndfunc_arg_out_t aout[1] = { { numo_cRObject, 0 } }; \
|
|
217
|
+
ndfunc_t ndf = { iter_robject_left_shift, STRIDE_LOOP, 2, 1, ain, aout }; \
|
|
218
|
+
return na_ndloop(&ndf, 2, self, other); \
|
|
219
|
+
} \
|
|
220
|
+
\
|
|
221
|
+
static VALUE robject_left_shift(VALUE self, VALUE other) { \
|
|
222
|
+
return robject_left_shift_self(self, other); \
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
#endif /* NUMO_NARRAY_MH_BIT_LEFT_SHIFT_H */
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
#ifndef NUMO_NARRAY_MH_BIT_NOT_H
|
|
2
|
+
#define NUMO_NARRAY_MH_BIT_NOT_H 1
|
|
3
|
+
|
|
4
|
+
#define DEF_NARRAY_INT_BIT_NOT_METHOD_FUNC(tDType, tNAryClass) \
|
|
5
|
+
static void iter_##tDType##_bit_not(na_loop_t* const lp) { \
|
|
6
|
+
size_t n; \
|
|
7
|
+
char* p1; \
|
|
8
|
+
char* p2; \
|
|
9
|
+
ssize_t s1; \
|
|
10
|
+
ssize_t s2; \
|
|
11
|
+
size_t* idx1; \
|
|
12
|
+
size_t* idx2; \
|
|
13
|
+
INIT_COUNTER(lp, n); \
|
|
14
|
+
INIT_PTR_IDX(lp, 0, p1, s1, idx1); \
|
|
15
|
+
INIT_PTR_IDX(lp, 1, p2, s2, idx2); \
|
|
16
|
+
tDType x; \
|
|
17
|
+
if (idx1) { \
|
|
18
|
+
if (idx2) { \
|
|
19
|
+
for (size_t i = 0; i < n; i++) { \
|
|
20
|
+
GET_DATA_INDEX(p1, idx1, tDType, x); \
|
|
21
|
+
x = m_bit_not(x); \
|
|
22
|
+
SET_DATA_INDEX(p2, idx2, tDType, x); \
|
|
23
|
+
} \
|
|
24
|
+
} else { \
|
|
25
|
+
for (size_t i = 0; i < n; i++) { \
|
|
26
|
+
GET_DATA_INDEX(p1, idx1, tDType, x); \
|
|
27
|
+
x = m_bit_not(x); \
|
|
28
|
+
SET_DATA_STRIDE(p2, s2, tDType, x); \
|
|
29
|
+
} \
|
|
30
|
+
} \
|
|
31
|
+
} else { \
|
|
32
|
+
if (idx2) { \
|
|
33
|
+
for (size_t i = 0; i < n; i++) { \
|
|
34
|
+
GET_DATA_STRIDE(p1, s1, tDType, x); \
|
|
35
|
+
x = m_bit_not(x); \
|
|
36
|
+
SET_DATA_INDEX(p2, idx2, tDType, x); \
|
|
37
|
+
} \
|
|
38
|
+
} else { \
|
|
39
|
+
if (is_aligned(p1, sizeof(tDType)) && is_aligned(p2, sizeof(tDType))) { \
|
|
40
|
+
if (s1 == sizeof(tDType) && s2 == sizeof(tDType)) { \
|
|
41
|
+
for (size_t i = 0; i < n; i++) { \
|
|
42
|
+
((tDType*)p2)[i] = m_bit_not(((tDType*)p1)[i]); \
|
|
43
|
+
} \
|
|
44
|
+
return; \
|
|
45
|
+
} \
|
|
46
|
+
if (is_aligned_step(s1, sizeof(tDType)) && is_aligned_step(s2, sizeof(tDType))) { \
|
|
47
|
+
for (size_t i = 0; i < n; i++) { \
|
|
48
|
+
*(tDType*)p2 = m_bit_not(*(tDType*)p1); \
|
|
49
|
+
p1 += s1; \
|
|
50
|
+
p2 += s2; \
|
|
51
|
+
} \
|
|
52
|
+
return; \
|
|
53
|
+
} \
|
|
54
|
+
} \
|
|
55
|
+
for (size_t i = 0; i < n; i++) { \
|
|
56
|
+
GET_DATA_STRIDE(p1, s1, tDType, x); \
|
|
57
|
+
x = m_bit_not(x); \
|
|
58
|
+
SET_DATA_STRIDE(p2, s2, tDType, x); \
|
|
59
|
+
} \
|
|
60
|
+
} \
|
|
61
|
+
} \
|
|
62
|
+
} \
|
|
63
|
+
\
|
|
64
|
+
static VALUE tDType##_bit_not(VALUE self) { \
|
|
65
|
+
ndfunc_arg_in_t ain[1] = { { tNAryClass, 0 } }; \
|
|
66
|
+
ndfunc_arg_out_t aout[1] = { { tNAryClass, 0 } }; \
|
|
67
|
+
ndfunc_t ndf = { iter_##tDType##_bit_not, FULL_LOOP, 1, 1, ain, aout }; \
|
|
68
|
+
return na_ndloop(&ndf, 1, self); \
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
#define DEF_NARRAY_INT8_BIT_NOT_METHOD_FUNC(tDType, tNAryClass) \
|
|
72
|
+
static void iter_##tDType##_bit_not(na_loop_t* const lp) { \
|
|
73
|
+
size_t n; \
|
|
74
|
+
char* p1; \
|
|
75
|
+
char* p2; \
|
|
76
|
+
ssize_t s1; \
|
|
77
|
+
ssize_t s2; \
|
|
78
|
+
size_t* idx1; \
|
|
79
|
+
size_t* idx2; \
|
|
80
|
+
INIT_COUNTER(lp, n); \
|
|
81
|
+
INIT_PTR_IDX(lp, 0, p1, s1, idx1); \
|
|
82
|
+
INIT_PTR_IDX(lp, 1, p2, s2, idx2); \
|
|
83
|
+
tDType x; \
|
|
84
|
+
if (idx1) { \
|
|
85
|
+
if (idx2) { \
|
|
86
|
+
for (size_t i = 0; i < n; i++) { \
|
|
87
|
+
GET_DATA_INDEX(p1, idx1, tDType, x); \
|
|
88
|
+
x = m_bit_not(x); \
|
|
89
|
+
SET_DATA_INDEX(p2, idx2, tDType, x); \
|
|
90
|
+
} \
|
|
91
|
+
} else { \
|
|
92
|
+
for (size_t i = 0; i < n; i++) { \
|
|
93
|
+
GET_DATA_INDEX(p1, idx1, tDType, x); \
|
|
94
|
+
x = m_bit_not(x); \
|
|
95
|
+
SET_DATA_STRIDE(p2, s2, tDType, x); \
|
|
96
|
+
} \
|
|
97
|
+
} \
|
|
98
|
+
} else { \
|
|
99
|
+
if (idx2) { \
|
|
100
|
+
for (size_t i = 0; i < n; i++) { \
|
|
101
|
+
GET_DATA_STRIDE(p1, s1, tDType, x); \
|
|
102
|
+
x = m_bit_not(x); \
|
|
103
|
+
SET_DATA_INDEX(p2, idx2, tDType, x); \
|
|
104
|
+
} \
|
|
105
|
+
} else { \
|
|
106
|
+
for (size_t i = 0; i < n; i++) { \
|
|
107
|
+
*(tDType*)p2 = m_bit_not(*(tDType*)p1); \
|
|
108
|
+
p1 += s1; \
|
|
109
|
+
p2 += s2; \
|
|
110
|
+
} \
|
|
111
|
+
} \
|
|
112
|
+
} \
|
|
113
|
+
} \
|
|
114
|
+
\
|
|
115
|
+
static VALUE tDType##_bit_not(VALUE self) { \
|
|
116
|
+
ndfunc_arg_in_t ain[1] = { { tNAryClass, 0 } }; \
|
|
117
|
+
ndfunc_arg_out_t aout[1] = { { tNAryClass, 0 } }; \
|
|
118
|
+
ndfunc_t ndf = { iter_##tDType##_bit_not, FULL_LOOP, 1, 1, ain, aout }; \
|
|
119
|
+
return na_ndloop(&ndf, 1, self); \
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
#define DEF_NARRAY_ROBJ_BIT_NOT_METHOD_FUNC() \
|
|
123
|
+
static void iter_robject_bit_not(na_loop_t* const lp) { \
|
|
124
|
+
size_t n; \
|
|
125
|
+
char* p1; \
|
|
126
|
+
char* p2; \
|
|
127
|
+
ssize_t s1; \
|
|
128
|
+
ssize_t s2; \
|
|
129
|
+
size_t* idx1; \
|
|
130
|
+
size_t* idx2; \
|
|
131
|
+
INIT_COUNTER(lp, n); \
|
|
132
|
+
INIT_PTR_IDX(lp, 0, p1, s1, idx1); \
|
|
133
|
+
INIT_PTR_IDX(lp, 1, p2, s2, idx2); \
|
|
134
|
+
robject x; \
|
|
135
|
+
if (idx1) { \
|
|
136
|
+
if (idx2) { \
|
|
137
|
+
for (size_t i = 0; i < n; i++) { \
|
|
138
|
+
GET_DATA_INDEX(p1, idx1, robject, x); \
|
|
139
|
+
x = m_bit_not(x); \
|
|
140
|
+
SET_DATA_INDEX(p2, idx2, robject, x); \
|
|
141
|
+
} \
|
|
142
|
+
} else { \
|
|
143
|
+
for (size_t i = 0; i < n; i++) { \
|
|
144
|
+
GET_DATA_INDEX(p1, idx1, robject, x); \
|
|
145
|
+
x = m_bit_not(x); \
|
|
146
|
+
SET_DATA_STRIDE(p2, s2, robject, x); \
|
|
147
|
+
} \
|
|
148
|
+
} \
|
|
149
|
+
} else { \
|
|
150
|
+
if (idx2) { \
|
|
151
|
+
for (size_t i = 0; i < n; i++) { \
|
|
152
|
+
GET_DATA_STRIDE(p1, s1, robject, x); \
|
|
153
|
+
x = m_bit_not(x); \
|
|
154
|
+
SET_DATA_INDEX(p2, idx2, robject, x); \
|
|
155
|
+
} \
|
|
156
|
+
} else { \
|
|
157
|
+
for (size_t i = 0; i < n; i++) { \
|
|
158
|
+
*(robject*)p2 = m_bit_not(*(robject*)p1); \
|
|
159
|
+
p1 += s1; \
|
|
160
|
+
p2 += s2; \
|
|
161
|
+
} \
|
|
162
|
+
} \
|
|
163
|
+
} \
|
|
164
|
+
} \
|
|
165
|
+
\
|
|
166
|
+
static VALUE robject_bit_not(VALUE self) { \
|
|
167
|
+
ndfunc_arg_in_t ain[1] = { { numo_cRObject, 0 } }; \
|
|
168
|
+
ndfunc_arg_out_t aout[1] = { { numo_cRObject, 0 } }; \
|
|
169
|
+
ndfunc_t ndf = { iter_robject_bit_not, FULL_LOOP, 1, 1, ain, aout }; \
|
|
170
|
+
return na_ndloop(&ndf, 1, self); \
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
#endif /* NUMO_NARRAY_MH_BIT_NOT_H */
|