LAPACK 3.3.0

cspt01.f

Go to the documentation of this file.
00001       SUBROUTINE CSPT01( UPLO, N, A, AFAC, IPIV, C, LDC, RWORK, RESID )
00002 *
00003 *  -- LAPACK test routine (version 3.1) --
00004 *     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
00005 *     November 2006
00006 *
00007 *     .. Scalar Arguments ..
00008       CHARACTER          UPLO
00009       INTEGER            LDC, N
00010       REAL               RESID
00011 *     ..
00012 *     .. Array Arguments ..
00013       INTEGER            IPIV( * )
00014       REAL               RWORK( * )
00015       COMPLEX            A( * ), AFAC( * ), C( LDC, * )
00016 *     ..
00017 *
00018 *  Purpose
00019 *  =======
00020 *
00021 *  CSPT01 reconstructs a symmetric indefinite packed matrix A from its
00022 *  diagonal pivoting factorization A = U*D*U' or A = L*D*L' and computes
00023 *  the residual
00024 *     norm( C - A ) / ( N * norm(A) * EPS ),
00025 *  where C is the reconstructed matrix and EPS is the machine epsilon.
00026 *
00027 *  Arguments
00028 *  ==========
00029 *
00030 *  UPLO    (input) CHARACTER*1
00031 *          Specifies whether the upper or lower triangular part of the
00032 *          Hermitian matrix A is stored:
00033 *          = 'U':  Upper triangular
00034 *          = 'L':  Lower triangular
00035 *
00036 *  N       (input) INTEGER
00037 *          The order of the matrix A.  N >= 0.
00038 *
00039 *  A       (input) COMPLEX array, dimension (N*(N+1)/2)
00040 *          The original symmetric matrix A, stored as a packed
00041 *          triangular matrix.
00042 *
00043 *  AFAC    (input) COMPLEX array, dimension (N*(N+1)/2)
00044 *          The factored form of the matrix A, stored as a packed
00045 *          triangular matrix.  AFAC contains the block diagonal matrix D
00046 *          and the multipliers used to obtain the factor L or U from the
00047 *          L*D*L' or U*D*U' factorization as computed by CSPTRF.
00048 *
00049 *  IPIV    (input) INTEGER array, dimension (N)
00050 *          The pivot indices from CSPTRF.
00051 *
00052 *  C       (workspace) COMPLEX array, dimension (LDC,N)
00053 *
00054 *  LDC     (integer) INTEGER
00055 *          The leading dimension of the array C.  LDC >= max(1,N).
00056 *
00057 *  RWORK   (workspace) REAL array, dimension (N)
00058 *
00059 *  RESID   (output) REAL
00060 *          If UPLO = 'L', norm(L*D*L' - A) / ( N * norm(A) * EPS )
00061 *          If UPLO = 'U', norm(U*D*U' - A) / ( N * norm(A) * EPS )
00062 *
00063 *  =====================================================================
00064 *
00065 *     .. Parameters ..
00066       REAL               ZERO, ONE
00067       PARAMETER          ( ZERO = 0.0E+0, ONE = 1.0E+0 )
00068       COMPLEX            CZERO, CONE
00069       PARAMETER          ( CZERO = ( 0.0E+0, 0.0E+0 ),
00070      $                   CONE = ( 1.0E+0, 0.0E+0 ) )
00071 *     ..
00072 *     .. Local Scalars ..
00073       INTEGER            I, INFO, J, JC
00074       REAL               ANORM, EPS
00075 *     ..
00076 *     .. External Functions ..
00077       LOGICAL            LSAME
00078       REAL               CLANSP, CLANSY, SLAMCH
00079       EXTERNAL           LSAME, CLANSP, CLANSY, SLAMCH
00080 *     ..
00081 *     .. External Subroutines ..
00082       EXTERNAL           CLAVSP, CLASET
00083 *     ..
00084 *     .. Intrinsic Functions ..
00085       INTRINSIC          REAL
00086 *     ..
00087 *     .. Executable Statements ..
00088 *
00089 *     Quick exit if N = 0.
00090 *
00091       IF( N.LE.0 ) THEN
00092          RESID = ZERO
00093          RETURN
00094       END IF
00095 *
00096 *     Determine EPS and the norm of A.
00097 *
00098       EPS = SLAMCH( 'Epsilon' )
00099       ANORM = CLANSP( '1', UPLO, N, A, RWORK )
00100 *
00101 *     Initialize C to the identity matrix.
00102 *
00103       CALL CLASET( 'Full', N, N, CZERO, CONE, C, LDC )
00104 *
00105 *     Call CLAVSP to form the product D * U' (or D * L' ).
00106 *
00107       CALL CLAVSP( UPLO, 'Transpose', 'Non-unit', N, N, AFAC, IPIV, C,
00108      $             LDC, INFO )
00109 *
00110 *     Call CLAVSP again to multiply by U ( or L ).
00111 *
00112       CALL CLAVSP( UPLO, 'No transpose', 'Unit', N, N, AFAC, IPIV, C,
00113      $             LDC, INFO )
00114 *
00115 *     Compute the difference  C - A .
00116 *
00117       IF( LSAME( UPLO, 'U' ) ) THEN
00118          JC = 0
00119          DO 20 J = 1, N
00120             DO 10 I = 1, J
00121                C( I, J ) = C( I, J ) - A( JC+I )
00122    10       CONTINUE
00123             JC = JC + J
00124    20    CONTINUE
00125       ELSE
00126          JC = 1
00127          DO 40 J = 1, N
00128             DO 30 I = J, N
00129                C( I, J ) = C( I, J ) - A( JC+I-J )
00130    30       CONTINUE
00131             JC = JC + N - J + 1
00132    40    CONTINUE
00133       END IF
00134 *
00135 *     Compute norm( C - A ) / ( N * norm(A) * EPS )
00136 *
00137       RESID = CLANSY( '1', UPLO, N, C, LDC, RWORK )
00138 *
00139       IF( ANORM.LE.ZERO ) THEN
00140          IF( RESID.NE.ZERO )
00141      $      RESID = ONE / EPS
00142       ELSE
00143          RESID = ( ( RESID/REAL( N ) )/ANORM ) / EPS
00144       END IF
00145 *
00146       RETURN
00147 *
00148 *     End of CSPT01
00149 *
00150       END
 All Files Functions