Project

General

Profile

Feature #10077 » Implement_Matrix#row_merge.patch

gogotanaka (Kazuki Tanaka), 07/21/2014 02:52 AM

View differences:

lib/matrix.rb
# * #minor(*param)
# * #first_minor(row, column)
# * #cofactor(row, column)
# * #row_merge(*matrices)
# * #merge(*matrices)
# * #column_merge(*matrices)
#
# Properties of a matrix:
......
end
#
# Merge matrices between rows.
#
# Matrix[[1, 2], [3, 4]].row_merge(Matrix[[5], [6]])
# => 1 2 5
# 3 4 6
#
def row_merge(*matrices)
if matrices.any?{|m| m.row_size != row_size}
raise ErrDimensionMismatch, "all matrices should have same row size"
end
transpose.column_merge(*matrices.map(&:transpose)).transpose
end
alias_method :merge, :row_merge
#
# Merge matrices between column vertically.
#
# Matrix[[1, 2], [3, 4]].column_merge(Matrix[[5, 6]])
(4-4/6)