Class: Hornetseye::Pointer_
Overview
Class for representing native pointer types
Class Attribute Summary collapse
-
.target ⇒ Node
Target type of pointer.
Class Method Summary collapse
-
.==(other) ⇒ Boolean
Test equality of classes.
-
.basetype ⇒ Class
Base type of this data type.
-
.construct(*args) ⇒ Element
Construct new object from arguments.
-
.default ⇒ Memory, List
Get default value for elements of this type.
-
.descriptor(hash) ⇒ String
Get unique descriptor of this class.
-
.eql? ⇒ Boolean
Equality for hash operations.
-
.finalised? ⇒ Boolean
Check whether objects of this class are finalised computations.
-
.hash ⇒ Fixnum
Compute hash value for this class.
-
.inspect ⇒ String
Display string with information about this class.
-
.typecode ⇒ Class
Get element type.
Instance Method Summary collapse
-
#assign(value) ⇒ Object
Store a value in this native element.
-
#decompose(i) ⇒ Node
Decompose composite elements.
-
#demand ⇒ Node, Object
Reevaluate computation.
-
#descriptor(hash) ⇒ String
Get unique descriptor of this object.
-
#initialize(value = self.class.default) ⇒ Pointer_
constructor
Constructor for pointer object.
-
#lookup(value, stride) ⇒ Object
Lookup element of an array.
-
#memory ⇒ Malloc, List
Get access to storage object.
- #sexp? ⇒ Boolean
-
#skip(index, start) ⇒ Node
Skip elements of an array.
-
#store(value) ⇒ Object
Store new value in this pointer.
-
#strides ⇒ Array<Integer>, NilClass
Get strides of array.
-
#strip ⇒ Array<Array,Node>
Strip of all values.
-
#values ⇒ Array<Object>
Get array with components of this value.
Methods inherited from Node
#+@, #<=>, ===, #[], #[]=, #allocate, #b=, #b_with_decompose, #basetype, #between?, bool, byte, #check_shape, #clip, #coerce, coercion_bool, coercion_byte, coercion_maxint, #collect, #compilable?, compilable?, #components, cond, #conditional, #convolve, define_binary_op, define_unary_op, #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, #memorise, #min, #normalise, #r=, #r_with_decompose, #range, #real=, #real_with_decompose, #reshape, #rgb?, rgb?, #roll, scalar, #shape, shape, #shift, #simplify, #size, #sobel, #stride, strip, #subst, 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, 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(value = self.class.default) ⇒ Pointer_
Constructor for pointer object
126 127 128 |
# File 'lib/multiarray/pointer.rb', line 126 def initialize( value = self.class.default ) @value = value end |
Class Attribute Details
.target ⇒ Node
Target type of pointer
28 29 30 |
# File 'lib/multiarray/pointer.rb', line 28 def target @target end |
Class Method Details
.==(other) ⇒ Boolean
Test equality of classes
71 72 73 74 |
# File 'lib/multiarray/pointer.rb', line 71 def ==( other ) other.is_a? Class and other < Pointer_ and target == other.target end |
.basetype ⇒ Class
Base type of this data type
108 109 110 |
# File 'lib/multiarray/pointer.rb', line 108 def basetype target.basetype end |
.construct(*args) ⇒ Element
Construct new object from arguments
37 38 39 |
# File 'lib/multiarray/pointer.rb', line 37 def construct( *args ) new *args end |
.default ⇒ Memory, List
Get default value for elements of this type
62 63 64 |
# File 'lib/multiarray/pointer.rb', line 62 def default target.memory_type.new target.storage_size end |
.descriptor(hash) ⇒ String
Get unique descriptor of this class
55 56 57 |
# File 'lib/multiarray/pointer.rb', line 55 def descriptor( hash ) inspect end |
.eql? ⇒ Boolean
Equality for hash operations
92 93 94 |
# File 'lib/multiarray/pointer.rb', line 92 def eql? self == other end |
.finalised? ⇒ Boolean
Check whether objects of this class are finalised computations
117 118 119 |
# File 'lib/multiarray/pointer.rb', line 117 def finalised? false end |
.hash ⇒ Fixnum
Compute hash value for this class
81 82 83 |
# File 'lib/multiarray/pointer.rb', line 81 def hash [ :Pointer_, target ].hash end |
.inspect ⇒ String
Display string with information about this class
44 45 46 |
# File 'lib/multiarray/pointer.rb', line 44 def inspect "*(#{target.inspect})" end |
.typecode ⇒ Class
Get element type
99 100 101 |
# File 'lib/multiarray/pointer.rb', line 99 def typecode target end |
Instance Method Details
#assign(value) ⇒ Object
Store a value in this native element
182 183 184 185 186 187 188 189 |
# File 'lib/multiarray/pointer.rb', line 182 def assign( value ) if @value.respond_to? :assign @value.assign value.simplify.get else @value = value.simplify.get end value end |
#decompose(i) ⇒ Node
Decompose composite elements
This method decomposes composite elements into array.
247 248 249 250 251 252 253 254 |
# File 'lib/multiarray/pointer.rb', line 247 def decompose( i ) if self.class.target < Composite pointer = Hornetseye::Pointer( self.class.target.element_type ).new @value pointer.lookup INT.new( i ), INT.new( 1 ) else super end end |
#demand ⇒ Node, Object
Reevaluate computation
211 212 213 |
# File 'lib/multiarray/pointer.rb', line 211 def demand self.class.target.fetch(@value).simplify end |
#descriptor(hash) ⇒ String
Get unique descriptor of this object
171 172 173 |
# File 'lib/multiarray/pointer.rb', line 171 def descriptor( hash ) "#{self.class.to_s}(#{@value.to_s})" end |
#lookup(value, stride) ⇒ Object
Lookup element of an array
221 222 223 224 225 226 227 228 |
# File 'lib/multiarray/pointer.rb', line 221 def lookup( value, stride ) if value.is_a? Variable Lookup.new self, value, stride else self.class.new @value + ( stride.get * self.class.target.storage_size ) * value.get end end |
#memory ⇒ Malloc, List
Get access to storage object
137 138 139 |
# File 'lib/multiarray/pointer.rb', line 137 def memory @value end |
#sexp? ⇒ Boolean
130 131 132 |
# File 'lib/multiarray/pointer.rb', line 130 def sexp? true end |
#skip(index, start) ⇒ Node
Skip elements of an array
238 239 240 |
# File 'lib/multiarray/pointer.rb', line 238 def skip( index, start ) self end |
#store(value) ⇒ Object
Store new value in this pointer
198 199 200 201 202 |
# File 'lib/multiarray/pointer.rb', line 198 def store( value ) result = value.simplify self.class.target.new(result.get).write @value result end |
#strides ⇒ Array<Integer>, NilClass
Get strides of array
146 147 148 |
# File 'lib/multiarray/pointer.rb', line 146 def strides [] 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.
159 160 161 162 |
# File 'lib/multiarray/pointer.rb', line 159 def strip variable = Variable.new self.class return [ variable ], [ self ], variable end |