Module: Hornetseye::COMPLEX_::Match
- Included in:
- Node
- Defined in:
- lib/multiarray/complex.rb
Instance Method Summary collapse
-
#align(context) ⇒ Object
Perform type alignment.
-
#fit(*values) ⇒ Class
Method for matching elements of type COMPLEX_.
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.
678 679 680 681 682 683 684 |
# File 'lib/multiarray/complex.rb', line 678 def align( context ) if self < COMPLEX_ Hornetseye::COMPLEX element_type.align( context ) else super context end end |
#fit(*values) ⇒ Class
Method for matching elements of type COMPLEX_
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 |
# File 'lib/multiarray/complex.rb', line 645 def fit( *values ) if values.all? { |value| value.is_a? InternalComplex or value.is_a? Complex or value.is_a? Float or value.is_a? Integer } if values.any? { |value| value.is_a? InternalComplex or value.is_a? Complex } elements = values.inject( [] ) do |arr,value| if value.is_a? InternalComplex or value.is_a? Complex arr + [ value.real, value.imag ] else arr + [ value ] end end element_fit = fit *elements if element_fit == OBJECT super *values else Hornetseye::COMPLEX element_fit end else super *values end else super *values end end |