LAPACK  3.6.1
LAPACK: Linear Algebra PACKage
subroutine sqrt02 ( integer  M,
integer  N,
integer  K,
real, dimension( lda, * )  A,
real, dimension( lda, * )  AF,
real, dimension( lda, * )  Q,
real, dimension( lda, * )  R,
integer  LDA,
real, dimension( * )  TAU,
real, dimension( lwork )  WORK,
integer  LWORK,
real, dimension( * )  RWORK,
real, dimension( * )  RESULT 
)

SQRT02

Purpose:
 SQRT02 tests SORGQR, which generates an m-by-n matrix Q with
 orthonornmal columns that is defined as the product of k elementary
 reflectors.

 Given the QR factorization of an m-by-n matrix A, SQRT02 generates
 the orthogonal matrix Q defined by the factorization of the first k
 columns of A; it compares R(1:n,1:k) with Q(1:m,1:n)'*A(1:m,1:k),
 and checks that the columns of Q are orthonormal.
Parameters
[in]M
          M is INTEGER
          The number of rows of the matrix Q to be generated.  M >= 0.
[in]N
          N is INTEGER
          The number of columns of the matrix Q to be generated.
          M >= N >= 0.
[in]K
          K is INTEGER
          The number of elementary reflectors whose product defines the
          matrix Q. N >= K >= 0.
[in]A
          A is REAL array, dimension (LDA,N)
          The m-by-n matrix A which was factorized by SQRT01.
[in]AF
          AF is REAL array, dimension (LDA,N)
          Details of the QR factorization of A, as returned by SGEQRF.
          See SGEQRF for further details.
[out]Q
          Q is REAL array, dimension (LDA,N)
[out]R
          R is REAL array, dimension (LDA,N)
[in]LDA
          LDA is INTEGER
          The leading dimension of the arrays A, AF, Q and R. LDA >= M.
[in]TAU
          TAU is REAL array, dimension (N)
          The scalar factors of the elementary reflectors corresponding
          to the QR factorization in AF.
[out]WORK
          WORK is REAL array, dimension (LWORK)
[in]LWORK
          LWORK is INTEGER
          The dimension of the array WORK.
[out]RWORK
          RWORK is REAL array, dimension (M)
[out]RESULT
          RESULT is REAL array, dimension (2)
          The test ratios:
          RESULT(1) = norm( R - Q'*A ) / ( M * norm(A) * EPS )
          RESULT(2) = norm( I - Q'*Q ) / ( M * EPS )
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
November 2011

Definition at line 137 of file sqrt02.f.

137 *
138 * -- LAPACK test routine (version 3.4.0) --
139 * -- LAPACK is a software package provided by Univ. of Tennessee, --
140 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
141 * November 2011
142 *
143 * .. Scalar Arguments ..
144  INTEGER k, lda, lwork, m, n
145 * ..
146 * .. Array Arguments ..
147  REAL a( lda, * ), af( lda, * ), q( lda, * ),
148  $ r( lda, * ), result( * ), rwork( * ), tau( * ),
149  $ work( lwork )
150 * ..
151 *
152 * =====================================================================
153 *
154 * .. Parameters ..
155  REAL zero, one
156  parameter ( zero = 0.0e+0, one = 1.0e+0 )
157  REAL rogue
158  parameter ( rogue = -1.0e+10 )
159 * ..
160 * .. Local Scalars ..
161  INTEGER info
162  REAL anorm, eps, resid
163 * ..
164 * .. External Functions ..
165  REAL slamch, slange, slansy
166  EXTERNAL slamch, slange, slansy
167 * ..
168 * .. External Subroutines ..
169  EXTERNAL sgemm, slacpy, slaset, sorgqr, ssyrk
170 * ..
171 * .. Intrinsic Functions ..
172  INTRINSIC max, real
173 * ..
174 * .. Scalars in Common ..
175  CHARACTER*32 srnamt
176 * ..
177 * .. Common blocks ..
178  COMMON / srnamc / srnamt
179 * ..
180 * .. Executable Statements ..
181 *
182  eps = slamch( 'Epsilon' )
183 *
184 * Copy the first k columns of the factorization to the array Q
185 *
186  CALL slaset( 'Full', m, n, rogue, rogue, q, lda )
187  CALL slacpy( 'Lower', m-1, k, af( 2, 1 ), lda, q( 2, 1 ), lda )
188 *
189 * Generate the first n columns of the matrix Q
190 *
191  srnamt = 'SORGQR'
192  CALL sorgqr( m, n, k, q, lda, tau, work, lwork, info )
193 *
194 * Copy R(1:n,1:k)
195 *
196  CALL slaset( 'Full', n, k, zero, zero, r, lda )
197  CALL slacpy( 'Upper', n, k, af, lda, r, lda )
198 *
199 * Compute R(1:n,1:k) - Q(1:m,1:n)' * A(1:m,1:k)
200 *
201  CALL sgemm( 'Transpose', 'No transpose', n, k, m, -one, q, lda, a,
202  $ lda, one, r, lda )
203 *
204 * Compute norm( R - Q'*A ) / ( M * norm(A) * EPS ) .
205 *
206  anorm = slange( '1', m, k, a, lda, rwork )
207  resid = slange( '1', n, k, r, lda, rwork )
208  IF( anorm.GT.zero ) THEN
209  result( 1 ) = ( ( resid / REAL( MAX( 1, M ) ) ) / anorm ) / eps
210  ELSE
211  result( 1 ) = zero
212  END IF
213 *
214 * Compute I - Q'*Q
215 *
216  CALL slaset( 'Full', n, n, zero, one, r, lda )
217  CALL ssyrk( 'Upper', 'Transpose', n, m, -one, q, lda, one, r,
218  $ lda )
219 *
220 * Compute norm( I - Q'*Q ) / ( M * EPS ) .
221 *
222  resid = slansy( '1', 'Upper', n, r, lda, rwork )
223 *
224  result( 2 ) = ( resid / REAL( MAX( 1, M ) ) ) / eps
225 *
226  RETURN
227 *
228 * End of SQRT02
229 *
subroutine ssyrk(UPLO, TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC)
SSYRK
Definition: ssyrk.f:171
subroutine sgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
SGEMM
Definition: sgemm.f:189
subroutine slacpy(UPLO, M, N, A, LDA, B, LDB)
SLACPY copies all or part of one two-dimensional array to another.
Definition: slacpy.f:105
subroutine slaset(UPLO, M, N, ALPHA, BETA, A, LDA)
SLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values...
Definition: slaset.f:112
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 slamch(CMACH)
SLAMCH
Definition: slamch.f:69
subroutine sorgqr(M, N, K, A, LDA, TAU, WORK, LWORK, INFO)
SORGQR
Definition: sorgqr.f:130
real function slansy(NORM, UPLO, N, A, LDA, WORK)
SLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm, or the element of largest absolute value of a real symmetric matrix.
Definition: slansy.f:124

Here is the call graph for this function:

Here is the caller graph for this function: