Class: Hornetseye::Argument
- Inherits:
-
Node
show all
- Defined in:
- docs/multiarray/lib/multiarray/argument.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Node
#<=>, ===, #[], #[]=, #allocate, #b=, #b_with_decompose, #basetype, #between?, bool, #check_shape, #clip, coercion_bool, coercion_byte, coercion_maxint, #collect, #components, cond, #conditional, #convolve, #decompose, #dilate, dimension, #dimension, #downsample, #dup, #each, #empty?, #eq_with_multiarray, #erode, #fill!, #flip, float_scalar, floating, #fmod_with_float, #g=, #g_with_decompose, #gauss_blur, #gauss_gradient, #height, #histogram, #histogram_with_rgb, #if, #if_else, #imag=, #imag_with_decompose, indgen, #inject, #inspect, #integral, #lut, #lut_with_rgb, #mask, #matched?, #max, #mean, #memorise, #memory, #min, #normalise, #orig_to_cvmat, #orig_to_type_with_frame, #prod, #r=, #r_with_decompose, #range, #real=, #real_with_decompose, #reshape, rgb?, #rgb?, #roll, #save_dfloat, #save_dfloatrgb, #save_magick, #save_openexr, #save_sfloat, #save_sfloatrgb, #save_ubyte, #save_ubytergb, #save_uint, #save_uintrgb, #save_usint, #save_usintrgb, scalar, shape, #shift, #show, #size, #sobel, #stretch, #sum, #swap_rgb_with_scalar, #to_a, #to_cvmat, #to_magick, #to_narray, to_type, #to_type, #to_type_with_frame, #to_type_with_identity, #to_type_with_rgb, #transpose, typecode, #unmask, #unroll, #warp, #width
Constructor Details
#initialize(value, index, block, var1, var2, zero) ⇒ Argument
Returns a new instance of Argument.
30
31
32
|
# File 'docs/multiarray/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 'docs/multiarray/lib/multiarray/argument.rb', line 24
def finalised?
false
end
|
Instance Method Details
#compilable? ⇒ Boolean
88
89
90
|
# File 'docs/multiarray/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 'docs/multiarray/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 'docs/multiarray/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 'docs/multiarray/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 'docs/multiarray/lib/multiarray/argument.rb', line 46
def shape
@value.shape
end
|
70
71
72
73
74
75
76
77
78
|
# File 'docs/multiarray/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 'docs/multiarray/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 'docs/multiarray/lib/multiarray/argument.rb', line 42
def typecode
INT
end
|
#variables ⇒ Object
66
67
68
|
# File 'docs/multiarray/lib/multiarray/argument.rb', line 66
def variables
@value.variables + @zero.variables - @index.variables
end
|