Method: Matrix#column

Defined in:
lib/matrix.rb

#column(j) ⇒ Object

Returns column vector number j of the matrix as a Vector (starting at 0 like an array). When a block is given, the elements of that vector are iterated.



305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/matrix.rb', line 305

def column(j) # :yield: e
  if block_given?
    0.upto(row_size - 1) do
      |i|
      yield @rows[i][j]
    end
  else
    col = (0 .. row_size - 1).collect {
      |i|
      @rows[i][j]
    }
    Vector.elements(col, false)
  end
end