 LAPACK  3.10.0 LAPACK: Linear Algebra PACKage

## ◆ dlamrg()

 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.

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.```

Definition at line 98 of file dlamrg.f.

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