LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ sqrt02()

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
 orthonormal 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.

Definition at line 133 of file sqrt02.f.

135*
136* -- LAPACK test routine --
137* -- LAPACK is a software package provided by Univ. of Tennessee, --
138* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
139*
140* .. Scalar Arguments ..
141 INTEGER K, LDA, LWORK, M, N
142* ..
143* .. Array Arguments ..
144 REAL A( LDA, * ), AF( LDA, * ), Q( LDA, * ),
145 $ R( LDA, * ), RESULT( * ), RWORK( * ), TAU( * ),
146 $ WORK( LWORK )
147* ..
148*
149* =====================================================================
150*
151* .. Parameters ..
152 REAL ZERO, ONE
153 parameter( zero = 0.0e+0, one = 1.0e+0 )
154 REAL ROGUE
155 parameter( rogue = -1.0e+10 )
156* ..
157* .. Local Scalars ..
158 INTEGER INFO
159 REAL ANORM, EPS, RESID
160* ..
161* .. External Functions ..
162 REAL SLAMCH, SLANGE, SLANSY
163 EXTERNAL slamch, slange, slansy
164* ..
165* .. External Subroutines ..
166 EXTERNAL sgemm, slacpy, slaset, sorgqr, ssyrk
167* ..
168* .. Intrinsic Functions ..
169 INTRINSIC max, real
170* ..
171* .. Scalars in Common ..
172 CHARACTER*32 SRNAMT
173* ..
174* .. Common blocks ..
175 COMMON / srnamc / srnamt
176* ..
177* .. Executable Statements ..
178*
179 eps = slamch( 'Epsilon' )
180*
181* Copy the first k columns of the factorization to the array Q
182*
183 CALL slaset( 'Full', m, n, rogue, rogue, q, lda )
184 CALL slacpy( 'Lower', m-1, k, af( 2, 1 ), lda, q( 2, 1 ), lda )
185*
186* Generate the first n columns of the matrix Q
187*
188 srnamt = 'SORGQR'
189 CALL sorgqr( m, n, k, q, lda, tau, work, lwork, info )
190*
191* Copy R(1:n,1:k)
192*
193 CALL slaset( 'Full', n, k, zero, zero, r, lda )
194 CALL slacpy( 'Upper', n, k, af, lda, r, lda )
195*
196* Compute R(1:n,1:k) - Q(1:m,1:n)' * A(1:m,1:k)
197*
198 CALL sgemm( 'Transpose', 'No transpose', n, k, m, -one, q, lda, a,
199 $ lda, one, r, lda )
200*
201* Compute norm( R - Q'*A ) / ( M * norm(A) * EPS ) .
202*
203 anorm = slange( '1', m, k, a, lda, rwork )
204 resid = slange( '1', n, k, r, lda, rwork )
205 IF( anorm.GT.zero ) THEN
206 result( 1 ) = ( ( resid / real( max( 1, m ) ) ) / anorm ) / eps
207 ELSE
208 result( 1 ) = zero
209 END IF
210*
211* Compute I - Q'*Q
212*
213 CALL slaset( 'Full', n, n, zero, one, r, lda )
214 CALL ssyrk( 'Upper', 'Transpose', n, m, -one, q, lda, one, r,
215 $ lda )
216*
217* Compute norm( I - Q'*Q ) / ( M * EPS ) .
218*
219 resid = slansy( '1', 'Upper', n, r, lda, rwork )
220*
221 result( 2 ) = ( resid / real( max( 1, m ) ) ) / eps
222*
223 RETURN
224*
225* End of SQRT02
226*
subroutine sgemm(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc)
SGEMM
Definition sgemm.f:188
subroutine ssyrk(uplo, trans, n, k, alpha, a, lda, beta, c, ldc)
SSYRK
Definition ssyrk.f:169
subroutine slacpy(uplo, m, n, a, lda, b, ldb)
SLACPY copies all or part of one two-dimensional array to another.
Definition slacpy.f:103
real function slamch(cmach)
SLAMCH
Definition slamch.f:68
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 slansy(norm, uplo, n, a, lda, work)
SLANSY returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition slansy.f:122
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:110
subroutine sorgqr(m, n, k, a, lda, tau, work, lwork, info)
SORGQR
Definition sorgqr.f:128
Here is the call graph for this function:
Here is the caller graph for this function: