PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
dlaord.f
Go to the documentation of this file.
1  SUBROUTINE dlaord( JOB, N, X, INCX )
2 *
3 * -- LAPACK auxiliary routine (version 3.1) --
4 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
5 * November 2006
6 *
7 * .. Scalar Arguments ..
8  CHARACTER job
9  INTEGER incx, n
10 * ..
11 * .. Array Arguments ..
12  DOUBLE PRECISION x( * )
13 * ..
14 *
15 * Purpose
16 * =======
17 *
18 * DLAORD sorts the elements of a vector x in increasing or decreasing
19 * order.
20 *
21 * Arguments
22 * =========
23 *
24 * JOB (input) CHARACTER
25 * = 'I': Sort in increasing order
26 * = 'D': Sort in decreasing order
27 *
28 * N (input) INTEGER
29 * The length of the vector X.
30 *
31 * X (input/output) DOUBLE PRECISION array, dimension
32 * (1+(N-1)*INCX)
33 * On entry, the vector of length n to be sorted.
34 * On exit, the vector x is sorted in the prescribed order.
35 *
36 * INCX (input) INTEGER
37 * The spacing between successive elements of X. INCX >= 0.
38 *
39 * =====================================================================
40 *
41 * .. Local Scalars ..
42  INTEGER i, inc, ix, ixnext
43  DOUBLE PRECISION temp
44 * ..
45 * .. External Functions ..
46  LOGICAL lsame
47  EXTERNAL lsame
48 * ..
49 * .. Intrinsic Functions ..
50  INTRINSIC abs
51 * ..
52 * .. Executable Statements ..
53 *
54  inc = abs( incx )
55  IF( lsame( job, 'I' ) ) THEN
56 *
57 * Sort in increasing order
58 *
59  DO 20 i = 2, n
60  ix = 1 + ( i-1 )*inc
61  10 continue
62  IF( ix.EQ.1 )
63  $ go to 20
64  ixnext = ix - inc
65  IF( x( ix ).GT.x( ixnext ) ) THEN
66  go to 20
67  ELSE
68  temp = x( ix )
69  x( ix ) = x( ixnext )
70  x( ixnext ) = temp
71  END IF
72  ix = ixnext
73  go to 10
74  20 continue
75 *
76  ELSE IF( lsame( job, 'D' ) ) THEN
77 *
78 * Sort in decreasing order
79 *
80  DO 40 i = 2, n
81  ix = 1 + ( i-1 )*inc
82  30 continue
83  IF( ix.EQ.1 )
84  $ go to 40
85  ixnext = ix - inc
86  IF( x( ix ).LT.x( ixnext ) ) THEN
87  go to 40
88  ELSE
89  temp = x( ix )
90  x( ix ) = x( ixnext )
91  x( ixnext ) = temp
92  END IF
93  ix = ixnext
94  go to 30
95  40 continue
96  END IF
97  return
98 *
99 * End of DLAORD
100 *
101  END