column(j)
public
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.
Show source
def column(j)
if block_given?
return self if j >= column_size || j < -column_size
row_size.times do |i|
yield @rows[i][j]
end
self
else
return nil if j >= column_size || j < -column_size
col = Array.new(row_size) {|i|
@rows[i][j]
}
Vector.elements(col, false)
end
end