APIdock / Ruby
/
method

column

ruby latest stable - Class: Matrix
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.

# File lib/matrix.rb, line 344
 def column(j) # :yield: e
 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

AltStyle によって変換されたページ (->オリジナル) /