cumo 0.1.0
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 +7 -0
- data/.gitignore +27 -0
- data/.travis.yml +5 -0
- data/3rd_party/mkmf-cu/.gitignore +36 -0
- data/3rd_party/mkmf-cu/Gemfile +3 -0
- data/3rd_party/mkmf-cu/LICENSE +21 -0
- data/3rd_party/mkmf-cu/README.md +36 -0
- data/3rd_party/mkmf-cu/Rakefile +11 -0
- data/3rd_party/mkmf-cu/bin/mkmf-cu-nvcc +4 -0
- data/3rd_party/mkmf-cu/lib/mkmf-cu.rb +32 -0
- data/3rd_party/mkmf-cu/lib/mkmf-cu/cli.rb +80 -0
- data/3rd_party/mkmf-cu/lib/mkmf-cu/nvcc.rb +157 -0
- data/3rd_party/mkmf-cu/mkmf-cu.gemspec +16 -0
- data/3rd_party/mkmf-cu/test/test_mkmf-cu.rb +67 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +82 -0
- data/README.md +252 -0
- data/Rakefile +43 -0
- data/bench/broadcast_fp32.rb +138 -0
- data/bench/cumo_bench.rb +193 -0
- data/bench/numo_bench.rb +138 -0
- data/bench/reduction_fp32.rb +117 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/cumo.gemspec +32 -0
- data/ext/cumo/cuda/cublas.c +278 -0
- data/ext/cumo/cuda/driver.c +421 -0
- data/ext/cumo/cuda/memory_pool.cpp +185 -0
- data/ext/cumo/cuda/memory_pool_impl.cpp +308 -0
- data/ext/cumo/cuda/memory_pool_impl.hpp +370 -0
- data/ext/cumo/cuda/memory_pool_impl_test.cpp +554 -0
- data/ext/cumo/cuda/nvrtc.c +207 -0
- data/ext/cumo/cuda/runtime.c +167 -0
- data/ext/cumo/cumo.c +148 -0
- data/ext/cumo/depend.erb +58 -0
- data/ext/cumo/extconf.rb +179 -0
- data/ext/cumo/include/cumo.h +25 -0
- data/ext/cumo/include/cumo/compat.h +23 -0
- data/ext/cumo/include/cumo/cuda/cublas.h +153 -0
- data/ext/cumo/include/cumo/cuda/cumo_thrust.hpp +187 -0
- data/ext/cumo/include/cumo/cuda/cumo_thrust_complex.hpp +79 -0
- data/ext/cumo/include/cumo/cuda/driver.h +22 -0
- data/ext/cumo/include/cumo/cuda/memory_pool.h +28 -0
- data/ext/cumo/include/cumo/cuda/nvrtc.h +22 -0
- data/ext/cumo/include/cumo/cuda/runtime.h +40 -0
- data/ext/cumo/include/cumo/indexer.h +238 -0
- data/ext/cumo/include/cumo/intern.h +142 -0
- data/ext/cumo/include/cumo/intern_fwd.h +38 -0
- data/ext/cumo/include/cumo/intern_kernel.h +6 -0
- data/ext/cumo/include/cumo/narray.h +429 -0
- data/ext/cumo/include/cumo/narray_kernel.h +149 -0
- data/ext/cumo/include/cumo/ndloop.h +95 -0
- data/ext/cumo/include/cumo/reduce_kernel.h +126 -0
- data/ext/cumo/include/cumo/template.h +158 -0
- data/ext/cumo/include/cumo/template_kernel.h +77 -0
- data/ext/cumo/include/cumo/types/bit.h +40 -0
- data/ext/cumo/include/cumo/types/bit_kernel.h +34 -0
- data/ext/cumo/include/cumo/types/complex.h +402 -0
- data/ext/cumo/include/cumo/types/complex_kernel.h +414 -0
- data/ext/cumo/include/cumo/types/complex_macro.h +382 -0
- data/ext/cumo/include/cumo/types/complex_macro_kernel.h +186 -0
- data/ext/cumo/include/cumo/types/dcomplex.h +46 -0
- data/ext/cumo/include/cumo/types/dcomplex_kernel.h +13 -0
- data/ext/cumo/include/cumo/types/dfloat.h +47 -0
- data/ext/cumo/include/cumo/types/dfloat_kernel.h +14 -0
- data/ext/cumo/include/cumo/types/float_def.h +34 -0
- data/ext/cumo/include/cumo/types/float_def_kernel.h +39 -0
- data/ext/cumo/include/cumo/types/float_macro.h +191 -0
- data/ext/cumo/include/cumo/types/float_macro_kernel.h +158 -0
- data/ext/cumo/include/cumo/types/int16.h +24 -0
- data/ext/cumo/include/cumo/types/int16_kernel.h +23 -0
- data/ext/cumo/include/cumo/types/int32.h +24 -0
- data/ext/cumo/include/cumo/types/int32_kernel.h +19 -0
- data/ext/cumo/include/cumo/types/int64.h +24 -0
- data/ext/cumo/include/cumo/types/int64_kernel.h +19 -0
- data/ext/cumo/include/cumo/types/int8.h +24 -0
- data/ext/cumo/include/cumo/types/int8_kernel.h +19 -0
- data/ext/cumo/include/cumo/types/int_macro.h +67 -0
- data/ext/cumo/include/cumo/types/int_macro_kernel.h +48 -0
- data/ext/cumo/include/cumo/types/real_accum.h +486 -0
- data/ext/cumo/include/cumo/types/real_accum_kernel.h +101 -0
- data/ext/cumo/include/cumo/types/robj_macro.h +80 -0
- data/ext/cumo/include/cumo/types/robj_macro_kernel.h +0 -0
- data/ext/cumo/include/cumo/types/robject.h +27 -0
- data/ext/cumo/include/cumo/types/robject_kernel.h +7 -0
- data/ext/cumo/include/cumo/types/scomplex.h +46 -0
- data/ext/cumo/include/cumo/types/scomplex_kernel.h +13 -0
- data/ext/cumo/include/cumo/types/sfloat.h +48 -0
- data/ext/cumo/include/cumo/types/sfloat_kernel.h +14 -0
- data/ext/cumo/include/cumo/types/uint16.h +25 -0
- data/ext/cumo/include/cumo/types/uint16_kernel.h +20 -0
- data/ext/cumo/include/cumo/types/uint32.h +25 -0
- data/ext/cumo/include/cumo/types/uint32_kernel.h +20 -0
- data/ext/cumo/include/cumo/types/uint64.h +25 -0
- data/ext/cumo/include/cumo/types/uint64_kernel.h +20 -0
- data/ext/cumo/include/cumo/types/uint8.h +25 -0
- data/ext/cumo/include/cumo/types/uint8_kernel.h +20 -0
- data/ext/cumo/include/cumo/types/uint_macro.h +58 -0
- data/ext/cumo/include/cumo/types/uint_macro_kernel.h +38 -0
- data/ext/cumo/include/cumo/types/xint_macro.h +169 -0
- data/ext/cumo/include/cumo/types/xint_macro_kernel.h +88 -0
- data/ext/cumo/narray/SFMT-params.h +97 -0
- data/ext/cumo/narray/SFMT-params19937.h +46 -0
- data/ext/cumo/narray/SFMT.c +620 -0
- data/ext/cumo/narray/SFMT.h +167 -0
- data/ext/cumo/narray/array.c +638 -0
- data/ext/cumo/narray/data.c +961 -0
- data/ext/cumo/narray/gen/cogen.rb +56 -0
- data/ext/cumo/narray/gen/cogen_kernel.rb +58 -0
- data/ext/cumo/narray/gen/def/bit.rb +37 -0
- data/ext/cumo/narray/gen/def/dcomplex.rb +39 -0
- data/ext/cumo/narray/gen/def/dfloat.rb +37 -0
- data/ext/cumo/narray/gen/def/int16.rb +36 -0
- data/ext/cumo/narray/gen/def/int32.rb +36 -0
- data/ext/cumo/narray/gen/def/int64.rb +36 -0
- data/ext/cumo/narray/gen/def/int8.rb +36 -0
- data/ext/cumo/narray/gen/def/robject.rb +37 -0
- data/ext/cumo/narray/gen/def/scomplex.rb +39 -0
- data/ext/cumo/narray/gen/def/sfloat.rb +37 -0
- data/ext/cumo/narray/gen/def/uint16.rb +36 -0
- data/ext/cumo/narray/gen/def/uint32.rb +36 -0
- data/ext/cumo/narray/gen/def/uint64.rb +36 -0
- data/ext/cumo/narray/gen/def/uint8.rb +36 -0
- data/ext/cumo/narray/gen/erbpp2.rb +346 -0
- data/ext/cumo/narray/gen/narray_def.rb +268 -0
- data/ext/cumo/narray/gen/spec.rb +425 -0
- data/ext/cumo/narray/gen/tmpl/accum.c +86 -0
- data/ext/cumo/narray/gen/tmpl/accum_binary.c +121 -0
- data/ext/cumo/narray/gen/tmpl/accum_binary_kernel.cu +61 -0
- data/ext/cumo/narray/gen/tmpl/accum_index.c +119 -0
- data/ext/cumo/narray/gen/tmpl/accum_index_kernel.cu +66 -0
- data/ext/cumo/narray/gen/tmpl/accum_kernel.cu +12 -0
- data/ext/cumo/narray/gen/tmpl/alloc_func.c +107 -0
- data/ext/cumo/narray/gen/tmpl/allocate.c +37 -0
- data/ext/cumo/narray/gen/tmpl/aref.c +66 -0
- data/ext/cumo/narray/gen/tmpl/aref_cpu.c +50 -0
- data/ext/cumo/narray/gen/tmpl/aset.c +56 -0
- data/ext/cumo/narray/gen/tmpl/binary.c +162 -0
- data/ext/cumo/narray/gen/tmpl/binary2.c +70 -0
- data/ext/cumo/narray/gen/tmpl/binary2_kernel.cu +15 -0
- data/ext/cumo/narray/gen/tmpl/binary_kernel.cu +31 -0
- data/ext/cumo/narray/gen/tmpl/binary_s.c +45 -0
- data/ext/cumo/narray/gen/tmpl/binary_s_kernel.cu +15 -0
- data/ext/cumo/narray/gen/tmpl/bincount.c +181 -0
- data/ext/cumo/narray/gen/tmpl/cast.c +44 -0
- data/ext/cumo/narray/gen/tmpl/cast_array.c +13 -0
- data/ext/cumo/narray/gen/tmpl/class.c +9 -0
- data/ext/cumo/narray/gen/tmpl/class_kernel.cu +6 -0
- data/ext/cumo/narray/gen/tmpl/clip.c +121 -0
- data/ext/cumo/narray/gen/tmpl/coerce_cast.c +10 -0
- data/ext/cumo/narray/gen/tmpl/complex_accum_kernel.cu +129 -0
- data/ext/cumo/narray/gen/tmpl/cond_binary.c +68 -0
- data/ext/cumo/narray/gen/tmpl/cond_binary_kernel.cu +18 -0
- data/ext/cumo/narray/gen/tmpl/cond_unary.c +46 -0
- data/ext/cumo/narray/gen/tmpl/cum.c +50 -0
- data/ext/cumo/narray/gen/tmpl/each.c +47 -0
- data/ext/cumo/narray/gen/tmpl/each_with_index.c +70 -0
- data/ext/cumo/narray/gen/tmpl/ewcomp.c +79 -0
- data/ext/cumo/narray/gen/tmpl/ewcomp_kernel.cu +19 -0
- data/ext/cumo/narray/gen/tmpl/extract.c +22 -0
- data/ext/cumo/narray/gen/tmpl/extract_cpu.c +26 -0
- data/ext/cumo/narray/gen/tmpl/extract_data.c +53 -0
- data/ext/cumo/narray/gen/tmpl/eye.c +105 -0
- data/ext/cumo/narray/gen/tmpl/eye_kernel.cu +19 -0
- data/ext/cumo/narray/gen/tmpl/fill.c +52 -0
- data/ext/cumo/narray/gen/tmpl/fill_kernel.cu +29 -0
- data/ext/cumo/narray/gen/tmpl/float_accum_kernel.cu +106 -0
- data/ext/cumo/narray/gen/tmpl/format.c +62 -0
- data/ext/cumo/narray/gen/tmpl/format_to_a.c +49 -0
- data/ext/cumo/narray/gen/tmpl/frexp.c +38 -0
- data/ext/cumo/narray/gen/tmpl/gemm.c +203 -0
- data/ext/cumo/narray/gen/tmpl/init_class.c +20 -0
- data/ext/cumo/narray/gen/tmpl/init_module.c +12 -0
- data/ext/cumo/narray/gen/tmpl/inspect.c +21 -0
- data/ext/cumo/narray/gen/tmpl/lib.c +50 -0
- data/ext/cumo/narray/gen/tmpl/lib_kernel.cu +24 -0
- data/ext/cumo/narray/gen/tmpl/logseq.c +102 -0
- data/ext/cumo/narray/gen/tmpl/logseq_kernel.cu +31 -0
- data/ext/cumo/narray/gen/tmpl/map_with_index.c +98 -0
- data/ext/cumo/narray/gen/tmpl/median.c +66 -0
- data/ext/cumo/narray/gen/tmpl/minmax.c +47 -0
- data/ext/cumo/narray/gen/tmpl/module.c +9 -0
- data/ext/cumo/narray/gen/tmpl/module_kernel.cu +1 -0
- data/ext/cumo/narray/gen/tmpl/new_dim0.c +15 -0
- data/ext/cumo/narray/gen/tmpl/new_dim0_kernel.cu +8 -0
- data/ext/cumo/narray/gen/tmpl/poly.c +50 -0
- data/ext/cumo/narray/gen/tmpl/pow.c +97 -0
- data/ext/cumo/narray/gen/tmpl/pow_kernel.cu +29 -0
- data/ext/cumo/narray/gen/tmpl/powint.c +17 -0
- data/ext/cumo/narray/gen/tmpl/qsort.c +212 -0
- data/ext/cumo/narray/gen/tmpl/rand.c +168 -0
- data/ext/cumo/narray/gen/tmpl/rand_norm.c +121 -0
- data/ext/cumo/narray/gen/tmpl/real_accum_kernel.cu +75 -0
- data/ext/cumo/narray/gen/tmpl/seq.c +112 -0
- data/ext/cumo/narray/gen/tmpl/seq_kernel.cu +43 -0
- data/ext/cumo/narray/gen/tmpl/set2.c +57 -0
- data/ext/cumo/narray/gen/tmpl/sort.c +48 -0
- data/ext/cumo/narray/gen/tmpl/sort_index.c +111 -0
- data/ext/cumo/narray/gen/tmpl/store.c +41 -0
- data/ext/cumo/narray/gen/tmpl/store_array.c +187 -0
- data/ext/cumo/narray/gen/tmpl/store_array_kernel.cu +58 -0
- data/ext/cumo/narray/gen/tmpl/store_bit.c +86 -0
- data/ext/cumo/narray/gen/tmpl/store_bit_kernel.cu +66 -0
- data/ext/cumo/narray/gen/tmpl/store_from.c +81 -0
- data/ext/cumo/narray/gen/tmpl/store_from_kernel.cu +58 -0
- data/ext/cumo/narray/gen/tmpl/store_kernel.cu +3 -0
- data/ext/cumo/narray/gen/tmpl/store_numeric.c +9 -0
- data/ext/cumo/narray/gen/tmpl/to_a.c +43 -0
- data/ext/cumo/narray/gen/tmpl/unary.c +132 -0
- data/ext/cumo/narray/gen/tmpl/unary2.c +60 -0
- data/ext/cumo/narray/gen/tmpl/unary_kernel.cu +72 -0
- data/ext/cumo/narray/gen/tmpl/unary_ret2.c +34 -0
- data/ext/cumo/narray/gen/tmpl/unary_s.c +86 -0
- data/ext/cumo/narray/gen/tmpl/unary_s_kernel.cu +58 -0
- data/ext/cumo/narray/gen/tmpl_bit/allocate.c +24 -0
- data/ext/cumo/narray/gen/tmpl_bit/aref.c +54 -0
- data/ext/cumo/narray/gen/tmpl_bit/aref_cpu.c +57 -0
- data/ext/cumo/narray/gen/tmpl_bit/aset.c +56 -0
- data/ext/cumo/narray/gen/tmpl_bit/binary.c +98 -0
- data/ext/cumo/narray/gen/tmpl_bit/bit_count.c +64 -0
- data/ext/cumo/narray/gen/tmpl_bit/bit_count_cpu.c +88 -0
- data/ext/cumo/narray/gen/tmpl_bit/bit_count_kernel.cu +76 -0
- data/ext/cumo/narray/gen/tmpl_bit/bit_reduce.c +133 -0
- data/ext/cumo/narray/gen/tmpl_bit/each.c +48 -0
- data/ext/cumo/narray/gen/tmpl_bit/each_with_index.c +70 -0
- data/ext/cumo/narray/gen/tmpl_bit/extract.c +30 -0
- data/ext/cumo/narray/gen/tmpl_bit/extract_cpu.c +29 -0
- data/ext/cumo/narray/gen/tmpl_bit/fill.c +69 -0
- data/ext/cumo/narray/gen/tmpl_bit/format.c +64 -0
- data/ext/cumo/narray/gen/tmpl_bit/format_to_a.c +51 -0
- data/ext/cumo/narray/gen/tmpl_bit/inspect.c +21 -0
- data/ext/cumo/narray/gen/tmpl_bit/mask.c +136 -0
- data/ext/cumo/narray/gen/tmpl_bit/none_p.c +14 -0
- data/ext/cumo/narray/gen/tmpl_bit/store_array.c +108 -0
- data/ext/cumo/narray/gen/tmpl_bit/store_bit.c +70 -0
- data/ext/cumo/narray/gen/tmpl_bit/store_from.c +60 -0
- data/ext/cumo/narray/gen/tmpl_bit/to_a.c +47 -0
- data/ext/cumo/narray/gen/tmpl_bit/unary.c +81 -0
- data/ext/cumo/narray/gen/tmpl_bit/where.c +90 -0
- data/ext/cumo/narray/gen/tmpl_bit/where2.c +95 -0
- data/ext/cumo/narray/index.c +880 -0
- data/ext/cumo/narray/kwargs.c +153 -0
- data/ext/cumo/narray/math.c +142 -0
- data/ext/cumo/narray/narray.c +1948 -0
- data/ext/cumo/narray/ndloop.c +2105 -0
- data/ext/cumo/narray/rand.c +45 -0
- data/ext/cumo/narray/step.c +474 -0
- data/ext/cumo/narray/struct.c +886 -0
- data/lib/cumo.rb +3 -0
- data/lib/cumo/cuda.rb +11 -0
- data/lib/cumo/cuda/compile_error.rb +36 -0
- data/lib/cumo/cuda/compiler.rb +161 -0
- data/lib/cumo/cuda/device.rb +47 -0
- data/lib/cumo/cuda/link_state.rb +31 -0
- data/lib/cumo/cuda/module.rb +40 -0
- data/lib/cumo/cuda/nvrtc_program.rb +27 -0
- data/lib/cumo/linalg.rb +12 -0
- data/lib/cumo/narray.rb +2 -0
- data/lib/cumo/narray/extra.rb +1278 -0
- data/lib/erbpp.rb +294 -0
- data/lib/erbpp/line_number.rb +137 -0
- data/lib/erbpp/narray_def.rb +381 -0
- data/numo-narray-version +1 -0
- data/run.gdb +7 -0
- metadata +353 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
require_relative './erbpp2'
|
|
2
|
+
|
|
3
|
+
module NArrayMethod
|
|
4
|
+
|
|
5
|
+
def binary(meth, ope=nil)
|
|
6
|
+
ope = meth if ope.nil?
|
|
7
|
+
def_method(meth, "binary", op:ope)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def binary2(meth, ope=nil)
|
|
11
|
+
ope = meth if ope.nil?
|
|
12
|
+
def_method(meth, "binary2", op:ope)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def unary(meth, ope=nil)
|
|
16
|
+
def_method(meth, "unary", op:ope)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def pow
|
|
20
|
+
def_method("pow", "pow", op:"**")
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def unary2(meth, dtype, result_class)
|
|
24
|
+
h = {dtype:dtype, result_class:result_class}
|
|
25
|
+
def_method(meth, "unary2", **h)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def set2(meth, dtype, result_class)
|
|
29
|
+
h = {dtype:dtype, result_class:result_class}
|
|
30
|
+
def_method(meth, "set2", h)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def cond_binary(meth,op=nil)
|
|
34
|
+
op = meth unless op
|
|
35
|
+
def_method(meth, "cond_binary", op:op)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def cond_unary(meth)
|
|
39
|
+
def_method(meth, "cond_unary")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def bit_count(meth)
|
|
43
|
+
def_method(meth, "bit_count")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def bit_count_cpu(meth)
|
|
47
|
+
def_method(meth, "bit_count_cpu")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def bit_reduce(meth, init_bit)
|
|
51
|
+
h = {init_bit:init_bit}
|
|
52
|
+
def_method(meth, "bit_reduce", **h)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def accum(meth, dtype, result_class)
|
|
56
|
+
h = {dtype:dtype, result_class:result_class}
|
|
57
|
+
def_method(meth, "accum", **h)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def accum_index(meth)
|
|
61
|
+
def_method(meth, "accum_index")
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def cum(meth, cmacro)
|
|
65
|
+
def_method(meth, "cum", cmacro:cmacro)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def accum_binary(meth, ope=nil)
|
|
69
|
+
ope = meth if ope.nil?
|
|
70
|
+
def_method(meth, "accum_binary", op:ope)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def qsort(type_name, dtype, dcast, suffix="")
|
|
74
|
+
h = {type_name:type_name, dtype:dtype, dcast:dcast, suffix:suffix}
|
|
75
|
+
def_method("qsort", **h)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
module NMathMethod
|
|
80
|
+
|
|
81
|
+
def math(meth, n=1, tmpl=nil, **h)
|
|
82
|
+
if tmpl.nil?
|
|
83
|
+
case n
|
|
84
|
+
when 1
|
|
85
|
+
tmpl = "unary_s"
|
|
86
|
+
when 2
|
|
87
|
+
tmpl = "binary_s"
|
|
88
|
+
when 3
|
|
89
|
+
tmpl = "ternary_s"
|
|
90
|
+
else
|
|
91
|
+
raise "invalid n=#{n}"
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
def_module_function(meth, tmpl, **h)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# ----------------------------------------------------------------------
|
|
99
|
+
|
|
100
|
+
module NArrayType
|
|
101
|
+
|
|
102
|
+
def type_name
|
|
103
|
+
@opts[:type_name] ||= class_name.downcase
|
|
104
|
+
end
|
|
105
|
+
alias tp type_name
|
|
106
|
+
|
|
107
|
+
def type_var
|
|
108
|
+
@opts[:type_var] ||= "cumo_c"+class_name
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def math_var
|
|
112
|
+
@opts[:math_var] ||= "cumo_m"+class_name+"Math"
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def real_class_name(arg=nil)
|
|
116
|
+
if arg.nil?
|
|
117
|
+
@opts[:real_class_name] ||= class_name
|
|
118
|
+
else
|
|
119
|
+
@opts[:real_class_name] = arg
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def real_ctype(arg=nil)
|
|
124
|
+
if arg.nil?
|
|
125
|
+
@opts[:real_ctype] ||= ctype
|
|
126
|
+
else
|
|
127
|
+
@opts[:real_ctype] = arg
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def real_type_var
|
|
132
|
+
@opts[:real_type_var] ||= "cumo_c"+real_class_name
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def real_type_name
|
|
136
|
+
@opts[:real_type_name] ||= real_class_name.downcase
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def class_alias(*args)
|
|
140
|
+
case a = @opts[:class_alias]
|
|
141
|
+
when Array
|
|
142
|
+
when nil
|
|
143
|
+
a = @opts[:class_alias] = []
|
|
144
|
+
else
|
|
145
|
+
a = @opts[:class_alias] = [a]
|
|
146
|
+
end
|
|
147
|
+
a.concat(args)
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def upcast(c=nil,t=nil)
|
|
151
|
+
@opts[:upcast] ||= []
|
|
152
|
+
if c
|
|
153
|
+
if t
|
|
154
|
+
t = "cumo_c#{t}"
|
|
155
|
+
else
|
|
156
|
+
t = "cT"
|
|
157
|
+
end
|
|
158
|
+
@opts[:upcast] << "rb_hash_aset(hCast, cumo_c#{c}, #{t});"
|
|
159
|
+
else
|
|
160
|
+
@opts[:upcast]
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def upcast_rb(c,t=nil)
|
|
165
|
+
@opts[:upcast] ||= []
|
|
166
|
+
if t
|
|
167
|
+
t = "cumo_c#{t}"
|
|
168
|
+
else
|
|
169
|
+
t = "cT"
|
|
170
|
+
end
|
|
171
|
+
if c=="Integer"
|
|
172
|
+
@opts[:upcast] << "#ifdef RUBY_INTEGER_UNIFICATION"
|
|
173
|
+
@opts[:upcast] << "rb_hash_aset(hCast, rb_cInteger, #{t});"
|
|
174
|
+
@opts[:upcast] << "#else"
|
|
175
|
+
@opts[:upcast] << "rb_hash_aset(hCast, rb_cFixnum, #{t});"
|
|
176
|
+
@opts[:upcast] << "rb_hash_aset(hCast, rb_cBignum, #{t});"
|
|
177
|
+
@opts[:upcast] << "#endif"
|
|
178
|
+
else
|
|
179
|
+
@opts[:upcast] << "rb_hash_aset(hCast, rb_c#{c}, #{t});"
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# ----------------------------------------------------------------------
|
|
185
|
+
|
|
186
|
+
module StoreFrom
|
|
187
|
+
|
|
188
|
+
def store_from(cname, dtype=nil, macro=nil)
|
|
189
|
+
tmpl = (cname=="Bit") ? "store_bit" : "store_from"
|
|
190
|
+
h = { name:cname.downcase,
|
|
191
|
+
type_name:cname,
|
|
192
|
+
type_var:"cumo_c"+cname,
|
|
193
|
+
dtype:dtype,
|
|
194
|
+
macro:macro }
|
|
195
|
+
Store.new(self, tmpl, **h)
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def store_numeric
|
|
199
|
+
StoreNum.new(self, "store_numeric", name:"numeric")
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def store_array
|
|
203
|
+
StoreArray.new(self, "store_array", name:"array")
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def definitions
|
|
207
|
+
a = []
|
|
208
|
+
@children.each do |x|
|
|
209
|
+
if x.condition("")
|
|
210
|
+
if x.get(:type_name) == parent.class_name
|
|
211
|
+
a.unshift(x)
|
|
212
|
+
else
|
|
213
|
+
a.push(x)
|
|
214
|
+
end
|
|
215
|
+
end
|
|
216
|
+
end
|
|
217
|
+
a
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
# ----------------------------------------------------------------------
|
|
222
|
+
|
|
223
|
+
class Store < DefMethod
|
|
224
|
+
def c_func(n=nil)
|
|
225
|
+
"#{parent.parent.name}_store_#{name}"
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
def condition(klass)
|
|
229
|
+
"#{klass}==#{type_var}"
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def extract_data(ptr,pos,x)
|
|
233
|
+
case type_name
|
|
234
|
+
when "Bit"
|
|
235
|
+
"{BIT_DIGIT b; LOAD_BIT(#{ptr},#{pos},b); x = m_from_sint(b);}"
|
|
236
|
+
when "RObject"
|
|
237
|
+
"#{x} = m_num_to_data(*(#{dtype}*)(#{ptr}+#{pos}))"
|
|
238
|
+
when /Complex/
|
|
239
|
+
"{#{dtype} *p = (#{dtype}*)(#{ptr}+#{pos}); #{x} = c_new(REAL(*p),IMAG(*p));}"
|
|
240
|
+
when /Float/
|
|
241
|
+
"#{x} = m_from_real(*(#{dtype}*)(#{ptr}+#{pos}))"
|
|
242
|
+
when /UInt64/
|
|
243
|
+
"#{x} = m_from_uint64(*(#{dtype}*)(#{ptr}+#{pos}))"
|
|
244
|
+
when /UInt32/
|
|
245
|
+
"#{x} = m_from_uint32(*(#{dtype}*)(#{ptr}+#{pos}))"
|
|
246
|
+
when /Int64/
|
|
247
|
+
"#{x} = m_from_int64(*(#{dtype}*)(#{ptr}+#{pos}))"
|
|
248
|
+
when /Int32/
|
|
249
|
+
"#{x} = m_from_int32(*(#{dtype}*)(#{ptr}+#{pos}))"
|
|
250
|
+
when /Int/
|
|
251
|
+
"#{x} = m_from_sint(*(#{dtype}*)(#{ptr}+#{pos}))"
|
|
252
|
+
else
|
|
253
|
+
raise "unknown type: #{type_name}"
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
class StoreNum < Store
|
|
259
|
+
def condition(klass)
|
|
260
|
+
"IS_INTEGER_CLASS(#{klass}) || #{klass}==rb_cFloat || #{klass}==rb_cComplex"
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
class StoreArray < Store
|
|
265
|
+
def condition(klass)
|
|
266
|
+
"#{klass}==rb_cArray"
|
|
267
|
+
end
|
|
268
|
+
end
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
def_id "cast"
|
|
2
|
+
def_id "eq"
|
|
3
|
+
def_id "ne"
|
|
4
|
+
def_id "pow"
|
|
5
|
+
def_id "mulsum"
|
|
6
|
+
if is_complex
|
|
7
|
+
def_id "real"
|
|
8
|
+
def_id "imag"
|
|
9
|
+
else
|
|
10
|
+
def_id "divmod"
|
|
11
|
+
end
|
|
12
|
+
if is_float
|
|
13
|
+
def_id "nearly_eq"
|
|
14
|
+
def_id "copysign"
|
|
15
|
+
end
|
|
16
|
+
if is_int
|
|
17
|
+
def_id "<<","left_shift"
|
|
18
|
+
def_id ">>","right_shift"
|
|
19
|
+
end
|
|
20
|
+
if is_comparable && !is_object
|
|
21
|
+
def_id "gt"
|
|
22
|
+
def_id "ge"
|
|
23
|
+
def_id "lt"
|
|
24
|
+
def_id "le"
|
|
25
|
+
end
|
|
26
|
+
if is_comparable
|
|
27
|
+
def_id "nan"
|
|
28
|
+
end
|
|
29
|
+
if is_object
|
|
30
|
+
def_id "bit_and"
|
|
31
|
+
def_id "bit_or"
|
|
32
|
+
def_id "bit_xor"
|
|
33
|
+
def_id "bit_not"
|
|
34
|
+
def_id "abs"
|
|
35
|
+
def_id "minus"
|
|
36
|
+
def_id "reciprocal"
|
|
37
|
+
def_id "square"
|
|
38
|
+
def_id "floor"
|
|
39
|
+
def_id "round"
|
|
40
|
+
def_id "ceil"
|
|
41
|
+
def_id "truncate"
|
|
42
|
+
def_id "nan?"
|
|
43
|
+
def_id "infinite?"
|
|
44
|
+
def_id "finite?"
|
|
45
|
+
def_id "==","eq"
|
|
46
|
+
def_id "!=","ne"
|
|
47
|
+
def_id ">" ,"gt"
|
|
48
|
+
def_id ">=","ge"
|
|
49
|
+
def_id "<" ,"lt"
|
|
50
|
+
def_id "<=","le"
|
|
51
|
+
def_id "<=>","ufo"
|
|
52
|
+
end
|
|
53
|
+
if (is_float || is_complex) && !is_object
|
|
54
|
+
def_id "gemm"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
if is_int && !is_object
|
|
58
|
+
def_id "minlength" # for bincount
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Constatnts
|
|
62
|
+
|
|
63
|
+
if is_bit
|
|
64
|
+
def_const "ELEMENT_BIT_SIZE", "INT2FIX(1)"
|
|
65
|
+
def_const "ELEMENT_BYTE_SIZE", "rb_float_new(1.0/8)"
|
|
66
|
+
def_const "CONTIGUOUS_STRIDE", "INT2FIX(1)"
|
|
67
|
+
else
|
|
68
|
+
def_const "ELEMENT_BIT_SIZE", "INT2FIX(sizeof(dtype)*8)"
|
|
69
|
+
def_const "ELEMENT_BYTE_SIZE", "INT2FIX(sizeof(dtype))"
|
|
70
|
+
def_const "CONTIGUOUS_STRIDE", "INT2FIX(sizeof(dtype))"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
if !is_object
|
|
74
|
+
if is_float
|
|
75
|
+
def_const "EPSILON", "M_EPSILON"
|
|
76
|
+
end
|
|
77
|
+
if is_float || is_int
|
|
78
|
+
def_const "MAX", "M_MAX"
|
|
79
|
+
def_const "MIN", "M_MIN"
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# Un-define
|
|
84
|
+
|
|
85
|
+
if is_object
|
|
86
|
+
undef_singleton_method "from_binary"
|
|
87
|
+
undef_method "to_binary"
|
|
88
|
+
undef_method "swap_byte"
|
|
89
|
+
undef_method "to_network"
|
|
90
|
+
undef_method "to_vacs"
|
|
91
|
+
undef_method "to_host"
|
|
92
|
+
undef_method "to_swapped"
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Allocation
|
|
96
|
+
|
|
97
|
+
def_alloc_func "alloc_func"
|
|
98
|
+
def_method "allocate"
|
|
99
|
+
|
|
100
|
+
# Type conversion
|
|
101
|
+
|
|
102
|
+
def_method "extract"
|
|
103
|
+
def_method "extract_cpu"
|
|
104
|
+
def_method "new_dim0"
|
|
105
|
+
|
|
106
|
+
def_method "store" do
|
|
107
|
+
extend StoreFrom
|
|
108
|
+
store_numeric
|
|
109
|
+
store_from "Bit"
|
|
110
|
+
if is_complex
|
|
111
|
+
store_from "DComplex","dcomplex","m_from_dcomplex"
|
|
112
|
+
store_from "SComplex","scomplex","m_from_scomplex"
|
|
113
|
+
end
|
|
114
|
+
store_from "DFloat","double", "m_from_real"
|
|
115
|
+
store_from "SFloat","float", "m_from_real"
|
|
116
|
+
store_from "Int64", "int64_t", "m_from_int64"
|
|
117
|
+
store_from "Int32", "int32_t", "m_from_int32"
|
|
118
|
+
store_from "Int16", "int16_t", "m_from_sint"
|
|
119
|
+
store_from "Int8", "int8_t", "m_from_sint"
|
|
120
|
+
store_from "UInt64","u_int64_t","m_from_uint64"
|
|
121
|
+
store_from "UInt32","u_int32_t","m_from_uint32"
|
|
122
|
+
store_from "UInt16","u_int16_t","m_from_sint"
|
|
123
|
+
store_from "UInt8", "u_int8_t", "m_from_sint"
|
|
124
|
+
store_from "RObject", "VALUE", "m_num_to_data"
|
|
125
|
+
store_array
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def_method "extract_data"
|
|
129
|
+
|
|
130
|
+
def_method "cast_array"
|
|
131
|
+
def_singleton_method "cast"
|
|
132
|
+
|
|
133
|
+
def_method "aref", op:"[]"
|
|
134
|
+
def_method "aref_cpu"
|
|
135
|
+
def_method "aset", op:"[]="
|
|
136
|
+
|
|
137
|
+
def_method "coerce_cast"
|
|
138
|
+
def_method "to_a"
|
|
139
|
+
def_method "fill"
|
|
140
|
+
def_method "format"
|
|
141
|
+
def_method "format_to_a"
|
|
142
|
+
def_method "inspect"
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
# Array manipulation
|
|
146
|
+
|
|
147
|
+
def_method "each"
|
|
148
|
+
unary "map" if !is_bit
|
|
149
|
+
def_method "each_with_index"
|
|
150
|
+
|
|
151
|
+
if is_bit
|
|
152
|
+
unary "copy"
|
|
153
|
+
unary "not", "~"
|
|
154
|
+
binary "and", "&"
|
|
155
|
+
binary "or" , "|"
|
|
156
|
+
binary "xor", "^"
|
|
157
|
+
binary "eq"
|
|
158
|
+
bit_count "count_true"
|
|
159
|
+
def_alias "count_1","count_true"
|
|
160
|
+
def_alias "count","count_true"
|
|
161
|
+
bit_count "count_false"
|
|
162
|
+
def_alias "count_0","count_false"
|
|
163
|
+
bit_count_cpu "count_true_cpu"
|
|
164
|
+
def_alias "count_1_cpu","count_true_cpu"
|
|
165
|
+
def_alias "count_cpu","count_true_cpu"
|
|
166
|
+
bit_count_cpu "count_false_cpu"
|
|
167
|
+
def_alias "count_0_cpu","count_false_cpu"
|
|
168
|
+
bit_reduce "all?", 1
|
|
169
|
+
bit_reduce "any?", 0
|
|
170
|
+
def_method "none?", "none_p"
|
|
171
|
+
def_method "where"
|
|
172
|
+
def_method "where2"
|
|
173
|
+
def_method "mask"
|
|
174
|
+
else
|
|
175
|
+
|
|
176
|
+
def_method "map_with_index"
|
|
177
|
+
|
|
178
|
+
# Arithmetic
|
|
179
|
+
|
|
180
|
+
unary2 "abs", "rtype", "cRT"
|
|
181
|
+
|
|
182
|
+
binary "add", "+"
|
|
183
|
+
binary "sub", "-"
|
|
184
|
+
binary "mul", "*"
|
|
185
|
+
binary "div", "/"
|
|
186
|
+
|
|
187
|
+
if !is_complex
|
|
188
|
+
binary "mod", "%"
|
|
189
|
+
binary2 "divmod"
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
pow
|
|
193
|
+
|
|
194
|
+
unary "minus", "-@"
|
|
195
|
+
unary "reciprocal"
|
|
196
|
+
unary "sign"
|
|
197
|
+
unary "square"
|
|
198
|
+
|
|
199
|
+
# Complex
|
|
200
|
+
|
|
201
|
+
if is_complex
|
|
202
|
+
unary "conj"
|
|
203
|
+
unary "im"
|
|
204
|
+
unary2 "real", "rtype", "cRT"
|
|
205
|
+
unary2 "imag", "rtype", "cRT"
|
|
206
|
+
unary2 "arg", "rtype", "cRT"
|
|
207
|
+
def_alias "angle","arg"
|
|
208
|
+
set2 "set_imag", "rtype", "cRT"
|
|
209
|
+
set2 "set_real", "rtype", "cRT"
|
|
210
|
+
def_alias "imag=","set_imag"
|
|
211
|
+
def_alias "real=","set_real"
|
|
212
|
+
else
|
|
213
|
+
def_alias "conj", "view"
|
|
214
|
+
def_alias "im", "view"
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def_alias "conjugate","conj"
|
|
218
|
+
|
|
219
|
+
# base_cond
|
|
220
|
+
|
|
221
|
+
cond_binary "eq"
|
|
222
|
+
cond_binary "ne"
|
|
223
|
+
|
|
224
|
+
# nearly_eq : x=~y is true if |x-y| <= (|x|+|y|)*epsilon
|
|
225
|
+
if is_float
|
|
226
|
+
cond_binary "nearly_eq"
|
|
227
|
+
else
|
|
228
|
+
def_alias "nearly_eq", "eq"
|
|
229
|
+
end
|
|
230
|
+
def_alias "close_to", "nearly_eq"
|
|
231
|
+
|
|
232
|
+
# Integer
|
|
233
|
+
if is_int
|
|
234
|
+
binary "bit_and", "&"
|
|
235
|
+
binary "bit_or" , "|"
|
|
236
|
+
binary "bit_xor", "^"
|
|
237
|
+
unary "bit_not", "~"
|
|
238
|
+
binary "left_shift", "<<"
|
|
239
|
+
binary "right_shift", ">>"
|
|
240
|
+
if !is_object
|
|
241
|
+
def_alias "floor", "view"
|
|
242
|
+
def_alias "round", "view"
|
|
243
|
+
def_alias "ceil", "view"
|
|
244
|
+
def_alias "trunc", "view"
|
|
245
|
+
def_alias "rint", "view"
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
if is_float
|
|
250
|
+
unary "floor"
|
|
251
|
+
unary "round"
|
|
252
|
+
unary "ceil"
|
|
253
|
+
unary "trunc"
|
|
254
|
+
if !is_object
|
|
255
|
+
unary "rint"
|
|
256
|
+
binary "copysign"
|
|
257
|
+
if !is_complex
|
|
258
|
+
cond_unary "signbit"
|
|
259
|
+
def_method "modf", "unary_ret2"
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
if is_comparable
|
|
265
|
+
cond_binary "gt"
|
|
266
|
+
cond_binary "ge"
|
|
267
|
+
cond_binary "lt"
|
|
268
|
+
cond_binary "le"
|
|
269
|
+
def_alias ">", "gt"
|
|
270
|
+
def_alias ">=","ge"
|
|
271
|
+
def_alias "<", "lt"
|
|
272
|
+
def_alias "<=","le"
|
|
273
|
+
def_method "clip"
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
# Float
|
|
277
|
+
|
|
278
|
+
if is_float
|
|
279
|
+
cond_unary "isnan"
|
|
280
|
+
cond_unary "isinf"
|
|
281
|
+
cond_unary "isposinf"
|
|
282
|
+
cond_unary "isneginf"
|
|
283
|
+
cond_unary "isfinite"
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
if is_int
|
|
287
|
+
if is_unsigned
|
|
288
|
+
accum "sum","u_int64_t","cumo_cUInt64"
|
|
289
|
+
accum "prod","u_int64_t","cumo_cUInt64"
|
|
290
|
+
else
|
|
291
|
+
accum "sum","int64_t","cumo_cInt64"
|
|
292
|
+
accum "prod","int64_t","cumo_cInt64"
|
|
293
|
+
end
|
|
294
|
+
else
|
|
295
|
+
accum "sum","dtype","cT"
|
|
296
|
+
accum "prod","dtype","cT"
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
if is_double_precision
|
|
300
|
+
accum "kahan_sum","dtype","cT"
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
if is_float
|
|
304
|
+
accum "mean","dtype","cT"
|
|
305
|
+
accum "stddev","rtype","cRT"
|
|
306
|
+
accum "var","rtype","cRT"
|
|
307
|
+
accum "rms","rtype","cRT"
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
if is_comparable
|
|
311
|
+
accum "min","dtype","cT"
|
|
312
|
+
accum "max","dtype","cT"
|
|
313
|
+
accum "ptp","dtype","cT"
|
|
314
|
+
accum_index "max_index"
|
|
315
|
+
accum_index "min_index"
|
|
316
|
+
def_method "minmax"
|
|
317
|
+
def_module_function "maximum", "ewcomp", n_arg:2
|
|
318
|
+
def_module_function "minimum", "ewcomp", n_arg:2
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
if is_int && !is_object
|
|
322
|
+
def_method "bincount"
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
cum "cumsum","add"
|
|
326
|
+
cum "cumprod","mul"
|
|
327
|
+
|
|
328
|
+
# dot
|
|
329
|
+
accum_binary "mulsum"
|
|
330
|
+
if (is_float || is_complex) && !is_object
|
|
331
|
+
def_method "gemm"
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
# rmsdev
|
|
335
|
+
# prod
|
|
336
|
+
|
|
337
|
+
# shuffle
|
|
338
|
+
# histogram
|
|
339
|
+
|
|
340
|
+
def_method "seq"
|
|
341
|
+
if is_float
|
|
342
|
+
def_method "logseq"
|
|
343
|
+
end
|
|
344
|
+
def_method "eye"
|
|
345
|
+
def_alias "indgen", "seq"
|
|
346
|
+
|
|
347
|
+
def_method "rand"
|
|
348
|
+
if is_float && !is_object
|
|
349
|
+
def_method "rand_norm"
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
# y = a[0] + a[1]*x + a[2]*x^2 + a[3]*x^3 + ... + a[n]*x^n
|
|
353
|
+
def_method "poly"
|
|
354
|
+
|
|
355
|
+
if is_comparable && !is_object
|
|
356
|
+
if is_float
|
|
357
|
+
qsort type_name,"dtype","*(dtype*)","_prnan"
|
|
358
|
+
qsort type_name,"dtype","*(dtype*)","_ignan"
|
|
359
|
+
else
|
|
360
|
+
qsort type_name,"dtype","*(dtype*)"
|
|
361
|
+
end
|
|
362
|
+
def_method "sort"
|
|
363
|
+
if is_float
|
|
364
|
+
qsort type_name+"_index","dtype*","**(dtype**)","_prnan"
|
|
365
|
+
qsort type_name+"_index","dtype*","**(dtype**)","_ignan"
|
|
366
|
+
else
|
|
367
|
+
qsort type_name+"_index","dtype*","**(dtype**)"
|
|
368
|
+
end
|
|
369
|
+
def_method "sort_index"
|
|
370
|
+
def_method "median"
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
# Math
|
|
374
|
+
# histogram
|
|
375
|
+
|
|
376
|
+
if has_math
|
|
377
|
+
fn = get(:full_class_name)
|
|
378
|
+
cn = get(:class_name)
|
|
379
|
+
nm = get(:name)
|
|
380
|
+
is_c = is_complex
|
|
381
|
+
|
|
382
|
+
def_module do
|
|
383
|
+
extend NMathMethod
|
|
384
|
+
set ns_var: "cT"
|
|
385
|
+
set class_name: cn
|
|
386
|
+
set name: "#{nm}_math"
|
|
387
|
+
set full_module_name: fn+"::NMath"
|
|
388
|
+
set module_name: "Math"
|
|
389
|
+
set module_var: "mTM"
|
|
390
|
+
|
|
391
|
+
math "sqrt"
|
|
392
|
+
math "cbrt"
|
|
393
|
+
math "log"
|
|
394
|
+
math "log2"
|
|
395
|
+
math "log10"
|
|
396
|
+
math "exp"
|
|
397
|
+
math "exp2"
|
|
398
|
+
math "exp10"
|
|
399
|
+
math "sin"
|
|
400
|
+
math "cos"
|
|
401
|
+
math "tan"
|
|
402
|
+
math "asin"
|
|
403
|
+
math "acos"
|
|
404
|
+
math "atan"
|
|
405
|
+
math "sinh"
|
|
406
|
+
math "cosh"
|
|
407
|
+
math "tanh"
|
|
408
|
+
math "asinh"
|
|
409
|
+
math "acosh"
|
|
410
|
+
math "atanh"
|
|
411
|
+
math "sinc"
|
|
412
|
+
if !is_c
|
|
413
|
+
math "atan2",2
|
|
414
|
+
math "hypot",2
|
|
415
|
+
math "erf"
|
|
416
|
+
math "erfc"
|
|
417
|
+
math "log1p"
|
|
418
|
+
math "expm1"
|
|
419
|
+
math "ldexp",2
|
|
420
|
+
math "frexp",1,"frexp"
|
|
421
|
+
end
|
|
422
|
+
end
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
end # other than Bit
|