![]() |
LAPACK
3.4.1
LAPACK: Linear Algebra PACKage
|
00001 *> \brief \b SLANSY 00002 * 00003 * =========== DOCUMENTATION =========== 00004 * 00005 * Online html documentation available at 00006 * http://www.netlib.org/lapack/explore-html/ 00007 * 00008 *> \htmlonly 00009 *> Download SLANSY + dependencies 00010 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/slansy.f"> 00011 *> [TGZ]</a> 00012 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/slansy.f"> 00013 *> [ZIP]</a> 00014 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/slansy.f"> 00015 *> [TXT]</a> 00016 *> \endhtmlonly 00017 * 00018 * Definition: 00019 * =========== 00020 * 00021 * REAL FUNCTION SLANSY( NORM, UPLO, N, A, LDA, WORK ) 00022 * 00023 * .. Scalar Arguments .. 00024 * CHARACTER NORM, UPLO 00025 * INTEGER LDA, N 00026 * .. 00027 * .. Array Arguments .. 00028 * REAL A( LDA, * ), WORK( * ) 00029 * .. 00030 * 00031 * 00032 *> \par Purpose: 00033 * ============= 00034 *> 00035 *> \verbatim 00036 *> 00037 *> SLANSY returns the value of the one norm, or the Frobenius norm, or 00038 *> the infinity norm, or the element of largest absolute value of a 00039 *> real symmetric matrix A. 00040 *> \endverbatim 00041 *> 00042 *> \return SLANSY 00043 *> \verbatim 00044 *> 00045 *> SLANSY = ( max(abs(A(i,j))), NORM = 'M' or 'm' 00046 *> ( 00047 *> ( norm1(A), NORM = '1', 'O' or 'o' 00048 *> ( 00049 *> ( normI(A), NORM = 'I' or 'i' 00050 *> ( 00051 *> ( normF(A), NORM = 'F', 'f', 'E' or 'e' 00052 *> 00053 *> where norm1 denotes the one norm of a matrix (maximum column sum), 00054 *> normI denotes the infinity norm of a matrix (maximum row sum) and 00055 *> normF denotes the Frobenius norm of a matrix (square root of sum of 00056 *> squares). Note that max(abs(A(i,j))) is not a consistent matrix norm. 00057 *> \endverbatim 00058 * 00059 * Arguments: 00060 * ========== 00061 * 00062 *> \param[in] NORM 00063 *> \verbatim 00064 *> NORM is CHARACTER*1 00065 *> Specifies the value to be returned in SLANSY as described 00066 *> above. 00067 *> \endverbatim 00068 *> 00069 *> \param[in] UPLO 00070 *> \verbatim 00071 *> UPLO is CHARACTER*1 00072 *> Specifies whether the upper or lower triangular part of the 00073 *> symmetric matrix A is to be referenced. 00074 *> = 'U': Upper triangular part of A is referenced 00075 *> = 'L': Lower triangular part of A is referenced 00076 *> \endverbatim 00077 *> 00078 *> \param[in] N 00079 *> \verbatim 00080 *> N is INTEGER 00081 *> The order of the matrix A. N >= 0. When N = 0, SLANSY is 00082 *> set to zero. 00083 *> \endverbatim 00084 *> 00085 *> \param[in] A 00086 *> \verbatim 00087 *> A is REAL array, dimension (LDA,N) 00088 *> The symmetric matrix A. If UPLO = 'U', the leading n by n 00089 *> upper triangular part of A contains the upper triangular part 00090 *> of the matrix A, and the strictly lower triangular part of A 00091 *> is not referenced. If UPLO = 'L', the leading n by n lower 00092 *> triangular part of A contains the lower triangular part of 00093 *> the matrix A, and the strictly upper triangular part of A is 00094 *> not referenced. 00095 *> \endverbatim 00096 *> 00097 *> \param[in] LDA 00098 *> \verbatim 00099 *> LDA is INTEGER 00100 *> The leading dimension of the array A. LDA >= max(N,1). 00101 *> \endverbatim 00102 *> 00103 *> \param[out] WORK 00104 *> \verbatim 00105 *> WORK is REAL array, dimension (MAX(1,LWORK)), 00106 *> where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise, 00107 *> WORK is not referenced. 00108 *> \endverbatim 00109 * 00110 * Authors: 00111 * ======== 00112 * 00113 *> \author Univ. of Tennessee 00114 *> \author Univ. of California Berkeley 00115 *> \author Univ. of Colorado Denver 00116 *> \author NAG Ltd. 00117 * 00118 *> \date November 2011 00119 * 00120 *> \ingroup realSYauxiliary 00121 * 00122 * ===================================================================== 00123 REAL FUNCTION SLANSY( NORM, UPLO, N, A, LDA, WORK ) 00124 * 00125 * -- LAPACK auxiliary routine (version 3.4.0) -- 00126 * -- LAPACK is a software package provided by Univ. of Tennessee, -- 00127 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- 00128 * November 2011 00129 * 00130 * .. Scalar Arguments .. 00131 CHARACTER NORM, UPLO 00132 INTEGER LDA, N 00133 * .. 00134 * .. Array Arguments .. 00135 REAL A( LDA, * ), WORK( * ) 00136 * .. 00137 * 00138 * ===================================================================== 00139 * 00140 * .. Parameters .. 00141 REAL ONE, ZERO 00142 PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 ) 00143 * .. 00144 * .. Local Scalars .. 00145 INTEGER I, J 00146 REAL ABSA, SCALE, SUM, VALUE 00147 * .. 00148 * .. External Subroutines .. 00149 EXTERNAL SLASSQ 00150 * .. 00151 * .. External Functions .. 00152 LOGICAL LSAME 00153 EXTERNAL LSAME 00154 * .. 00155 * .. Intrinsic Functions .. 00156 INTRINSIC ABS, MAX, SQRT 00157 * .. 00158 * .. Executable Statements .. 00159 * 00160 IF( N.EQ.0 ) THEN 00161 VALUE = ZERO 00162 ELSE IF( LSAME( NORM, 'M' ) ) THEN 00163 * 00164 * Find max(abs(A(i,j))). 00165 * 00166 VALUE = ZERO 00167 IF( LSAME( UPLO, 'U' ) ) THEN 00168 DO 20 J = 1, N 00169 DO 10 I = 1, J 00170 VALUE = MAX( VALUE, ABS( A( I, J ) ) ) 00171 10 CONTINUE 00172 20 CONTINUE 00173 ELSE 00174 DO 40 J = 1, N 00175 DO 30 I = J, N 00176 VALUE = MAX( VALUE, ABS( A( I, J ) ) ) 00177 30 CONTINUE 00178 40 CONTINUE 00179 END IF 00180 ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR. 00181 $ ( NORM.EQ.'1' ) ) THEN 00182 * 00183 * Find normI(A) ( = norm1(A), since A is symmetric). 00184 * 00185 VALUE = ZERO 00186 IF( LSAME( UPLO, 'U' ) ) THEN 00187 DO 60 J = 1, N 00188 SUM = ZERO 00189 DO 50 I = 1, J - 1 00190 ABSA = ABS( A( I, J ) ) 00191 SUM = SUM + ABSA 00192 WORK( I ) = WORK( I ) + ABSA 00193 50 CONTINUE 00194 WORK( J ) = SUM + ABS( A( J, J ) ) 00195 60 CONTINUE 00196 DO 70 I = 1, N 00197 VALUE = MAX( VALUE, WORK( I ) ) 00198 70 CONTINUE 00199 ELSE 00200 DO 80 I = 1, N 00201 WORK( I ) = ZERO 00202 80 CONTINUE 00203 DO 100 J = 1, N 00204 SUM = WORK( J ) + ABS( A( J, J ) ) 00205 DO 90 I = J + 1, N 00206 ABSA = ABS( A( I, J ) ) 00207 SUM = SUM + ABSA 00208 WORK( I ) = WORK( I ) + ABSA 00209 90 CONTINUE 00210 VALUE = MAX( VALUE, SUM ) 00211 100 CONTINUE 00212 END IF 00213 ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN 00214 * 00215 * Find normF(A). 00216 * 00217 SCALE = ZERO 00218 SUM = ONE 00219 IF( LSAME( UPLO, 'U' ) ) THEN 00220 DO 110 J = 2, N 00221 CALL SLASSQ( J-1, A( 1, J ), 1, SCALE, SUM ) 00222 110 CONTINUE 00223 ELSE 00224 DO 120 J = 1, N - 1 00225 CALL SLASSQ( N-J, A( J+1, J ), 1, SCALE, SUM ) 00226 120 CONTINUE 00227 END IF 00228 SUM = 2*SUM 00229 CALL SLASSQ( N, A, LDA+1, SCALE, SUM ) 00230 VALUE = SCALE*SQRT( SUM ) 00231 END IF 00232 * 00233 SLANSY = VALUE 00234 RETURN 00235 * 00236 * End of SLANSY 00237 * 00238 END