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_count || j < -column_count
row_count.times do |i|
yield @rows[i][j]
end
self
else
return nil if j >= column_count || j < -column_count
col = Array.new(row_count) {|i|
@rows[i][j]
}
Vector.elements(col, false)
end
end