LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine dlamrg ( integer  N1,
integer  N2,
double precision, dimension( * )  A,
integer  DTRD1,
integer  DTRD2,
integer, dimension( * )  INDEX 
)

DLAMRG creates a permutation list to merge the entries of two independently sorted sets into a single set sorted in ascending order.

Download DLAMRG + dependencies [TGZ] [ZIP] [TXT]

Purpose:
 DLAMRG will create a permutation list which will merge the elements
 of A (which is composed of two independently sorted sets) into a
 single set which is sorted in ascending order.
Parameters
[in]N1
          N1 is INTEGER
[in]N2
          N2 is INTEGER
         These arguments contain the respective lengths of the two
         sorted lists to be merged.
[in]A
          A is DOUBLE PRECISION array, dimension (N1+N2)
         The first N1 elements of A contain a list of numbers which
         are sorted in either ascending or descending order.  Likewise
         for the final N2 elements.
[in]DTRD1
          DTRD1 is INTEGER
[in]DTRD2
          DTRD2 is INTEGER
         These are the strides to be taken through the array A.
         Allowable strides are 1 and -1.  They indicate whether a
         subset of A is sorted in ascending (DTRDx = 1) or descending
         (DTRDx = -1) order.
[out]INDEX
          INDEX is INTEGER array, dimension (N1+N2)
         On exit this array will contain a permutation such that
         if B( I ) = A( INDEX( I ) ) for I=1,N1+N2, then B will be
         sorted in ascending order.
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
June 2016

Definition at line 101 of file dlamrg.f.

101 *
102 * -- LAPACK computational routine (version 3.6.1) --
103 * -- LAPACK is a software package provided by Univ. of Tennessee, --
104 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
105 * June 2016
106 *
107 * .. Scalar Arguments ..
108  INTEGER dtrd1, dtrd2, n1, n2
109 * ..
110 * .. Array Arguments ..
111  INTEGER index( * )
112  DOUBLE PRECISION a( * )
113 * ..
114 *
115 * =====================================================================
116 *
117 * .. Local Scalars ..
118  INTEGER i, ind1, ind2, n1sv, n2sv
119 * ..
120 * .. Executable Statements ..
121 *
122  n1sv = n1
123  n2sv = n2
124  IF( dtrd1.GT.0 ) THEN
125  ind1 = 1
126  ELSE
127  ind1 = n1
128  END IF
129  IF( dtrd2.GT.0 ) THEN
130  ind2 = 1 + n1
131  ELSE
132  ind2 = n1 + n2
133  END IF
134  i = 1
135 * while ( (N1SV > 0) & (N2SV > 0) )
136  10 CONTINUE
137  IF( n1sv.GT.0 .AND. n2sv.GT.0 ) THEN
138  IF( a( ind1 ).LE.a( ind2 ) ) THEN
139  index( i ) = ind1
140  i = i + 1
141  ind1 = ind1 + dtrd1
142  n1sv = n1sv - 1
143  ELSE
144  index( i ) = ind2
145  i = i + 1
146  ind2 = ind2 + dtrd2
147  n2sv = n2sv - 1
148  END IF
149  GO TO 10
150  END IF
151 * end while
152  IF( n1sv.EQ.0 ) THEN
153  DO 20 n1sv = 1, n2sv
154  index( i ) = ind2
155  i = i + 1
156  ind2 = ind2 + dtrd2
157  20 CONTINUE
158  ELSE
159 * N2SV .EQ. 0
160  DO 30 n2sv = 1, n1sv
161  index( i ) = ind1
162  i = i + 1
163  ind1 = ind1 + dtrd1
164  30 CONTINUE
165  END IF
166 *
167  RETURN
168 *
169 * End of DLAMRG
170 *

Here is the caller graph for this function: