You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
# Transpose of a matrix in Linear Algebra,
|
|
# see examples in test/matrix_test.rb
|
|
module Matrix
|
|
def self.transpose(matrix)
|
|
transposed = []
|
|
|
|
matrix.each do |row|
|
|
row.each_with_index do |el, j|
|
|
transposed << [] if transposed[j].nil?
|
|
transposed[j] << el
|
|
end
|
|
end
|
|
|
|
transposed
|
|
end
|
|
end
|