Skip to content

Commit 9d69d12

Browse files
authored
Merge pull request #215 from nbelakovski/initialize_b
Initialize B to zero for inverse of non-triangular matrices
2 parents 627459b + f750302 commit 9d69d12

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fortran/common/linalg.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ function inv(A) result(B)
751751
! This is NOT the best algorithm for the inverse, but since the QR subroutine is available ...
752752
call qr(A, Q, R, P)
753753
R = transpose(R) ! Take transpose to work on columns.
754+
B = ZERO
754755
do i = n, 1, -1
755756
B(:, i) = (Q(:, i) - matprod(B(:, i + 1:n), R(i + 1:n, i))) / R(i, i)
756757
end do

0 commit comments

Comments
 (0)