solve_ez Subroutine

private subroutine solve_ez(me, b, damp, x, istop, se, itn, anorm, acond, rnorm, arnorm, xnorm)

Wrapper for LSQR for the easy version of the class.

Type Bound

lsqr_solver_ez

Arguments

Type IntentOptional Attributes Name
class(lsqr_solver_ez), intent(inout) :: me
real(kind=wp), intent(in), dimension(me%m) :: b
real(kind=wp), intent(in) :: damp
real(kind=wp), intent(out), dimension(me%n) :: x

the computed solution x.

integer, intent(out) :: istop

exit code (see LSQR).

real(kind=wp), intent(out), optional, dimension(me%n) :: se
integer, intent(out), optional :: itn
real(kind=wp), intent(out), optional :: anorm
real(kind=wp), intent(out), optional :: acond
real(kind=wp), intent(out), optional :: rnorm
real(kind=wp), intent(out), optional :: arnorm
real(kind=wp), intent(out), optional :: xnorm

Calls

proc~~solve_ez~~CallsGraph proc~solve_ez lsqr_module::lsqr_solver_ez%solve_ez proc~lsqr lsqr_module::lsqr_solver%LSQR proc~solve_ez->proc~lsqr aprod aprod proc~lsqr->aprod proc~d2norm lsqr_module::d2norm proc~lsqr->proc~d2norm proc~dcopy lsqpblas_module::dcopy proc~lsqr->proc~dcopy proc~dnrm2 lsqpblas_module::dnrm2 proc~lsqr->proc~dnrm2 proc~dscal lsqpblas_module::dscal proc~lsqr->proc~dscal

Source Code

   subroutine solve_ez( me, b, damp, x, istop, &
                        se, itn, anorm, acond, rnorm, arnorm, xnorm)

   implicit none

   class(lsqr_solver_ez),intent(inout)   :: me
   real(wp),dimension(me%m),intent(in)   :: b
   real(wp),intent(in)                   :: damp
   real(wp),dimension(me%n),intent(out)  :: x       !! the computed solution `x`.
   integer,intent(out)                   :: istop   !! exit code (see [[lsqr]]).
   real(wp),dimension(me%n),intent(out),optional :: se
   integer,intent(out) ,optional         :: itn
   real(wp),intent(out),optional         :: anorm
   real(wp),intent(out),optional         :: acond
   real(wp),intent(out),optional         :: rnorm
   real(wp),intent(out),optional         :: arnorm
   real(wp),intent(out),optional         :: xnorm

   real(wp),dimension(:),allocatable :: u  !! copy of `b` for call to [[lsqr]]
   real(wp),dimension(:),allocatable :: se_
   logical  :: wantse   !! if `se` is to be returned
   integer  :: itn_
   real(wp) :: anorm_,acond_,rnorm_,arnorm_,xnorm_

   ! get optional inputs:
   wantse = present(se)
   if (wantse) then
      allocate(se_(me%n))
   else
      allocate(se_(1)) ! not needed
   end if
   allocate(u(me%m))
   if (.not. allocated(me%v)) allocate(me%v(me%n))
   if (.not. allocated(me%w)) allocate(me%w(me%n))

   u = b    ! make a copy for input to lsqr (since it will be overwritten)

   ! main routine:
   call me%lsqr(me%m, me%n, damp, wantse, &
                u, me%v, me%w, x, se_, &
                me%atol, me%btol, me%conlim, me%itnlim, me%nout, &
                istop, itn_, anorm_, acond_, rnorm_, arnorm_, xnorm_)

   ! optional outputs:
   if (wantse)          se     = se_
   if (present(itn))    itn    = itn_
   if (present(anorm))  anorm  = anorm_
   if (present(acond))  acond  = acond_
   if (present(rnorm))  rnorm  = rnorm_
   if (present(arnorm)) arnorm = arnorm_
   if (present(xnorm))  xnorm  = xnorm_

   end subroutine solve_ez