ddwnrm Function

pure function ddwnrm(neq, v, rwt, rpar, ipar)

Uses

  • proc~~ddwnrm~~UsesGraph proc~ddwnrm ddwnrm module~daskr_kinds daskr_kinds proc~ddwnrm->module~daskr_kinds iso_fortran_env iso_fortran_env module~daskr_kinds->iso_fortran_env

This function computes the weighted root-mean-square norm of the vector v with reciprocal weights rwt:

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: neq

Vector length.

real(kind=rk), intent(in) :: v(neq)

Vector.

real(kind=rk), intent(in) :: rwt(neq)

Reciprocal weights.

real(kind=rk), intent(in) :: rpar(*)

User real workspace.

integer, intent(in) :: ipar(*)

User integer workspace.

Return Value real(kind=rk)


Variables

Type Visibility Attributes Name Initial
integer, public :: i
real(kind=rk), public :: accum
real(kind=rk), public :: vmax

Source Code

real(rk) pure function ddwnrm(neq, v, rwt, rpar, ipar)
!! This function computes the weighted root-mean-square norm of the vector `v` with
!! reciprocal weights `rwt`:
!!
!! $$ \sqrt{ \frac{1}{N} \sum_{i=1}^N \left( v_i \cdot w_i \right)^2 } $$

   use daskr_kinds, only: rk, zero
   implicit none

   integer, intent(in) :: neq
      !! Vector length.
   real(rk), intent(in) :: v(neq)
      !! Vector.
   real(rk), intent(in) :: rwt(neq)
      !! Reciprocal weights.
   real(rk), intent(in) :: rpar(*)
      !! User real workspace.
   integer, intent(in) :: ipar(*)
      !! User integer workspace.

   integer :: i
   real(rk) :: accum, vmax

   ddwnrm = zero
   vmax = zero
   do i = 1, neq
      if (abs(v(i)*rwt(i)) .gt. vmax) then
         vmax = abs(v(i)*rwt(i))
      end if
   end do

   if (vmax .le. zero) return

   accum = zero
   do i = 1, neq
      accum = accum + ((v(i)*rwt(i))/vmax)**2
   end do

   ddwnrm = vmax*sqrt(accum/neq)

end function ddwnrm