Module: Hornetseye::Field_::Match
- Included in:
- Node
- Defined in:
- lib/multiarray/field.rb
Overview
Namespace containing method for matching elements of type Field_
Instance Method Summary collapse
-
#align(context) ⇒ Object
Perform type alignment.
-
#fit(*values) ⇒ Class
Method for matching elements of type Field_.
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.
365 366 367 368 369 370 371 |
# File 'lib/multiarray/field.rb', line 365 def align(context) if self < Field_ Hornetseye::MultiArray typecode.align(context), dimension else super context end end |
#fit(*values) ⇒ Class
Method for matching elements of type Field_
343 344 345 346 347 348 349 350 351 352 353 354 355 |
# File 'lib/multiarray/field.rb', line 343 def fit( *values ) n = values.inject 0 do |size,value| value.is_a?(Array) ? [size, value.size].max : size end if n > 0 elements = values.inject [] do |flat,value| flat + (value.is_a?(Array) ? value : [value]) end Hornetseye::MultiArray fit( *elements ), 1 else super *values end end |