NORMALIZE Function

public pure function NORMALIZE(v1, nVal) result(normalize)

normalizes a nDim vector with respect to the eucledian norm

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: v1(nVal)

vector

integer, intent(in) :: nVal

vector size

Return Value real(kind=wp), (nVal)

result, normalized vector


Source Code

PURE FUNCTION NORMALIZE(v1,nVal)
  ! MODULES
  IMPLICIT NONE
  ! INPUT/OUTPUT VARIABLES ------------------------------------------------------------------------------------------------------!
  INTEGER,INTENT(IN)  :: nVal     !! vector size
  REAL(wp),INTENT(IN) :: v1(nVal) !! vector
  REAL(wp)            :: normalize(nVal) !! result, normalized vector
  ! LOCAL VARIABLES -------------------------------------------------------------------------------------------------------------!
  ! CODE ------------------------------------------------------------------------------------------------------------------------!
  normalize=v1/SQRT(SUM(v1*v1))
END FUNCTION NORMALIZE