Method: NMatrix#map

Defined in:
lib/nmatrix/enumerate.rb

#map(&bl) ⇒ Object

call-seq:

map -> Enumerator
map { |elem| block } -> NMatrix

Returns an NMatrix if a block is given. For an Array, use #flat_map

Note that #map will always return an :object matrix, because it has no way of knowing how to handle operations on the different dtypes.



72
73
74
75
76
77
78
# File 'lib/nmatrix/enumerate.rb', line 72

def map(&bl)
  return enum_for(:map) unless block_given?
  # NMatrix-jruby currently supports only doubles
  cp  = jruby? ? self : self.cast(dtype: :object)
  cp.map!(&bl)
  cp
end