Class: Hornetseye::FLOAT_
- Defined in:
- lib/multiarray/float.rb
Overview
Class for representing native floating point numbers
Defined Under Namespace
Modules: Match
Class Attribute Summary collapse
-
.double ⇒ Boolean
Boolean indicating whether this number is single or double precision.
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 ⇒ String
Directive for packing/unpacking elements of this type.
-
.eql?(other) ⇒ Boolean
Equality for hash operations.
-
.float ⇒ Class
Convert to type based on floating point numbers.
-
.hash ⇒ Fixnum
Compute hash value for this class.
- .inherit(double) ⇒ Object
-
.inspect ⇒ String
Return string with information about this class.
-
.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.
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_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, #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 Hornetseye::Field_::Match
Methods included from 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
This class inherits a constructor from Hornetseye::Element
Class Attribute Details
.double ⇒ Boolean
Boolean indicating whether this number is single or double precision
30 31 32 |
# File 'lib/multiarray/float.rb', line 30 def double @double end |
Class Method Details
.==(other) ⇒ Boolean
Test equality of classes
140 141 142 |
# File 'lib/multiarray/float.rb', line 140 def ==( other ) other.is_a? Class and other < FLOAT_ and double == other.double end |
.coerce(other) ⇒ Array<Class>
Type coercion for native elements
89 90 91 92 93 94 95 96 97 |
# File 'lib/multiarray/float.rb', line 89 def coerce( other ) if other < FLOAT_ return other, self elsif other < INT_ return self, self else super other end end |
.coercion(other) ⇒ Class
Compute balanced type for binary operation
72 73 74 75 76 77 78 79 80 |
# File 'lib/multiarray/float.rb', line 72 def coercion( other ) if other < FLOAT_ Hornetseye::FLOAT( ( double or other.double ) ) elsif other < INT_ self else super other end end |
.default ⇒ Object
Get default value for elements of this type
61 62 63 |
# File 'lib/multiarray/float.rb', line 61 def default 0.0 end |
.descriptor(hash) ⇒ String
Get unique descriptor of this class
131 132 133 |
# File 'lib/multiarray/float.rb', line 131 def descriptor( hash ) inspect end |
.directive ⇒ String
Directive for packing/unpacking elements of this type
113 114 115 |
# File 'lib/multiarray/float.rb', line 113 def directive double ? 'd' : 'f' end |
.eql?(other) ⇒ Boolean
Equality for hash operations
160 161 162 |
# File 'lib/multiarray/float.rb', line 160 def eql?( other ) self == other end |
.float ⇒ Class
Convert to type based on floating point numbers
104 105 106 |
# File 'lib/multiarray/float.rb', line 104 def float self end |
.hash ⇒ Fixnum
Compute hash value for this class
149 150 151 |
# File 'lib/multiarray/float.rb', line 149 def hash [ :FLOAT_, double ].hash end |
.inherit(double) ⇒ Object
32 33 34 35 36 |
# File 'lib/multiarray/float.rb', line 32 def inherit(double) retval = Class.new self retval.double = double retval end |
.inspect ⇒ String
Return string with information about this class
120 121 122 |
# File 'lib/multiarray/float.rb', line 120 def inspect "#{ double ? 'D' : 'S' }FLOAT" end |
.memory_type ⇒ Class
Memory type required to store elements of this type
43 44 45 |
# File 'lib/multiarray/float.rb', line 43 def memory_type Malloc end |
.storage_size ⇒ Integer
Get storage size to store an element of this type
52 53 54 |
# File 'lib/multiarray/float.rb', line 52 def storage_size double ? 8 : 4 end |