Class: Hornetseye::INT_
Overview
Class for representing native integers
Defined Under Namespace
Modules: Match
Constant Summary collapse
- DIRECTIVES =
Hash table used internally
{ [ 8, true ] => 'c', [ 8, false ] => 'C', [ 16, true ] => 's', [ 16, false ] => 'S', [ 32, true ] => 'i', [ 32, false ] => 'I', [ 64, true ] => 'q', [ 64, false ] => 'Q' }
- IDENTIFIER =
Hash table used internally
{ [ 8, true ] => 'BYTE', [ 8, false ] => 'UBYTE', [ 16, true ] => 'SINT', [ 16, false ] => 'USINT', [ 32, true ] => 'INT', [ 32, false ] => 'UINT', [ 64, true ] => 'LONG', [ 64, false ] => 'ULONG' }
Class Attribute Summary collapse
-
.bits ⇒ Integer
Number of bits of this integer.
-
.signed ⇒ Boolean
Boolean indicating whether this is a signed integer or not.
Class Method Summary collapse
-
.==(other) ⇒ Boolean
Test equality of classes.
-
.coerce(other) ⇒ Array<Class>
Type coercion for native elements.
-
.coercion(other) ⇒ Class
Compute balanced type for binary operation.
-
.default ⇒ Object
Get default value for elements of this type.
-
.descriptor(hash) ⇒ String
Get unique descriptor of this class.
-
.directive ⇒ Object
Directive for packing/unpacking elements of this type.
-
.eql?(other) ⇒ Boolean
Equality for hash operations.
-
.hash ⇒ Fixnum
Compute hash value for this class.
- .inherit(bits, signed) ⇒ Object
-
.inspect ⇒ String
Get string with information about this class.
-
.maxint ⇒ Class
Get corresponding maximal integer type.
-
.memory_type ⇒ Class
Memory type required to store elements of this type.
-
.storage_size ⇒ Integer
Get storage size to store an element of this type.
Instance Method Summary collapse
-
#times(&action) ⇒ GCCValue
Loop statement.
-
#upto(other, &action) ⇒ GCCValue
Loop statement.
Methods inherited from Element
#assign, #compilable?, construct, #descriptor, #dup, fetch, #get, #initialize, #skip, #strip, #values, #write
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, #inspect, #integral, #lut, #lut_with_rgb, #malloc, #mask, match, #matched?, #max, #mean, #memorise, #memory, #min, #normalise, #prod, #r=, #r_with_decompose, #range, #real=, #real_with_decompose, #reshape, #rgb?, rgb?, #roll, scalar, #shape, shape, #shift, #simplify, #size, #sobel, #stretch, #stride, #strides, #strip, 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, 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 Match
Constructor Details
This class inherits a constructor from Hornetseye::Element
Class Attribute Details
.bits ⇒ Integer
Number of bits of this integer
28 29 30 |
# File 'lib/multiarray/int.rb', line 28 def bits @bits end |
.signed ⇒ Boolean
Boolean indicating whether this is a signed integer or not
signed integer or not.
34 35 36 |
# File 'lib/multiarray/int.rb', line 34 def signed @signed end |
Class Method Details
.==(other) ⇒ Boolean
Test equality of classes
175 176 177 178 |
# File 'lib/multiarray/int.rb', line 175 def ==( other ) other.is_a? Class and other < INT_ and bits == other.bits and signed == other.signed end |
.coerce(other) ⇒ Array<Class>
Type coercion for native elements
101 102 103 104 105 106 107 |
# File 'lib/multiarray/int.rb', line 101 def coerce( other ) if other < INT_ return other, self else super other end end |
.coercion(other) ⇒ Class
Compute balanced type for binary operation
86 87 88 89 90 91 92 |
# File 'lib/multiarray/int.rb', line 86 def coercion( other ) if other < INT_ Hornetseye::INT [ bits, other.bits ].max, ( signed or other.signed ) else super other end end |
.default ⇒ Object
Get default value for elements of this type
66 67 68 |
# File 'lib/multiarray/int.rb', line 66 def default 0 end |
.descriptor(hash) ⇒ String
Get unique descriptor of this class
162 163 164 165 166 167 168 |
# File 'lib/multiarray/int.rb', line 162 def descriptor( hash ) unless bits.nil? or signed.nil? inspect else super hash end end |
.directive ⇒ Object
Directive for packing/unpacking elements of this type
124 125 126 127 128 |
# File 'lib/multiarray/int.rb', line 124 def directive retval = DIRECTIVES[ [ bits, signed ] ] raise "No directive for packing/unpacking #{inspect}" unless retval retval end |
.eql?(other) ⇒ Boolean
Equality for hash operations
196 197 198 |
# File 'lib/multiarray/int.rb', line 196 def eql?( other ) self == other end |
.hash ⇒ Fixnum
Compute hash value for this class
185 186 187 |
# File 'lib/multiarray/int.rb', line 185 def hash [ :INT_, bits, signed ].hash end |
.inherit(bits, signed) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/multiarray/int.rb', line 36 def inherit(bits, signed) retval = Class.new self retval.bits = bits retval.signed = signed retval end |
.inspect ⇒ String
Get string with information about this class
146 147 148 149 150 151 152 153 |
# File 'lib/multiarray/int.rb', line 146 def inspect unless bits.nil? or signed.nil? IDENTIFIER[ [ bits, signed ] ] || "INT(#{bits.inspect},#{ signed ? 'SIGNED' : 'UNSIGNED' })" else super end end |
.maxint ⇒ Class
Get corresponding maximal integer type
75 76 77 |
# File 'lib/multiarray/int.rb', line 75 def maxint Hornetseye::INT [ 32, bits ].max, signed end |
.memory_type ⇒ Class
Memory type required to store elements of this type
48 49 50 |
# File 'lib/multiarray/int.rb', line 48 def memory_type Malloc end |
.storage_size ⇒ Integer
Get storage size to store an element of this type
57 58 59 |
# File 'lib/multiarray/int.rb', line 57 def storage_size ( bits + 7 ).div 8 end |
Instance Method Details
#times(&action) ⇒ GCCValue
Loop statement
209 210 211 212 |
# File 'lib/multiarray/int.rb', line 209 def times( &action ) get.times &action self end |
#upto(other, &action) ⇒ GCCValue
Loop statement
222 223 224 225 |
# File 'lib/multiarray/int.rb', line 222 def upto( other, &action ) get.upto other.get, &action self end |