Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python built-in function to do matrix reduction

Does python have a built-in function that converts a matrix into row echelon form (also known as upper triangular)?

like image 658
user968102 Avatar asked Oct 05 '11 16:10

user968102


People also ask

How do you reduce a matrix to row echelon form in Python?

rref() method, we can put a matrix into reduced Row echelon form. Matrix(). rref() returns a tuple of two elements. The first is the reduced row echelon form, and the second is a tuple of indices of the pivot columns.

What is matrix manipulation in Python?

It stands for 'Numerical Python'. It is a library consisting of multidimensional array objects and a collection of routines for processing of array. Using NumPy, mathematical and logical operations on arrays can be performed.

How do you deal with a matrix in python?

Python does not have a straightforward way to implement a matrix data type. Python matrix can be created using a nested list data type and by using the numpy library. The python library Numpy helps to deal with arrays. Numpy processes an array a little faster in comparison to the list.

How do you reduce matrix?

To row reduce a matrix: Perform elementary row operations to yield a "1" in the first row, first column. Create zeros in all the rows of the first column except the first row by adding the first row times a constant to each other row. Perform elementary row operations to yield a "1" in the second row, second column.


1 Answers

If you can use sympy, Matrix.rref() can do it:

In [8]: sympy.Matrix(np.random.random((4,4))).rref() Out[8]:  ([1, 1.42711055402454e-17, 0, -1.38777878078145e-17] [0,                  1.0, 0,  2.22044604925031e-16] [0, -2.3388341405089e-16, 1, -2.22044604925031e-16] [0, 3.65674099486992e-17, 0,                   1.0],  [0, 1, 2, 3]) 
like image 91
NPE Avatar answered Sep 18 '22 22:09

NPE