QR decomposition using Givens rotations
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=dp), | intent(in), | dimension(:, :) | :: | A | ||
| real(kind=dp), | intent(out), | dimension(size(A, 1), size(A, 2)) | :: | Q | ||
| real(kind=dp), | intent(out), | dimension(size(A, 1), size(A, 2)) | :: | R |
subroutine QR_Givens_decomposition(A, Q, R) real(dp), dimension(:, :), intent(in) :: A real(dp), dimension(size(A, 1), size(A, 2)), intent(out) :: Q, R real(dp), dimension(size(A, 1), size(A, 2)) :: G integer :: N, i, j N = size(A, 1) R = A Q = Identity_n(N) do j = 1, N - 1 do i = j + 1, N G = rotation_matrix(R, [i, j]) R = matmul(G, R) Q = matmul(Q, transpose(G)) end do end do end subroutine QR_Givens_decomposition