Method: NMatrix#each_layer
- Defined in:
- lib/nmatrix/enumerate.rb
#each_layer(get_by = :reference) ⇒ Object
call-seq:
each_layer -> { |column| block } -> ...
Iterate through each layer, referencing it as an NMatrix slice.
Note: If you have a 3-dimensional matrix, the first dimension contains rows, the second contains columns, and the third contains layers.
160 161 162 163 164 165 166 |
# File 'lib/nmatrix/enumerate.rb', line 160 def each_layer(get_by=:reference) return enum_for(:each_layer, get_by) unless block_given? (0...self.shape[2]).each do |k| yield self.layer(k, get_by) end self end |