Module: FunctionCreation
- Included in:
- BitwiseOperators, BooleanFunctions, CernDoubleFunctions, CernFloatFunctions, CernIntFunctions, CernLongFunctions, ComparisonOperators, GenericFunctions, NumericFunctions, RubyMath, RubyStats
- Defined in:
- lib/mdarray/function_creation.rb
Instance Method Summary collapse
-
#make_binary_op(name, exec_type, func, helper_class, force_type = nil, pre_condition = nil, post_condition = nil) ⇒ Object
———————————————————————————— name is the name of the function being created exec_type is the execution type.
-
#make_unary_op(name, exec_type, func, helper_class, force_type = nil, pre_condition = nil, post_condition = nil) ⇒ Object
————————————————————————————.
Instance Method Details
#make_binary_op(name, exec_type, func, helper_class, force_type = nil, pre_condition = nil, post_condition = nil) ⇒ Object
name is the name of the function being created exec_type is the execution type. The following execution types are defined default in_place, fill and reduce
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/mdarray/function_creation.rb', line 34 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
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/mdarray/function_creation.rb', line 55 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 |