Module: FunctionCreation

Instance Method Summary collapse

Instance Method Details

#make_binary_op(name, exec_type, func, helper_class, force_type = nil, pre_condition = nil, post_condition = nil) ⇒ Object





32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/mdarray/function_creation.rb', line 32

def make_binary_op(name, exec_type, func, helper_class, force_type = nil, 
                   pre_condition = nil, post_condition = nil)

  define_method(name) do |op2, requested_type = nil, *args|
    if (@type == "lazy" || ((op2.is_a? MDArray) && op2.type == "lazy"))
      binary_op = LazyBinaryOperator
    else
      binary_op = get_binary_op
    end
    op = binary_op.new(name, exec_type, force_type, pre_condition, post_condition)
    op.exec(self, op2, requested_type, *args)
  end

  MDArray.register_function(name, func, 2, helper_class)

end

#make_unary_op(name, exec_type, func, helper_class, force_type = nil, pre_condition = nil, post_condition = nil) ⇒ Object





53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/mdarray/function_creation.rb', line 53

def make_unary_op(name, exec_type, func, helper_class, force_type = nil, 
                  pre_condition = nil, post_condition = nil)
  
  define_method(name) do |requested_type = nil, *args|
    unary_op = get_unary_op
    op = unary_op.new(name, exec_type, force_type, pre_condition, post_condition)
    op.exec(self, requested_type, *args)
  end

  MDArray.register_function(name, func, 1, helper_class)

end