Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages | Examples

dlange.c

Go to the documentation of this file.
00001 /* DLANGE.F -- translated by f2c (version 19941215).
00002    You must link the resulting object file with the libraries:
00003         -lf2c -lm   (in that order)
00004 */
00005 
00006 #include "f2c.h"
00007 
00008 /* Table of constant values */
00009 
00010 static integer c__1 = 1;
00011 
00012 doublereal dlange_(norm, m, n, a, lda, work, norm_len)
00013 char *norm;
00014 integer *m, *n;
00015 doublereal *a;
00016 integer *lda;
00017 doublereal *work;
00018 ftnlen norm_len;
00019 {
00020     /* System generated locals */
00021     integer a_dim1, a_offset, i__1, i__2;
00022     doublereal ret_val, d__1, d__2, d__3;
00023 
00024     /* Builtin functions */
00025     double sqrt();
00026 
00027     /* Local variables */
00028     static integer i, j;
00029     static doublereal scale;
00030     extern logical lsame_();
00031     static doublereal value;
00032     extern /* Subroutine */ int dlassq_();
00033     static doublereal sum;
00034 
00035 
00036 /*  -- LAPACK auxiliary routine (version 1.1) -- */
00037 /*     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
00038 /*     Courant Institute, Argonne National Lab, and Rice University */
00039 /*     October 31, 1992 */
00040 
00041 /*     .. Scalar Arguments .. */
00042 /*     .. */
00043 /*     .. Array Arguments .. */
00044 /*     .. */
00045 
00046 /*  Purpose */
00047 /*  ======= */
00048 
00049 /*  DLANGE  returns the value of the one norm,  or the Frobenius norm, or 
00050 */
00051 /*  the  infinity norm,  or the  element of  largest absolute value  of a 
00052 */
00053 /*  real matrix A. */
00054 
00055 /*  Description */
00056 /*  =========== */
00057 
00058 /*  DLANGE returns the value */
00059 
00060 /*     DLANGE = ( max(abs(A(i,j))), NORM = 'M' or 'm' */
00061 /*              ( */
00062 /*              ( norm1(A),         NORM = '1', 'O' or 'o' */
00063 /*              ( */
00064 /*              ( normI(A),         NORM = 'I' or 'i' */
00065 /*              ( */
00066 /*              ( normF(A),         NORM = 'F', 'f', 'E' or 'e' */
00067 
00068 /*  where  norm1  denotes the  one norm of a matrix (maximum column sum), 
00069 */
00070 /*  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and 
00071 */
00072 /*  normF  denotes the  Frobenius norm of a matrix (square root of sum of 
00073 */
00074 /*  squares).  Note that  max(abs(A(i,j)))  is not a  matrix norm. */
00075 
00076 /*  Arguments */
00077 /*  ========= */
00078 
00079 /*  NORM    (input) CHARACTER*1 */
00080 /*          Specifies the value to be returned in DLANGE as described */
00081 /*          above. */
00082 
00083 /*  M       (input) INTEGER */
00084 /*          The number of rows of the matrix A.  M >= 0.  When M = 0, */
00085 /*          DLANGE is set to zero. */
00086 
00087 /*  N       (input) INTEGER */
00088 /*          The number of columns of the matrix A.  N >= 0.  When N = 0, 
00089 */
00090 /*          DLANGE is set to zero. */
00091 
00092 /*  A       (input) DOUBLE PRECISION array, dimension (LDA,N) */
00093 /*          The m by n matrix A. */
00094 
00095 /*  LDA     (input) INTEGER */
00096 /*          The leading dimension of the array A.  LDA >= max(M,1). */
00097 
00098 /*  WORK    (workspace) DOUBLE PRECISION array, dimension (LWORK), */
00099 /*          where LWORK >= M when NORM = 'I'; otherwise, WORK is not */
00100 /*          referenced. */
00101 
00102 /* ===================================================================== 
00103 */
00104 
00105 /*     .. Parameters .. */
00106 /*     .. */
00107 /*     .. Local Scalars .. */
00108 /*     .. */
00109 /*     .. External Subroutines .. */
00110 /*     .. */
00111 /*     .. External Functions .. */
00112 /*     .. */
00113 /*     .. Intrinsic Functions .. */
00114 /*     .. */
00115 /*     .. Executable Statements .. */
00116 
00117     /* Parameter adjustments */
00118     a_dim1 = *lda;
00119     a_offset = a_dim1 + 1;
00120     a -= a_offset;
00121     --work;
00122 
00123     /* Function Body */
00124     if (min(*m,*n) == 0) {
00125         value = 0.;
00126     } else if (lsame_(norm, "M", 1L, 1L)) {
00127 
00128 /*        Find max(abs(A(i,j))). */
00129 
00130         value = 0.;
00131         i__1 = *n;
00132         for (j = 1; j <= i__1; ++j) {
00133             i__2 = *m;
00134             for (i = 1; i <= i__2; ++i) {
00135 /* Computing MAX */
00136                 d__2 = value, d__3 = (d__1 = a[i + j * a_dim1], abs(d__1));
00137                 value = max(d__2,d__3);
00138 /* L10: */
00139             }
00140 /* L20: */
00141         }
00142     } else if (lsame_(norm, "O", 1L, 1L) || *(unsigned char *)norm == '1') {
00143 
00144 /*        Find norm1(A). */
00145 
00146         value = 0.;
00147         i__1 = *n;
00148         for (j = 1; j <= i__1; ++j) {
00149             sum = 0.;
00150             i__2 = *m;
00151             for (i = 1; i <= i__2; ++i) {
00152                 sum += (d__1 = a[i + j * a_dim1], abs(d__1));
00153 /* L30: */
00154             }
00155             value = max(value,sum);
00156 /* L40: */
00157         }
00158     } else if (lsame_(norm, "I", 1L, 1L)) {
00159 
00160 /*        Find normI(A). */
00161 
00162         i__1 = *m;
00163         for (i = 1; i <= i__1; ++i) {
00164             work[i] = 0.;
00165 /* L50: */
00166         }
00167         i__1 = *n;
00168         for (j = 1; j <= i__1; ++j) {
00169             i__2 = *m;
00170             for (i = 1; i <= i__2; ++i) {
00171                 work[i] += (d__1 = a[i + j * a_dim1], abs(d__1));
00172 /* L60: */
00173             }
00174 /* L70: */
00175         }
00176         value = 0.;
00177         i__1 = *m;
00178         for (i = 1; i <= i__1; ++i) {
00179 /* Computing MAX */
00180             d__1 = value, d__2 = work[i];
00181             value = max(d__1,d__2);
00182 /* L80: */
00183         }
00184     } else if (lsame_(norm, "F", 1L, 1L) || lsame_(norm, "E", 1L, 1L)) {
00185 
00186 /*        Find normF(A). */
00187 
00188         scale = 0.;
00189         sum = 1.;
00190         i__1 = *n;
00191         for (j = 1; j <= i__1; ++j) {
00192             dlassq_(m, &a[j * a_dim1 + 1], &c__1, &scale, &sum);
00193 /* L90: */
00194         }
00195         value = scale * sqrt(sum);
00196     }
00197 
00198     ret_val = value;
00199     return ret_val;
00200 
00201 /*     End of DLANGE */
00202 
00203 } /* dlange_ */
00204 

Generated on Wed Sep 5 12:54:19 2007 for DSACSS Operational Code by  doxygen 1.3.9.1