Ruby | Matrix lup() function
The lup() is an inbuilt method in Ruby returns the LUP decomposition of the given matrix.
Syntax: mat1.lup()
Parameters: The function needs the matrix whose LUP decomposition is to be returned.
Return Value: It returns the LUP decomposition of the matrix.
Example 1:
#Ruby program for lup() method in Matrix #Include matrix require "matrix" #Initialize a matrix mat1 = Matrix[[ 1, 21 ], [ 31, 18 ]] #Prints the decomposition puts mat1.lup() |
chevron_right
filter_none
Output:
Matrix[[1, 0], [1/31, 1]] Matrix[[31, 18], [0, 633/31]] Matrix[[0, 1], [1, 0]]
Example 2:
#Ruby program for lup() method in Matrix #Include matrix require "matrix" #Initialize a matrix mat1 = Matrix[[ 1, 0, 0 ], [ 2, 3, 0 ], [ 31, 18, 19 ]] #Prints the decomposition puts mat1.lup() |
chevron_right
filter_none
Output:
Matrix[[1, 0, 0], [2/31, 1, 0], [1/31, -6/19, 1]] Matrix[[31, 18, 19], [0, 57/31, -38/31], [0, 0, -1/1]] Matrix[[0, 0, 1], [0, 1, 0], [1, 0, 0]]
Recommended Posts:
- Ruby | Matrix t() function
- Ruby | Matrix I() function
- Ruby | Matrix zero() function
- Ruby | Matrix det() function
- Ruby | Matrix row() function
- Ruby | Matrix zero?() function
- Ruby | Matrix tr() function
- Ruby | Matrix eql? function
- Ruby | Matrix inv() function
- Ruby | Matrix hash() function
- Ruby | Matrix hermitian?() function
- Ruby | Matrix to_s() function
- Ruby | Matrix first_minor() function
- Ruby | Matrix unitary?() function
- Ruby | Matrix regular?() 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.

