![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b DLAMRG 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download DLAMRG + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlamrg.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlamrg.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlamrg.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * SUBROUTINE DLAMRG( N1, N2, A, DTRD1, DTRD2, INDEX ) 00022 * 00023 * .. Scalar Arguments .. 00024 * INTEGER DTRD1, DTRD2, N1, N2 00025 * .. 00026 * .. Array Arguments .. 00027 * INTEGER INDEX( * ) 00028 * DOUBLE PRECISION A( * ) 00029 * .. 00030 * 00031 * 00032 *> \par Purpose: 00033 * ============= 00034 *> 00035 *> \verbatim 00036 *> 00037 *> DLAMRG will create a permutation list which will merge the elements 00038 *> of A (which is composed of two independently sorted sets) into a 00039 *> single set which is sorted in ascending order. 00040 *> \endverbatim 00041 * 00042 * Arguments: 00043 * ========== 00044 * 00045 *> \param[in] N1 00046 *> \verbatim 00047 *> N1 is INTEGER 00048 *> \endverbatim 00049 *> 00050 *> \param[in] N2 00051 *> \verbatim 00052 *> N2 is INTEGER 00053 *> These arguements contain the respective lengths of the two 00054 *> sorted lists to be merged. 00055 *> \endverbatim 00056 *> 00057 *> \param[in] A 00058 *> \verbatim 00059 *> A is DOUBLE PRECISION array, dimension (N1+N2) 00060 *> The first N1 elements of A contain a list of numbers which 00061 *> are sorted in either ascending or descending order. Likewise 00062 *> for the final N2 elements. 00063 *> \endverbatim 00064 *> 00065 *> \param[in] DTRD1 00066 *> \verbatim 00067 *> DTRD1 is INTEGER 00068 *> \endverbatim 00069 *> 00070 *> \param[in] DTRD2 00071 *> \verbatim 00072 *> DTRD2 is INTEGER 00073 *> These are the strides to be taken through the array A. 00074 *> Allowable strides are 1 and -1. They indicate whether a 00075 *> subset of A is sorted in ascending (DTRDx = 1) or descending 00076 *> (DTRDx = -1) order. 00077 *> \endverbatim 00078 *> 00079 *> \param[out] INDEX 00080 *> \verbatim 00081 *> INDEX is INTEGER array, dimension (N1+N2) 00082 *> On exit this array will contain a permutation such that 00083 *> if B( I ) = A( INDEX( I ) ) for I=1,N1+N2, then B will be 00084 *> sorted in ascending order. 00085 *> \endverbatim 00086 * 00087 * Authors: 00088 * ======== 00089 * 00090 *> \author Univ. of Tennessee 00091 *> \author Univ. of California Berkeley 00092 *> \author Univ. of Colorado Denver 00093 *> \author NAG Ltd. 00094 * 00095 *> \date November 2011 00096 * 00097 *> \ingroup auxOTHERcomputational 00098 * 00099 * ===================================================================== 00100 SUBROUTINE DLAMRG( N1, N2, A, DTRD1, DTRD2, INDEX ) 00101 * 00102 * -- LAPACK computational routine (version 3.4.0) -- 00103 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00104 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00105 * November 2011 00106 * 00107 * .. Scalar Arguments .. 00108 INTEGER DTRD1, DTRD2, N1, N2 00109 * .. 00110 * .. Array Arguments .. 00111 INTEGER INDEX( * ) 00112 DOUBLE PRECISION A( * ) 00113 * .. 00114 * 00115 * ===================================================================== 00116 * 00117 * .. Local Scalars .. 00118 INTEGER I, IND1, IND2, N1SV, N2SV 00119 * .. 00120 * .. Executable Statements .. 00121 * 00122 N1SV = N1 00123 N2SV = N2 00124 IF( DTRD1.GT.0 ) THEN 00125 IND1 = 1 00126 ELSE 00127 IND1 = N1 00128 END IF 00129 IF( DTRD2.GT.0 ) THEN 00130 IND2 = 1 + N1 00131 ELSE 00132 IND2 = N1 + N2 00133 END IF 00134 I = 1 00135 * while ( (N1SV > 0) & (N2SV > 0) ) 00136 10 CONTINUE 00137 IF( N1SV.GT.0 .AND. N2SV.GT.0 ) THEN 00138 IF( A( IND1 ).LE.A( IND2 ) ) THEN 00139 INDEX( I ) = IND1 00140 I = I + 1 00141 IND1 = IND1 + DTRD1 00142 N1SV = N1SV - 1 00143 ELSE 00144 INDEX( I ) = IND2 00145 I = I + 1 00146 IND2 = IND2 + DTRD2 00147 N2SV = N2SV - 1 00148 END IF 00149 GO TO 10 00150 END IF 00151 * end while 00152 IF( N1SV.EQ.0 ) THEN 00153 DO 20 N1SV = 1, N2SV 00154 INDEX( I ) = IND2 00155 I = I + 1 00156 IND2 = IND2 + DTRD2 00157 20 CONTINUE 00158 ELSE 00159 * N2SV .EQ. 0 00160 DO 30 N2SV = 1, N1SV 00161 INDEX( I ) = IND1 00162 I = I + 1 00163 IND1 = IND1 + DTRD1 00164 30 CONTINUE 00165 END IF 00166 * 00167 RETURN 00168 * 00169 * End of DLAMRG 00170 * 00171 END