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
dlaqge.f
Go to the documentation of this file.
1  SUBROUTINE dlaqge( M, N, A, LDA, R, C, ROWCND, COLCND, AMAX,
2  $ equed )
3 *
4 * -- LAPACK auxiliary routine (version 3.2) --
5 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
6 * November 2006
7 *
8 * .. Scalar Arguments ..
9  CHARACTER equed
10  INTEGER lda, m, n
11  DOUBLE PRECISION amax, colcnd, rowcnd
12 * ..
13 * .. Array Arguments ..
14  DOUBLE PRECISION a( lda, * ), c( * ), r( * )
15 * ..
16 *
17 * Purpose
18 * =======
19 *
20 * DLAQGE equilibrates a general M by N matrix A using the row and
21 * column scaling factors in the vectors R and C.
22 *
23 * Arguments
24 * =========
25 *
26 * M (input) INTEGER
27 * The number of rows of the matrix A. M >= 0.
28 *
29 * N (input) INTEGER
30 * The number of columns of the matrix A. N >= 0.
31 *
32 * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
33 * On entry, the M by N matrix A.
34 * On exit, the equilibrated matrix. See EQUED for the form of
35 * the equilibrated matrix.
36 *
37 * LDA (input) INTEGER
38 * The leading dimension of the array A. LDA >= max(M,1).
39 *
40 * R (input) DOUBLE PRECISION array, dimension (M)
41 * The row scale factors for A.
42 *
43 * C (input) DOUBLE PRECISION array, dimension (N)
44 * The column scale factors for A.
45 *
46 * ROWCND (input) DOUBLE PRECISION
47 * Ratio of the smallest R(i) to the largest R(i).
48 *
49 * COLCND (input) DOUBLE PRECISION
50 * Ratio of the smallest C(i) to the largest C(i).
51 *
52 * AMAX (input) DOUBLE PRECISION
53 * Absolute value of largest matrix entry.
54 *
55 * EQUED (output) CHARACTER*1
56 * Specifies the form of equilibration that was done.
57 * = 'N': No equilibration
58 * = 'R': Row equilibration, i.e., A has been premultiplied by
59 * diag(R).
60 * = 'C': Column equilibration, i.e., A has been postmultiplied
61 * by diag(C).
62 * = 'B': Both row and column equilibration, i.e., A has been
63 * replaced by diag(R) * A * diag(C).
64 *
65 * Internal Parameters
66 * ===================
67 *
68 * THRESH is a threshold value used to decide if row or column scaling
69 * should be done based on the ratio of the row or column scaling
70 * factors. If ROWCND < THRESH, row scaling is done, and if
71 * COLCND < THRESH, column scaling is done.
72 *
73 * LARGE and SMALL are threshold values used to decide if row scaling
74 * should be done based on the absolute size of the largest matrix
75 * element. If AMAX > LARGE or AMAX < SMALL, row scaling is done.
76 *
77 * =====================================================================
78 *
79 * .. Parameters ..
80  DOUBLE PRECISION one, thresh
81  parameter( one = 1.0d+0, thresh = 0.1d+0 )
82 * ..
83 * .. Local Scalars ..
84  INTEGER i, j
85  DOUBLE PRECISION cj, large, small
86 * ..
87 * .. External Functions ..
88  DOUBLE PRECISION dlamch
89  EXTERNAL dlamch
90 * ..
91 * .. Executable Statements ..
92 *
93 * Quick return if possible
94 *
95  IF( m.LE.0 .OR. n.LE.0 ) THEN
96  equed = 'N'
97  return
98  END IF
99 *
100 * Initialize LARGE and SMALL.
101 *
102  small = dlamch( 'Safe minimum' ) / dlamch( 'Precision' )
103  large = one / small
104 *
105  IF( rowcnd.GE.thresh .AND. amax.GE.small .AND. amax.LE.large )
106  $ THEN
107 *
108 * No row scaling
109 *
110  IF( colcnd.GE.thresh ) THEN
111 *
112 * No column scaling
113 *
114  equed = 'N'
115  ELSE
116 *
117 * Column scaling
118 *
119  DO 20 j = 1, n
120  cj = c( j )
121  DO 10 i = 1, m
122  a( i, j ) = cj*a( i, j )
123  10 continue
124  20 continue
125  equed = 'C'
126  END IF
127  ELSE IF( colcnd.GE.thresh ) THEN
128 *
129 * Row scaling, no column scaling
130 *
131  DO 40 j = 1, n
132  DO 30 i = 1, m
133  a( i, j ) = r( i )*a( i, j )
134  30 continue
135  40 continue
136  equed = 'R'
137  ELSE
138 *
139 * Row and column scaling
140 *
141  DO 60 j = 1, n
142  cj = c( j )
143  DO 50 i = 1, m
144  a( i, j ) = cj*r( i )*a( i, j )
145  50 continue
146  60 continue
147  equed = 'B'
148  END IF
149 *
150  return
151 *
152 * End of DLAQGE
153 *
154  END