Sorts an integer array by nondecreasing absolute value.
IA — Integer vector of length N containing the array to be sorted. (Input)
IB — Integer
vector of length N containing the
sorted array. (Output)
If IA is not needed,
IA and IB can share the same
storage locations.
N — Number of
elements in the array to be sorted. (Input)
Default: N = size
(IA,1).
Generic: CALL SVIBN (IA, IB [,…])
Specific: The specific interface name is S_SVIBN.
Single: CALL SVIBN (N, IA, IB)
Routine SVIBN sorts the elements of an integer array, A, into ascending order by absolute value. This routine SVIBN uses the algorithm discussed in SVRGN. On completion, Aj ≤ Ai for j < i.
This example sorts the 10-element array IA by absolute value.
USE SVIBN_INT
USE UMACH_INT
IMPLICIT NONE
! Declare variables
INTEGER I, J, NOUT, N
PARAMETER (N=10)
INTEGER IA(N), IB(N)
! Set values for IA
! IA = ( -1 3 -4 2 -1 0 -7 6 10 -7)
!
DATA IA/-1, 3, -4, 2, -1, 0, -7, 6, 10, -7/
! Sort IA by absolute value into IB
CALL SVIBN (IA, IB)
! Print results
CALL UMACH (2,NOUT)
WRITE (NOUT, 99999) (IB(J),J=1,N)
!
99999 FORMAT (' The output vector is:', /, 10(1X,I5))
END
The Output vector
is:
0 -1 -1
2 3 -4
6 -7 -7 10
Visual Numerics, Inc. PHONE: 713.784.3131 FAX:713.781.9260 |