Skip to content
Snippets Groups Projects
Commit c3baa36f authored by Dimitri Tayo Fongang Wembe's avatar Dimitri Tayo Fongang Wembe
Browse files

fix mistake in formula of Q in QR-split

parent 968aa090
No related branches found
No related tags found
No related merge requests found
......@@ -16,8 +16,12 @@ def givens_rotation(A, i, j):
np.ndarray: Rotation Matrix ``J`` as above.
"""
# TODO
c = abs(A[j][j]) / ((A[i][j] ** 2 + A[j][j] ** 2) ** 0.5)
s = abs(A[i][j]) / ((A[i][j] ** 2 + A[j][j] ** 2) ** 0.5)
if abs(A[j][j]) == 0.0:
p = ((A[i][j] ** 2 + A[j][j] ** 2) ** 0.5)
else:
p = np.sign(A[j][j]) * ((A[i][j] ** 2 + A[j][j] ** 2) ** 0.5)
c = A[j][j] / p
s = A[i][j] / p
n, m = np.shape(A)
J = np.eye(n)
J[j][j] = c
......@@ -99,7 +103,15 @@ def main():
Hier kann beliebiger Testcode stehen, der bei der Korrektur vollständig
ignoriert wird.
"""
pass
arr1 = np.array(([3, -4], [3, 5]))
J1 = givens_rotation(arr1, 1, 0)
arr2 = np.array(([3, 4], [3, 5]))
J2 = givens_rotation(arr2, 1, 0)
Q, R = qr_decompose(arr1)
print(f"J1= {J1}")
print(f"J2= {J2}")
print(f"J1*arr= {np.dot(J1, arr1)}")
print(f"J2*arr= {np.dot(J2, arr2)}")
if __name__ == "__main__": main()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment