DISL1
This function computes the 1-norm distance between two points.
Function Return Value
DISL1 — 1-norm distance between the points X and Y. (Output)
Required Arguments
X — Vector of length max(N * INCX, 1). (Input)
Y — Vector of length max(N * INCY, 1). (Input)
Optional Arguments
N — Length of the vectors X and Y. (Input)
Default: N = SIZE (X,1).
INCX — Displacement between elements of X. (Input)
The I-th element of X is X(1 + (I  1) * INCX) if INCX is greater than or equal to zero, or X(1 + (I  N* INCX) if INCX is less than zero.
Default: INCX = 1.
INCY — Displacement between elements of Y. (Input)
The I-th element of Y is Y(1 + (I  1) * INCY) if INCY is greater than or equal to zero, or Y(1 + (I  N* INCY) if INCY is less than zero.
Default: INCY = 1.
FORTRAN 90 Interface
Generic: DISL1 (X, Y [])
Specific: The specific interface names are S_DISL1 and D_DISL1.
FORTRAN 77 Interface
Single: DISL1(N, X, INCX, Y, INCY)
Double: The double precision function name is DDISL1.
Description
The function DISL1 computes the 1-norm distance between two points x and y. The 1-norm distance is defined to be
Example
Compute the 1-norm distance between two vectors of length 4.
 
USE DISL1_INT
USE UMACH_INT
 
IMPLICIT NONE
! Declare variables
INTEGER INCX, INCY, N
PARAMETER (N=4)
!
INTEGER NOUT
REAL VAL, X(N), Y(N)
!
! Set values for X and Y
! X = ( 1.0 -1.0 0.0 2.0 )
!
! Y = ( 4.0 2.0 1.0 -3.0 )
!
DATA X/1.0, -1.0, 0.0, 2.0/
DATA Y/4.0, 2.0, 1.0, -3.0/
! Compute L1 distance
VAL = DISL1(X,Y)
! Print results
CALL UMACH (2, NOUT)
WRITE (NOUT,*) ' The 1-norm distance is ', VAL
END
Output
 
The 1-norm distance is 12.0000