Module JBLAS::MatrixEnumMixin
In: lib/jblas/mixin_enum.rb

Mixin for collecting enumerable operations.

Collected in MatrixMixin.

Methods

each   each_column   each_row   map   map!  

Included Modules

Enumerable

Public Instance methods

Each iterates over each element, going down rows first.

[Source]

# File lib/jblas/mixin_enum.rb, line 57
    def each
      (0...length).each do |i|
        yield get(i)
      end
    end

Iterate over columns.

[Source]

# File lib/jblas/mixin_enum.rb, line 50
    def each_column
      (0...columns).each do |j|
        yield column(j)
      end
    end

Iterate over rows.

[Source]

# File lib/jblas/mixin_enum.rb, line 43
    def each_row
      (0...rows).each do |i|
        yield row(i)
      end
    end

Map each element.

Returns a new matrix of the same type. This means that the block must return something which can again be stored in the matrix.

[Source]

# File lib/jblas/mixin_enum.rb, line 67
    def map(&block)
      return dup.map!(&block)
    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.

[Source]

# 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

[Validate]