LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine sqrt16 ( character  TRANS,
integer  M,
integer  N,
integer  NRHS,
real, dimension( lda, * )  A,
integer  LDA,
real, dimension( ldx, * )  X,
integer  LDX,
real, dimension( ldb, * )  B,
integer  LDB,
real, dimension( * )  RWORK,
real  RESID 
)

SQRT16

Purpose:
 SQRT16 computes the residual for a solution of a system of linear
 equations  A*x = b  or  A'*x = b:
    RESID = norm(B - A*X) / ( max(m,n) * norm(A) * norm(X) * EPS ),
 where EPS is the machine epsilon.
Parameters
[in]TRANS
          TRANS is CHARACTER*1
          Specifies the form of the system of equations:
          = 'N':  A *x = b
          = 'T':  A'*x = b, where A' is the transpose of A
          = 'C':  A'*x = b, where A' is the transpose of A
[in]M
          M is INTEGER
          The number of rows of the matrix A.  M >= 0.
[in]N
          N is INTEGER
          The number of columns of the matrix A.  N >= 0.
[in]NRHS
          NRHS is INTEGER
          The number of columns of B, the matrix of right hand sides.
          NRHS >= 0.
[in]A
          A is REAL array, dimension (LDA,N)
          The original M x N matrix A.
[in]LDA
          LDA is INTEGER
          The leading dimension of the array A.  LDA >= max(1,M).
[in]X
          X is REAL array, dimension (LDX,NRHS)
          The computed solution vectors for the system of linear
          equations.
[in]LDX
          LDX is INTEGER
          The leading dimension of the array X.  If TRANS = 'N',
          LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,M).
[in,out]B
          B is REAL array, dimension (LDB,NRHS)
          On entry, the right hand side vectors for the system of
          linear equations.
          On exit, B is overwritten with the difference B - A*X.
[in]LDB
          LDB is INTEGER
          The leading dimension of the array B.  IF TRANS = 'N',
          LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N).
[out]RWORK
          RWORK is REAL array, dimension (M)
[out]RESID
          RESID is REAL
          The maximum over the number of right hand sides of
          norm(B - A*X) / ( max(m,n) * norm(A) * norm(X) * EPS ).
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2011

Definition at line 135 of file sqrt16.f.

135 *
136 * -- LAPACK test routine (version 3.4.0) --
137 * -- LAPACK is a software package provided by Univ. of Tennessee, --
138 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
139 * November 2011
140 *
141 * .. Scalar Arguments ..
142  CHARACTER trans
143  INTEGER lda, ldb, ldx, m, n, nrhs
144  REAL resid
145 * ..
146 * .. Array Arguments ..
147  REAL a( lda, * ), b( ldb, * ), rwork( * ),
148  $ x( ldx, * )
149 * ..
150 *
151 * =====================================================================
152 *
153 * .. Parameters ..
154  REAL zero, one
155  parameter ( zero = 0.0e+0, one = 1.0e+0 )
156 * ..
157 * .. Local Scalars ..
158  INTEGER j, n1, n2
159  REAL anorm, bnorm, eps, xnorm
160 * ..
161 * .. External Functions ..
162  LOGICAL lsame
163  REAL sasum, slamch, slange
164  EXTERNAL lsame, sasum, slamch, slange
165 * ..
166 * .. External Subroutines ..
167  EXTERNAL sgemm
168 * ..
169 * .. Intrinsic Functions ..
170  INTRINSIC max
171 * ..
172 * .. Executable Statements ..
173 *
174 * Quick exit if M = 0 or N = 0 or NRHS = 0
175 *
176  IF( m.LE.0 .OR. n.LE.0 .OR. nrhs.EQ.0 ) THEN
177  resid = zero
178  RETURN
179  END IF
180 *
181  IF( lsame( trans, 'T' ) .OR. lsame( trans, 'C' ) ) THEN
182  anorm = slange( 'I', m, n, a, lda, rwork )
183  n1 = n
184  n2 = m
185  ELSE
186  anorm = slange( '1', m, n, a, lda, rwork )
187  n1 = m
188  n2 = n
189  END IF
190 *
191  eps = slamch( 'Epsilon' )
192 *
193 * Compute B - A*X (or B - A'*X ) and store in B.
194 *
195  CALL sgemm( trans, 'No transpose', n1, nrhs, n2, -one, a, lda, x,
196  $ ldx, one, b, ldb )
197 *
198 * Compute the maximum over the number of right hand sides of
199 * norm(B - A*X) / ( max(m,n) * norm(A) * norm(X) * EPS ) .
200 *
201  resid = zero
202  DO 10 j = 1, nrhs
203  bnorm = sasum( n1, b( 1, j ), 1 )
204  xnorm = sasum( n2, x( 1, j ), 1 )
205  IF( anorm.EQ.zero .AND. bnorm.EQ.zero ) THEN
206  resid = zero
207  ELSE IF( anorm.LE.zero .OR. xnorm.LE.zero ) THEN
208  resid = one / eps
209  ELSE
210  resid = max( resid, ( ( bnorm / anorm ) / xnorm ) /
211  $ ( max( m, n )*eps ) )
212  END IF
213  10 CONTINUE
214 *
215  RETURN
216 *
217 * End of SQRT16
218 *
subroutine sgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
SGEMM
Definition: sgemm.f:189
real function slange(NORM, M, N, A, LDA, WORK)
SLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
Definition: slange.f:116
real function sasum(N, SX, INCX)
SASUM
Definition: sasum.f:54
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:69
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55

Here is the call graph for this function:

Here is the caller graph for this function: