Compute the inverse of a square matrix with Gauss-Jordan elimination. The inverse A−1 satisfies:
AA−1=A−1A=IForm the augmented matrix [A∣I]. For each column, choose the remaining row with the largest absolute pivot, swap it into place, scale the pivot row to make the pivot one, and eliminate that column from every other row. Return None if no nonzero pivot exists. Do not use NumPy linear-algebra solver or inverse functions. Return the right half as a floating-point NumPy array.
Input: A = [[1, 2], [3, 4]]
Output: [[-2, 1], [1.5, -0.5]]
Explanation: Multiplying A by this matrix gives the 2 by 2 identity matrix.
Input: A = [[2.0]]
Output: [[0.5]]
Build the augmented matrix with np.concatenate((matrix, np.eye(n)), axis=1).
Find each pivot row with column + np.argmax(np.abs(augmented[column:, column])).
Eliminate all non-pivot rows using their current value in the pivot column.
Sign in to take notes on this problem
Accepts: array
Compute the inverse of a square matrix with Gauss-Jordan elimination. The inverse A−1 satisfies:
AA−1=A−1A=IForm the augmented matrix [A∣I]. For each column, choose the remaining row with the largest absolute pivot, swap it into place, scale the pivot row to make the pivot one, and eliminate that column from every other row. Return None if no nonzero pivot exists. Do not use NumPy linear-algebra solver or inverse functions. Return the right half as a floating-point NumPy array.
Input: A = [[1, 2], [3, 4]]
Output: [[-2, 1], [1.5, -0.5]]
Explanation: Multiplying A by this matrix gives the 2 by 2 identity matrix.
Input: A = [[2.0]]
Output: [[0.5]]
Build the augmented matrix with np.concatenate((matrix, np.eye(n)), axis=1).
Find each pivot row with column + np.argmax(np.abs(augmented[column:, column])).
Eliminate all non-pivot rows using their current value in the pivot column.
Sign in to take notes on this problem
Accepts: array