|
|
|
@ -39,12 +39,12 @@
|
|
|
|
|
! where sub( X ) denotes X(:,JX).
|
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
! x - real,dimension(:,:). The input vector containing the entries of X.
|
|
|
|
|
! x(:,:) - real The input vector containing the entries of sub( X ).
|
|
|
|
|
! desc_a - type(psb_desc_type). The communication descriptor.
|
|
|
|
|
! info - integer. Return code
|
|
|
|
|
! jx - integer(optional). The column offset for X .
|
|
|
|
|
! jx - integer(optional). The column offset for sub( X ).
|
|
|
|
|
!
|
|
|
|
|
function psb_dnrm2(x, desc_a, info, jx)
|
|
|
|
|
function psb_dnrm2(x, desc_a, info, jx) result(res)
|
|
|
|
|
use psb_descriptor_type
|
|
|
|
|
use psb_check_mod
|
|
|
|
|
use psb_error_mod
|
|
|
|
@ -55,17 +55,16 @@ function psb_dnrm2(x, desc_a, info, jx)
|
|
|
|
|
type(psb_desc_type), intent(in) :: desc_a
|
|
|
|
|
integer(psb_ipk_), intent(in), optional :: jx
|
|
|
|
|
integer(psb_ipk_), intent(out) :: info
|
|
|
|
|
real(psb_dpk_) :: psb_dnrm2
|
|
|
|
|
real(psb_dpk_) :: res
|
|
|
|
|
|
|
|
|
|
! locals
|
|
|
|
|
integer(psb_ipk_) :: ictxt, np, me,&
|
|
|
|
|
& err_act, iix, jjx, ndim, ix, ijx, i, m, id, idx, ndm
|
|
|
|
|
real(psb_dpk_) :: nrm2, dnrm2, dd
|
|
|
|
|
!!$ external dcombnrm2
|
|
|
|
|
& err_act, iix, jjx, ndim, ix, ijx, i, m, id, idx, ndm, ldx
|
|
|
|
|
real(psb_dpk_) :: dnrm2, dd
|
|
|
|
|
character(len=20) :: name, ch_err
|
|
|
|
|
|
|
|
|
|
name='psb_dnrm2'
|
|
|
|
|
if (psb_errstatus_fatal()) return
|
|
|
|
|
if(psb_get_errstatus() /= 0) return
|
|
|
|
|
info=psb_success_
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
|
|
|
|
@ -86,7 +85,8 @@ function psb_dnrm2(x, desc_a, info, jx)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
m = desc_a%get_global_rows()
|
|
|
|
|
call psb_chkvect(m,1,size(x,1),ix,ijx,desc_a,info,iix,jjx)
|
|
|
|
|
ldx = size(x,1)
|
|
|
|
|
call psb_chkvect(m,ione,ldx,ix,ijx,desc_a,info,iix,jjx)
|
|
|
|
|
if(info /= psb_success_) then
|
|
|
|
|
info=psb_err_from_subroutine_
|
|
|
|
|
ch_err='psb_chkvect'
|
|
|
|
@ -99,29 +99,22 @@ function psb_dnrm2(x, desc_a, info, jx)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
if(m /= 0) then
|
|
|
|
|
if (desc_a%get_local_rows() > 0) then
|
|
|
|
|
ndim = desc_a%get_local_rows()
|
|
|
|
|
nrm2 = dnrm2( ndim, x(iix:,jjx), ione )
|
|
|
|
|
res = dnrm2( int(ndim,kind=psb_mpik_), x(iix:,jjx), int(ione,kind=psb_mpik_) )
|
|
|
|
|
|
|
|
|
|
! adjust because overlapped elements are computed more than once
|
|
|
|
|
do i=1,size(desc_a%ovrlap_elem,1)
|
|
|
|
|
idx = desc_a%ovrlap_elem(i,1)
|
|
|
|
|
ndm = desc_a%ovrlap_elem(i,2)
|
|
|
|
|
dd = dble(ndm-1)/dble(ndm)
|
|
|
|
|
nrm2 = nrm2 * sqrt(done - dd*(abs(x(idx,jjx))/nrm2)**2)
|
|
|
|
|
dd = real(ndm-1)/real(ndm)
|
|
|
|
|
res = res * sqrt(sone - dd*(abs(x(idx,jjx))/res)**2)
|
|
|
|
|
end do
|
|
|
|
|
else
|
|
|
|
|
nrm2 = dzero
|
|
|
|
|
end if
|
|
|
|
|
else
|
|
|
|
|
nrm2 = dzero
|
|
|
|
|
res = dzero
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
!!$ call pdtreecomb(ictxt,'All',1,nrm2,-1,-1,dcombnrm2)
|
|
|
|
|
call psb_nrm2(ictxt,nrm2)
|
|
|
|
|
|
|
|
|
|
psb_dnrm2 = nrm2
|
|
|
|
|
call psb_nrm2(ictxt,res)
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
@ -176,11 +169,11 @@ end function psb_dnrm2
|
|
|
|
|
! norm2 := sqrt ( X**T * X)
|
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
! x - real,dimension(:). The input vector containing the entries of X.
|
|
|
|
|
! x(:) - real The input vector containing the entries of X.
|
|
|
|
|
! desc_a - type(psb_desc_type). The communication descriptor.
|
|
|
|
|
! info - integer. Return code
|
|
|
|
|
!
|
|
|
|
|
function psb_dnrm2v(x, desc_a, info)
|
|
|
|
|
function psb_dnrm2v(x, desc_a, info) result(res)
|
|
|
|
|
use psb_descriptor_type
|
|
|
|
|
use psb_check_mod
|
|
|
|
|
use psb_error_mod
|
|
|
|
@ -190,17 +183,18 @@ function psb_dnrm2v(x, desc_a, info)
|
|
|
|
|
real(psb_dpk_), intent(in) :: x(:)
|
|
|
|
|
type(psb_desc_type), intent(in) :: desc_a
|
|
|
|
|
integer(psb_ipk_), intent(out) :: info
|
|
|
|
|
real(psb_dpk_) :: psb_dnrm2v
|
|
|
|
|
real(psb_dpk_) :: res
|
|
|
|
|
|
|
|
|
|
! locals
|
|
|
|
|
integer(psb_ipk_) :: ictxt, np, me,&
|
|
|
|
|
& err_act, iix, jjx, ndim, ix, jx, i, m, id, idx, ndm
|
|
|
|
|
real(psb_dpk_) :: nrm2, dnrm2, dd
|
|
|
|
|
!!$ external dcombnrm2
|
|
|
|
|
& err_act, iix, jjx, ndim, ix, jx, i, m, id, idx, ndm, ldx
|
|
|
|
|
real(psb_dpk_) :: dnrm2, dd
|
|
|
|
|
|
|
|
|
|
!!$ external scombnrm2
|
|
|
|
|
character(len=20) :: name, ch_err
|
|
|
|
|
|
|
|
|
|
name='psb_dnrm2v'
|
|
|
|
|
if (psb_errstatus_fatal()) return
|
|
|
|
|
if(psb_get_errstatus() /= 0) return
|
|
|
|
|
info=psb_success_
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
|
|
|
|
@ -216,8 +210,8 @@ function psb_dnrm2v(x, desc_a, info)
|
|
|
|
|
ix = 1
|
|
|
|
|
jx=1
|
|
|
|
|
m = desc_a%get_global_rows()
|
|
|
|
|
|
|
|
|
|
call psb_chkvect(m,1,size(x),ix,jx,desc_a,info,iix,jjx)
|
|
|
|
|
ldx = size(x,1)
|
|
|
|
|
call psb_chkvect(m,ione,ldx,ix,jx,desc_a,info,iix,jjx)
|
|
|
|
|
if(info /= psb_success_) then
|
|
|
|
|
info=psb_err_from_subroutine_
|
|
|
|
|
ch_err='psb_chkvect'
|
|
|
|
@ -230,28 +224,22 @@ function psb_dnrm2v(x, desc_a, info)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
if(m /= 0) then
|
|
|
|
|
if (desc_a%get_local_rows() > 0) then
|
|
|
|
|
ndim = desc_a%get_local_rows()
|
|
|
|
|
nrm2 = dnrm2( ndim, x, ione )
|
|
|
|
|
res = dnrm2( int(ndim,kind=psb_mpik_), x, int(ione,kind=psb_mpik_) )
|
|
|
|
|
! adjust because overlapped elements are computed more than once
|
|
|
|
|
do i=1,size(desc_a%ovrlap_elem,1)
|
|
|
|
|
idx = desc_a%ovrlap_elem(i,1)
|
|
|
|
|
ndm = desc_a%ovrlap_elem(i,2)
|
|
|
|
|
dd = dble(ndm-1)/dble(ndm)
|
|
|
|
|
nrm2 = nrm2 * sqrt(done - dd*(abs(x(idx))/nrm2)**2)
|
|
|
|
|
dd = real(ndm-1)/real(ndm)
|
|
|
|
|
res = res * sqrt(sone - dd*(abs(x(idx))/res)**2)
|
|
|
|
|
end do
|
|
|
|
|
else
|
|
|
|
|
nrm2 = dzero
|
|
|
|
|
end if
|
|
|
|
|
else
|
|
|
|
|
nrm2 = dzero
|
|
|
|
|
res = dzero
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
!!$ call pdtreecomb(ictxt,'All',1,nrm2,-1,-1,dcombnrm2)
|
|
|
|
|
call psb_nrm2(ictxt,nrm2)
|
|
|
|
|
call psb_nrm2(ictxt,res)
|
|
|
|
|
|
|
|
|
|
psb_dnrm2v = nrm2
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
@ -267,6 +255,7 @@ function psb_dnrm2v(x, desc_a, info)
|
|
|
|
|
end function psb_dnrm2v
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function psb_dnrm2_vect(x, desc_a, info) result(res)
|
|
|
|
|
use psb_descriptor_type
|
|
|
|
|
use psb_check_mod
|
|
|
|
@ -282,8 +271,8 @@ function psb_dnrm2_vect(x, desc_a, info) result(res)
|
|
|
|
|
|
|
|
|
|
! locals
|
|
|
|
|
integer(psb_ipk_) :: ictxt, np, me,&
|
|
|
|
|
& err_act, iix, jjx, ndim, ix, jx, i, m, id, idx, ndm
|
|
|
|
|
real(psb_dpk_) :: nrm2, dnrm2, dd
|
|
|
|
|
& err_act, iix, jjx, ndim, ix, jx, i, m, id, idx, ndm, ldx
|
|
|
|
|
real(psb_dpk_) :: snrm2, dd
|
|
|
|
|
!!$ external dcombnrm2
|
|
|
|
|
character(len=20) :: name, ch_err
|
|
|
|
|
|
|
|
|
@ -311,8 +300,8 @@ function psb_dnrm2_vect(x, desc_a, info) result(res)
|
|
|
|
|
ix = 1
|
|
|
|
|
jx=1
|
|
|
|
|
m = desc_a%get_global_rows()
|
|
|
|
|
|
|
|
|
|
call psb_chkvect(m,1,x%get_nrows(),ix,jx,desc_a,info,iix,jjx)
|
|
|
|
|
ldx = x%get_nrows()
|
|
|
|
|
call psb_chkvect(m,ione,ldx,ix,jx,desc_a,info,iix,jjx)
|
|
|
|
|
if(info /= psb_success_) then
|
|
|
|
|
info=psb_err_from_subroutine_
|
|
|
|
|
ch_err='psb_chkvect'
|
|
|
|
@ -325,10 +314,9 @@ function psb_dnrm2_vect(x, desc_a, info) result(res)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
if(m /= 0) then
|
|
|
|
|
if (desc_a%get_local_rows() > 0) then
|
|
|
|
|
ndim = desc_a%get_local_rows()
|
|
|
|
|
nrm2 = x%nrm2(ndim)
|
|
|
|
|
res = x%nrm2(ndim)
|
|
|
|
|
!!$ ! adjust because overlapped elements are computed more than once
|
|
|
|
|
!!$ do i=1,size(desc_a%ovrlap_elem,1)
|
|
|
|
|
!!$ idx = desc_a%ovrlap_elem(i,1)
|
|
|
|
@ -337,16 +325,10 @@ function psb_dnrm2_vect(x, desc_a, info) result(res)
|
|
|
|
|
!!$ nrm2 = nrm2 * sqrt(done - dd*(abs(x(idx))/nrm2)**2)
|
|
|
|
|
!!$ end do
|
|
|
|
|
else
|
|
|
|
|
nrm2 = dzero
|
|
|
|
|
end if
|
|
|
|
|
else
|
|
|
|
|
nrm2 = dzero
|
|
|
|
|
res = dzero
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
!!$ call pdtreecomb(ictxt,'All',1,nrm2,-1,-1,dcombnrm2)
|
|
|
|
|
call psb_nrm2(ictxt,nrm2)
|
|
|
|
|
|
|
|
|
|
res = nrm2
|
|
|
|
|
call psb_nrm2(ictxt,res)
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
@ -363,8 +345,6 @@ end function psb_dnrm2_vect
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
!!$
|
|
|
|
|
!!$ Parallel Sparse BLAS version 3.0
|
|
|
|
|
!!$ (C) Copyright 2006, 2007, 2008, 2009, 2010
|
|
|
|
@ -400,11 +380,11 @@ end function psb_dnrm2_vect
|
|
|
|
|
! Subroutine: psb_dnrm2vs
|
|
|
|
|
! Forms the norm2 of a distributed vector,
|
|
|
|
|
!
|
|
|
|
|
! res := sqrt ( X**T * X)
|
|
|
|
|
! norm2 := sqrt ( X**T * X)
|
|
|
|
|
!
|
|
|
|
|
! Arguments:
|
|
|
|
|
! res - real. The result.
|
|
|
|
|
! x - real,dimension(:). The input vector containing the entries of X.
|
|
|
|
|
! res - real The result.
|
|
|
|
|
! x(:) - real The input vector containing the entries of X.
|
|
|
|
|
! desc_a - type(psb_desc_type). The communication descriptor.
|
|
|
|
|
! info - integer. Return code
|
|
|
|
|
!
|
|
|
|
@ -422,13 +402,14 @@ subroutine psb_dnrm2vs(res, x, desc_a, info)
|
|
|
|
|
|
|
|
|
|
! locals
|
|
|
|
|
integer(psb_ipk_) :: ictxt, np, me,&
|
|
|
|
|
& err_act, iix, jjx, ndim, ix, jx, i, m, id, idx, ndm
|
|
|
|
|
& err_act, iix, jjx, ndim, ix, jx, i, m, id, idx, ndm, ldx
|
|
|
|
|
real(psb_dpk_) :: nrm2, dnrm2, dd
|
|
|
|
|
!!$ external dcombnrm2
|
|
|
|
|
|
|
|
|
|
!!$ external scombnrm2
|
|
|
|
|
character(len=20) :: name, ch_err
|
|
|
|
|
|
|
|
|
|
name='psb_dnrm2'
|
|
|
|
|
if (psb_errstatus_fatal()) return
|
|
|
|
|
if(psb_get_errstatus() /= 0) return
|
|
|
|
|
info=psb_success_
|
|
|
|
|
call psb_erractionsave(err_act)
|
|
|
|
|
|
|
|
|
@ -444,8 +425,8 @@ subroutine psb_dnrm2vs(res, x, desc_a, info)
|
|
|
|
|
ix = 1
|
|
|
|
|
jx = 1
|
|
|
|
|
m = desc_a%get_global_rows()
|
|
|
|
|
|
|
|
|
|
call psb_chkvect(m,1,size(x),ix,jx,desc_a,info,iix,jjx)
|
|
|
|
|
ldx = size(x,1)
|
|
|
|
|
call psb_chkvect(m,ione,ldx,ix,jx,desc_a,info,iix,jjx)
|
|
|
|
|
if(info /= psb_success_) then
|
|
|
|
|
info=psb_err_from_subroutine_
|
|
|
|
|
ch_err='psb_chkvect'
|
|
|
|
@ -458,28 +439,23 @@ subroutine psb_dnrm2vs(res, x, desc_a, info)
|
|
|
|
|
goto 9999
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
if(m /= 0) then
|
|
|
|
|
if (desc_a%get_local_rows() > 0) then
|
|
|
|
|
ndim = desc_a%get_local_rows()
|
|
|
|
|
nrm2 = dnrm2( ndim, x, ione )
|
|
|
|
|
res = dnrm2( int(ndim,kind=psb_mpik_), x, int(ione,kind=psb_mpik_) )
|
|
|
|
|
|
|
|
|
|
! adjust because overlapped elements are computed more than once
|
|
|
|
|
do i=1,size(desc_a%ovrlap_elem,1)
|
|
|
|
|
idx = desc_a%ovrlap_elem(i,1)
|
|
|
|
|
ndm = desc_a%ovrlap_elem(i,2)
|
|
|
|
|
dd = dble(ndm-1)/dble(ndm)
|
|
|
|
|
nrm2 = nrm2 * sqrt(done - dd*(abs(x(idx))/nrm2)**2)
|
|
|
|
|
dd = real(ndm-1)/real(ndm)
|
|
|
|
|
res = res * sqrt(sone - dd*(abs(x(idx))/res)**2)
|
|
|
|
|
end do
|
|
|
|
|
else
|
|
|
|
|
nrm2 = dzero
|
|
|
|
|
end if
|
|
|
|
|
else
|
|
|
|
|
nrm2 = dzero
|
|
|
|
|
res = dzero
|
|
|
|
|
end if
|
|
|
|
|
|
|
|
|
|
!!$ call pdtreecomb(ictxt,'All',1,nrm2,-1,-1,dcombnrm2)
|
|
|
|
|
call psb_nrm2(ictxt,nrm2)
|
|
|
|
|
call psb_nrm2(ictxt,res)
|
|
|
|
|
|
|
|
|
|
res = nrm2
|
|
|
|
|
|
|
|
|
|
call psb_erractionrestore(err_act)
|
|
|
|
|
return
|
|
|
|
|