Improve clean_zeros

repack-newsolve
sfilippone 3 months ago
parent 108d544fc1
commit 1c235f9281

@ -601,9 +601,12 @@ subroutine psb_c_coo_clean_zeros(a, info)
nzin = a%get_nzeros()
j = 0
do i=1, nzin
cpy = (a%val(i) /= czero)
if (a%val(i) /= czero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
if (.not.cpy) cpy = (a%ia(i) == a%ja(i))
cpy = (a%ia(i) == a%ja(i))
end if
if (cpy) then
j = j + 1
a%val(j) = a%val(i)
@ -5930,12 +5933,19 @@ subroutine psb_lc_coo_clean_zeros(a, info)
integer(psb_ipk_), intent(out) :: info
!
integer(psb_lpk_) :: i,j,k, nzin
logical :: cpy
info = 0
nzin = a%get_nzeros()
j = 0
do i=1, nzin
if (a%val(i) /= czero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
cpy = (a%ia(i) == a%ja(i))
end if
if (cpy) then
j = j + 1
a%val(j) = a%val(i)
a%ia(j) = a%ia(i)

@ -2422,9 +2422,12 @@ subroutine psb_c_csc_clean_zeros(a, info)
j = a%icp(1)
do i=1, nc
do k = ilcp(i), ilcp(i+1) -1
cpy = (a%val(k) /= czero)
if (a%val(k) /= czero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
if (.not.cpy) cpy = (i == a%ia(k))
cpy = (i == a%ia(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ia(j) = a%ia(k)
@ -4317,6 +4320,7 @@ subroutine psb_lc_csc_clean_zeros(a, info)
!
integer(psb_lpk_) :: i, j, k, nc
integer(psb_lpk_), allocatable :: ilcp(:)
logical :: cpy
info = 0
call a%sync()
@ -4327,6 +4331,12 @@ subroutine psb_lc_csc_clean_zeros(a, info)
do i=1, nc
do k = ilcp(i), ilcp(i+1) -1
if (a%val(k) /= czero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
cpy = (i == a%ia(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ia(j) = a%ia(k)
j = j + 1

@ -3643,9 +3643,12 @@ subroutine psb_c_csr_clean_zeros(a, info)
j = a%irp(1)
do i=1, nr
do k = ilrp(i), ilrp(i+1) -1
cpy = (a%val(k) /= czero)
if (a%val(k) /= czero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
if (.not.cpy) cpy = (i == a%ja(k))
cpy = (i == a%ja(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ja(j) = a%ja(k)
@ -6556,6 +6559,7 @@ subroutine psb_lc_csr_clean_zeros(a, info)
!
integer(psb_lpk_) :: i, j, k, nr
integer(psb_lpk_), allocatable :: ilrp(:)
logical :: cpy
info = 0
call a%sync()
@ -6566,6 +6570,12 @@ subroutine psb_lc_csr_clean_zeros(a, info)
do i=1, nr
do k = ilrp(i), ilrp(i+1) -1
if (a%val(k) /= czero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
cpy = (i == a%ja(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ja(j) = a%ja(k)
j = j + 1

@ -601,9 +601,12 @@ subroutine psb_d_coo_clean_zeros(a, info)
nzin = a%get_nzeros()
j = 0
do i=1, nzin
cpy = (a%val(i) /= dzero)
if (a%val(i) /= dzero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
if (.not.cpy) cpy = (a%ia(i) == a%ja(i))
cpy = (a%ia(i) == a%ja(i))
end if
if (cpy) then
j = j + 1
a%val(j) = a%val(i)
@ -5930,12 +5933,19 @@ subroutine psb_ld_coo_clean_zeros(a, info)
integer(psb_ipk_), intent(out) :: info
!
integer(psb_lpk_) :: i,j,k, nzin
logical :: cpy
info = 0
nzin = a%get_nzeros()
j = 0
do i=1, nzin
if (a%val(i) /= dzero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
cpy = (a%ia(i) == a%ja(i))
end if
if (cpy) then
j = j + 1
a%val(j) = a%val(i)
a%ia(j) = a%ia(i)

@ -2422,9 +2422,12 @@ subroutine psb_d_csc_clean_zeros(a, info)
j = a%icp(1)
do i=1, nc
do k = ilcp(i), ilcp(i+1) -1
cpy = (a%val(k) /= dzero)
if (a%val(k) /= dzero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
if (.not.cpy) cpy = (i == a%ia(k))
cpy = (i == a%ia(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ia(j) = a%ia(k)
@ -4317,6 +4320,7 @@ subroutine psb_ld_csc_clean_zeros(a, info)
!
integer(psb_lpk_) :: i, j, k, nc
integer(psb_lpk_), allocatable :: ilcp(:)
logical :: cpy
info = 0
call a%sync()
@ -4327,6 +4331,12 @@ subroutine psb_ld_csc_clean_zeros(a, info)
do i=1, nc
do k = ilcp(i), ilcp(i+1) -1
if (a%val(k) /= dzero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
cpy = (i == a%ia(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ia(j) = a%ia(k)
j = j + 1

@ -3643,9 +3643,12 @@ subroutine psb_d_csr_clean_zeros(a, info)
j = a%irp(1)
do i=1, nr
do k = ilrp(i), ilrp(i+1) -1
cpy = (a%val(k) /= dzero)
if (a%val(k) /= dzero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
if (.not.cpy) cpy = (i == a%ja(k))
cpy = (i == a%ja(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ja(j) = a%ja(k)
@ -6556,6 +6559,7 @@ subroutine psb_ld_csr_clean_zeros(a, info)
!
integer(psb_lpk_) :: i, j, k, nr
integer(psb_lpk_), allocatable :: ilrp(:)
logical :: cpy
info = 0
call a%sync()
@ -6566,6 +6570,12 @@ subroutine psb_ld_csr_clean_zeros(a, info)
do i=1, nr
do k = ilrp(i), ilrp(i+1) -1
if (a%val(k) /= dzero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
cpy = (i == a%ja(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ja(j) = a%ja(k)
j = j + 1

@ -601,9 +601,12 @@ subroutine psb_s_coo_clean_zeros(a, info)
nzin = a%get_nzeros()
j = 0
do i=1, nzin
cpy = (a%val(i) /= szero)
if (a%val(i) /= szero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
if (.not.cpy) cpy = (a%ia(i) == a%ja(i))
cpy = (a%ia(i) == a%ja(i))
end if
if (cpy) then
j = j + 1
a%val(j) = a%val(i)
@ -5930,12 +5933,19 @@ subroutine psb_ls_coo_clean_zeros(a, info)
integer(psb_ipk_), intent(out) :: info
!
integer(psb_lpk_) :: i,j,k, nzin
logical :: cpy
info = 0
nzin = a%get_nzeros()
j = 0
do i=1, nzin
if (a%val(i) /= szero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
cpy = (a%ia(i) == a%ja(i))
end if
if (cpy) then
j = j + 1
a%val(j) = a%val(i)
a%ia(j) = a%ia(i)

@ -2422,9 +2422,12 @@ subroutine psb_s_csc_clean_zeros(a, info)
j = a%icp(1)
do i=1, nc
do k = ilcp(i), ilcp(i+1) -1
cpy = (a%val(k) /= szero)
if (a%val(k) /= szero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
if (.not.cpy) cpy = (i == a%ia(k))
cpy = (i == a%ia(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ia(j) = a%ia(k)
@ -4317,6 +4320,7 @@ subroutine psb_ls_csc_clean_zeros(a, info)
!
integer(psb_lpk_) :: i, j, k, nc
integer(psb_lpk_), allocatable :: ilcp(:)
logical :: cpy
info = 0
call a%sync()
@ -4327,6 +4331,12 @@ subroutine psb_ls_csc_clean_zeros(a, info)
do i=1, nc
do k = ilcp(i), ilcp(i+1) -1
if (a%val(k) /= szero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
cpy = (i == a%ia(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ia(j) = a%ia(k)
j = j + 1

@ -3643,9 +3643,12 @@ subroutine psb_s_csr_clean_zeros(a, info)
j = a%irp(1)
do i=1, nr
do k = ilrp(i), ilrp(i+1) -1
cpy = (a%val(k) /= szero)
if (a%val(k) /= szero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
if (.not.cpy) cpy = (i == a%ja(k))
cpy = (i == a%ja(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ja(j) = a%ja(k)
@ -6556,6 +6559,7 @@ subroutine psb_ls_csr_clean_zeros(a, info)
!
integer(psb_lpk_) :: i, j, k, nr
integer(psb_lpk_), allocatable :: ilrp(:)
logical :: cpy
info = 0
call a%sync()
@ -6566,6 +6570,12 @@ subroutine psb_ls_csr_clean_zeros(a, info)
do i=1, nr
do k = ilrp(i), ilrp(i+1) -1
if (a%val(k) /= szero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
cpy = (i == a%ja(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ja(j) = a%ja(k)
j = j + 1

@ -601,9 +601,12 @@ subroutine psb_z_coo_clean_zeros(a, info)
nzin = a%get_nzeros()
j = 0
do i=1, nzin
cpy = (a%val(i) /= zzero)
if (a%val(i) /= zzero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
if (.not.cpy) cpy = (a%ia(i) == a%ja(i))
cpy = (a%ia(i) == a%ja(i))
end if
if (cpy) then
j = j + 1
a%val(j) = a%val(i)
@ -5930,12 +5933,19 @@ subroutine psb_lz_coo_clean_zeros(a, info)
integer(psb_ipk_), intent(out) :: info
!
integer(psb_lpk_) :: i,j,k, nzin
logical :: cpy
info = 0
nzin = a%get_nzeros()
j = 0
do i=1, nzin
if (a%val(i) /= zzero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
cpy = (a%ia(i) == a%ja(i))
end if
if (cpy) then
j = j + 1
a%val(j) = a%val(i)
a%ia(j) = a%ia(i)

@ -2422,9 +2422,12 @@ subroutine psb_z_csc_clean_zeros(a, info)
j = a%icp(1)
do i=1, nc
do k = ilcp(i), ilcp(i+1) -1
cpy = (a%val(k) /= zzero)
if (a%val(k) /= zzero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
if (.not.cpy) cpy = (i == a%ia(k))
cpy = (i == a%ia(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ia(j) = a%ia(k)
@ -4317,6 +4320,7 @@ subroutine psb_lz_csc_clean_zeros(a, info)
!
integer(psb_lpk_) :: i, j, k, nc
integer(psb_lpk_), allocatable :: ilcp(:)
logical :: cpy
info = 0
call a%sync()
@ -4327,6 +4331,12 @@ subroutine psb_lz_csc_clean_zeros(a, info)
do i=1, nc
do k = ilcp(i), ilcp(i+1) -1
if (a%val(k) /= zzero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
cpy = (i == a%ia(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ia(j) = a%ia(k)
j = j + 1

@ -3643,9 +3643,12 @@ subroutine psb_z_csr_clean_zeros(a, info)
j = a%irp(1)
do i=1, nr
do k = ilrp(i), ilrp(i+1) -1
cpy = (a%val(k) /= zzero)
if (a%val(k) /= zzero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
if (.not.cpy) cpy = (i == a%ja(k))
cpy = (i == a%ja(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ja(j) = a%ja(k)
@ -6556,6 +6559,7 @@ subroutine psb_lz_csr_clean_zeros(a, info)
!
integer(psb_lpk_) :: i, j, k, nr
integer(psb_lpk_), allocatable :: ilrp(:)
logical :: cpy
info = 0
call a%sync()
@ -6566,6 +6570,12 @@ subroutine psb_lz_csr_clean_zeros(a, info)
do i=1, nr
do k = ilrp(i), ilrp(i+1) -1
if (a%val(k) /= zzero) then
cpy = .true.
else
! Always keep the diagonal, even if numerically zero
cpy = (i == a%ja(k))
end if
if (cpy) then
a%val(j) = a%val(k)
a%ja(j) = a%ja(k)
j = j + 1

Loading…
Cancel
Save