Function that returns the Euclidean norm of a vector .
Note
Replaced original SLSQP routine with this one from BLAS.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | n | |||
real(kind=wp), | intent(in), | dimension(*) | :: | x | ||
integer, | intent(in) | :: | incx |
real(wp) function dnrm2(n,x,incx) implicit none integer,intent(in) :: incx integer,intent(in) :: n real(wp),dimension(*),intent(in) :: 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