# Ruby program for t() method in Matrix# Include matrix require"matrix"# Initialize a matrix
mat1 =Matrix[[3,12],[2,8]]# Prints the transpose matrix
puts mat1.t()
Ruby
输出:
Matrix[[3,2],[12,8]]
Ruby
例2 :
# Ruby program for t() method in Matrix# Include matrix require"matrix"# Initialize a matrix
mat1 =Matrix[[1,0],[6,1],[1,2]]# Prints the transpose matrix
puts mat1.t()