3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * REAL FUNCTION SQRT14( TRANS, M, N, NRHS, A, LDA, X,
14 * .. Scalar Arguments ..
16 * INTEGER LDA, LDX, LWORK, M, N, NRHS
18 * .. Array Arguments ..
19 * REAL A( LDA, * ), WORK( LWORK ), X( LDX, * )
28 *> SQRT14 checks whether X is in the row space of A or A'. It does so
29 *> by scaling both X and A such that their norms are in the range
30 *> [sqrt(eps), 1/sqrt(eps)], then computing a QR factorization of [A,X]
31 *> (if TRANS = 'T') or an LQ factorization of [A',X]' (if TRANS = 'N'),
32 *> and returning the norm of the trailing triangle, scaled by
41 *> TRANS is CHARACTER*1
42 *> = 'N': No transpose, check for X in the row space of A
43 *> = 'T': Transpose, check for X in the row space of A'.
49 *> The number of rows of the matrix A.
55 *> The number of columns of the matrix A.
61 *> The number of right hand sides, i.e., the number of columns
67 *> A is REAL array, dimension (LDA,N)
68 *> The M-by-N matrix A.
74 *> The leading dimension of the array A.
79 *> X is REAL array, dimension (LDX,NRHS)
80 *> If TRANS = 'N', the N-by-NRHS matrix X.
81 *> IF TRANS = 'T', the M-by-NRHS matrix X.
87 *> The leading dimension of the array X.
92 *> WORK is REAL array dimension (LWORK)
98 *> length of workspace array required
99 *> If TRANS = 'N', LWORK >= (M+NRHS)*(N+2);
100 *> if TRANS = 'T', LWORK >= (N+NRHS)*(M+2).
106 *> \author Univ. of Tennessee
107 *> \author Univ. of California Berkeley
108 *> \author Univ. of Colorado Denver
111 *> \date November 2011
113 *> \ingroup single_lin
115 * =====================================================================
116 REAL FUNCTION SQRT14( TRANS, M, N, NRHS, A, LDA, X,
119 * -- LAPACK test routine (version 3.4.0) --
120 * -- LAPACK is a software package provided by Univ. of Tennessee, --
121 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
124 * .. Scalar Arguments ..
126 INTEGER LDA, LDX, LWORK, M, N, NRHS
128 * .. Array Arguments ..
129 REAL A( LDA, * ), WORK( LWORK ), X( LDX, * )
132 * =====================================================================
136 PARAMETER ( ZERO = 0.0E0, ONE = 1.0E0 )
138 * .. Local Scalars ..
140 INTEGER I, INFO, J, LDWORK
146 * .. External Functions ..
149 EXTERNAL LSAME, SLAMCH, SLANGE
151 * .. External Subroutines ..
152 EXTERNAL SGELQ2, SGEQR2, SLACPY, SLASCL, XERBLA
154 * .. Intrinsic Functions ..
155 INTRINSIC ABS, MAX, MIN, REAL
157 * .. Executable Statements ..
160 IF( LSAME( TRANS, 'N' ) ) THEN
163 IF( LWORK.LT.( M+NRHS )*( N+2 ) ) THEN
164 CALL XERBLA( 'SQRT14', 10 )
166 ELSE IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
169 ELSE IF( LSAME( TRANS, 'T' ) ) THEN
172 IF( LWORK.LT.( N+NRHS )*( M+2 ) ) THEN
173 CALL XERBLA( 'SQRT14', 10 )
175 ELSE IF( M.LE.0 .OR. NRHS.LE.0 ) THEN
179 CALL XERBLA( 'SQRT14', 1 )
185 CALL SLACPY( 'All', M, N, A, LDA, WORK, LDWORK )
186 ANRM = SLANGE( 'M', M, N, WORK, LDWORK, RWORK )
188 $ CALL SLASCL( 'G', 0, 0, ANRM, ONE, M, N, WORK, LDWORK, INFO )
190 * Copy X or X' into the right place and scale it
194 * Copy X into columns n+1:n+nrhs of work
196 CALL SLACPY( 'All', M, NRHS, X, LDX, WORK( N*LDWORK+1 ),
198 XNRM = SLANGE( 'M', M, NRHS, WORK( N*LDWORK+1 ), LDWORK,
201 $ CALL SLASCL( 'G', 0, 0, XNRM, ONE, M, NRHS,
202 $ WORK( N*LDWORK+1 ), LDWORK, INFO )
203 ANRM = SLANGE( 'One-norm', M, N+NRHS, WORK, LDWORK, RWORK )
205 * Compute QR factorization of X
207 CALL SGEQR2( M, N+NRHS, WORK, LDWORK,
208 $ WORK( LDWORK*( N+NRHS )+1 ),
209 $ WORK( LDWORK*( N+NRHS )+MIN( M, N+NRHS )+1 ),
212 * Compute largest entry in upper triangle of
213 * work(n+1:m,n+1:n+nrhs)
216 DO 20 J = N + 1, N + NRHS
217 DO 10 I = N + 1, MIN( M, J )
218 ERR = MAX( ERR, ABS( WORK( I+( J-1 )*M ) ) )
224 * Copy X' into rows m+1:m+nrhs of work
228 WORK( M+J+( I-1 )*LDWORK ) = X( I, J )
232 XNRM = SLANGE( 'M', NRHS, N, WORK( M+1 ), LDWORK, RWORK )
234 $ CALL SLASCL( 'G', 0, 0, XNRM, ONE, NRHS, N, WORK( M+1 ),
237 * Compute LQ factorization of work
239 CALL SGELQ2( LDWORK, N, WORK, LDWORK, WORK( LDWORK*N+1 ),
240 $ WORK( LDWORK*( N+1 )+1 ), INFO )
242 * Compute largest entry in lower triangle in
243 * work(m+1:m+nrhs,m+1:n)
248 ERR = MAX( ERR, ABS( WORK( I+( J-1 )*LDWORK ) ) )
254 SQRT14 = ERR / ( REAL( MAX( M, N, NRHS ) )*SLAMCH( 'Epsilon' ) )