renormalise_norm Subroutine

public subroutine renormalise_norm(input, norm, mirror)

Renormalise input data to a unit norm

Arguments

Type IntentOptional Attributes Name
real(kind=real32), intent(inout), dimension(:) :: input

Input data to be renormalised

real(kind=real32), intent(in), optional :: norm

Desired norm value

logical, intent(in), optional :: mirror

Boolean whether the data should be mirrored


Source Code

  subroutine renormalise_norm(input, norm, mirror)
    !! Renormalise input data to a unit norm
    implicit none

    ! Arguments
    real(real32), dimension(:), intent(inout) :: input
    !! Input data to be renormalised
    real(real32), optional, intent(in) :: norm
    !! Desired norm value
    logical, optional, intent(in) :: mirror
    !! Boolean whether the data should be mirrored

    ! Local variables
    real(real32) :: scale
    !! Scaling factor

    if(present(norm))then
       scale = norm
    else
       scale = 1._real32
    end if

    if(present(mirror))then
       if(mirror) call linear_renormalise(input)
    end if
    input = input * scale/sqrt(dot_product(input,input))
  end subroutine renormalise_norm