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.
- #sexp? ⇒ Boolean
- #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, #memorise, #memory, #min, #normalise, #r=, #r_with_decompose, #range, #real=, #real_with_decompose, #reshape, #rgb?, rgb?, #roll, scalar, shape, #shift, #simplify, #sobel, #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
62 63 64 65 66 67 68 |
# File 'lib/multiarray/variable.rb', line 62 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
51 52 53 |
# File 'lib/multiarray/variable.rb', line 51 def inspect "Variable(#{@meta.inspect})" end |
#lookup(value, stride) ⇒ Object
Lookup element of an array
157 158 159 |
# File 'lib/multiarray/variable.rb', line 157 def lookup( value, stride ) Lookup.new self, value, stride end |
#sexp? ⇒ Boolean
41 42 43 |
# File 'lib/multiarray/variable.rb', line 41 def sexp? true end |
#shape ⇒ Object
101 102 103 |
# File 'lib/multiarray/variable.rb', line 101 def shape @meta.shape end |
#size ⇒ Node
Get array size for index variable
75 76 77 |
# File 'lib/multiarray/variable.rb', line 75 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.
88 89 90 |
# File 'lib/multiarray/variable.rb', line 88 def size=( value ) @meta.size = value end |
#skip(index, start) ⇒ Node
Skip elements of an array
169 170 171 172 173 174 175 |
# File 'lib/multiarray/variable.rb', line 169 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.
114 115 116 117 118 119 120 121 |
# File 'lib/multiarray/variable.rb', line 114 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.
132 133 134 135 136 137 138 139 140 |
# File 'lib/multiarray/variable.rb', line 132 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
97 98 99 |
# File 'lib/multiarray/variable.rb', line 97 def typecode @meta.typecode end |
#variables ⇒ Set
Get variables contained in this object
147 148 149 |
# File 'lib/multiarray/variable.rb', line 147 def variables Set[ self ] end |