This function computes the 1-norm distance between two points.
DISL1 — 1-norm distance between the points X and Y. (Output)
X — Vector of length max(N * |INCX|, 1). (Input)
Y — Vector of length max(N * |INCY|, 1). (Input)
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.
Generic: DISL1 (X, Y [,…])
Specific: The specific interface names are S_DISL1 and D_DISL1.
Single: DISL1(N, X, INCX, Y, INCY)
Double: The double precision function name is DDISL1.
The function DISL1 computes the 1-norm distance between two points x and y. The 1-norm distance is defined to be
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
The 1-norm distance is 12.0000
Visual Numerics, Inc. PHONE: 713.784.3131 FAX:713.781.9260 |