Module: DefMethod
- Included in:
- DataType
- Defined in:
- lib/erbpp/narray_def.rb
Instance Method Summary collapse
- #accum(meth, dtype, tpclass) ⇒ Object
- #accum_binary(meth, ope = nil) ⇒ Object
- #accum_index(meth) ⇒ Object
- #binary(meth, ope = nil) ⇒ Object
- #binary2(meth, ope = nil) ⇒ Object
- #bit_count(meth) ⇒ Object
- #bit_reduce(meth, init_bit) ⇒ Object
- #cast_array ⇒ Object
- #cast_func ⇒ Object
- #cond_binary(meth, op = nil) ⇒ Object
- #cond_unary(meth) ⇒ Object
- #cum(meth, cmacro) ⇒ Object
- #def_alias(dst, src) ⇒ Object
- #def_allocate(tmpl) ⇒ Object
- #def_id(meth, var = nil) ⇒ Object
- #def_method(meth, n_arg, tmpl = nil, opts = {}) ⇒ Object
- #def_singleton(meth, n_arg, tmpl = nil, opts = {}) ⇒ Object
- #find_method(meth) ⇒ Object
- #find_tmpl(meth) ⇒ Object
- #math(meth, n = 1) ⇒ Object
- #pow ⇒ Object
- #qsort(tp, dtype, dcast) ⇒ Object
- #set2(meth, dtype, tpclass) ⇒ Object
- #store ⇒ Object
- #store_array ⇒ Object
- #store_bit(cname) ⇒ Object
- #store_from(cname, dtype, macro) ⇒ Object
- #store_numeric ⇒ Object
- #unary(meth, ope = nil) ⇒ Object
- #unary2(meth, dtype, tpclass) ⇒ Object
Instance Method Details
#accum(meth, dtype, tpclass) ⇒ Object
74 75 76 77 |
# File 'lib/erbpp/narray_def.rb', line 74 def accum(meth, dtype, tpclass) h = {:dtype => dtype, :tpclass => tpclass} def_method(meth, -1, "accum", h) end |
#accum_binary(meth, ope = nil) ⇒ Object
87 88 89 90 |
# File 'lib/erbpp/narray_def.rb', line 87 def accum_binary(meth, ope=nil) ope = meth if ope.nil? def_method(meth, -1, "accum_binary", :op => ope) end |
#accum_index(meth) ⇒ Object
79 80 81 |
# File 'lib/erbpp/narray_def.rb', line 79 def accum_index(meth) def_method(meth, -1, "accum_index") end |
#binary(meth, ope = nil) ⇒ Object
29 30 31 32 |
# File 'lib/erbpp/narray_def.rb', line 29 def binary(meth, ope=nil) ope = meth if ope.nil? def_method(meth, 1, "binary", :op => ope) end |
#binary2(meth, ope = nil) ⇒ Object
34 35 36 37 |
# File 'lib/erbpp/narray_def.rb', line 34 def binary2(meth, ope=nil) ope = meth if ope.nil? def_method(meth, 1, "binary2", :op =>ope) end |
#bit_count(meth) ⇒ Object
65 66 67 |
# File 'lib/erbpp/narray_def.rb', line 65 def bit_count(meth) def_method(meth, -1, "bit_count") end |
#bit_reduce(meth, init_bit) ⇒ Object
69 70 71 72 |
# File 'lib/erbpp/narray_def.rb', line 69 def bit_reduce(meth, init_bit) h = {:init_bit=>init_bit} def_method(meth, -1, "bit_reduce", h) end |
#cast_array ⇒ Object
119 120 121 |
# File 'lib/erbpp/narray_def.rb', line 119 def cast_array CastArray.new(self,"cast_array") end |
#cast_func ⇒ Object
143 144 145 |
# File 'lib/erbpp/narray_def.rb', line 143 def cast_func "numo_#{tp}_s_cast" end |
#cond_binary(meth, op = nil) ⇒ Object
57 58 59 |
# File 'lib/erbpp/narray_def.rb', line 57 def cond_binary(meth,op=nil) def_method(meth, 1, "cond_binary", :op => op) end |
#cond_unary(meth) ⇒ Object
61 62 63 |
# File 'lib/erbpp/narray_def.rb', line 61 def cond_unary(meth) def_method(meth, 0, "cond_unary") end |
#cum(meth, cmacro) ⇒ Object
83 84 85 |
# File 'lib/erbpp/narray_def.rb', line 83 def cum(meth, cmacro) def_method(meth, -1, "cum", cmacro:cmacro) end |
#def_alias(dst, src) ⇒ Object
20 21 22 |
# File 'lib/erbpp/narray_def.rb', line 20 def def_alias(dst, src) Alias.new(self, dst, src) end |
#def_allocate(tmpl) ⇒ Object
24 25 26 27 |
# File 'lib/erbpp/narray_def.rb', line 24 def def_allocate(tmpl) h = {:meth => "allocate", :singleton => true} Allocate.new(self, tmpl, h) end |
#def_id(meth, var = nil) ⇒ Object
5 6 7 |
# File 'lib/erbpp/narray_def.rb', line 5 def def_id(meth,var=nil) IdVar.new(self, meth, var) end |
#def_method(meth, n_arg, tmpl = nil, opts = {}) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/erbpp/narray_def.rb', line 9 def def_method(meth, n_arg, tmpl=nil, opts={}) h = {:meth => meth, :n_arg => n_arg} h.merge!(opts) tmpl ||= meth Function.new(self, tmpl, h) end |
#def_singleton(meth, n_arg, tmpl = nil, opts = {}) ⇒ Object
16 17 18 |
# File 'lib/erbpp/narray_def.rb', line 16 def def_singleton(meth, n_arg, tmpl=nil, opts={}) def_method(meth, n_arg, tmpl, :singleton => true) end |
#find_method(meth) ⇒ Object
135 136 137 |
# File 'lib/erbpp/narray_def.rb', line 135 def find_method(meth) Function::DEFS.find{|x| x.kind_of?(Function) and meth == x.meth } end |
#find_tmpl(meth) ⇒ Object
139 140 141 |
# File 'lib/erbpp/narray_def.rb', line 139 def find_tmpl(meth) Function::DEFS.find{|x| x.kind_of?(Function) and meth == x.tmpl } end |
#math(meth, n = 1) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/erbpp/narray_def.rb', line 97 def math(meth, n=1) h = {:meth => meth, :mod_var => 'mTM', :n_arg => n} case n when 1 ModuleFunction.new(self, "unary_s", h) when 2 ModuleFunction.new(self, "binary_s", h) when 3 ModuleFunction.new(self, "ternary_s", h) else raise "invalid n=#{n}" end end |
#pow ⇒ Object
43 44 45 |
# File 'lib/erbpp/narray_def.rb', line 43 def pow def_method("pow", 1, "pow", :op => "**") end |
#qsort(tp, dtype, dcast) ⇒ Object
92 93 94 95 |
# File 'lib/erbpp/narray_def.rb', line 92 def qsort(tp, dtype, dcast) h = {:tp => tp, :dtype => dtype, :dcast => dcast} NodefFunction.new(self, "qsort", h) end |
#set2(meth, dtype, tpclass) ⇒ Object
52 53 54 55 |
# File 'lib/erbpp/narray_def.rb', line 52 def set2(meth, dtype, tpclass) h = {:dtype => dtype, :tpclass => tpclass} def_method(meth, 1, "set2", h) end |
#store ⇒ Object
131 132 133 |
# File 'lib/erbpp/narray_def.rb', line 131 def store Function.new(self,"store","store") end |
#store_array ⇒ Object
115 116 117 |
# File 'lib/erbpp/narray_def.rb', line 115 def store_array StoreArray.new(self,"store_array") end |
#store_bit(cname) ⇒ Object
127 128 129 |
# File 'lib/erbpp/narray_def.rb', line 127 def store_bit(cname) Store.new(self,"store_bit",cname.downcase,nil,"numo_c"+cname,nil) end |
#store_from(cname, dtype, macro) ⇒ Object
123 124 125 |
# File 'lib/erbpp/narray_def.rb', line 123 def store_from(cname,dtype,macro) Store.new(self,"store_from",cname.downcase,dtype,"numo_c"+cname,macro) end |
#store_numeric ⇒ Object
111 112 113 |
# File 'lib/erbpp/narray_def.rb', line 111 def store_numeric StoreNum.new(self,"store_numeric") end |
#unary(meth, ope = nil) ⇒ Object
39 40 41 |
# File 'lib/erbpp/narray_def.rb', line 39 def unary(meth, ope=nil) def_method(meth, 0, "unary", :op => ope) end |
#unary2(meth, dtype, tpclass) ⇒ Object
47 48 49 50 |
# File 'lib/erbpp/narray_def.rb', line 47 def unary2(meth, dtype, tpclass) h = {:dtype => dtype, :tpclass => tpclass} def_method(meth, 0, "unary2", h) end |