Skip to content

Commit

Permalink
Better logging output for sqrtm errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Simkern committed Aug 1, 2024
1 parent 9e643ef commit a503622
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/Utils.f90
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,8 @@ subroutine sqrtm_rsp(X, sqrtmX, info)
! Check if the matrix is symmetric
symmetry_error = 0.5*maxval(X - transpose(X))
if (symmetry_error > rtol_sp) then
write(msg,*) "Input matrix is not symmetric. 0.5*max(X-X.T) = ", symmetry_error
write(msg,*) "Input matrix is not symmetric. 0.5*max(X-X.T) = ", &
& symmetry_error, ", tol = ", rtol_sp
call stop_error(msg, module=this_module, procedure='sqrtm_rsp')
else if (symmetry_error > 10*atol_sp) then
write(msg,*) "Input matrix is not exactly symmetric. 0.5*max(X-X.T) = ", symmetry_error
Expand Down Expand Up @@ -758,7 +759,8 @@ subroutine sqrtm_rdp(X, sqrtmX, info)
! Check if the matrix is symmetric
symmetry_error = 0.5*maxval(X - transpose(X))
if (symmetry_error > rtol_dp) then
write(msg,*) "Input matrix is not symmetric. 0.5*max(X-X.T) = ", symmetry_error
write(msg,*) "Input matrix is not symmetric. 0.5*max(X-X.T) = ", &
& symmetry_error, ", tol = ", rtol_dp
call stop_error(msg, module=this_module, procedure='sqrtm_rdp')
else if (symmetry_error > 10*atol_dp) then
write(msg,*) "Input matrix is not exactly symmetric. 0.5*max(X-X.T) = ", symmetry_error
Expand Down Expand Up @@ -991,7 +993,8 @@ subroutine sqrtm_csp(X, sqrtmX, info)
! Check if the matrix is hermitian
symmetry_error = 0.5*maxval(abs(X - conjg(transpose(X))))
if (symmetry_error > rtol_sp) then
write(msg,*) "Input matrix is not hermitian. 0.5*max(abs(X-X.H)) = ", symmetry_error
write(msg,*) "Input matrix is not hermitian. 0.5*max(abs(X-X.H)) = ", &
& symmetry_error, ", tol = ", rtol_sp
call stop_error(msg, module=this_module, procedure='sqrtm_csp')
else if (symmetry_error > 10*atol_sp) then
write(msg,*) "Input matrix is not exactly hermitian. 0.5*max(X-X.T) = ", symmetry_error
Expand Down Expand Up @@ -1224,7 +1227,8 @@ subroutine sqrtm_cdp(X, sqrtmX, info)
! Check if the matrix is hermitian
symmetry_error = 0.5*maxval(abs(X - conjg(transpose(X))))
if (symmetry_error > rtol_dp) then
write(msg,*) "Input matrix is not hermitian. 0.5*max(abs(X-X.H)) = ", symmetry_error
write(msg,*) "Input matrix is not hermitian. 0.5*max(abs(X-X.H)) = ", &
& symmetry_error, ", tol = ", rtol_dp
call stop_error(msg, module=this_module, procedure='sqrtm_cdp')
else if (symmetry_error > 10*atol_dp) then
write(msg,*) "Input matrix is not exactly hermitian. 0.5*max(X-X.T) = ", symmetry_error
Expand Down
6 changes: 4 additions & 2 deletions src/Utils.fypp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ contains
! Check if the matrix is symmetric
symmetry_error = 0.5*maxval(X - transpose(X))
if (symmetry_error > rtol_${kind}$) then
write(msg,*) "Input matrix is not symmetric. 0.5*max(X-X.T) = ", symmetry_error
write(msg,*) "Input matrix is not symmetric. 0.5*max(X-X.T) = ", &
& symmetry_error, ", tol = ", rtol_${kind}$
call stop_error(msg, module=this_module, procedure='sqrtm_${type[0]}$${kind}$')
else if (symmetry_error > 10*atol_${kind}$) then
write(msg,*) "Input matrix is not exactly symmetric. 0.5*max(X-X.T) = ", symmetry_error
Expand All @@ -432,7 +433,8 @@ contains
! Check if the matrix is hermitian
symmetry_error = 0.5*maxval(abs(X - conjg(transpose(X))))
if (symmetry_error > rtol_${kind}$) then
write(msg,*) "Input matrix is not hermitian. 0.5*max(abs(X-X.H)) = ", symmetry_error
write(msg,*) "Input matrix is not hermitian. 0.5*max(abs(X-X.H)) = ", &
& symmetry_error, ", tol = ", rtol_${kind}$
call stop_error(msg, module=this_module, procedure='sqrtm_${type[0]}$${kind}$')
else if (symmetry_error > 10*atol_${kind}$) then
write(msg,*) "Input matrix is not exactly hermitian. 0.5*max(X-X.T) = ", symmetry_error
Expand Down

0 comments on commit a503622

Please sign in to comment.