Class: Hornetseye::FLOAT_

Inherits:
Element show all
Defined in:
lib/multiarray/float.rb

Defined Under Namespace

Modules: Match

Class Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Element

#compilable?, construct, #descriptor, #dup, fetch, #get, #initialize, #skip, #store, #strip, #values, #write

Methods inherited from Node

===, #[], #[]=, #array_type, 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_scalar, floating, #force, #get, height, #height, indgen, #inspect, match, maxint, #memory, #pointer_type, pointer_type, rgb?, #rgb?, scalar, #shape, shape, #simplify, size, #size, #storage_size, strip, #strip, subst, #subst, #to_a, to_s, #to_s, to_type, #typecode, typecode, typecodes, variables, #variables, #width, width

Methods included from Match

#align, #fit

Methods included from OBJECT::Match

#align, #fit

Methods included from COMPLEX_::Match

#align, #fit

Methods included from Sequence_::Match

#align, #fit

Methods included from BOOL::Match

#fit

Methods included from RGB_::Match

#align, #fit

Methods included from INT_::Match

#fit

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, #histogram_with_composite, #imag=, #imag_with_decompose, #inject, #integral, #lut, #lut_with_composite, #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

This class inherits a constructor from Hornetseye::Element

Class Attribute Details

.doubleObject

Returns the value of attribute double.



24
25
26
# File 'lib/multiarray/float.rb', line 24

def double
  @double
end

Class Method Details

.==(other) ⇒ Boolean

Test equality of classes



128
129
130
# File 'lib/multiarray/float.rb', line 128

def ==( other )
  other.is_a? Class and other < FLOAT_ and double == other.double
end

.coerce(other) ⇒ Array<Class>

Type coercion for native elements



77
78
79
80
81
82
83
84
85
# File 'lib/multiarray/float.rb', line 77

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



60
61
62
63
64
65
66
67
68
# File 'lib/multiarray/float.rb', line 60

def coercion( other )
  if other < FLOAT_
    Hornetseye::FLOAT( ( double or other.double ) )
  elsif other < INT_
    self
  else
    super other
  end
end

.defaultObject

Get default value for elements of this type



49
50
51
# File 'lib/multiarray/float.rb', line 49

def default
  0.0
end

.descriptor(hash) ⇒ String

Get unique descriptor of this class



119
120
121
# File 'lib/multiarray/float.rb', line 119

def descriptor( hash )
  inspect
end

.directiveString

Directive for packing/unpacking elements of this type



101
102
103
# File 'lib/multiarray/float.rb', line 101

def directive
  double ? 'd' : 'f'
end

.eql?(other) ⇒ Boolean

Equality for hash operations



148
149
150
# File 'lib/multiarray/float.rb', line 148

def eql?( other )
  self == other
end

.floatClass

Convert to type based on floating point numbers



92
93
94
# File 'lib/multiarray/float.rb', line 92

def float
  self
end

.hashFixnum

Compute hash value for this class.



137
138
139
# File 'lib/multiarray/float.rb', line 137

def hash
  [ :FLOAT_, double ].hash
end

.inspectString

Return string with information about this class.



108
109
110
# File 'lib/multiarray/float.rb', line 108

def inspect
  "#{ double ? 'D' : 'S' }FLOAT"
end

.memoryClass

Memory type required to store elements of this type



31
32
33
# File 'lib/multiarray/float.rb', line 31

def memory
  Malloc
end

.storage_sizeInteger

Get storage size to store an element of this type



40
41
42
# File 'lib/multiarray/float.rb', line 40

def storage_size
  double ? 8 : 4
end