1 *> \brief \b DLANSF returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a symmetric matrix in RFP format.
3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
9 *> Download DLANSF + dependencies
10 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlansf.f">
12 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlansf.f">
14 *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlansf.f">
21 * DOUBLE PRECISION FUNCTION DLANSF( NORM, TRANSR, UPLO, N, A, WORK )
23 * .. Scalar Arguments ..
24 * CHARACTER NORM, TRANSR, UPLO
27 * .. Array Arguments ..
28 * DOUBLE PRECISION A( 0: * ), WORK( 0: * )
37 *> DLANSF returns the value of the one norm, or the Frobenius norm, or
38 *> the infinity norm, or the element of largest absolute value of a
39 *> real symmetric matrix A in RFP format.
45 *> DLANSF = ( max(abs(A(i,j))), NORM = 'M' or 'm'
47 *> ( norm1(A), NORM = '1', 'O' or 'o'
49 *> ( normI(A), NORM = 'I' or 'i'
51 *> ( normF(A), NORM = 'F', 'f', 'E' or 'e'
53 *> where norm1 denotes the one norm of a matrix (maximum column sum),
54 *> normI denotes the infinity norm of a matrix (maximum row sum) and
55 *> normF denotes the Frobenius norm of a matrix (square root of sum of
56 *> squares). Note that max(abs(A(i,j))) is not a matrix norm.
64 *> NORM is CHARACTER*1
65 *> Specifies the value to be returned in DLANSF as described
71 *> TRANSR is CHARACTER*1
72 *> Specifies whether the RFP format of A is normal or
74 *> = 'N': RFP format is Normal;
75 *> = 'T': RFP format is Transpose.
80 *> UPLO is CHARACTER*1
81 *> On entry, UPLO specifies whether the RFP matrix A came from
82 *> an upper or lower triangular matrix as follows:
83 *> = 'U': RFP A came from an upper triangular matrix;
84 *> = 'L': RFP A came from a lower triangular matrix.
90 *> The order of the matrix A. N >= 0. When N = 0, DLANSF is
96 *> A is DOUBLE PRECISION array, dimension ( N*(N+1)/2 );
97 *> On entry, the upper (if UPLO = 'U') or lower (if UPLO = 'L')
98 *> part of the symmetric matrix A stored in RFP format. See the
99 *> "Notes" below for more details.
100 *> Unchanged on exit.
105 *> WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK)),
106 *> where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
107 *> WORK is not referenced.
113 *> \author Univ. of Tennessee
114 *> \author Univ. of California Berkeley
115 *> \author Univ. of Colorado Denver
118 *> \date September 2012
120 *> \ingroup doubleOTHERcomputational
122 *> \par Further Details:
123 * =====================
127 *> We first consider Rectangular Full Packed (RFP) Format when N is
128 *> even. We give an example where N = 6.
130 *> AP is Upper AP is Lower
132 *> 00 01 02 03 04 05 00
133 *> 11 12 13 14 15 10 11
134 *> 22 23 24 25 20 21 22
135 *> 33 34 35 30 31 32 33
136 *> 44 45 40 41 42 43 44
137 *> 55 50 51 52 53 54 55
140 *> Let TRANSR = 'N'. RFP holds AP as follows:
141 *> For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last
142 *> three columns of AP upper. The lower triangle A(4:6,0:2) consists of
143 *> the transpose of the first three columns of AP upper.
144 *> For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first
145 *> three columns of AP lower. The upper triangle A(0:2,0:2) consists of
146 *> the transpose of the last three columns of AP lower.
147 *> This covers the case N even and TRANSR = 'N'.
159 *> Now let TRANSR = 'T'. RFP A in both UPLO cases is just the
160 *> transpose of RFP A above. One therefore gets:
165 *> 03 13 23 33 00 01 02 33 00 10 20 30 40 50
166 *> 04 14 24 34 44 11 12 43 44 11 21 31 41 51
167 *> 05 15 25 35 45 55 22 53 54 55 22 32 42 52
170 *> We then consider Rectangular Full Packed (RFP) Format when N is
171 *> odd. We give an example where N = 5.
173 *> AP is Upper AP is Lower
182 *> Let TRANSR = 'N'. RFP holds AP as follows:
183 *> For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last
184 *> three columns of AP upper. The lower triangle A(3:4,0:1) consists of
185 *> the transpose of the first two columns of AP upper.
186 *> For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first
187 *> three columns of AP lower. The upper triangle A(0:1,1:2) consists of
188 *> the transpose of the last two columns of AP lower.
189 *> This covers the case N odd and TRANSR = 'N'.
199 *> Now let TRANSR = 'T'. RFP A in both UPLO cases is just the
200 *> transpose of RFP A above. One therefore gets:
204 *> 02 12 22 00 01 00 10 20 30 40 50
205 *> 03 13 23 33 11 33 11 21 31 41 51
206 *> 04 14 24 34 44 43 44 22 32 42 52
209 * =====================================================================
210 DOUBLE PRECISION FUNCTION DLANSF( NORM, TRANSR, UPLO, N, A, WORK )
212 * -- LAPACK computational routine (version 3.4.2) --
213 * -- LAPACK is a software package provided by Univ. of Tennessee, --
214 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
217 * .. Scalar Arguments ..
218 CHARACTER NORM, TRANSR, UPLO
221 * .. Array Arguments ..
222 DOUBLE PRECISION A( 0: * ), WORK( 0: * )
225 * =====================================================================
228 DOUBLE PRECISION ONE, ZERO
229 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
231 * .. Local Scalars ..
232 INTEGER I, J, IFM, ILU, NOE, N1, K, L, LDA
233 DOUBLE PRECISION SCALE, S, VALUE, AA, TEMP
235 * .. External Functions ..
236 LOGICAL LSAME, DISNAN
237 EXTERNAL LSAME, DISNAN
239 * .. External Subroutines ..
242 * .. Intrinsic Functions ..
243 INTRINSIC ABS, MAX, SQRT
245 * .. Executable Statements ..
250 ELSE IF( N.EQ.1 ) THEN
255 * set noe = 1 if n is odd. if n is even set noe=0
258 IF( MOD( N, 2 ).EQ.0 )
261 * set ifm = 0 when form='T or 't' and 1 otherwise
264 IF( LSAME( TRANSR, 'T' ) )
267 * set ilu = 0 when uplo='U or 'u' and 1 otherwise
270 IF( LSAME( UPLO, 'U' ) )
273 * set lda = (n+1)/2 when ifm = 0
274 * set lda = n when ifm = 1 and noe = 1
275 * set lda = n+1 when ifm = 1 and noe = 0
289 IF( LSAME( NORM, 'M' ) ) THEN
291 * Find max(abs(A(i,j))).
301 TEMP = ABS( A( I+J*LDA ) )
302 IF( VALUE .LT. TEMP .OR. DISNAN( TEMP ) )
307 * xpose case; A is k by n
310 TEMP = ABS( A( I+J*LDA ) )
311 IF( VALUE .LT. TEMP .OR. DISNAN( TEMP ) )
322 TEMP = ABS( A( I+J*LDA ) )
323 IF( VALUE .LT. TEMP .OR. DISNAN( TEMP ) )
328 * xpose case; A is k by n+1
331 TEMP = ABS( A( I+J*LDA ) )
332 IF( VALUE .LT. TEMP .OR. DISNAN( TEMP ) )
338 ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR.
339 $ ( NORM.EQ.'1' ) ) THEN
341 * Find normI(A) ( = norm1(A), since A is symmetric).
354 AA = ABS( A( I+J*LDA ) )
357 WORK( I ) = WORK( I ) + AA
359 AA = ABS( A( I+J*LDA ) )
365 AA = ABS( A( I+J*LDA ) )
367 WORK( J ) = WORK( J ) + AA
371 AA = ABS( A( I+J*LDA ) )
374 WORK( L ) = WORK( L ) + AA
376 WORK( J ) = WORK( J ) + S
382 IF( VALUE .LT. TEMP .OR. DISNAN( TEMP ) )
388 * k=(n+1)/2 for n odd and ilu=1
395 AA = ABS( A( I+J*LDA ) )
398 WORK( I+K ) = WORK( I+K ) + AA
401 AA = ABS( A( I+J*LDA ) )
404 WORK( I+K ) = WORK( I+K ) + S
408 AA = ABS( A( I+J*LDA ) )
414 AA = ABS( A( I+J*LDA ) )
417 WORK( L ) = WORK( L ) + AA
419 WORK( J ) = WORK( J ) + S
424 IF( VALUE .LT. TEMP .OR. DISNAN( TEMP ) )
437 AA = ABS( A( I+J*LDA ) )
440 WORK( I ) = WORK( I ) + AA
442 AA = ABS( A( I+J*LDA ) )
446 AA = ABS( A( I+J*LDA ) )
448 WORK( J ) = WORK( J ) + AA
452 AA = ABS( A( I+J*LDA ) )
455 WORK( L ) = WORK( L ) + AA
457 WORK( J ) = WORK( J ) + S
462 IF( VALUE .LT. TEMP .OR. DISNAN( TEMP ) )
473 AA = ABS( A( I+J*LDA ) )
476 WORK( I+K ) = WORK( I+K ) + AA
478 AA = ABS( A( I+J*LDA ) )
481 WORK( I+K ) = WORK( I+K ) + S
484 AA = ABS( A( I+J*LDA ) )
490 AA = ABS( A( I+J*LDA ) )
493 WORK( L ) = WORK( L ) + AA
495 WORK( J ) = WORK( J ) + S
500 IF( VALUE .LT. TEMP .OR. DISNAN( TEMP ) )
514 * k is the row size and lda
521 AA = ABS( A( I+J*LDA ) )
523 WORK( I+N1 ) = WORK( I+N1 ) + AA
528 * j=n1=k-1 is special
529 S = ABS( A( 0+J*LDA ) )
532 AA = ABS( A( I+J*LDA ) )
534 WORK( I+N1 ) = WORK( I+N1 ) + AA
537 WORK( J ) = WORK( J ) + S
541 AA = ABS( A( I+J*LDA ) )
543 WORK( I ) = WORK( I ) + AA
547 AA = ABS( A( I+J*LDA ) )
550 WORK( J-K ) = WORK( J-K ) + S
552 S = ABS( A( I+J*LDA ) )
556 AA = ABS( A( I+J*LDA ) )
558 WORK( L ) = WORK( L ) + AA
561 WORK( J ) = WORK( J ) + S
566 IF( VALUE .LT. TEMP .OR. DISNAN( TEMP ) )
572 * k=(n+1)/2 for n odd and ilu=1
580 AA = ABS( A( I+J*LDA ) )
582 WORK( I ) = WORK( I ) + AA
585 AA = ABS( A( I+J*LDA ) )
586 * i=j so process of A(j,j)
589 * is initialised here
591 * i=j process A(j+k,j+k)
592 AA = ABS( A( I+J*LDA ) )
594 DO L = K + J + 1, N - 1
596 AA = ABS( A( I+J*LDA ) )
599 WORK( L ) = WORK( L ) + AA
601 WORK( K+J ) = WORK( K+J ) + S
603 * j=k-1 is special :process col A(k-1,0:k-1)
606 AA = ABS( A( I+J*LDA ) )
608 WORK( I ) = WORK( I ) + AA
612 AA = ABS( A( I+J*LDA ) )
616 * done with col j=k+1
618 * process col j of A = A(j,0:k-1)
621 AA = ABS( A( I+J*LDA ) )
623 WORK( I ) = WORK( I ) + AA
626 WORK( J ) = WORK( J ) + S
631 IF( VALUE .LT. TEMP .OR. DISNAN( TEMP ) )
644 AA = ABS( A( I+J*LDA ) )
646 WORK( I+K ) = WORK( I+K ) + AA
652 AA = ABS( A( 0+J*LDA ) )
656 AA = ABS( A( I+J*LDA ) )
658 WORK( I+K ) = WORK( I+K ) + AA
661 WORK( J ) = WORK( J ) + S
665 AA = ABS( A( I+J*LDA ) )
667 WORK( I ) = WORK( I ) + AA
671 AA = ABS( A( I+J*LDA ) )
674 WORK( J-K-1 ) = WORK( J-K-1 ) + S
676 AA = ABS( A( I+J*LDA ) )
681 AA = ABS( A( I+J*LDA ) )
683 WORK( L ) = WORK( L ) + AA
686 WORK( J ) = WORK( J ) + S
691 AA = ABS( A( I+J*LDA ) )
693 WORK( I ) = WORK( I ) + AA
697 AA = ABS( A( I+J*LDA ) )
700 WORK( I ) = WORK( I ) + S
704 IF( VALUE .LT. TEMP .OR. DISNAN( TEMP ) )
712 * j=0 is special :process col A(k:n-1,k)
718 WORK( I+K ) = WORK( I+K ) + AA
721 WORK( K ) = WORK( K ) + S
726 AA = ABS( A( I+J*LDA ) )
728 WORK( I ) = WORK( I ) + AA
731 AA = ABS( A( I+J*LDA ) )
732 * i=j-1 so process of A(j-1,j-1)
735 * is initialised here
737 * i=j process A(j+k,j+k)
738 AA = ABS( A( I+J*LDA ) )
740 DO L = K + J + 1, N - 1
742 AA = ABS( A( I+J*LDA ) )
745 WORK( L ) = WORK( L ) + AA
747 WORK( K+J ) = WORK( K+J ) + S
749 * j=k is special :process col A(k,0:k-1)
752 AA = ABS( A( I+J*LDA ) )
754 WORK( I ) = WORK( I ) + AA
758 AA = ABS( A( I+J*LDA ) )
762 * done with col j=k+1
764 * process col j-1 of A = A(j-1,0:k-1)
767 AA = ABS( A( I+J*LDA ) )
769 WORK( I ) = WORK( I ) + AA
772 WORK( J-1 ) = WORK( J-1 ) + S
777 IF( VALUE .LT. TEMP .OR. DISNAN( TEMP ) )
783 ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
797 CALL DLASSQ( K-J-2, A( K+J+1+J*LDA ), 1, SCALE, S )
801 CALL DLASSQ( K+J-1, A( 0+J*LDA ), 1, SCALE, S )
805 * double s for the off diagonal elements
806 CALL DLASSQ( K-1, A( K ), LDA+1, SCALE, S )
808 CALL DLASSQ( K, A( K-1 ), LDA+1, SCALE, S )
813 CALL DLASSQ( N-J-1, A( J+1+J*LDA ), 1, SCALE, S )
817 CALL DLASSQ( J, A( 0+( 1+J )*LDA ), 1, SCALE, S )
821 * double s for the off diagonal elements
822 CALL DLASSQ( K, A( 0 ), LDA+1, SCALE, S )
824 CALL DLASSQ( K-1, A( 0+LDA ), LDA+1, SCALE, S )
832 CALL DLASSQ( J, A( 0+( K+J )*LDA ), 1, SCALE, S )
836 CALL DLASSQ( K, A( 0+J*LDA ), 1, SCALE, S )
837 * k by k-1 rect. at A(0,0)
840 CALL DLASSQ( K-J-1, A( J+1+( J+K-1 )*LDA ), 1,
845 * double s for the off diagonal elements
846 CALL DLASSQ( K-1, A( 0+K*LDA ), LDA+1, SCALE, S )
848 CALL DLASSQ( K, A( 0+( K-1 )*LDA ), LDA+1, SCALE, S )
853 CALL DLASSQ( J, A( 0+J*LDA ), 1, SCALE, S )
857 CALL DLASSQ( K, A( 0+J*LDA ), 1, SCALE, S )
858 * k by k-1 rect. at A(0,k)
861 CALL DLASSQ( K-J-2, A( J+2+J*LDA ), 1, SCALE, S )
865 * double s for the off diagonal elements
866 CALL DLASSQ( K, A( 0 ), LDA+1, SCALE, S )
868 CALL DLASSQ( K-1, A( 1 ), LDA+1, SCALE, S )
879 CALL DLASSQ( K-J-1, A( K+J+2+J*LDA ), 1, SCALE, S )
883 CALL DLASSQ( K+J, A( 0+J*LDA ), 1, SCALE, S )
887 * double s for the off diagonal elements
888 CALL DLASSQ( K, A( K+1 ), LDA+1, SCALE, S )
890 CALL DLASSQ( K, A( K ), LDA+1, SCALE, S )
895 CALL DLASSQ( N-J-1, A( J+2+J*LDA ), 1, SCALE, S )
899 CALL DLASSQ( J, A( 0+J*LDA ), 1, SCALE, S )
903 * double s for the off diagonal elements
904 CALL DLASSQ( K, A( 1 ), LDA+1, SCALE, S )
906 CALL DLASSQ( K, A( 0 ), LDA+1, SCALE, S )
914 CALL DLASSQ( J, A( 0+( K+1+J )*LDA ), 1, SCALE, S )
918 CALL DLASSQ( K, A( 0+J*LDA ), 1, SCALE, S )
919 * k by k rect. at A(0,0)
922 CALL DLASSQ( K-J-1, A( J+1+( J+K )*LDA ), 1, SCALE,
927 * double s for the off diagonal elements
928 CALL DLASSQ( K, A( 0+( K+1 )*LDA ), LDA+1, SCALE, S )
930 CALL DLASSQ( K, A( 0+K*LDA ), LDA+1, SCALE, S )
935 CALL DLASSQ( J, A( 0+( J+1 )*LDA ), 1, SCALE, S )
939 CALL DLASSQ( K, A( 0+J*LDA ), 1, SCALE, S )
940 * k by k rect. at A(0,k+1)
943 CALL DLASSQ( K-J-1, A( J+1+J*LDA ), 1, SCALE, S )
947 * double s for the off diagonal elements
948 CALL DLASSQ( K, A( LDA ), LDA+1, SCALE, S )
950 CALL DLASSQ( K, A( 0 ), LDA+1, SCALE, S )
955 VALUE = SCALE*SQRT( S )