Class: Hornetseye::Pointer_
Class Attribute Summary collapse
-
.target ⇒ Node
Target type of pointer.
Class Method Summary collapse
-
.==(other) ⇒ Boolean
Test equality of classes.
-
.array_type ⇒ Class
Get type of result of delayed operation.
-
.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.
-
.pointer_type ⇒ Class
Get corresponding pointer type.
-
.typecode ⇒ Class
Get element type.
Instance Method Summary collapse
-
#decompose(i) ⇒ Node
Decompose composite elements.
-
#demand ⇒ Node, Object
Reevaluate computation.
- #descriptor(hash) ⇒ Object
-
#initialize(value = self.class.default) ⇒ Pointer_
constructor
A new instance of Pointer_.
-
#lookup(value, stride) ⇒ Object
Lookup element of an array.
- #memory ⇒ Object
- #skip(index, start) ⇒ Object
-
#store(value) ⇒ Object
Store new value in this pointer.
-
#strip ⇒ Array<Array,Node>
Strip of all values.
-
#values ⇒ Array<Object>
Get array with components of this value.
Methods inherited from Node
===, #[], #[]=, #array_type, #basetype, bool, byte, #check_shape, #coerce, coercion_bool, coercion_byte, coercion_maxint, #compilable?, compilable?, cond, contiguous, dimension, #dimension, #dup, empty?, #empty?, #finalised?, float, float_scalar, floating, #force, #get, #height, height, indgen, #inspect, match, maxint, #pointer_type, rgb?, #rgb?, scalar, shape, #shape, #simplify, #size, size, #storage_size, strip, subst, #subst, #to_a, to_s, #to_s, to_type, #typecode, typecodes, variables, #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(value = self.class.default) ⇒ Pointer_
Returns a new instance of Pointer_.
137 138 139 |
# File 'lib/multiarray/pointer.rb', line 137 def initialize( value = self.class.default ) @value = value end |
Class Attribute Details
.target ⇒ Node
Target type of pointer
26 27 28 |
# File 'lib/multiarray/pointer.rb', line 26 def target @target end |
Class Method Details
.==(other) ⇒ Boolean
Test equality of classes
69 70 71 72 |
# File 'lib/multiarray/pointer.rb', line 69 def ==( other ) other.is_a? Class and other < Pointer_ and target == other.target end |
.array_type ⇒ Class
Get type of result of delayed operation
115 116 117 |
# File 'lib/multiarray/pointer.rb', line 115 def array_type target end |
.basetype ⇒ Class
Base type of this data type
106 107 108 |
# File 'lib/multiarray/pointer.rb', line 106 def basetype target.basetype end |
.construct(*args) ⇒ Element
Construct new object from arguments
35 36 37 |
# File 'lib/multiarray/pointer.rb', line 35 def construct( *args ) new *args end |
.default ⇒ Memory, List
Get default value for elements of this type
60 61 62 |
# File 'lib/multiarray/pointer.rb', line 60 def default target.memory.new target.storage_size end |
.descriptor(hash) ⇒ String
Get unique descriptor of this class
53 54 55 |
# File 'lib/multiarray/pointer.rb', line 53 def descriptor( hash ) inspect end |
.eql? ⇒ Boolean
Equality for hash operations
90 91 92 |
# File 'lib/multiarray/pointer.rb', line 90 def eql? self == other end |
.finalised? ⇒ Boolean
Check whether objects of this class are finalised computations
131 132 133 |
# File 'lib/multiarray/pointer.rb', line 131 def finalised? false end |
.hash ⇒ Fixnum
Compute hash value for this class.
79 80 81 |
# File 'lib/multiarray/pointer.rb', line 79 def hash [ :Pointer_, target ].hash end |
.inspect ⇒ String
Display string with information about this class
42 43 44 |
# File 'lib/multiarray/pointer.rb', line 42 def inspect "*(#{target.inspect})" end |
.pointer_type ⇒ Class
Get corresponding pointer type
122 123 124 |
# File 'lib/multiarray/pointer.rb', line 122 def pointer_type self end |
.typecode ⇒ Class
Get element type
97 98 99 |
# File 'lib/multiarray/pointer.rb', line 97 def typecode target end |
Instance Method Details
#decompose(i) ⇒ Node
Decompose composite elements
This method decomposes composite elements into array.
211 212 213 214 215 216 217 218 |
# File 'lib/multiarray/pointer.rb', line 211 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
183 184 185 |
# File 'lib/multiarray/pointer.rb', line 183 def demand self.class.target.fetch( @value ).simplify end |
#descriptor(hash) ⇒ Object
159 160 161 |
# File 'lib/multiarray/pointer.rb', line 159 def descriptor( hash ) "#{self.class.to_s}(#{@value.to_s})" end |
#lookup(value, stride) ⇒ Object
Lookup element of an array
193 194 195 196 197 198 199 200 |
# File 'lib/multiarray/pointer.rb', line 193 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 ⇒ Object
141 142 143 |
# File 'lib/multiarray/pointer.rb', line 141 def memory @value end |
#skip(index, start) ⇒ Object
202 203 204 |
# File 'lib/multiarray/pointer.rb', line 202 def skip( index, start ) self end |
#store(value) ⇒ Object
Store new value in this pointer
170 171 172 173 174 |
# File 'lib/multiarray/pointer.rb', line 170 def store( value ) result = value.simplify self.class.target.new( result.get ).write @value result 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.
154 155 156 157 |
# File 'lib/multiarray/pointer.rb', line 154 def strip variable = Variable.new self.class return [ variable ], [ self ], variable end |