Module: Hornetseye::FLOAT_::Match

Included in:
Node
Defined in:
lib/multiarray/float.rb

Overview

Namespace containing method for matching elements of type FLOAT_

See Also:

Instance Method Summary collapse

Instance Method Details

#align(context) ⇒ Object

Perform type alignment

Align this type to another. This is used to prefer single-precision floating point in certain cases.

Parameters:

  • context (Class)

    Other type to align with.



203
204
205
206
207
208
209
# File 'lib/multiarray/float.rb', line 203

def align( context )
  if self < FLOAT_ and context < FLOAT_
    context
  else
    super context
  end
end

#fit(*values) ⇒ Class

Method for matching elements of type FLOAT_

Parameters:

  • *values (Array<Object>)

    Values to find matching native element type for.

Returns:

  • (Class)

    Native type fitting all values.

See Also:



183
184
185
186
187
188
189
190
191
192
193
# File 'lib/multiarray/float.rb', line 183

def fit( *values )
  if values.all? { |value| value.is_a? Float or value.is_a? Integer }
    if values.any? { |value| value.is_a? Float }
      DFLOAT
    else
      super *values
    end
  else
    super *values
  end
end