Module | JBLAS::MatrixEnumMixin |
In: |
lib/jblas/mixin_enum.rb
|
Mixin for collecting enumerable operations.
Collected in MatrixMixin.
Iterate over columns.
# File lib/jblas/mixin_enum.rb, line 50 def each_column (0...columns).each do |j| yield column(j) end end
Iterate over rows.
# File lib/jblas/mixin_enum.rb, line 43 def each_row (0...rows).each do |i| yield row(i) end end
Map each element and store the result in the matrix.
Note that the result must be again something which can be stored in the matrix. Otherwise you should do an to_a first.
# File lib/jblas/mixin_enum.rb, line 76 def map!(&block) (0...length).each do |i| put(i, block.call(get(i))) end self end