Class: RubyUnaryOperator
- Inherits:
-
UnaryOperator
- Object
- Operator
- UnaryOperator
- RubyUnaryOperator
- 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
—————————————————————————————.
-
#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
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/mdarray/ruby_operators.rb', line 115 def default(*args) get_args(*args) do |op_iterator, shape, *other_args| result = MDArray.build(@type, shape) res_iterator = result.get_iterator_fast while (res_iterator.has_next?) res_iterator.set_next(@do_func.call(op_iterator.get_next)) end return result end end |
#in_place(*args) ⇒ Object
152 153 154 155 156 157 158 159 160 161 |
# File 'lib/mdarray/ruby_operators.rb', line 152 def in_place(*args) get_args(*args) do |op_iterator, *other_args| while (op_iterator.has_next?) op_iterator.set_current(@do_func.call(op_iterator.get_next)) end return self end end |
#reduce(*args) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/mdarray/ruby_operators.rb', line 167 def reduce(*args) get_args(*args) do |op_iterator, shape, *other_args| result = @pre_condition_result while (op_iterator.has_next?) result = @do_func.call(result, op_iterator.get_next) end return result end end |
#set_block(*args) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/mdarray/ruby_operators.rb', line 132 def set_block(*args) get_args(*args) do |op_iterator, shape, *other_args| block = other_args[0] while (op_iterator.has_next?) op_iterator.next if (shape.size < 8) op_iterator.set_current(block.call(*op_iterator.get_current_counter)) else op_iterator.set_current(block.call(op_iterator.get_current_counter)) end end if block end end |