Class: LazyUnaryOperator

Inherits:
UnaryOperator show all
Defined in:
lib/mdarray/lazy_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

#complex_reduce(*args) ⇒ Object





170
171
172
# File 'lib/mdarray/lazy_operators.rb', line 170

def complex_reduce(*args)
  raise "Cannot reduce array in lazy operation"
end

#default(*args) ⇒ Object


A default unary operator takes one arrays and loops through all elements of the array applying a given method to it. For instance, operator ‘log’ in a.log is a default unary operator.




133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/mdarray/lazy_operators.rb', line 133

def default(*args)

  get_args(*args)
  lazy = @op

  if (@op.is_a? LazyMDArray)
    lazy.push(self)
  else
    lazy = LazyMDArray.new
    lazy.push(@op)
    lazy.push(self)
  end

  return lazy

end

#get_args(*args) ⇒ Object





120
121
122
123
124
125
# File 'lib/mdarray/lazy_operators.rb', line 120

def get_args(*args)

  @op = args.shift
  @other_args = args

end

#in_place(*args) ⇒ Object





154
155
156
# File 'lib/mdarray/lazy_operators.rb', line 154

def in_place(*args)
  raise "Cannot operate in_place lazyly"
end

#reduce(*args) ⇒ Object





162
163
164
# File 'lib/mdarray/lazy_operators.rb', line 162

def reduce(*args)
  raise "Cannot reduce array in lazy operation"
end