Class: Hornetseye::Variable
Instance Attribute Summary collapse
-
#meta ⇒ Class
readonly
Type information about this variable.
Instance Method Summary collapse
-
#array_type ⇒ Class
Get type of result of delayed operation.
-
#descriptor(hash) ⇒ String
Get unique descriptor of this object.
-
#initialize(meta) ⇒ Variable
constructor
A new instance of Variable.
-
#inspect ⇒ String
Display string with information about this object.
-
#lookup(value, stride) ⇒ Object
Lookup element of an array.
-
#size ⇒ Node
Get array size for index variable.
-
#size=(value) ⇒ Object
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.
-
#variables ⇒ Set
Get variables contained in this object.
Methods inherited from Node
===, #[], #[]=, array_type, basetype, #basetype, bool, byte, #check_shape, #coerce, coercion_bool, coercion_byte, coercion_maxint, compilable?, #compilable?, cond, contiguous, #decompose, #demand, descriptor, dimension, #dimension, #dup, empty?, #empty?, #finalised?, finalised?, float, float_scalar, floating, #force, #get, height, #height, indgen, match, maxint, #memory, pointer_type, #pointer_type, #rgb?, rgb?, scalar, #shape, shape, #simplify, size, #storage_size, strip, subst, #to_a, #to_s, to_s, to_type, #typecode, typecode, typecodes, variables, #width, width
Methods included from FLOAT_::Match
Methods included from OBJECT::Match
Methods included from COMPLEX_::Match
Methods included from Sequence_::Match
Methods included from BOOL::Match
Methods included from RGB_::Match
Methods included from INT_::Match
Methods included from Operations
#+@, #<=>, #b=, #b_with_decompose, #collect, #conditional, #convolve, define_binary_op, define_unary_op, #diagonal, #eq_with_multiarray, #fill!, #g=, #g_with_decompose, #histogram, #imag=, #imag_with_decompose, #inject, #integral, #lut, #max, #min, #normalise, #product, #r=, #r_with_decompose, #range, #real=, #real_with_decompose, #roll, #sum, #to_type, #to_type_with_rgb, #transpose, #unroll
Constructor Details
#initialize(meta) ⇒ Variable
Returns a new instance of Variable.
27 28 29 |
# File 'lib/multiarray/variable.rb', line 27 def initialize( ) @meta = end |
Instance Attribute Details
#meta ⇒ Class (readonly)
Type information about this variable
25 26 27 |
# File 'lib/multiarray/variable.rb', line 25 def @meta end |
Instance Method Details
#array_type ⇒ Class
Get type of result of delayed operation
75 76 77 |
# File 'lib/multiarray/variable.rb', line 75 def array_type @meta.array_type end |
#descriptor(hash) ⇒ String
Get unique descriptor of this object
46 47 48 49 50 51 52 |
# File 'lib/multiarray/variable.rb', line 46 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
35 36 37 |
# File 'lib/multiarray/variable.rb', line 35 def inspect "Variable(#{@meta.inspect})" end |
#lookup(value, stride) ⇒ Object
Lookup element of an array
131 132 133 |
# File 'lib/multiarray/variable.rb', line 131 def lookup( value, stride ) Lookup.new self, value, stride end |
#size ⇒ Node
Get array size for index variable
57 58 59 |
# File 'lib/multiarray/variable.rb', line 57 def size @meta.size end |
#size=(value) ⇒ Object
Set array size for index variable
Set the dimension of the array assuming this is an index variable.
66 67 68 |
# File 'lib/multiarray/variable.rb', line 66 def size=( value ) @meta.size = value end |
#skip(index, start) ⇒ Node
Skip elements of an array
143 144 145 146 147 148 149 |
# File 'lib/multiarray/variable.rb', line 143 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.
88 89 90 91 92 93 94 95 |
# File 'lib/multiarray/variable.rb', line 88 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.
106 107 108 109 110 111 112 113 114 |
# File 'lib/multiarray/variable.rb', line 106 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 |
#variables ⇒ Set
Get variables contained in this object
121 122 123 |
# File 'lib/multiarray/variable.rb', line 121 def variables Set[ self ] end |