numo-narray 0.9.0.1-x64-mingw32 → 0.9.0.3-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -7
- data/Rakefile +20 -5
- data/ext/numo/narray/array.c +3 -3
- data/ext/numo/narray/data.c +102 -81
- data/ext/numo/narray/depend.erb +9 -7
- data/ext/numo/narray/extconf.rb +5 -24
- data/ext/numo/narray/gen/cogen.rb +19 -4
- data/ext/numo/narray/gen/def/bit.rb +31 -0
- data/ext/numo/narray/gen/def/robject.rb +1 -1
- data/ext/numo/narray/gen/dtype.erb.c +11 -257
- data/ext/numo/narray/gen/spec.rb +294 -0
- data/ext/numo/narray/gen/tmpl/aset.c +1 -1
- data/ext/numo/narray/gen/tmpl/each_with_index.c +1 -1
- data/ext/numo/narray/gen/tmpl/eye.c +5 -5
- data/ext/numo/narray/gen/tmpl/logseq.c +82 -0
- data/ext/numo/narray/gen/tmpl/map_with_index.c +1 -1
- data/ext/numo/narray/gen/tmpl/rand.c +126 -5
- data/ext/numo/narray/gen/tmpl/seq.c +43 -12
- data/ext/numo/narray/gen/tmpl/store_bit.c +55 -0
- data/ext/numo/narray/gen/tmpl_bit/allocate.c +28 -0
- data/ext/numo/narray/gen/tmpl_bit/aref.c +53 -0
- data/ext/numo/narray/gen/tmpl_bit/aset.c +63 -0
- data/ext/numo/narray/gen/{tmpl/bit_binary.c → tmpl_bit/binary.c} +1 -1
- data/ext/numo/narray/gen/{tmpl → tmpl_bit}/bit_count.c +5 -3
- data/ext/numo/narray/gen/tmpl_bit/bit_reduce.c +128 -0
- data/ext/numo/narray/gen/tmpl_bit/cast.c +37 -0
- data/ext/numo/narray/gen/tmpl_bit/cast_array.c +80 -0
- data/ext/numo/narray/gen/tmpl_bit/cast_numeric.c +22 -0
- data/ext/numo/narray/gen/tmpl_bit/coerce_cast.c +8 -0
- data/ext/numo/narray/gen/tmpl_bit/each.c +44 -0
- data/ext/numo/narray/gen/tmpl_bit/each_with_index.c +66 -0
- data/ext/numo/narray/gen/tmpl_bit/extract.c +25 -0
- data/ext/numo/narray/gen/tmpl_bit/fill.c +65 -0
- data/ext/numo/narray/gen/tmpl_bit/format.c +61 -0
- data/ext/numo/narray/gen/tmpl_bit/format_to_a.c +48 -0
- data/ext/numo/narray/gen/tmpl_bit/inspect.c +18 -0
- data/ext/numo/narray/gen/tmpl_bit/map_with_index.c +94 -0
- data/ext/numo/narray/gen/tmpl_bit/mask.c +117 -0
- data/ext/numo/narray/gen/tmpl_bit/none_p.c +14 -0
- data/ext/numo/narray/gen/tmpl_bit/store.c +32 -0
- data/ext/numo/narray/gen/tmpl_bit/store_array.c +5 -0
- data/ext/numo/narray/gen/tmpl_bit/store_bit.c +66 -0
- data/ext/numo/narray/gen/tmpl_bit/store_from.c +56 -0
- data/ext/numo/narray/gen/tmpl_bit/store_numeric.c +22 -0
- data/ext/numo/narray/gen/tmpl_bit/to_a.c +43 -0
- data/ext/numo/narray/gen/{tmpl/bit_unary.c → tmpl_bit/unary.c} +1 -1
- data/ext/numo/narray/gen/tmpl_bit/where.c +102 -0
- data/ext/numo/narray/gen/tmpl_bit/where2.c +37 -0
- data/ext/numo/narray/index.c +9 -7
- data/ext/numo/narray/math.c +6 -1
- data/ext/numo/narray/narray.c +307 -103
- data/ext/numo/narray/ndloop.c +21 -36
- data/ext/numo/narray/numo/intern.h +3 -3
- data/ext/numo/narray/numo/narray.h +5 -41
- data/ext/numo/narray/numo/template.h +2 -2
- data/ext/numo/narray/numo/types/bit.h +27 -13
- data/ext/numo/narray/numo/types/complex.h +2 -2
- data/ext/numo/narray/numo/types/complex_macro.h +19 -7
- data/ext/numo/narray/numo/types/dcomplex.h +9 -0
- data/ext/numo/narray/numo/types/dfloat.h +6 -0
- data/ext/numo/narray/numo/types/float_macro.h +9 -2
- data/ext/numo/narray/numo/types/int16.h +0 -1
- data/ext/numo/narray/numo/types/int32.h +0 -1
- data/ext/numo/narray/numo/types/int64.h +0 -1
- data/ext/numo/narray/numo/types/int8.h +0 -1
- data/ext/numo/narray/numo/types/int_macro.h +2 -1
- data/ext/numo/narray/numo/types/robj_macro.h +9 -2
- data/ext/numo/narray/numo/types/robject.h +6 -0
- data/ext/numo/narray/numo/types/scomplex.h +9 -0
- data/ext/numo/narray/numo/types/sfloat.h +6 -0
- data/ext/numo/narray/numo/types/uint16.h +0 -1
- data/ext/numo/narray/numo/types/uint32.h +0 -1
- data/ext/numo/narray/numo/types/uint64.h +0 -1
- data/ext/numo/narray/numo/types/uint8.h +0 -1
- data/ext/numo/narray/numo/types/uint_macro.h +2 -1
- data/ext/numo/narray/numo/types/xint_macro.h +6 -1
- data/ext/numo/narray/rand.c +2 -2
- data/ext/numo/narray/step.c +7 -7
- data/ext/numo/narray/struct.c +11 -12
- data/lib/2.0/numo/narray.so +0 -0
- data/lib/2.1/numo/narray.so +0 -0
- data/lib/2.2/numo/narray.so +0 -0
- data/lib/2.3/numo/narray.so +0 -0
- data/lib/2.4/numo/narray.so +0 -0
- data/lib/erbpp.rb +6 -2
- data/lib/erbpp/line_number.rb +1 -1
- data/lib/erbpp/narray_def.rb +23 -19
- data/numo-narray.gemspec +2 -2
- metadata +45 -10
- data/ext/numo/narray/gen/bit.erb.c +0 -811
@@ -4,9 +4,18 @@ libpath = File.absolute_path(File.dirname(__FILE__))+"/../../../../lib"
|
|
4
4
|
$LOAD_PATH.unshift libpath
|
5
5
|
|
6
6
|
require "erbpp/narray_def"
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
while true
|
8
|
+
if ARGV[0] == "-l"
|
9
|
+
require "erbpp/line_number"
|
10
|
+
ARGV.shift
|
11
|
+
elsif ARGV[0] == "-o"
|
12
|
+
ARGV.shift
|
13
|
+
$output = ARGV.shift
|
14
|
+
require "fileutils"
|
15
|
+
FileUtils.rm_f($output)
|
16
|
+
else
|
17
|
+
break
|
18
|
+
end
|
10
19
|
end
|
11
20
|
|
12
21
|
unless (1..2) === ARGV.size
|
@@ -15,4 +24,10 @@ unless (1..2) === ARGV.size
|
|
15
24
|
end
|
16
25
|
|
17
26
|
erb_path, type_file = ARGV
|
18
|
-
|
27
|
+
|
28
|
+
if $output
|
29
|
+
s = DataType.new(erb_path, type_file).result
|
30
|
+
open($output,"w").write(s)
|
31
|
+
else
|
32
|
+
DataType.new(erb_path, type_file).run
|
33
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class_name "Bit"
|
2
|
+
#ctype ""
|
3
|
+
|
4
|
+
template_dir "tmpl_bit"
|
5
|
+
|
6
|
+
has_math false
|
7
|
+
is_bit true
|
8
|
+
is_int false
|
9
|
+
is_float false
|
10
|
+
is_complex false
|
11
|
+
is_object false
|
12
|
+
is_real false
|
13
|
+
is_comparable false
|
14
|
+
|
15
|
+
upcast_rb "Integer"
|
16
|
+
upcast_rb "Float", "DFloat"
|
17
|
+
upcast_rb "Complex", "DComplex"
|
18
|
+
|
19
|
+
upcast "RObject", "RObject"
|
20
|
+
upcast "DComplex", "DComplex"
|
21
|
+
upcast "SComplex", "SComplex"
|
22
|
+
upcast "DFloat", "DFloat"
|
23
|
+
upcast "SFloat", "SFloat"
|
24
|
+
upcast "Int64", "Int64"
|
25
|
+
upcast "Int32", "Int32"
|
26
|
+
upcast "Int16", "Int16"
|
27
|
+
upcast "Int8", "Int8"
|
28
|
+
upcast "UInt64", "UInt64"
|
29
|
+
upcast "UInt32", "UInt32"
|
30
|
+
upcast "UInt16", "UInt16"
|
31
|
+
upcast "UInt8", "UInt8"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
<%=type_name%>.c
|
3
3
|
Numerical Array Extension for Ruby
|
4
|
-
(C) Copyright 1999-2011,2013 by Masahiro TANAKA
|
4
|
+
(C) Copyright 1999-2011,2013-2016 by Masahiro TANAKA
|
5
5
|
|
6
6
|
This program is free software.
|
7
7
|
You can distribute/modify this program
|
@@ -18,52 +18,13 @@
|
|
18
18
|
#define m_map(x) m_num_to_data(rb_yield(m_data_to_num(x)))
|
19
19
|
|
20
20
|
<%
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
def_id "mulsum"
|
26
|
-
if is_complex
|
27
|
-
def_id "real"
|
28
|
-
def_id "imag"
|
29
|
-
else
|
30
|
-
def_id "divmod"
|
31
|
-
end
|
32
|
-
if is_float
|
33
|
-
def_id "nearly_eq"
|
34
|
-
end
|
35
|
-
if is_comparable
|
36
|
-
def_id "gt"
|
37
|
-
def_id "ge"
|
38
|
-
def_id "lt"
|
39
|
-
def_id "le"
|
40
|
-
end
|
41
|
-
if is_object
|
42
|
-
def_id "bit_and"
|
43
|
-
def_id "bit_or"
|
44
|
-
def_id "bit_xor"
|
45
|
-
def_id "bit_not"
|
46
|
-
def_id "abs"
|
47
|
-
def_id "minus"
|
48
|
-
def_id "inverse"
|
49
|
-
def_id "square"
|
50
|
-
def_id "floor"
|
51
|
-
def_id "round"
|
52
|
-
def_id "ceil"
|
53
|
-
def_id "nan?"
|
54
|
-
def_id "infinite?"
|
55
|
-
def_id "finite?"
|
56
|
-
def_id ">" ,"op_gt"
|
57
|
-
def_id ">=","op_ge"
|
58
|
-
def_id "<" ,"op_lt"
|
59
|
-
def_id "<=","op_le"
|
21
|
+
eval open(File.join(File.dirname(__FILE__),"spec.rb")).read
|
22
|
+
|
23
|
+
IdVar.declaration.each do |x| %>
|
24
|
+
<%= x %><%
|
60
25
|
end
|
61
26
|
%>
|
62
27
|
|
63
|
-
<% IdVar.declaration.each do |x| %><%=
|
64
|
-
x %>
|
65
|
-
<% end %>
|
66
|
-
|
67
28
|
#include "numo/types/<%=type_name%>.h"
|
68
29
|
|
69
30
|
VALUE cT;
|
@@ -72,219 +33,6 @@ extern VALUE cRT;
|
|
72
33
|
VALUE mTM;
|
73
34
|
#endif
|
74
35
|
|
75
|
-
<%
|
76
|
-
if is_object
|
77
|
-
def_allocate "robj_allocate"
|
78
|
-
end
|
79
|
-
def_method "allocate", 0
|
80
|
-
|
81
|
-
def_method "extract", 0
|
82
|
-
store_numeric
|
83
|
-
cast_array
|
84
|
-
store_array
|
85
|
-
if is_complex
|
86
|
-
store_from "DComplex","dcomplex","m_from_dcomplex"
|
87
|
-
store_from "SComplex","scomplex","m_from_scomplex"
|
88
|
-
end
|
89
|
-
store_from "DFloat","double", "m_from_real"
|
90
|
-
store_from "SFloat","float", "m_from_real"
|
91
|
-
store_from "Int64", "int64_t", "m_from_real"
|
92
|
-
store_from "Int32", "int32_t", "m_from_real"
|
93
|
-
store_from "Int16", "int16_t", "m_from_real"
|
94
|
-
store_from "Int8", "int8_t", "m_from_real"
|
95
|
-
store_from "UInt64","u_int64_t","m_from_real"
|
96
|
-
store_from "UInt32","u_int32_t","m_from_real"
|
97
|
-
store_from "UInt16","u_int16_t","m_from_real"
|
98
|
-
store_from "UInt8", "u_int8_t", "m_from_real"
|
99
|
-
|
100
|
-
def_method "store", 1
|
101
|
-
def_singleton "cast", 1
|
102
|
-
|
103
|
-
def_method "aref", -1, "aref", :op=>"[]"
|
104
|
-
def_method "aset", -1, "aset", :op=>"[]="
|
105
|
-
|
106
|
-
def_method "coerce_cast", 1
|
107
|
-
def_method "to_a", 0
|
108
|
-
def_method "fill", 1
|
109
|
-
def_method "format", -1
|
110
|
-
def_method "format_to_a", -1
|
111
|
-
def_method "inspect", 0
|
112
|
-
|
113
|
-
def_method "each", 0
|
114
|
-
unary "map"
|
115
|
-
def_method "each_with_index", 0
|
116
|
-
def_method "map_with_index", 0
|
117
|
-
|
118
|
-
# Arithmetic
|
119
|
-
|
120
|
-
unary2 "abs", "rtype", "cRT"
|
121
|
-
|
122
|
-
binary "add", "+"
|
123
|
-
binary "sub", "-"
|
124
|
-
binary "mul", "*"
|
125
|
-
binary "div", "/"
|
126
|
-
|
127
|
-
if !is_complex
|
128
|
-
binary "mod", "%"
|
129
|
-
binary2 "divmod"
|
130
|
-
end
|
131
|
-
|
132
|
-
pow
|
133
|
-
|
134
|
-
unary "minus", "-@"
|
135
|
-
unary "inverse"
|
136
|
-
|
137
|
-
# Complex
|
138
|
-
|
139
|
-
if is_complex
|
140
|
-
unary "conj"
|
141
|
-
unary "im"
|
142
|
-
unary2 "real", "rtype", "cRT"
|
143
|
-
unary2 "imag", "rtype", "cRT"
|
144
|
-
unary2 "arg", "rtype", "cRT"
|
145
|
-
def_alias "angle","arg"
|
146
|
-
set2 "set_imag", "rtype", "cRT"
|
147
|
-
set2 "set_real", "rtype", "cRT"
|
148
|
-
def_alias "imag=","set_imag"
|
149
|
-
def_alias "real=","set_real"
|
150
|
-
else
|
151
|
-
def_alias "conj", "copy"
|
152
|
-
def_alias "im", "copy"
|
153
|
-
end
|
154
|
-
|
155
|
-
def_alias "conjugate","conj"
|
156
|
-
|
157
|
-
# base_cond
|
158
|
-
|
159
|
-
cond_binary "eq"
|
160
|
-
cond_binary "ne"
|
161
|
-
|
162
|
-
# nearly_eq : x=~y is true if |x-y| <= (|x|+|y|)*epsilon
|
163
|
-
if is_float
|
164
|
-
cond_binary "nearly_eq"
|
165
|
-
else
|
166
|
-
def_alias "nearly_eq", "eq"
|
167
|
-
end
|
168
|
-
def_alias "close_to", "nearly_eq"
|
169
|
-
|
170
|
-
# Integer
|
171
|
-
if is_int
|
172
|
-
binary "bit_and", "&"
|
173
|
-
binary "bit_or" , "|"
|
174
|
-
binary "bit_xor", "^"
|
175
|
-
unary "bit_not", "~"
|
176
|
-
def_alias "floor", "copy"
|
177
|
-
def_alias "round", "copy"
|
178
|
-
def_alias "ceil", "copy"
|
179
|
-
end
|
180
|
-
|
181
|
-
if is_float && is_real
|
182
|
-
unary "floor"
|
183
|
-
unary "round"
|
184
|
-
unary "ceil"
|
185
|
-
end
|
186
|
-
|
187
|
-
if is_comparable
|
188
|
-
cond_binary "gt"
|
189
|
-
cond_binary "ge"
|
190
|
-
cond_binary "lt"
|
191
|
-
cond_binary "le"
|
192
|
-
def_alias ">", "gt"
|
193
|
-
def_alias ">=","ge"
|
194
|
-
def_alias "<", "lt"
|
195
|
-
def_alias "<=","le"
|
196
|
-
end
|
197
|
-
|
198
|
-
# Float
|
199
|
-
|
200
|
-
if is_float
|
201
|
-
cond_unary "isnan"
|
202
|
-
cond_unary "isinf"
|
203
|
-
cond_unary "isfinite"
|
204
|
-
end
|
205
|
-
|
206
|
-
accum "sum","dtype","cT"
|
207
|
-
accum "prod","dtype","cT"
|
208
|
-
|
209
|
-
if is_float
|
210
|
-
accum "mean","dtype","cT"
|
211
|
-
accum "stddev","rtype","cRT"
|
212
|
-
accum "var","rtype","cRT"
|
213
|
-
accum "rms","rtype","cRT"
|
214
|
-
end
|
215
|
-
|
216
|
-
if is_comparable
|
217
|
-
accum "min","dtype","cT"
|
218
|
-
accum "max","dtype","cT"
|
219
|
-
accum_index "max_index"
|
220
|
-
accum_index "min_index"
|
221
|
-
def_method "minmax",-1
|
222
|
-
end
|
223
|
-
|
224
|
-
cum "cumsum","add"
|
225
|
-
cum "cumprod","mul"
|
226
|
-
|
227
|
-
# dot
|
228
|
-
accum_binary "mulsum"
|
229
|
-
|
230
|
-
# rmsdev
|
231
|
-
# prod
|
232
|
-
|
233
|
-
# shuffle
|
234
|
-
# histogram
|
235
|
-
|
236
|
-
def_method "seq",-1
|
237
|
-
def_method "eye",-1
|
238
|
-
def_alias "indgen", "seq"
|
239
|
-
|
240
|
-
if !is_object
|
241
|
-
def_method "rand", 0
|
242
|
-
end
|
243
|
-
|
244
|
-
# y = a[0] + a[1]*x + a[2]*x^2 + a[3]*x^3 + ... + a[n]*x^n
|
245
|
-
def_method "poly",-2
|
246
|
-
|
247
|
-
if is_comparable && !is_object
|
248
|
-
qsort type_name,"dtype","*(dtype*)"
|
249
|
-
def_method "sort",-1
|
250
|
-
qsort type_name+"_index","dtype*","**(dtype**)"
|
251
|
-
def_method "sort_index",-1
|
252
|
-
def_method "median",-1
|
253
|
-
end
|
254
|
-
|
255
|
-
# Math
|
256
|
-
# histogram
|
257
|
-
|
258
|
-
if has_math
|
259
|
-
math "sqrt"
|
260
|
-
math "cbrt"
|
261
|
-
math "log"
|
262
|
-
math "log2"
|
263
|
-
math "log10"
|
264
|
-
math "exp"
|
265
|
-
math "exp2"
|
266
|
-
math "exp10"
|
267
|
-
math "sin"
|
268
|
-
math "cos"
|
269
|
-
math "tan"
|
270
|
-
math "asin"
|
271
|
-
math "acos"
|
272
|
-
math "atan"
|
273
|
-
math "sinh"
|
274
|
-
math "cosh"
|
275
|
-
math "tanh"
|
276
|
-
math "asinh"
|
277
|
-
math "acosh"
|
278
|
-
math "atanh"
|
279
|
-
if !is_complex
|
280
|
-
math "atan2",2
|
281
|
-
math "hypot",2
|
282
|
-
math "erf"
|
283
|
-
math "erfc"
|
284
|
-
math "ldexp",2
|
285
|
-
end
|
286
|
-
end
|
287
|
-
%>
|
288
36
|
static VALUE <%= find_tmpl('store').c_func %>(VALUE,VALUE);
|
289
37
|
<%
|
290
38
|
Function.codes.each do |x| %>
|
@@ -304,9 +52,15 @@ Init_nary_<%=tp%>()
|
|
304
52
|
<% if has_math %>
|
305
53
|
mTM = rb_define_module_under(cT, "Math"); <% end %>
|
306
54
|
|
55
|
+
<% if is_bit %>
|
56
|
+
rb_define_const(cT, "ELEMENT_BIT_SIZE", INT2FIX(1));
|
57
|
+
rb_define_const(cT, "ELEMENT_BYTE_SIZE", rb_float_new(1.0/8));
|
58
|
+
rb_define_const(cT, "CONTIGUOUS_STRIDE", INT2FIX(1));
|
59
|
+
<% else %>
|
307
60
|
rb_define_const(cT, ELEMENT_BIT_SIZE, INT2FIX(sizeof(dtype)*8));
|
308
61
|
rb_define_const(cT, ELEMENT_BYTE_SIZE, INT2FIX(sizeof(dtype)));
|
309
62
|
rb_define_const(cT, CONTIGUOUS_STRIDE, INT2FIX(sizeof(dtype)));
|
63
|
+
<% end %>
|
310
64
|
|
311
65
|
rb_define_singleton_method(cT, "[]", <%=cast_func%>, -2);
|
312
66
|
|
@@ -0,0 +1,294 @@
|
|
1
|
+
# Define ID
|
2
|
+
|
3
|
+
def_id "cast"
|
4
|
+
def_id "eq"
|
5
|
+
def_id "ne"
|
6
|
+
def_id "pow"
|
7
|
+
def_id "mulsum"
|
8
|
+
if is_complex
|
9
|
+
def_id "real"
|
10
|
+
def_id "imag"
|
11
|
+
else
|
12
|
+
def_id "divmod"
|
13
|
+
end
|
14
|
+
if is_float
|
15
|
+
def_id "nearly_eq"
|
16
|
+
end
|
17
|
+
if is_comparable
|
18
|
+
def_id "gt"
|
19
|
+
def_id "ge"
|
20
|
+
def_id "lt"
|
21
|
+
def_id "le"
|
22
|
+
end
|
23
|
+
if is_object
|
24
|
+
def_id "bit_and"
|
25
|
+
def_id "bit_or"
|
26
|
+
def_id "bit_xor"
|
27
|
+
def_id "bit_not"
|
28
|
+
def_id "abs"
|
29
|
+
def_id "minus"
|
30
|
+
def_id "reciprocal"
|
31
|
+
def_id "square"
|
32
|
+
def_id "floor"
|
33
|
+
def_id "round"
|
34
|
+
def_id "ceil"
|
35
|
+
def_id "truncate"
|
36
|
+
def_id "nan?"
|
37
|
+
def_id "infinite?"
|
38
|
+
def_id "finite?"
|
39
|
+
def_id ">" ,"op_gt"
|
40
|
+
def_id ">=","op_ge"
|
41
|
+
def_id "<" ,"op_lt"
|
42
|
+
def_id "<=","op_le"
|
43
|
+
def_id "<=>","op_ufo"
|
44
|
+
end
|
45
|
+
|
46
|
+
# Allocation
|
47
|
+
|
48
|
+
if is_object
|
49
|
+
def_allocate "robj_allocate"
|
50
|
+
end
|
51
|
+
def_method "allocate", 0
|
52
|
+
|
53
|
+
# Type conversion
|
54
|
+
|
55
|
+
def_method "extract", 0
|
56
|
+
store_numeric
|
57
|
+
cast_array
|
58
|
+
store_array
|
59
|
+
store_bit "Bit"
|
60
|
+
if is_complex
|
61
|
+
store_from "DComplex","dcomplex","m_from_dcomplex"
|
62
|
+
store_from "SComplex","scomplex","m_from_scomplex"
|
63
|
+
end
|
64
|
+
store_from "DFloat","double", "m_from_real"
|
65
|
+
store_from "SFloat","float", "m_from_real"
|
66
|
+
store_from "Int64", "int64_t", "m_from_real"
|
67
|
+
store_from "Int32", "int32_t", "m_from_real"
|
68
|
+
store_from "Int16", "int16_t", "m_from_real"
|
69
|
+
store_from "Int8", "int8_t", "m_from_real"
|
70
|
+
store_from "UInt64","u_int64_t","m_from_real"
|
71
|
+
store_from "UInt32","u_int32_t","m_from_real"
|
72
|
+
store_from "UInt16","u_int16_t","m_from_real"
|
73
|
+
store_from "UInt8", "u_int8_t", "m_from_real"
|
74
|
+
|
75
|
+
def_method "store", 1
|
76
|
+
def_singleton "cast", 1
|
77
|
+
|
78
|
+
def_method "aref", -1, "aref", :op=>"[]"
|
79
|
+
def_method "aset", -1, "aset", :op=>"[]="
|
80
|
+
|
81
|
+
def_method "coerce_cast", 1
|
82
|
+
def_method "to_a", 0
|
83
|
+
def_method "fill", 1
|
84
|
+
def_method "format", -1
|
85
|
+
def_method "format_to_a", -1
|
86
|
+
def_method "inspect", 0
|
87
|
+
|
88
|
+
|
89
|
+
# Array manipulation
|
90
|
+
|
91
|
+
def_method "each", 0
|
92
|
+
unary "map" if !is_bit
|
93
|
+
def_method "each_with_index", 0
|
94
|
+
|
95
|
+
if is_bit
|
96
|
+
unary "copy"
|
97
|
+
unary "not", "~"
|
98
|
+
binary "and", "&"
|
99
|
+
binary "or" , "|"
|
100
|
+
binary "xor", "^"
|
101
|
+
binary "eq"
|
102
|
+
bit_count "count_true"
|
103
|
+
def_alias "count_1","count_true"
|
104
|
+
bit_count "count_false"
|
105
|
+
def_alias "count_0","count_false"
|
106
|
+
bit_reduce "all?", 1
|
107
|
+
bit_reduce "any?", 0
|
108
|
+
def_method "none?", -1, "none_p"
|
109
|
+
def_method "where", 0
|
110
|
+
def_method "where2", 0
|
111
|
+
def_method "mask", 1
|
112
|
+
else
|
113
|
+
def_method "map_with_index", 0
|
114
|
+
|
115
|
+
# Arithmetic
|
116
|
+
|
117
|
+
unary2 "abs", "rtype", "cRT"
|
118
|
+
|
119
|
+
binary "add", "+"
|
120
|
+
binary "sub", "-"
|
121
|
+
binary "mul", "*"
|
122
|
+
binary "div", "/"
|
123
|
+
|
124
|
+
if !is_complex
|
125
|
+
binary "mod", "%"
|
126
|
+
binary2 "divmod"
|
127
|
+
end
|
128
|
+
|
129
|
+
pow
|
130
|
+
|
131
|
+
unary "minus", "-@"
|
132
|
+
unary "reciprocal"
|
133
|
+
unary "sign"
|
134
|
+
|
135
|
+
# Complex
|
136
|
+
|
137
|
+
if is_complex
|
138
|
+
unary "conj"
|
139
|
+
unary "im"
|
140
|
+
unary2 "real", "rtype", "cRT"
|
141
|
+
unary2 "imag", "rtype", "cRT"
|
142
|
+
unary2 "arg", "rtype", "cRT"
|
143
|
+
def_alias "angle","arg"
|
144
|
+
set2 "set_imag", "rtype", "cRT"
|
145
|
+
set2 "set_real", "rtype", "cRT"
|
146
|
+
def_alias "imag=","set_imag"
|
147
|
+
def_alias "real=","set_real"
|
148
|
+
else
|
149
|
+
def_alias "conj", "copy"
|
150
|
+
def_alias "im", "copy"
|
151
|
+
end
|
152
|
+
|
153
|
+
def_alias "conjugate","conj"
|
154
|
+
|
155
|
+
# base_cond
|
156
|
+
|
157
|
+
cond_binary "eq"
|
158
|
+
cond_binary "ne"
|
159
|
+
|
160
|
+
# nearly_eq : x=~y is true if |x-y| <= (|x|+|y|)*epsilon
|
161
|
+
if is_float
|
162
|
+
cond_binary "nearly_eq"
|
163
|
+
else
|
164
|
+
def_alias "nearly_eq", "eq"
|
165
|
+
end
|
166
|
+
def_alias "close_to", "nearly_eq"
|
167
|
+
|
168
|
+
# Integer
|
169
|
+
if is_int
|
170
|
+
binary "bit_and", "&"
|
171
|
+
binary "bit_or" , "|"
|
172
|
+
binary "bit_xor", "^"
|
173
|
+
unary "bit_not", "~"
|
174
|
+
if !is_object
|
175
|
+
def_alias "floor", "copy"
|
176
|
+
def_alias "round", "copy"
|
177
|
+
def_alias "ceil", "copy"
|
178
|
+
def_alias "trunc", "copy"
|
179
|
+
def_alias "rint", "copy"
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
if is_float
|
184
|
+
unary "floor"
|
185
|
+
unary "round"
|
186
|
+
unary "ceil"
|
187
|
+
unary "trunc"
|
188
|
+
if !is_object
|
189
|
+
unary "rint"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
if is_comparable
|
194
|
+
cond_binary "gt"
|
195
|
+
cond_binary "ge"
|
196
|
+
cond_binary "lt"
|
197
|
+
cond_binary "le"
|
198
|
+
def_alias ">", "gt"
|
199
|
+
def_alias ">=","ge"
|
200
|
+
def_alias "<", "lt"
|
201
|
+
def_alias "<=","le"
|
202
|
+
end
|
203
|
+
|
204
|
+
# Float
|
205
|
+
|
206
|
+
if is_float
|
207
|
+
cond_unary "isnan"
|
208
|
+
cond_unary "isinf"
|
209
|
+
cond_unary "isfinite"
|
210
|
+
end
|
211
|
+
|
212
|
+
accum "sum","dtype","cT"
|
213
|
+
accum "prod","dtype","cT"
|
214
|
+
|
215
|
+
if is_float
|
216
|
+
accum "mean","dtype","cT"
|
217
|
+
accum "stddev","rtype","cRT"
|
218
|
+
accum "var","rtype","cRT"
|
219
|
+
accum "rms","rtype","cRT"
|
220
|
+
end
|
221
|
+
|
222
|
+
if is_comparable
|
223
|
+
accum "min","dtype","cT"
|
224
|
+
accum "max","dtype","cT"
|
225
|
+
accum_index "max_index"
|
226
|
+
accum_index "min_index"
|
227
|
+
def_method "minmax",-1
|
228
|
+
end
|
229
|
+
|
230
|
+
cum "cumsum","add"
|
231
|
+
cum "cumprod","mul"
|
232
|
+
|
233
|
+
# dot
|
234
|
+
accum_binary "mulsum"
|
235
|
+
|
236
|
+
# rmsdev
|
237
|
+
# prod
|
238
|
+
|
239
|
+
# shuffle
|
240
|
+
# histogram
|
241
|
+
|
242
|
+
def_method "seq",-1
|
243
|
+
if is_float
|
244
|
+
def_method "logseq",-1
|
245
|
+
end
|
246
|
+
def_method "eye",-1
|
247
|
+
def_alias "indgen", "seq"
|
248
|
+
|
249
|
+
def_method "rand", -1
|
250
|
+
|
251
|
+
# y = a[0] + a[1]*x + a[2]*x^2 + a[3]*x^3 + ... + a[n]*x^n
|
252
|
+
def_method "poly",-2
|
253
|
+
|
254
|
+
if is_comparable && !is_object
|
255
|
+
qsort type_name,"dtype","*(dtype*)"
|
256
|
+
def_method "sort",-1
|
257
|
+
qsort type_name+"_index","dtype*","**(dtype**)"
|
258
|
+
def_method "sort_index",-1
|
259
|
+
def_method "median",-1
|
260
|
+
end
|
261
|
+
|
262
|
+
# Math
|
263
|
+
# histogram
|
264
|
+
|
265
|
+
if has_math
|
266
|
+
math "sqrt"
|
267
|
+
math "cbrt"
|
268
|
+
math "log"
|
269
|
+
math "log2"
|
270
|
+
math "log10"
|
271
|
+
math "exp"
|
272
|
+
math "exp2"
|
273
|
+
math "exp10"
|
274
|
+
math "sin"
|
275
|
+
math "cos"
|
276
|
+
math "tan"
|
277
|
+
math "asin"
|
278
|
+
math "acos"
|
279
|
+
math "atan"
|
280
|
+
math "sinh"
|
281
|
+
math "cosh"
|
282
|
+
math "tanh"
|
283
|
+
math "asinh"
|
284
|
+
math "acosh"
|
285
|
+
math "atanh"
|
286
|
+
if !is_complex
|
287
|
+
math "atan2",2
|
288
|
+
math "hypot",2
|
289
|
+
math "erf"
|
290
|
+
math "erfc"
|
291
|
+
math "ldexp",2
|
292
|
+
end
|
293
|
+
end
|
294
|
+
end
|