Class: FastUnaryOperator
- Inherits:
-
UnaryOperator
- Object
- Operator
- UnaryOperator
- FastUnaryOperator
- Defined in:
- lib/mdarray/fast_operators.rb
Instance Attribute Summary
Attributes inherited from Operator
#arity, #exec_type, #fmap, #force_type, #helper, #name, #other_args, #post_condition, #pre_condition, #type
Instance Method Summary collapse
-
#default(*args) ⇒ Object
—————————————————————————————.
-
#get_args(*args) {|@op.nc_array, @op.shape, @other_args| ... } ⇒ Object
—————————————————————————————.
-
#in_place(*args) ⇒ Object
—————————————————————————————.
-
#reduce(*args) ⇒ Object
—————————————————————————————.
-
#set_block(*args) ⇒ Object
—————————————————————————————.
Methods inherited from UnaryOperator
Methods inherited from Operator
Constructor Details
This class inherits a constructor from UnaryOperator
Instance Method Details
#default(*args) ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/mdarray/fast_operators.rb', line 202 def default(*args) calc = nil get_args(*args) do |op1, shape, *other_args| calc = MDArray.build(@type, shape) helper = @helper::DefaultUnaryOperator helper.send("apply", calc.nc_array, op1, @do_func) end return calc end |
#get_args(*args) {|@op.nc_array, @op.shape, @other_args| ... } ⇒ Object
176 177 178 179 180 181 |
# File 'lib/mdarray/fast_operators.rb', line 176 def get_args(*args) parse_args(*args) yield @op.nc_array, @op.shape, *@other_args end |
#in_place(*args) ⇒ Object
218 219 220 221 222 223 224 225 |
# File 'lib/mdarray/fast_operators.rb', line 218 def in_place(*args) get_args(*args) do |op1, shape, *other_args| helper = @helper::InplaceUnaryOperator helper.send("apply", op1, @do_func) end end |
#reduce(*args) ⇒ Object
231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/mdarray/fast_operators.rb', line 231 def reduce(*args) calc = nil get_args(*args) do |op1, shape, *other_args| helper = @helper::ReduceUnaryOperator calc = @pre_condition_result calc = helper.send("apply", calc, op1, @do_func) end return calc end |
#set_block(*args) ⇒ Object
187 188 189 190 191 192 193 194 195 196 |
# File 'lib/mdarray/fast_operators.rb', line 187 def set_block(*args) get_args(*args) do |op1, shape, *other_args| block = other_args[0] helper = @helper::SetAll func = (shape.size <= 7)? "apply#{shape.size}" : "apply" helper.send(func, op1, &block) if block end end |