Module: Hornetseye::COMPLEX_::Match
- Included in:
- Node
- Defined in:
- lib/multiarray/complex.rb
Overview
Namespace containing method for matching elements of type COMPLEX_
Instance Method Summary collapse
-
#align(context) ⇒ Class
Perform type alignment.
-
#fit(*values) ⇒ Class
Method for matching elements of type COMPLEX_.
Instance Method Details
#align(context) ⇒ Class
Perform type alignment
Align this type to another. This is used to prefer single-precision floating point in certain cases.
967 968 969 970 971 972 973 |
# File 'lib/multiarray/complex.rb', line 967 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_
932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 |
# File 'lib/multiarray/complex.rb', line 932 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 |