00001 /* slaqge.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 slaqge_(integer *m, integer *n, real *a, integer *lda, 00017 real *r__, real *c__, real *rowcnd, real *colcnd, real *amax, char * 00018 equed) 00019 { 00020 /* System generated locals */ 00021 integer a_dim1, a_offset, i__1, i__2; 00022 00023 /* Local variables */ 00024 integer i__, j; 00025 real cj, large, small; 00026 extern doublereal slamch_(char *); 00027 00028 00029 /* -- LAPACK auxiliary routine (version 3.2) -- */ 00030 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */ 00031 /* November 2006 */ 00032 00033 /* .. Scalar Arguments .. */ 00034 /* .. */ 00035 /* .. Array Arguments .. */ 00036 /* .. */ 00037 00038 /* Purpose */ 00039 /* ======= */ 00040 00041 /* SLAQGE equilibrates a general M by N matrix A using the row and */ 00042 /* column scaling factors in the vectors R and C. */ 00043 00044 /* Arguments */ 00045 /* ========= */ 00046 00047 /* M (input) INTEGER */ 00048 /* The number of rows of the matrix A. M >= 0. */ 00049 00050 /* N (input) INTEGER */ 00051 /* The number of columns of the matrix A. N >= 0. */ 00052 00053 /* A (input/output) REAL array, dimension (LDA,N) */ 00054 /* On entry, the M by N matrix A. */ 00055 /* On exit, the equilibrated matrix. See EQUED for the form of */ 00056 /* the equilibrated matrix. */ 00057 00058 /* LDA (input) INTEGER */ 00059 /* The leading dimension of the array A. LDA >= max(M,1). */ 00060 00061 /* R (input) REAL array, dimension (M) */ 00062 /* The row scale factors for A. */ 00063 00064 /* C (input) REAL array, dimension (N) */ 00065 /* The column scale factors for A. */ 00066 00067 /* ROWCND (input) REAL */ 00068 /* Ratio of the smallest R(i) to the largest R(i). */ 00069 00070 /* COLCND (input) REAL */ 00071 /* Ratio of the smallest C(i) to the largest C(i). */ 00072 00073 /* AMAX (input) REAL */ 00074 /* Absolute value of largest matrix entry. */ 00075 00076 /* EQUED (output) CHARACTER*1 */ 00077 /* Specifies the form of equilibration that was done. */ 00078 /* = 'N': No equilibration */ 00079 /* = 'R': Row equilibration, i.e., A has been premultiplied by */ 00080 /* diag(R). */ 00081 /* = 'C': Column equilibration, i.e., A has been postmultiplied */ 00082 /* by diag(C). */ 00083 /* = 'B': Both row and column equilibration, i.e., A has been */ 00084 /* replaced by diag(R) * A * diag(C). */ 00085 00086 /* Internal Parameters */ 00087 /* =================== */ 00088 00089 /* THRESH is a threshold value used to decide if row or column scaling */ 00090 /* should be done based on the ratio of the row or column scaling */ 00091 /* factors. If ROWCND < THRESH, row scaling is done, and if */ 00092 /* COLCND < THRESH, column scaling is done. */ 00093 00094 /* LARGE and SMALL are threshold values used to decide if row scaling */ 00095 /* should be done based on the absolute size of the largest matrix */ 00096 /* element. If AMAX > LARGE or AMAX < SMALL, row scaling is done. */ 00097 00098 /* ===================================================================== */ 00099 00100 /* .. Parameters .. */ 00101 /* .. */ 00102 /* .. Local Scalars .. */ 00103 /* .. */ 00104 /* .. External Functions .. */ 00105 /* .. */ 00106 /* .. Executable Statements .. */ 00107 00108 /* Quick return if possible */ 00109 00110 /* Parameter adjustments */ 00111 a_dim1 = *lda; 00112 a_offset = 1 + a_dim1; 00113 a -= a_offset; 00114 --r__; 00115 --c__; 00116 00117 /* Function Body */ 00118 if (*m <= 0 || *n <= 0) { 00119 *(unsigned char *)equed = 'N'; 00120 return 0; 00121 } 00122 00123 /* Initialize LARGE and SMALL. */ 00124 00125 small = slamch_("Safe minimum") / slamch_("Precision"); 00126 large = 1.f / small; 00127 00128 if (*rowcnd >= .1f && *amax >= small && *amax <= large) { 00129 00130 /* No row scaling */ 00131 00132 if (*colcnd >= .1f) { 00133 00134 /* No column scaling */ 00135 00136 *(unsigned char *)equed = 'N'; 00137 } else { 00138 00139 /* Column scaling */ 00140 00141 i__1 = *n; 00142 for (j = 1; j <= i__1; ++j) { 00143 cj = c__[j]; 00144 i__2 = *m; 00145 for (i__ = 1; i__ <= i__2; ++i__) { 00146 a[i__ + j * a_dim1] = cj * a[i__ + j * a_dim1]; 00147 /* L10: */ 00148 } 00149 /* L20: */ 00150 } 00151 *(unsigned char *)equed = 'C'; 00152 } 00153 } else if (*colcnd >= .1f) { 00154 00155 /* Row scaling, no column scaling */ 00156 00157 i__1 = *n; 00158 for (j = 1; j <= i__1; ++j) { 00159 i__2 = *m; 00160 for (i__ = 1; i__ <= i__2; ++i__) { 00161 a[i__ + j * a_dim1] = r__[i__] * a[i__ + j * a_dim1]; 00162 /* L30: */ 00163 } 00164 /* L40: */ 00165 } 00166 *(unsigned char *)equed = 'R'; 00167 } else { 00168 00169 /* Row and column scaling */ 00170 00171 i__1 = *n; 00172 for (j = 1; j <= i__1; ++j) { 00173 cj = c__[j]; 00174 i__2 = *m; 00175 for (i__ = 1; i__ <= i__2; ++i__) { 00176 a[i__ + j * a_dim1] = cj * r__[i__] * a[i__ + j * a_dim1]; 00177 /* L50: */ 00178 } 00179 /* L60: */ 00180 } 00181 *(unsigned char *)equed = 'B'; 00182 } 00183 00184 return 0; 00185 00186 /* End of SLAQGE */ 00187 00188 } /* slaqge_ */