SVRBN

Sorts a real array by nondecreasing absolute value.

Required Arguments

RA — Vector of length N containing the array to be sorted.   (Input)

RB — Vector of length N containing the sorted array.   (Output)
If RA is not needed, RA and RB can share the same storage locations.

Optional Arguments

N — Number of elements in the array to be sorted.   (Input)
Default: N = size (RA,1).

FORTRAN 90 Interface

Generic:                              CALL SVRBN (RA, RB [,…])

Specific:                             The specific interface names are S_SVRBN and D_SVRBN.

FORTRAN 77 Interface

Single:                                CALL SVRBN (N, RA, RB)

Double:                              The double precision name is DSVRBN.

Description

Routine SVRBN sorts the elements of an array, A, into ascending order by absolute value. The routine SVRBN uses the algorithm discussed in SVRGN. On completion, |Aj| |Ai| for j < i.

Example

This example sorts the 10-element array RA by absolute value.

 

      USE SVRBN_INT

      USE UMACH_INT

 

      IMPLICIT   NONE

!                                 Declare variables

      INTEGER N, J, NOUT

      PARAMETER  (N=10)

      REAL       RA(N), RB(N)

!                                 Set values for  RA

!       RA = ( -1.0  3.0  -4.0  2.0  -1.0  0.0  -7.0  6.0  10.0  -7.0 )

!

      DATA RA/-1.0, 3.0, -4.0, 2.0, -1.0, 0.0, -7.0, 6.0, 10.0, -7.0/

!                                 Sort RA by absolute value into RB

      CALL SVRBN (RA, RB)

!                                 Print results

      CALL UMACH (2,NOUT)

      WRITE (NOUT, 99999) (RB(J),J=1,N)

!

99999 FORMAT ('  The output vector is :', /, 10(1X,F5.1))

      END

Output

 

The Output vector is :
0.0  -1.0  -1.0   2.0   3.0  -4.0   6.0  -7.0  -7.0  10.0


Visual Numerics, Inc.
Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260