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_XOR_H
|
|
2
|
+
#define NUMO_NARRAY_MH_BIT_XOR_H 1
|
|
3
|
+
|
|
4
|
+
#define DEF_NARRAY_INT_BIT_XOR_METHOD_FUNC(tDType, tNAryClass) \
|
|
5
|
+
static void iter_##tDType##_bit_xor(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_bit_xor(((tDType*)p1)[i], ((tDType*)p2)[i]); \
|
|
23
|
+
} \
|
|
24
|
+
} else { \
|
|
25
|
+
for (size_t i = 0; i < n; i++) { \
|
|
26
|
+
((tDType*)p3)[i] = m_bit_xor(((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
|
+
if (s1 == sizeof(tDType) && s3 == sizeof(tDType)) { \
|
|
35
|
+
if (p1 == p3) { \
|
|
36
|
+
for (size_t i = 0; i < n; i++) { \
|
|
37
|
+
((tDType*)p1)[i] = m_bit_xor(((tDType*)p1)[i], *(tDType*)p2); \
|
|
38
|
+
} \
|
|
39
|
+
} else { \
|
|
40
|
+
for (size_t i = 0; i < n; i++) { \
|
|
41
|
+
((tDType*)p3)[i] = m_bit_xor(((tDType*)p1)[i], *(tDType*)p2); \
|
|
42
|
+
} \
|
|
43
|
+
} \
|
|
44
|
+
} else { \
|
|
45
|
+
for (size_t i = 0; i < n; i++) { \
|
|
46
|
+
*(tDType*)p3 = m_bit_xor(*(tDType*)p1, *(tDType*)p2); \
|
|
47
|
+
p1 += s1; \
|
|
48
|
+
p3 += s3; \
|
|
49
|
+
} \
|
|
50
|
+
} \
|
|
51
|
+
} else { \
|
|
52
|
+
if (p1 == p3) { \
|
|
53
|
+
for (size_t i = 0; i < n; i++) { \
|
|
54
|
+
*(tDType*)p1 = m_bit_xor(*(tDType*)p1, *(tDType*)p2); \
|
|
55
|
+
p1 += s1; \
|
|
56
|
+
p2 += s2; \
|
|
57
|
+
} \
|
|
58
|
+
} else { \
|
|
59
|
+
for (size_t i = 0; i < n; i++) { \
|
|
60
|
+
*(tDType*)p3 = m_bit_xor(*(tDType*)p1, *(tDType*)p2); \
|
|
61
|
+
p1 += s1; \
|
|
62
|
+
p2 += s2; \
|
|
63
|
+
p3 += s3; \
|
|
64
|
+
} \
|
|
65
|
+
} \
|
|
66
|
+
} \
|
|
67
|
+
return; \
|
|
68
|
+
} \
|
|
69
|
+
} \
|
|
70
|
+
for (size_t i = 0; i < n; i++) { \
|
|
71
|
+
tDType x; \
|
|
72
|
+
tDType y; \
|
|
73
|
+
GET_DATA_STRIDE(p1, s1, tDType, x); \
|
|
74
|
+
GET_DATA_STRIDE(p2, s2, tDType, y); \
|
|
75
|
+
const tDType z = m_bit_xor(x, y); \
|
|
76
|
+
SET_DATA_STRIDE(p3, s3, tDType, z); \
|
|
77
|
+
} \
|
|
78
|
+
} \
|
|
79
|
+
\
|
|
80
|
+
static VALUE tDType##_bit_xor_self(VALUE self, VALUE other) { \
|
|
81
|
+
ndfunc_arg_in_t ain[2] = { { tNAryClass, 0 }, { tNAryClass, 0 } }; \
|
|
82
|
+
ndfunc_arg_out_t aout[1] = { { tNAryClass, 0 } }; \
|
|
83
|
+
ndfunc_t ndf = { iter_##tDType##_bit_xor, STRIDE_LOOP, 2, 1, ain, aout }; \
|
|
84
|
+
return na_ndloop(&ndf, 2, self, other); \
|
|
85
|
+
} \
|
|
86
|
+
\
|
|
87
|
+
static VALUE tDType##_bit_xor(VALUE self, VALUE other) { \
|
|
88
|
+
VALUE klass = na_upcast(rb_obj_class(self), rb_obj_class(other)); \
|
|
89
|
+
if (klass == tNAryClass) { \
|
|
90
|
+
return tDType##_bit_xor_self(self, other); \
|
|
91
|
+
} else { \
|
|
92
|
+
VALUE v = rb_funcall(klass, id_cast, 1, self); \
|
|
93
|
+
return rb_funcall(v, '^', 1, other); \
|
|
94
|
+
} \
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
#define DEF_NARRAY_INT8_BIT_XOR_METHOD_FUNC(tDType, tNAryClass) \
|
|
98
|
+
static void iter_##tDType##_bit_xor(na_loop_t* const lp) { \
|
|
99
|
+
size_t n; \
|
|
100
|
+
char* p1; \
|
|
101
|
+
char* p2; \
|
|
102
|
+
char* p3; \
|
|
103
|
+
ssize_t s1; \
|
|
104
|
+
ssize_t s2; \
|
|
105
|
+
ssize_t s3; \
|
|
106
|
+
INIT_COUNTER(lp, n); \
|
|
107
|
+
INIT_PTR(lp, 0, p1, s1); \
|
|
108
|
+
INIT_PTR(lp, 1, p2, s2); \
|
|
109
|
+
INIT_PTR(lp, 2, p3, s3); \
|
|
110
|
+
if (s2 == 0) { \
|
|
111
|
+
if (s1 == sizeof(tDType) && s3 == sizeof(tDType)) { \
|
|
112
|
+
if (p1 == p3) { \
|
|
113
|
+
for (size_t i = 0; i < n; i++) { \
|
|
114
|
+
((tDType*)p1)[i] = m_bit_xor(((tDType*)p1)[i], *(tDType*)p2); \
|
|
115
|
+
} \
|
|
116
|
+
} else { \
|
|
117
|
+
for (size_t i = 0; i < n; i++) { \
|
|
118
|
+
((tDType*)p3)[i] = m_bit_xor(((tDType*)p1)[i], *(tDType*)p2); \
|
|
119
|
+
} \
|
|
120
|
+
} \
|
|
121
|
+
} else { \
|
|
122
|
+
for (size_t i = 0; i < n; i++) { \
|
|
123
|
+
*(tDType*)p3 = m_bit_xor(*(tDType*)p1, *(tDType*)p2); \
|
|
124
|
+
p1 += s1; \
|
|
125
|
+
p3 += s3; \
|
|
126
|
+
} \
|
|
127
|
+
} \
|
|
128
|
+
} else { \
|
|
129
|
+
if (p1 == p3) { \
|
|
130
|
+
for (size_t i = 0; i < n; i++) { \
|
|
131
|
+
*(tDType*)p1 = m_bit_xor(*(tDType*)p1, *(tDType*)p2); \
|
|
132
|
+
p1 += s1; \
|
|
133
|
+
p2 += s2; \
|
|
134
|
+
} \
|
|
135
|
+
} else { \
|
|
136
|
+
for (size_t i = 0; i < n; i++) { \
|
|
137
|
+
*(tDType*)p3 = m_bit_xor(*(tDType*)p1, *(tDType*)p2); \
|
|
138
|
+
p1 += s1; \
|
|
139
|
+
p2 += s2; \
|
|
140
|
+
p3 += s3; \
|
|
141
|
+
} \
|
|
142
|
+
} \
|
|
143
|
+
} \
|
|
144
|
+
return; \
|
|
145
|
+
} \
|
|
146
|
+
\
|
|
147
|
+
static VALUE tDType##_bit_xor_self(VALUE self, VALUE other) { \
|
|
148
|
+
ndfunc_arg_in_t ain[2] = { { tNAryClass, 0 }, { tNAryClass, 0 } }; \
|
|
149
|
+
ndfunc_arg_out_t aout[1] = { { tNAryClass, 0 } }; \
|
|
150
|
+
ndfunc_t ndf = { iter_##tDType##_bit_xor, STRIDE_LOOP, 2, 1, ain, aout }; \
|
|
151
|
+
return na_ndloop(&ndf, 2, self, other); \
|
|
152
|
+
} \
|
|
153
|
+
\
|
|
154
|
+
static VALUE tDType##_bit_xor(VALUE self, VALUE other) { \
|
|
155
|
+
VALUE klass = na_upcast(rb_obj_class(self), rb_obj_class(other)); \
|
|
156
|
+
if (klass == tNAryClass) { \
|
|
157
|
+
return tDType##_bit_xor_self(self, other); \
|
|
158
|
+
} else { \
|
|
159
|
+
VALUE v = rb_funcall(klass, id_cast, 1, self); \
|
|
160
|
+
return rb_funcall(v, '^', 1, other); \
|
|
161
|
+
} \
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
#define DEF_NARRAY_ROBJ_BIT_XOR_METHOD_FUNC() \
|
|
165
|
+
static void iter_robject_bit_xor(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
|
+
if (s1 == sizeof(robject) && s3 == sizeof(robject)) { \
|
|
179
|
+
if (p1 == p3) { \
|
|
180
|
+
for (size_t i = 0; i < n; i++) { \
|
|
181
|
+
((robject*)p1)[i] = m_bit_xor(((robject*)p1)[i], *(robject*)p2); \
|
|
182
|
+
} \
|
|
183
|
+
} else { \
|
|
184
|
+
for (size_t i = 0; i < n; i++) { \
|
|
185
|
+
((robject*)p3)[i] = m_bit_xor(((robject*)p1)[i], *(robject*)p2); \
|
|
186
|
+
} \
|
|
187
|
+
} \
|
|
188
|
+
} else { \
|
|
189
|
+
for (size_t i = 0; i < n; i++) { \
|
|
190
|
+
*(robject*)p3 = m_bit_xor(*(robject*)p1, *(robject*)p2); \
|
|
191
|
+
p1 += s1; \
|
|
192
|
+
p3 += s3; \
|
|
193
|
+
} \
|
|
194
|
+
} \
|
|
195
|
+
} else { \
|
|
196
|
+
if (p1 == p3) { \
|
|
197
|
+
for (size_t i = 0; i < n; i++) { \
|
|
198
|
+
*(robject*)p1 = m_bit_xor(*(robject*)p1, *(robject*)p2); \
|
|
199
|
+
p1 += s1; \
|
|
200
|
+
p2 += s2; \
|
|
201
|
+
} \
|
|
202
|
+
} else { \
|
|
203
|
+
for (size_t i = 0; i < n; i++) { \
|
|
204
|
+
*(robject*)p3 = m_bit_xor(*(robject*)p1, *(robject*)p2); \
|
|
205
|
+
p1 += s1; \
|
|
206
|
+
p2 += s2; \
|
|
207
|
+
p3 += s3; \
|
|
208
|
+
} \
|
|
209
|
+
} \
|
|
210
|
+
} \
|
|
211
|
+
return; \
|
|
212
|
+
} \
|
|
213
|
+
\
|
|
214
|
+
static VALUE robject_bit_xor_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_bit_xor, STRIDE_LOOP, 2, 1, ain, aout }; \
|
|
218
|
+
return na_ndloop(&ndf, 2, self, other); \
|
|
219
|
+
} \
|
|
220
|
+
\
|
|
221
|
+
static VALUE robject_bit_xor(VALUE self, VALUE other) { \
|
|
222
|
+
return robject_bit_xor_self(self, other); \
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
#endif /* NUMO_NARRAY_MH_BIT_XOR_H */
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#ifndef NUMO_NARRAY_MH_COERCE_CAST_H
|
|
2
|
+
#define NUMO_NARRAY_MH_COERCE_CAST_H 1
|
|
3
|
+
|
|
4
|
+
#define DEF_NARRAY_COERCE_CAST_METHOD_FUNC(tDType) \
|
|
5
|
+
static VALUE tDType##_coerce_cast(VALUE self, VALUE type) { \
|
|
6
|
+
return Qnil; \
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
#endif /* NUMO_NARRAY_MH_COERCE_CAST_H */
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#ifndef NUMO_NARRAY_MH_COMP_BINARY_FUNC_H
|
|
2
|
+
#define NUMO_NARRAY_MH_COMP_BINARY_FUNC_H 1
|
|
3
|
+
|
|
4
|
+
#define DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(fCompFunc, tDType, tNAryClass) \
|
|
5
|
+
static void iter_##tDType##_##fCompFunc(na_loop_t* const lp) { \
|
|
6
|
+
size_t n; \
|
|
7
|
+
char* p1; \
|
|
8
|
+
char* p2; \
|
|
9
|
+
BIT_DIGIT* a3; \
|
|
10
|
+
size_t p3; \
|
|
11
|
+
ssize_t s1; \
|
|
12
|
+
ssize_t s2; \
|
|
13
|
+
ssize_t s3; \
|
|
14
|
+
tDType x; \
|
|
15
|
+
tDType y; \
|
|
16
|
+
BIT_DIGIT b; \
|
|
17
|
+
INIT_COUNTER(lp, n); \
|
|
18
|
+
INIT_PTR(lp, 0, p1, s1); \
|
|
19
|
+
INIT_PTR(lp, 1, p2, s2); \
|
|
20
|
+
INIT_PTR_BIT(lp, 2, a3, p3, s3); \
|
|
21
|
+
for (size_t i = 0; i < n; i++) { \
|
|
22
|
+
GET_DATA_STRIDE(p1, s1, tDType, x); \
|
|
23
|
+
GET_DATA_STRIDE(p2, s2, tDType, y); \
|
|
24
|
+
b = (m_##fCompFunc(x, y)) ? 1 : 0; \
|
|
25
|
+
STORE_BIT(a3, p3, b); \
|
|
26
|
+
p3 += s3; \
|
|
27
|
+
} \
|
|
28
|
+
} \
|
|
29
|
+
\
|
|
30
|
+
static VALUE tDType##_##fCompFunc##_self(VALUE self, VALUE other) { \
|
|
31
|
+
ndfunc_arg_in_t ain[2] = { { tNAryClass, 0 }, { tNAryClass, 0 } }; \
|
|
32
|
+
ndfunc_arg_out_t aout[1] = { { numo_cBit, 0 } }; \
|
|
33
|
+
ndfunc_t ndf = { iter_##tDType##_##fCompFunc, STRIDE_LOOP, 2, 1, ain, aout }; \
|
|
34
|
+
return na_ndloop(&ndf, 2, self, other); \
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#endif /* NUMO_NARRAY_MH_COMP_BINARY_FUNC_H */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef NUMO_NARRAY_MH_COMP_EQ_H
|
|
2
|
+
#define NUMO_NARRAY_MH_COMP_EQ_H 1
|
|
3
|
+
|
|
4
|
+
#include "binary_func.h"
|
|
5
|
+
|
|
6
|
+
#define DEF_NARRAY_EQ_METHOD_FUNC(tDType, tNAryClass) \
|
|
7
|
+
DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(eq, tDType, tNAryClass) \
|
|
8
|
+
\
|
|
9
|
+
static VALUE tDType##_eq(VALUE self, VALUE other) { \
|
|
10
|
+
VALUE klass = na_upcast(rb_obj_class(self), rb_obj_class(other)); \
|
|
11
|
+
if (klass == tNAryClass) { \
|
|
12
|
+
return tDType##_eq_self(self, other); \
|
|
13
|
+
} else { \
|
|
14
|
+
VALUE v = rb_funcall(klass, id_cast, 1, self); \
|
|
15
|
+
return rb_funcall(v, id_eq, 1, other); \
|
|
16
|
+
} \
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#define DEF_NARRAY_ROBJ_EQ_METHOD_FUNC() \
|
|
20
|
+
DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(eq, robject, numo_cRObject) \
|
|
21
|
+
\
|
|
22
|
+
static VALUE robject_eq(VALUE self, VALUE other) { \
|
|
23
|
+
return robject_eq_self(self, other); \
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#endif /* NUMO_NARRAY_MH_COMP_EQ_H */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef NUMO_NARRAY_MH_COMP_GE_H
|
|
2
|
+
#define NUMO_NARRAY_MH_COMP_GE_H 1
|
|
3
|
+
|
|
4
|
+
#include "binary_func.h"
|
|
5
|
+
|
|
6
|
+
#define DEF_NARRAY_GE_METHOD_FUNC(tDType, tNAryClass) \
|
|
7
|
+
DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(ge, tDType, tNAryClass) \
|
|
8
|
+
\
|
|
9
|
+
static VALUE tDType##_ge(VALUE self, VALUE other) { \
|
|
10
|
+
VALUE klass = na_upcast(rb_obj_class(self), rb_obj_class(other)); \
|
|
11
|
+
if (klass == tNAryClass) { \
|
|
12
|
+
return tDType##_ge_self(self, other); \
|
|
13
|
+
} else { \
|
|
14
|
+
VALUE v = rb_funcall(klass, id_cast, 1, self); \
|
|
15
|
+
return rb_funcall(v, id_ge, 1, other); \
|
|
16
|
+
} \
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#define DEF_NARRAY_ROBJ_GE_METHOD_FUNC() \
|
|
20
|
+
DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(ge, robject, numo_cRObject) \
|
|
21
|
+
\
|
|
22
|
+
static VALUE robject_ge(VALUE self, VALUE other) { \
|
|
23
|
+
return robject_ge_self(self, other); \
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#endif /* NUMO_NARRAY_MH_COMP_GE_H */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef NUMO_NARRAY_MH_COMP_GT_H
|
|
2
|
+
#define NUMO_NARRAY_MH_COMP_GT_H 1
|
|
3
|
+
|
|
4
|
+
#include "binary_func.h"
|
|
5
|
+
|
|
6
|
+
#define DEF_NARRAY_GT_METHOD_FUNC(tDType, tNAryClass) \
|
|
7
|
+
DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(gt, tDType, tNAryClass) \
|
|
8
|
+
\
|
|
9
|
+
static VALUE tDType##_gt(VALUE self, VALUE other) { \
|
|
10
|
+
VALUE klass = na_upcast(rb_obj_class(self), rb_obj_class(other)); \
|
|
11
|
+
if (klass == tNAryClass) { \
|
|
12
|
+
return tDType##_gt_self(self, other); \
|
|
13
|
+
} else { \
|
|
14
|
+
VALUE v = rb_funcall(klass, id_cast, 1, self); \
|
|
15
|
+
return rb_funcall(v, id_gt, 1, other); \
|
|
16
|
+
} \
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#define DEF_NARRAY_ROBJ_GT_METHOD_FUNC() \
|
|
20
|
+
DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(gt, robject, numo_cRObject) \
|
|
21
|
+
\
|
|
22
|
+
static VALUE robject_gt(VALUE self, VALUE other) { \
|
|
23
|
+
return robject_gt_self(self, other); \
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#endif /* NUMO_NARRAY_MH_COMP_GT_H */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef NUMO_NARRAY_MH_COMP_LE_H
|
|
2
|
+
#define NUMO_NARRAY_MH_COMP_LE_H 1
|
|
3
|
+
|
|
4
|
+
#include "binary_func.h"
|
|
5
|
+
|
|
6
|
+
#define DEF_NARRAY_LE_METHOD_FUNC(tDType, tNAryClass) \
|
|
7
|
+
DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(le, tDType, tNAryClass) \
|
|
8
|
+
\
|
|
9
|
+
static VALUE tDType##_le(VALUE self, VALUE other) { \
|
|
10
|
+
VALUE klass = na_upcast(rb_obj_class(self), rb_obj_class(other)); \
|
|
11
|
+
if (klass == tNAryClass) { \
|
|
12
|
+
return tDType##_le_self(self, other); \
|
|
13
|
+
} else { \
|
|
14
|
+
VALUE v = rb_funcall(klass, id_cast, 1, self); \
|
|
15
|
+
return rb_funcall(v, id_le, 1, other); \
|
|
16
|
+
} \
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#define DEF_NARRAY_ROBJ_LE_METHOD_FUNC() \
|
|
20
|
+
DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(le, robject, numo_cRObject) \
|
|
21
|
+
\
|
|
22
|
+
static VALUE robject_le(VALUE self, VALUE other) { \
|
|
23
|
+
return robject_le_self(self, other); \
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#endif /* NUMO_NARRAY_MH_COMP_LE_H */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef NUMO_NARRAY_MH_COMP_LT_H
|
|
2
|
+
#define NUMO_NARRAY_MH_COMP_LT_H 1
|
|
3
|
+
|
|
4
|
+
#include "binary_func.h"
|
|
5
|
+
|
|
6
|
+
#define DEF_NARRAY_LT_METHOD_FUNC(tDType, tNAryClass) \
|
|
7
|
+
DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(lt, tDType, tNAryClass) \
|
|
8
|
+
\
|
|
9
|
+
static VALUE tDType##_lt(VALUE self, VALUE other) { \
|
|
10
|
+
VALUE klass = na_upcast(rb_obj_class(self), rb_obj_class(other)); \
|
|
11
|
+
if (klass == tNAryClass) { \
|
|
12
|
+
return tDType##_lt_self(self, other); \
|
|
13
|
+
} else { \
|
|
14
|
+
VALUE v = rb_funcall(klass, id_cast, 1, self); \
|
|
15
|
+
return rb_funcall(v, id_lt, 1, other); \
|
|
16
|
+
} \
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#define DEF_NARRAY_ROBJ_LT_METHOD_FUNC() \
|
|
20
|
+
DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(lt, robject, numo_cRObject) \
|
|
21
|
+
\
|
|
22
|
+
static VALUE robject_lt(VALUE self, VALUE other) { \
|
|
23
|
+
return robject_lt_self(self, other); \
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#endif /* NUMO_NARRAY_MH_COMP_LT_H */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef NUMO_NARRAY_MH_COMP_NE_H
|
|
2
|
+
#define NUMO_NARRAY_MH_COMP_NE_H 1
|
|
3
|
+
|
|
4
|
+
#include "binary_func.h"
|
|
5
|
+
|
|
6
|
+
#define DEF_NARRAY_NE_METHOD_FUNC(tDType, tNAryClass) \
|
|
7
|
+
DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(ne, tDType, tNAryClass) \
|
|
8
|
+
\
|
|
9
|
+
static VALUE tDType##_ne(VALUE self, VALUE other) { \
|
|
10
|
+
VALUE klass = na_upcast(rb_obj_class(self), rb_obj_class(other)); \
|
|
11
|
+
if (klass == tNAryClass) { \
|
|
12
|
+
return tDType##_ne_self(self, other); \
|
|
13
|
+
} else { \
|
|
14
|
+
VALUE v = rb_funcall(klass, id_cast, 1, self); \
|
|
15
|
+
return rb_funcall(v, id_ne, 1, other); \
|
|
16
|
+
} \
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#define DEF_NARRAY_ROBJ_NE_METHOD_FUNC() \
|
|
20
|
+
DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(ne, robject, numo_cRObject) \
|
|
21
|
+
\
|
|
22
|
+
static VALUE robject_ne(VALUE self, VALUE other) { \
|
|
23
|
+
return robject_ne_self(self, other); \
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#endif /* NUMO_NARRAY_MH_COMP_NE_H */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#ifndef NUMO_NARRAY_MH_COMP_NEARLY_EQ_H
|
|
2
|
+
#define NUMO_NARRAY_MH_COMP_NEARLY_EQ_H 1
|
|
3
|
+
|
|
4
|
+
#include "binary_func.h"
|
|
5
|
+
|
|
6
|
+
#define DEF_NARRAY_NEARLY_EQ_METHOD_FUNC(tDType, tNAryClass) \
|
|
7
|
+
DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(nearly_eq, tDType, tNAryClass) \
|
|
8
|
+
\
|
|
9
|
+
static VALUE tDType##_nearly_eq(VALUE self, VALUE other) { \
|
|
10
|
+
VALUE klass = na_upcast(rb_obj_class(self), rb_obj_class(other)); \
|
|
11
|
+
if (klass == tNAryClass) { \
|
|
12
|
+
return tDType##_nearly_eq_self(self, other); \
|
|
13
|
+
} else { \
|
|
14
|
+
VALUE v = rb_funcall(klass, id_cast, 1, self); \
|
|
15
|
+
return rb_funcall(v, id_nearly_eq, 1, other); \
|
|
16
|
+
} \
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#define DEF_NARRAY_ROBJ_NEARLY_EQ_METHOD_FUNC() \
|
|
20
|
+
DEF_NARRAY_BINARY_COMPARISON_METHOD_FUNC(nearly_eq, robject, numo_cRObject) \
|
|
21
|
+
\
|
|
22
|
+
static VALUE robject_nearly_eq(VALUE self, VALUE other) { \
|
|
23
|
+
return robject_nearly_eq_self(self, other); \
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#endif /* NUMO_NARRAY_MH_COMP_NEARLY_EQ_H */
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
#ifndef NUMO_NARRAY_MH_DIVMOD_H
|
|
2
|
+
#define NUMO_NARRAY_MH_DIVMOD_H 1
|
|
3
|
+
|
|
4
|
+
#define DEF_NARRAY_FLT_DIVMOD_METHOD_FUNC(tDType, tNAryClass) \
|
|
5
|
+
static void iter_##tDType##_divmod(na_loop_t* const lp) { \
|
|
6
|
+
size_t n; \
|
|
7
|
+
char* p1; \
|
|
8
|
+
char* p2; \
|
|
9
|
+
char* p3; \
|
|
10
|
+
char* p4; \
|
|
11
|
+
ssize_t s1; \
|
|
12
|
+
ssize_t s2; \
|
|
13
|
+
ssize_t s3; \
|
|
14
|
+
ssize_t s4; \
|
|
15
|
+
INIT_COUNTER(lp, n); \
|
|
16
|
+
INIT_PTR(lp, 0, p1, s1); \
|
|
17
|
+
INIT_PTR(lp, 1, p2, s2); \
|
|
18
|
+
INIT_PTR(lp, 2, p3, s3); \
|
|
19
|
+
INIT_PTR(lp, 3, p4, s4); \
|
|
20
|
+
tDType x; \
|
|
21
|
+
tDType y; \
|
|
22
|
+
tDType a; \
|
|
23
|
+
tDType b; \
|
|
24
|
+
for (size_t i = 0; i < n; i++) { \
|
|
25
|
+
GET_DATA_STRIDE(p1, s1, tDType, x); \
|
|
26
|
+
GET_DATA_STRIDE(p2, s2, tDType, y); \
|
|
27
|
+
m_divmod(x, y, a, b); \
|
|
28
|
+
SET_DATA_STRIDE(p3, s3, tDType, a); \
|
|
29
|
+
SET_DATA_STRIDE(p4, s4, tDType, b); \
|
|
30
|
+
} \
|
|
31
|
+
} \
|
|
32
|
+
\
|
|
33
|
+
static VALUE tDType##_divmod_self(VALUE self, VALUE other) { \
|
|
34
|
+
ndfunc_arg_in_t ain[2] = { { tNAryClass, 0 }, { tNAryClass, 0 } }; \
|
|
35
|
+
ndfunc_arg_out_t aout[2] = { { tNAryClass, 0 }, { tNAryClass, 0 } }; \
|
|
36
|
+
ndfunc_t ndf = { iter_##tDType##_divmod, STRIDE_LOOP, 2, 2, ain, aout }; \
|
|
37
|
+
return na_ndloop(&ndf, 2, self, other); \
|
|
38
|
+
} \
|
|
39
|
+
\
|
|
40
|
+
static VALUE tDType##_divmod(VALUE self, VALUE other) { \
|
|
41
|
+
VALUE klass = na_upcast(rb_obj_class(self), rb_obj_class(other)); \
|
|
42
|
+
if (klass == tNAryClass) { \
|
|
43
|
+
return tDType##_divmod_self(self, other); \
|
|
44
|
+
} \
|
|
45
|
+
VALUE v = rb_funcall(klass, id_cast, 1, self); \
|
|
46
|
+
return rb_funcall(v, id_divmod, 1, other); \
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
#define DEF_NARRAY_INT_DIVMOD_METHOD_FUNC(tDType, tNAryClass) \
|
|
50
|
+
static void iter_##tDType##_divmod(na_loop_t* const lp) { \
|
|
51
|
+
size_t n; \
|
|
52
|
+
char* p1; \
|
|
53
|
+
char* p2; \
|
|
54
|
+
char* p3; \
|
|
55
|
+
char* p4; \
|
|
56
|
+
ssize_t s1; \
|
|
57
|
+
ssize_t s2; \
|
|
58
|
+
ssize_t s3; \
|
|
59
|
+
ssize_t s4; \
|
|
60
|
+
INIT_COUNTER(lp, n); \
|
|
61
|
+
INIT_PTR(lp, 0, p1, s1); \
|
|
62
|
+
INIT_PTR(lp, 1, p2, s2); \
|
|
63
|
+
INIT_PTR(lp, 2, p3, s3); \
|
|
64
|
+
INIT_PTR(lp, 3, p4, s4); \
|
|
65
|
+
tDType x; \
|
|
66
|
+
tDType y; \
|
|
67
|
+
tDType a; \
|
|
68
|
+
tDType b; \
|
|
69
|
+
for (size_t i = 0; i < n; i++) { \
|
|
70
|
+
GET_DATA_STRIDE(p1, s1, tDType, x); \
|
|
71
|
+
GET_DATA_STRIDE(p2, s2, tDType, y); \
|
|
72
|
+
if (y == 0) { \
|
|
73
|
+
lp->err_type = rb_eZeroDivError; \
|
|
74
|
+
return; \
|
|
75
|
+
} \
|
|
76
|
+
m_divmod(x, y, a, b); \
|
|
77
|
+
SET_DATA_STRIDE(p3, s3, tDType, a); \
|
|
78
|
+
SET_DATA_STRIDE(p4, s4, tDType, b); \
|
|
79
|
+
} \
|
|
80
|
+
} \
|
|
81
|
+
\
|
|
82
|
+
static VALUE tDType##_divmod_self(VALUE self, VALUE other) { \
|
|
83
|
+
ndfunc_arg_in_t ain[2] = { { tNAryClass, 0 }, { tNAryClass, 0 } }; \
|
|
84
|
+
ndfunc_arg_out_t aout[2] = { { tNAryClass, 0 }, { tNAryClass, 0 } }; \
|
|
85
|
+
ndfunc_t ndf = { iter_##tDType##_divmod, STRIDE_LOOP, 2, 2, ain, aout }; \
|
|
86
|
+
return na_ndloop(&ndf, 2, self, other); \
|
|
87
|
+
} \
|
|
88
|
+
\
|
|
89
|
+
static VALUE tDType##_divmod(VALUE self, VALUE other) { \
|
|
90
|
+
VALUE klass = na_upcast(rb_obj_class(self), rb_obj_class(other)); \
|
|
91
|
+
if (klass == tNAryClass) { \
|
|
92
|
+
return tDType##_divmod_self(self, other); \
|
|
93
|
+
} \
|
|
94
|
+
VALUE v = rb_funcall(klass, id_cast, 1, self); \
|
|
95
|
+
return rb_funcall(v, id_divmod, 1, other); \
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
#define DEF_NARRAY_ROBJ_DIVMOD_METHOD_FUNC() \
|
|
99
|
+
static void iter_robject_divmod(na_loop_t* const lp) { \
|
|
100
|
+
size_t n; \
|
|
101
|
+
char* p1; \
|
|
102
|
+
char* p2; \
|
|
103
|
+
char* p3; \
|
|
104
|
+
char* p4; \
|
|
105
|
+
ssize_t s1; \
|
|
106
|
+
ssize_t s2; \
|
|
107
|
+
ssize_t s3; \
|
|
108
|
+
ssize_t s4; \
|
|
109
|
+
INIT_COUNTER(lp, n); \
|
|
110
|
+
INIT_PTR(lp, 0, p1, s1); \
|
|
111
|
+
INIT_PTR(lp, 1, p2, s2); \
|
|
112
|
+
INIT_PTR(lp, 2, p3, s3); \
|
|
113
|
+
INIT_PTR(lp, 3, p4, s4); \
|
|
114
|
+
robject x; \
|
|
115
|
+
robject y; \
|
|
116
|
+
robject a; \
|
|
117
|
+
robject b; \
|
|
118
|
+
for (size_t i = 0; i < n; i++) { \
|
|
119
|
+
GET_DATA_STRIDE(p1, s1, robject, x); \
|
|
120
|
+
GET_DATA_STRIDE(p2, s2, robject, y); \
|
|
121
|
+
if (y == 0) { \
|
|
122
|
+
lp->err_type = rb_eZeroDivError; \
|
|
123
|
+
return; \
|
|
124
|
+
} \
|
|
125
|
+
m_divmod(x, y, a, b); \
|
|
126
|
+
SET_DATA_STRIDE(p3, s3, robject, a); \
|
|
127
|
+
SET_DATA_STRIDE(p4, s4, robject, b); \
|
|
128
|
+
} \
|
|
129
|
+
} \
|
|
130
|
+
\
|
|
131
|
+
static VALUE robject_divmod_self(VALUE self, VALUE other) { \
|
|
132
|
+
ndfunc_arg_in_t ain[2] = { { numo_cRObject, 0 }, { numo_cRObject, 0 } }; \
|
|
133
|
+
ndfunc_arg_out_t aout[2] = { { numo_cRObject, 0 }, { numo_cRObject, 0 } }; \
|
|
134
|
+
ndfunc_t ndf = { iter_robject_divmod, STRIDE_LOOP, 2, 2, ain, aout }; \
|
|
135
|
+
return na_ndloop(&ndf, 2, self, other); \
|
|
136
|
+
} \
|
|
137
|
+
\
|
|
138
|
+
static VALUE robject_divmod(VALUE self, VALUE other) { \
|
|
139
|
+
return robject_divmod_self(self, other); \
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
#endif /* NUMO_NARRAY_MH_DIVMOD_H */
|