Class: Hornetseye::Argument
- Inherits:
-
Node
show all
- Defined in:
- lib/multiarray/argument.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Node
#+@, #<=>, ===, #[], #[]=, #allocate, #b=, #b_with_decompose, basetype, #basetype, #between?, bool, byte, #check_shape, #clip, #coerce, coercion_bool, coercion_byte, coercion_maxint, #collect, compilable?, #components, cond, #conditional, #convolve, #decompose, define_binary_op, define_unary_op, descriptor, #diagonal, #dilate, #dimension, dimension, #downsample, #dup, #each, #empty?, #eq_with_multiarray, #erode, #fill!, #finalised?, #flip, float, float_scalar, floating, #fmod_with_float, #force, #g=, #g_with_decompose, #gauss_blur, #gauss_gradient, #get, #height, #histogram, #histogram_with_rgb, identity, #if, #if_else, #imag=, #imag_with_decompose, indgen, #inject, #inspect, #integral, #lut, #lut_with_rgb, #malloc, #mask, match, #matched?, #max, maxint, #mean, #memorise, #memory, #min, #normalise, #prod, #r=, #r_with_decompose, #range, #real=, #real_with_decompose, #reshape, #rgb?, rgb?, #roll, scalar, shape, #shift, #simplify, #size, #sobel, #stretch, #stride, #strides, strip, subst, #sum, #swap_rgb_with_scalar, #table, #to_a, #to_s, to_s, #to_type, to_type, #to_type_with_identity, #to_type_with_rgb, #transpose, typecode, typecodes, #unmask, #unroll, variables, #warp, #width
#align, #fit
#align, #fit
#align, #fit
#align, #fit
#fit
#align, #fit
#fit
Constructor Details
#initialize(value, index, block, var1, var2, zero) ⇒ Argument
Returns a new instance of Argument.
30
31
32
|
# File 'lib/multiarray/argument.rb', line 30
def initialize(value, index, block, var1, var2, zero)
@value, @index, @block, @var1, @var2, @zero = value, index, block, var1, var2, zero
end
|
Class Method Details
.finalised? ⇒ Boolean
24
25
26
|
# File 'lib/multiarray/argument.rb', line 24
def finalised?
false
end
|
Instance Method Details
#compilable? ⇒ Boolean
88
89
90
|
# File 'lib/multiarray/argument.rb', line 88
def compilable?
@value.compilable? and @block.compilable? and @zero.compilable?
end
|
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/multiarray/argument.rb', line 50
def demand
initial = @value.subst(@index => INT.new(0)).simplify
retval = @zero.simplify
INT.new(0).upto @index.size - 1 do |i|
sub = @value.subst @index => INT.new(i)
cond = @block.subst @var1 => sub, @var2 => initial
retval.assign cond.conditional(INT.new(i), retval)
initial.assign cond.conditional(sub, initial)
end
retval
end
|
#descriptor(hash) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/multiarray/argument.rb', line 34
def descriptor(hash)
hash = hash.merge @index => ((hash.values.max || 0) + 1)
hash = hash.merge @var1 => ((hash.values.max || 0) + 1)
hash = hash.merge @var2 => ((hash.values.max || 0) + 1)
"Argument(#{@value.descriptor(hash)},#{@index.descriptor(hash)}," +
"#{@block.descriptor(hash)},#{@zero.descriptor(hash)})"
end
|
#element(i) ⇒ Object
62
63
64
|
# File 'lib/multiarray/argument.rb', line 62
def element(i)
self.class.new @value.element(i), @index, @block, @var1, @var2, @zero
end
|
46
47
48
|
# File 'lib/multiarray/argument.rb', line 46
def shape
@value.shape
end
|
70
71
72
73
74
75
76
77
78
|
# File 'lib/multiarray/argument.rb', line 70
def strip
meta_vars, meta_values, var = @index.strip
vars, values, term = @value.subst(@index => var).strip
block_vars, block_values, block_term = @block.strip
zero_vars, zero_values, zero_term = @zero.strip
return vars + meta_vars + block_vars + zero_vars,
values + meta_values + block_values + zero_values,
self.class.new(term, var, block_term, @var1, @var2, zero_term)
end
|
#subst(hash) ⇒ Object
80
81
82
83
84
85
86
|
# File 'lib/multiarray/argument.rb', line 80
def subst(hash)
subst_var = @index.subst hash
value = @value.subst(@index => subst_var).subst hash
block = @block.subst hash
zero = @zero.subst hash
self.class.new value, subst_var, block, @var1, @var2, zero
end
|
42
43
44
|
# File 'lib/multiarray/argument.rb', line 42
def typecode
INT
end
|
#variables ⇒ Object
66
67
68
|
# File 'lib/multiarray/argument.rb', line 66
def variables
@value.variables + @zero.variables - @index.variables
end
|