Class: RubyBinaryOperator
- Inherits:
-
BinaryOperator
- Object
- Operator
- BinaryOperator
- RubyBinaryOperator
- Defined in:
- lib/mdarray/ruby_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
—————————————————————————————.
-
#fill(*args) ⇒ Object
—————————————————————————————.
-
#in_place(*args) ⇒ Object
—————————————————————————————.
-
#reduce(*args) ⇒ Object
(also: #complex_reduce)
—————————————————————————————.
Methods inherited from BinaryOperator
Methods inherited from Operator
Constructor Details
This class inherits a constructor from BinaryOperator
Instance Method Details
#default(*args) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mdarray/ruby_operators.rb', line 32 def default(*args) get_args(*args) do |op1_iterator, op2_iterator, shape, *other_args| result = MDArray.build(@type, shape) res_iterator = result.get_iterator_fast if (@coerced) while (res_iterator.has_next?) res_iterator.set_next(@do_func.call(op2_iterator.get_next, op1_iterator.get_next)) end else while (res_iterator.has_next?) res_iterator.set_next(@do_func.call(op1_iterator.get_next, op2_iterator.get_next)) end end return result end end |
#fill(*args) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/mdarray/ruby_operators.rb', line 58 def fill(*args) get_args(*args) do |op1_iterator, op2_iterator, shape, *other_args| while (op1_iterator.has_next?) op1_iterator.set_next(op2_iterator.get_next) end return self end end |
#in_place(*args) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/mdarray/ruby_operators.rb', line 73 def in_place(*args) get_args(*args) do |op1_iterator, op2_iterator, shape, *other_args| while (op1_iterator.has_next?) op1_iterator.set_current(@do_func.call(op1_iterator.get_next, op2_iterator.get_next)) end return self end end |
#reduce(*args) ⇒ Object Also known as: complex_reduce
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/mdarray/ruby_operators.rb', line 89 def reduce(*args) get_args(*args) do |op1_iterator, op2_iterator, shape, *other_args| result = @pre_condition_result while (op1_iterator.has_next?) result = @do_func.call(result, op1_iterator.get_next, op2_iterator.get_next) end return result end end |