Class: Hornetseye::Variable
Overview
Clas for representing variables
Instance Attribute Summary collapse
-
#meta ⇒ Class
readonly
Type information about this variable.
Instance Method Summary collapse
-
#descriptor(hash) ⇒ String
Get unique descriptor of this object.
-
#initialize(meta) ⇒ Variable
constructor
Constructor creating a variable.
-
#inspect ⇒ String
Display string with information about this object.
-
#lookup(value, stride) ⇒ Object
Lookup element of an array.
- #shape ⇒ Object
-
#size ⇒ Node
Get array size for index variable.
-
#size=(value) ⇒ Node
Set array size for index variable.
-
#skip(index, start) ⇒ Node
Skip elements of an array.
-
#strip ⇒ Array<Array,Node>
Strip of all values.
-
#subst(hash) ⇒ Node
Substitute variables.
-
#typecode ⇒ Class
Get type of result of delayed operation.
-
#variables ⇒ Set
Get variables contained in this object.
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?, compilable?, #components, cond, #conditional, #convolve, #decompose, define_binary_op, define_unary_op, #demand, descriptor, #diagonal, #dilate, dimension, #dimension, #downsample, #dup, #each, #empty?, #eq_with_multiarray, #erode, #fill!, finalised?, #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, #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, #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
Methods included from Field_::Match
Methods included from FLOAT_::Match
Methods included from OBJECT::Match
Methods included from COMPLEX_::Match
Methods included from BOOL::Match
Methods included from RGB_::Match
Methods included from INT_::Match
Constructor Details
#initialize(meta) ⇒ Variable
Constructor creating a variable
37 38 39 |
# File 'lib/multiarray/variable.rb', line 37 def initialize( ) @meta = end |
Instance Attribute Details
#meta ⇒ Class (readonly)
Type information about this variable
30 31 32 |
# File 'lib/multiarray/variable.rb', line 30 def @meta end |
Instance Method Details
#descriptor(hash) ⇒ String
Get unique descriptor of this object
58 59 60 61 62 63 64 |
# File 'lib/multiarray/variable.rb', line 58 def descriptor( hash ) if hash[ self ] "Variable#{hash[ self ]}(#{@meta.descriptor( hash )})" else "Variable(#{@meta.descriptor( hash )})" end end |
#inspect ⇒ String
Display string with information about this object
47 48 49 |
# File 'lib/multiarray/variable.rb', line 47 def inspect "Variable(#{@meta.inspect})" end |
#lookup(value, stride) ⇒ Object
Lookup element of an array
153 154 155 |
# File 'lib/multiarray/variable.rb', line 153 def lookup( value, stride ) Lookup.new self, value, stride end |
#shape ⇒ Object
97 98 99 |
# File 'lib/multiarray/variable.rb', line 97 def shape @meta.shape end |
#size ⇒ Node
Get array size for index variable
71 72 73 |
# File 'lib/multiarray/variable.rb', line 71 def size @meta.size end |
#size=(value) ⇒ Node
Set array size for index variable
Set the dimension of the array assuming this is an index variable.
84 85 86 |
# File 'lib/multiarray/variable.rb', line 84 def size=( value ) @meta.size = value end |
#skip(index, start) ⇒ Node
Skip elements of an array
165 166 167 168 169 170 171 |
# File 'lib/multiarray/variable.rb', line 165 def skip( index, start ) if index == self self + start else self end end |
#strip ⇒ Array<Array,Node>
Strip of all values
Split up into variables, values, and a term where all values have been replaced with variables.
values, and the term based on variables.
110 111 112 113 114 115 116 117 |
# File 'lib/multiarray/variable.rb', line 110 def strip , , = @meta.strip if .empty? return [], [], self else return , , Variable.new( ) end end |
#subst(hash) ⇒ Node
Substitute variables
Substitute the variables with the values given in the hash.
128 129 130 131 132 133 134 135 136 |
# File 'lib/multiarray/variable.rb', line 128 def subst( hash ) if hash[ self ] hash[ self ] elsif not @meta.variables.empty? and hash[ @meta.variables.to_a.first ] Variable.new @meta.subst( hash ) else self end end |
#typecode ⇒ Class
Get type of result of delayed operation
93 94 95 |
# File 'lib/multiarray/variable.rb', line 93 def typecode @meta.typecode end |
#variables ⇒ Set
Get variables contained in this object
143 144 145 |
# File 'lib/multiarray/variable.rb', line 143 def variables Set[ self ] end |