Module: Ikra::Symbolic::ParallelOperations

Included in:
Array, ArrayCommand
Defined in:
lib/symbolic/symbolic.rb

Instance Method Summary collapse

Instance Method Details

#&(other) ⇒ Object



106
107
108
109
110
# File 'lib/symbolic/symbolic.rb', line 106

def &(other)
    return pcombine(other) do |a, b|
        a & b
    end
end

#*(other) ⇒ Object



88
89
90
91
92
# File 'lib/symbolic/symbolic.rb', line 88

def *(other)
    return pcombine(other) do |a, b|
        a * b
    end
end

#+(other) ⇒ Object



76
77
78
79
80
# File 'lib/symbolic/symbolic.rb', line 76

def +(other)
    return pcombine(other) do |a, b|
        a + b
    end
end

#-(other) ⇒ Object



82
83
84
85
86
# File 'lib/symbolic/symbolic.rb', line 82

def -(other)
    return pcombine(other) do |a, b|
        a - b
    end
end

#/(other) ⇒ Object



94
95
96
97
98
# File 'lib/symbolic/symbolic.rb', line 94

def /(other)
    return pcombine(other) do |a, b|
        a / b
    end
end

#<(other) ⇒ Object



118
119
120
121
122
# File 'lib/symbolic/symbolic.rb', line 118

def <(other)
    return pcombine(other) do |a, b|
        a < b
    end
end

#<=(other) ⇒ Object



124
125
126
127
128
# File 'lib/symbolic/symbolic.rb', line 124

def <=(other)
    return pcombine(other) do |a, b|
        a <= b
    end
end

#>(other) ⇒ Object



130
131
132
133
134
# File 'lib/symbolic/symbolic.rb', line 130

def >(other)
    return pcombine(other) do |a, b|
        a > b
    end
end

#>=(other) ⇒ Object



136
137
138
139
140
# File 'lib/symbolic/symbolic.rb', line 136

def >=(other)
    return pcombine(other) do |a, b|
        a >= b
    end
end

#^(other) ⇒ Object



112
113
114
115
116
# File 'lib/symbolic/symbolic.rb', line 112

def ^(other)
    return pcombine(other) do |a, b|
        a ^ b
    end
end

#pcombine(*others, **options, &block) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/symbolic/symbolic.rb', line 61

def pcombine(*others, **options, &block)
    return ArrayCombineCommand.new(
        to_command, 
        wrap_in_command(*others), 
        block, 
        **options)
end

#pmap(**options, &block) ⇒ Object



55
56
57
58
59
# File 'lib/symbolic/symbolic.rb', line 55

def pmap(**options, &block)
    return pcombine(
        **options,
        &block)
end

#preduce(symbol = nil, **options, &block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/symbolic/symbolic.rb', line 20

def preduce(symbol = nil, **options, &block)
    if symbol == nil && (block != nil || options[:ast] != nil)
        return ArrayReduceCommand.new(
            to_command, 
            block, 
            **options)
    elsif symbol != nil && block == nil
        ast = AST::BlockDefNode.new(
            ruby_block: nil,
            parameters: [:a, :b],
            body: AST::RootNode.new(single_child:
                AST::SendNode.new(
                    receiver: AST::LVarReadNode.new(identifier: :a),
                    selector: symbol,
                    arguments: [AST::LVarReadNode.new(identifier: :b)])))

        return ArrayReduceCommand.new(
            to_command,
            nil,
            ast: ast,
            **options)
    else
        raise ArgumentError.new("Either block or symbol expected")
    end
end

#pstencil(offsets, out_of_range_value, **options, &block) ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/symbolic/symbolic.rb', line 46

def pstencil(offsets, out_of_range_value, **options, &block)
    return ArrayStencilCommand.new(
        to_command, 
        offsets, 
        out_of_range_value, 
        block, 
        **options)
end

#pzip(*others, **options) ⇒ Object



69
70
71
72
73
74
# File 'lib/symbolic/symbolic.rb', line 69

def pzip(*others, **options)
    return ArrayZipCommand.new(
        to_command, 
        wrap_in_command(*others),
        **options)
end

#|(other) ⇒ Object



100
101
102
103
104
# File 'lib/symbolic/symbolic.rb', line 100

def |(other)
    return pcombine(other) do |a, b|
        a | b
    end
end