The transpose() is an inbuilt method in Ruby returns the transpose of the matrix.
Syntax: mat1.transpose()
Parameters: The function needs the matrix to be transposed.
Return Value: It returns the transposed matrix.
Example 1:
# Ruby program for transpose() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[3, 12], [2, 8]] # Prints the transpose matrix puts mat1.transpose() |
chevron_right
filter_none
Output:
Matrix[[3, 2], [12, 8]]
Example 2:
# Ruby program for transpose() method in Matrix # Include matrix require "matrix" # Initialize a matrix mat1 = Matrix[[1, 0], [6, 1], [1, 2]] # Prints the transpose matrix puts mat1.transpose() |
chevron_right
filter_none
Output:
Matrix[[1, 6, 1], [0, 1, 2]]
Recommended Posts:
- Ruby | Array transpose() function
- Ruby | Matrix eql? function
- Ruby | Matrix zero?() function
- Ruby | Matrix I() function
- Ruby | Matrix det() function
- Ruby | Matrix zero() function
- Ruby | Matrix tr() function
- Ruby | Matrix lup() function
- Ruby | Matrix row() function
- Ruby | Matrix t() function
- Ruby | Matrix inv() function
- Ruby | Matrix singular?() function
- Ruby | Matrix unit() function
- Ruby | Matrix clone() function
- Ruby | Matrix upper_triangular?() function
- Ruby | Matrix trace() function
- Ruby | Matrix unitary?() function
- Ruby | Matrix to_s() function
- Ruby | Matrix scalar() function
- Ruby | Matrix diagonal() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

