LAPACK  3.10.0
LAPACK: Linear Algebra PACKage

◆ sqrt16()

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.

Definition at line 131 of file sqrt16.f.

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