dlamrg.c
Go to the documentation of this file.
00001 /* dlamrg.f -- translated by f2c (version 20061008).
00002    You must link the resulting object file with libf2c:
00003         on Microsoft Windows system, link with libf2c.lib;
00004         on Linux or Unix systems, link with .../path/to/libf2c.a -lm
00005         or, if you install libf2c.a in a standard place, with -lf2c -lm
00006         -- in that order, at the end of the command line, as in
00007                 cc *.o -lf2c -lm
00008         Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
00009 
00010                 http://www.netlib.org/f2c/libf2c.zip
00011 */
00012 
00013 #include "f2c.h"
00014 #include "blaswrap.h"
00015 
00016 /* Subroutine */ int dlamrg_(integer *n1, integer *n2, doublereal *a, integer 
00017         *dtrd1, integer *dtrd2, integer *index)
00018 {
00019     /* System generated locals */
00020     integer i__1;
00021 
00022     /* Local variables */
00023     integer i__, ind1, ind2, n1sv, n2sv;
00024 
00025 
00026 /*  -- LAPACK routine (version 3.2) -- */
00027 /*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
00028 /*     November 2006 */
00029 
00030 /*     .. Scalar Arguments .. */
00031 /*     .. */
00032 /*     .. Array Arguments .. */
00033 /*     .. */
00034 
00035 /*  Purpose */
00036 /*  ======= */
00037 
00038 /*  DLAMRG will create a permutation list which will merge the elements */
00039 /*  of A (which is composed of two independently sorted sets) into a */
00040 /*  single set which is sorted in ascending order. */
00041 
00042 /*  Arguments */
00043 /*  ========= */
00044 
00045 /*  N1     (input) INTEGER */
00046 /*  N2     (input) INTEGER */
00047 /*         These arguements contain the respective lengths of the two */
00048 /*         sorted lists to be merged. */
00049 
00050 /*  A      (input) DOUBLE PRECISION array, dimension (N1+N2) */
00051 /*         The first N1 elements of A contain a list of numbers which */
00052 /*         are sorted in either ascending or descending order.  Likewise */
00053 /*         for the final N2 elements. */
00054 
00055 /*  DTRD1  (input) INTEGER */
00056 /*  DTRD2  (input) INTEGER */
00057 /*         These are the strides to be taken through the array A. */
00058 /*         Allowable strides are 1 and -1.  They indicate whether a */
00059 /*         subset of A is sorted in ascending (DTRDx = 1) or descending */
00060 /*         (DTRDx = -1) order. */
00061 
00062 /*  INDEX  (output) INTEGER array, dimension (N1+N2) */
00063 /*         On exit this array will contain a permutation such that */
00064 /*         if B( I ) = A( INDEX( I ) ) for I=1,N1+N2, then B will be */
00065 /*         sorted in ascending order. */
00066 
00067 /*  ===================================================================== */
00068 
00069 /*     .. Local Scalars .. */
00070 /*     .. */
00071 /*     .. Executable Statements .. */
00072 
00073     /* Parameter adjustments */
00074     --index;
00075     --a;
00076 
00077     /* Function Body */
00078     n1sv = *n1;
00079     n2sv = *n2;
00080     if (*dtrd1 > 0) {
00081         ind1 = 1;
00082     } else {
00083         ind1 = *n1;
00084     }
00085     if (*dtrd2 > 0) {
00086         ind2 = *n1 + 1;
00087     } else {
00088         ind2 = *n1 + *n2;
00089     }
00090     i__ = 1;
00091 /*     while ( (N1SV > 0) & (N2SV > 0) ) */
00092 L10:
00093     if (n1sv > 0 && n2sv > 0) {
00094         if (a[ind1] <= a[ind2]) {
00095             index[i__] = ind1;
00096             ++i__;
00097             ind1 += *dtrd1;
00098             --n1sv;
00099         } else {
00100             index[i__] = ind2;
00101             ++i__;
00102             ind2 += *dtrd2;
00103             --n2sv;
00104         }
00105         goto L10;
00106     }
00107 /*     end while */
00108     if (n1sv == 0) {
00109         i__1 = n2sv;
00110         for (n1sv = 1; n1sv <= i__1; ++n1sv) {
00111             index[i__] = ind2;
00112             ++i__;
00113             ind2 += *dtrd2;
00114 /* L20: */
00115         }
00116     } else {
00117 /*     N2SV .EQ. 0 */
00118         i__1 = n1sv;
00119         for (n2sv = 1; n2sv <= i__1; ++n2sv) {
00120             index[i__] = ind1;
00121             ++i__;
00122             ind1 += *dtrd1;
00123 /* L30: */
00124         }
00125     }
00126 
00127     return 0;
00128 
00129 /*     End of DLAMRG */
00130 
00131 } /* dlamrg_ */


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:46