| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 | /* dlasrt.f -- translated by f2c (version 20061008).   You must link the resulting object file with libf2c:	on Microsoft Windows system, link with libf2c.lib;	on Linux or Unix systems, link with .../path/to/libf2c.a -lm	or, if you install libf2c.a in a standard place, with -lf2c -lm	-- in that order, at the end of the command line, as in		cc *.o -lf2c -lm	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,		http://www.netlib.org/f2c/libf2c.zip*/#include "f2c.h"#include "blaswrap.h"/* Subroutine */ int _starpu_dlasrt_(char *id, integer *n, doublereal *d__, integer *	info){    /* System generated locals */    integer i__1, i__2;    /* Local variables */    integer i__, j;    doublereal d1, d2, d3;    integer dir;    doublereal tmp;    integer endd;    extern logical _starpu_lsame_(char *, char *);    integer stack[64]	/* was [2][32] */;    doublereal dmnmx;    integer start;    extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);    integer stkpnt;/*  -- LAPACK routine (version 3.2) -- *//*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. *//*     November 2006 *//*     .. Scalar Arguments .. *//*     .. *//*     .. Array Arguments .. *//*     .. *//*  Purpose *//*  ======= *//*  Sort the numbers in D in increasing order (if ID = 'I') or *//*  in decreasing order (if ID = 'D' ). *//*  Use Quick Sort, reverting to Insertion sort on arrays of *//*  size <= 20. Dimension of STACK limits N to about 2**32. *//*  Arguments *//*  ========= *//*  ID      (input) CHARACTER*1 *//*          = 'I': sort D in increasing order; *//*          = 'D': sort D in decreasing order. *//*  N       (input) INTEGER *//*          The length of the array D. *//*  D       (input/output) DOUBLE PRECISION array, dimension (N) *//*          On entry, the array to be sorted. *//*          On exit, D has been sorted into increasing order *//*          (D(1) <= ... <= D(N) ) or into decreasing order *//*          (D(1) >= ... >= D(N) ), depending on ID. *//*  INFO    (output) INTEGER *//*          = 0:  successful exit *//*          < 0:  if INFO = -i, the i-th argument had an illegal value *//*  ===================================================================== *//*     .. Parameters .. *//*     .. *//*     .. Local Scalars .. *//*     .. *//*     .. Local Arrays .. *//*     .. *//*     .. External Functions .. *//*     .. *//*     .. External Subroutines .. *//*     .. *//*     .. Executable Statements .. *//*     Test the input paramters. */    /* Parameter adjustments */    --d__;    /* Function Body */    *info = 0;    dir = -1;    if (_starpu_lsame_(id, "D")) {	dir = 0;    } else if (_starpu_lsame_(id, "I")) {	dir = 1;    }    if (dir == -1) {	*info = -1;    } else if (*n < 0) {	*info = -2;    }    if (*info != 0) {	i__1 = -(*info);	_starpu_xerbla_("DLASRT", &i__1);	return 0;    }/*     Quick return if possible */    if (*n <= 1) {	return 0;    }    stkpnt = 1;    stack[0] = 1;    stack[1] = *n;L10:    start = stack[(stkpnt << 1) - 2];    endd = stack[(stkpnt << 1) - 1];    --stkpnt;    if (endd - start <= 20 && endd - start > 0) {/*        Do Insertion sort on D( START:ENDD ) */	if (dir == 0) {/*           Sort into decreasing order */	    i__1 = endd;	    for (i__ = start + 1; i__ <= i__1; ++i__) {		i__2 = start + 1;		for (j = i__; j >= i__2; --j) {		    if (d__[j] > d__[j - 1]) {			dmnmx = d__[j];			d__[j] = d__[j - 1];			d__[j - 1] = dmnmx;		    } else {			goto L30;		    }/* L20: */		}L30:		;	    }	} else {/*           Sort into increasing order */	    i__1 = endd;	    for (i__ = start + 1; i__ <= i__1; ++i__) {		i__2 = start + 1;		for (j = i__; j >= i__2; --j) {		    if (d__[j] < d__[j - 1]) {			dmnmx = d__[j];			d__[j] = d__[j - 1];			d__[j - 1] = dmnmx;		    } else {			goto L50;		    }/* L40: */		}L50:		;	    }	}    } else if (endd - start > 20) {/*        Partition D( START:ENDD ) and stack parts, largest one first *//*        Choose partition entry as median of 3 */	d1 = d__[start];	d2 = d__[endd];	i__ = (start + endd) / 2;	d3 = d__[i__];	if (d1 < d2) {	    if (d3 < d1) {		dmnmx = d1;	    } else if (d3 < d2) {		dmnmx = d3;	    } else {		dmnmx = d2;	    }	} else {	    if (d3 < d2) {		dmnmx = d2;	    } else if (d3 < d1) {		dmnmx = d3;	    } else {		dmnmx = d1;	    }	}	if (dir == 0) {/*           Sort into decreasing order */	    i__ = start - 1;	    j = endd + 1;L60:L70:	    --j;	    if (d__[j] < dmnmx) {		goto L70;	    }L80:	    ++i__;	    if (d__[i__] > dmnmx) {		goto L80;	    }	    if (i__ < j) {		tmp = d__[i__];		d__[i__] = d__[j];		d__[j] = tmp;		goto L60;	    }	    if (j - start > endd - j - 1) {		++stkpnt;		stack[(stkpnt << 1) - 2] = start;		stack[(stkpnt << 1) - 1] = j;		++stkpnt;		stack[(stkpnt << 1) - 2] = j + 1;		stack[(stkpnt << 1) - 1] = endd;	    } else {		++stkpnt;		stack[(stkpnt << 1) - 2] = j + 1;		stack[(stkpnt << 1) - 1] = endd;		++stkpnt;		stack[(stkpnt << 1) - 2] = start;		stack[(stkpnt << 1) - 1] = j;	    }	} else {/*           Sort into increasing order */	    i__ = start - 1;	    j = endd + 1;L90:L100:	    --j;	    if (d__[j] > dmnmx) {		goto L100;	    }L110:	    ++i__;	    if (d__[i__] < dmnmx) {		goto L110;	    }	    if (i__ < j) {		tmp = d__[i__];		d__[i__] = d__[j];		d__[j] = tmp;		goto L90;	    }	    if (j - start > endd - j - 1) {		++stkpnt;		stack[(stkpnt << 1) - 2] = start;		stack[(stkpnt << 1) - 1] = j;		++stkpnt;		stack[(stkpnt << 1) - 2] = j + 1;		stack[(stkpnt << 1) - 1] = endd;	    } else {		++stkpnt;		stack[(stkpnt << 1) - 2] = j + 1;		stack[(stkpnt << 1) - 1] = endd;		++stkpnt;		stack[(stkpnt << 1) - 2] = start;		stack[(stkpnt << 1) - 1] = j;	    }	}    }    if (stkpnt > 0) {	goto L10;    }    return 0;/*     End of DLASRT */} /* _starpu_dlasrt_ */
 |