Class: FastUnaryOperator

Inherits:
UnaryOperator show all
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

Methods inherited from UnaryOperator

#initialize

Methods inherited from Operator

#exec, #initialize

Constructor Details

This class inherits a constructor from UnaryOperator

Instance Method Details

#default(*args) ⇒ Object





199
200
201
202
203
204
205
206
207
208
209
# File 'lib/mdarray/fast_operators.rb', line 199

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



Yields:



173
174
175
176
177
178
# File 'lib/mdarray/fast_operators.rb', line 173

def get_args(*args)

  parse_args(*args)
  yield @op.nc_array, @op.shape, *@other_args

end

#in_place(*args) ⇒ Object





215
216
217
218
219
220
221
222
# File 'lib/mdarray/fast_operators.rb', line 215

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





228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/mdarray/fast_operators.rb', line 228

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





184
185
186
187
188
189
190
191
192
193
# File 'lib/mdarray/fast_operators.rb', line 184

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