Skip to content

Commit 28ac77c

Browse files
committed
changes in description and variable
1 parent 2d8f805 commit 28ac77c

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

linear_algebra/qr_decomposition.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@
1010
1111
Reference: https://en.wikipedia.org/wiki/QR_decomposition
1212
"""
13-
14-
from __future__ import annotations
1513
import numpy as np
14+
from __future__ import annotations
1615
from scipy.linalg import qr
1716

1817
def qr_decomposition(matrix_a: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
1918
"""
2019
Perform QR decomposition on a given matrix and raises an error if in
21-
m×n matrix a if m is smaller than n or m,n is less than 2
20+
rowXcolumn matrix a if row is smaller than column or row,column is less than 2
2221
2322
>>> matrix_a = np.array([[1, 2, 3], [4, 5, 9], [7, 8, 15]])
2423
>>> (matrix_q,matrix_r) = qr_decomposition(matrix_a)
@@ -71,12 +70,11 @@ def qr_decomposition(matrix_a: np.ndarray) -> tuple[np.ndarray, np.ndarray]:
7170
raise ValueError(msg)
7271
# Perform QR decomposition with pivoting
7372
# matrix_q: Orthogonal matrix
74-
# matrix_v: Upper triangular matrix
73+
# matrix_r: Upper triangular matrix
7574
# pivot: Pivot indices (permutation vector)
7675

7776
matrix_q, matrix_r, pivot = qr(matrix_a, pivoting=True)
7877

79-
# Note: The bottom row of matrix_r is all zeros because the matrix is rank-deficient.
8078
# Verification: matrix_a[:, pivot] should equal matrix_q @ matrix_r
8179
permute_matrix = matrix_a[:, pivot]
8280
if(np.allclose(permute_matrix, matrix_q @ matrix_r)):

0 commit comments

Comments
 (0)