dnrm2 Function

public function dnrm2(n, x, incx)

euclidean norm of a vector.

Arguments

Type IntentOptional Attributes Name
integer :: n
real(kind=wp) :: x(*)
integer :: incx

Return Value real(kind=wp)


Called by

proc~~dnrm2~~CalledByGraph proc~dnrm2 lsqpblas_module::dnrm2 proc~acheck lsqr_module::lsqr_solver%acheck proc~acheck->proc~dnrm2 proc~lsqr lsqr_module::lsqr_solver%LSQR proc~lsqr->proc~dnrm2 proc~xcheck lsqr_module::lsqr_solver%xcheck proc~xcheck->proc~dnrm2 proc~solve_ez lsqr_module::lsqr_solver_ez%solve_ez proc~solve_ez->proc~lsqr

Source Code

    real(wp) function dnrm2(n,x,incx)

    integer incx,n
    real(wp) x(*)

    real(wp) absxi,norm,scale,ssq
    integer ix

    if (n<1 .or. incx<1) then
        norm = zero
    else if (n==1) then
        norm = abs(x(1))
    else
        scale = zero
        ssq = one

        ! the following loop is equivalent to this call to the lapack
        ! auxiliary routine:
        ! call dlassq( n, x, incx, scale, ssq )

        do ix = 1,1 + (n-1)*incx,incx
            if (x(ix)/=zero) then
                absxi = abs(x(ix))
                if (scale<absxi) then
                    ssq = one + ssq* (scale/absxi)**2
                    scale = absxi
                else
                    ssq = ssq + (absxi/scale)**2
                end if
            end if
        end do
        norm = scale*sqrt(ssq)
    end if

    dnrm2 = norm

    end function dnrm2