LAPACK  3.8.0
LAPACK: Linear Algebra PACKage

◆ sqrt04()

subroutine sqrt04 ( integer  M,
integer  N,
integer  NB,
real, dimension(6)  RESULT 
)

SQRT04

Purpose:
 SQRT04 tests SGEQRT and SGEMQRT.
Parameters
[in]M
          M is INTEGER
          Number of rows in test matrix.
[in]N
          N is INTEGER
          Number of columns in test matrix.
[in]NB
          NB is INTEGER
          Block size of test matrix.  NB <= Min(M,N).
[out]RESULT
          RESULT is REAL array, dimension (6)
          Results of each of the six tests below.

          RESULT(1) = | A - Q R |
          RESULT(2) = | I - Q^H Q |
          RESULT(3) = | Q C - Q C |
          RESULT(4) = | Q^H C - Q^H C |
          RESULT(5) = | C Q - C Q |
          RESULT(6) = | C Q^H - C Q^H |
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.
Date
April 2012

Definition at line 75 of file sqrt04.f.

75  IMPLICIT NONE
76 *
77 * -- LAPACK test routine (version 3.8.0) --
78 * -- LAPACK is a software package provided by Univ. of Tennessee, --
79 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
80 * April 2012
81 *
82 * .. Scalar Arguments ..
83  INTEGER m, n, nb, ldt
84 * .. Return values ..
85  REAL result(6)
86 *
87 * =====================================================================
88 *
89 * ..
90 * .. Local allocatable arrays
91  REAL, ALLOCATABLE :: af(:,:), q(:,:),
92  $ r(:,:), rwork(:), work( : ), t(:,:),
93  $ cf(:,:), df(:,:), a(:,:), c(:,:), d(:,:)
94 *
95 * .. Parameters ..
96  REAL one, zero
97  parameter( zero = 0.0, one = 1.0 )
98 * ..
99 * .. Local Scalars ..
100  INTEGER info, j, k, l, lwork
101  REAL anorm, eps, resid, cnorm, dnorm
102 * ..
103 * .. Local Arrays ..
104  INTEGER iseed( 4 )
105 * ..
106 * .. External Subroutine ..
107  EXTERNAL sgemm, slacpy, slarnv, sgemqrt, slaset, sgeqrt, ssyrk
108 * ..
109 * .. External Functions ..
110  REAL slamch
111  REAL slange, slansy
112  LOGICAL lsame
113  EXTERNAL slamch, slange, slansy, lsame
114 * ..
115 * .. Intrinsic Functions ..
116  INTRINSIC max, min
117 * ..
118 * .. Data statements ..
119  DATA iseed / 1988, 1989, 1990, 1991 /
120 *
121  eps = slamch( 'Epsilon' )
122  k = min(m,n)
123  l = max(m,n)
124  lwork = max(2,l)*max(2,l)*nb
125 *
126 * Dynamically allocate local arrays
127 *
128  ALLOCATE ( a(m,n), af(m,n), q(m,m), r(m,l), rwork(l),
129  $ work(lwork), t(nb,n), c(m,n), cf(m,n),
130  $ d(n,m), df(n,m) )
131 *
132 * Put random numbers into A and copy to AF
133 *
134  ldt=nb
135  DO j=1,n
136  CALL slarnv( 2, iseed, m, a( 1, j ) )
137  END DO
138  CALL slacpy( 'Full', m, n, a, m, af, m )
139 *
140 * Factor the matrix A in the array AF.
141 *
142  CALL sgeqrt( m, n, nb, af, m, t, ldt, work, info )
143 *
144 * Generate the m-by-m matrix Q
145 *
146  CALL slaset( 'Full', m, m, zero, one, q, m )
147  CALL sgemqrt( 'R', 'N', m, m, k, nb, af, m, t, ldt, q, m,
148  $ work, info )
149 *
150 * Copy R
151 *
152  CALL slaset( 'Full', m, n, zero, zero, r, m )
153  CALL slacpy( 'Upper', m, n, af, m, r, m )
154 *
155 * Compute |R - Q'*A| / |A| and store in RESULT(1)
156 *
157  CALL sgemm( 'T', 'N', m, n, m, -one, q, m, a, m, one, r, m )
158  anorm = slange( '1', m, n, a, m, rwork )
159  resid = slange( '1', m, n, r, m, rwork )
160  IF( anorm.GT.zero ) THEN
161  result( 1 ) = resid / (eps*max(1,m)*anorm)
162  ELSE
163  result( 1 ) = zero
164  END IF
165 *
166 * Compute |I - Q'*Q| and store in RESULT(2)
167 *
168  CALL slaset( 'Full', m, m, zero, one, r, m )
169  CALL ssyrk( 'U', 'C', m, m, -one, q, m, one, r, m )
170  resid = slansy( '1', 'Upper', m, r, m, rwork )
171  result( 2 ) = resid / (eps*max(1,m))
172 *
173 * Generate random m-by-n matrix C and a copy CF
174 *
175  DO j=1,n
176  CALL slarnv( 2, iseed, m, c( 1, j ) )
177  END DO
178  cnorm = slange( '1', m, n, c, m, rwork)
179  CALL slacpy( 'Full', m, n, c, m, cf, m )
180 *
181 * Apply Q to C as Q*C
182 *
183  CALL sgemqrt( 'L', 'N', m, n, k, nb, af, m, t, nb, cf, m,
184  $ work, info)
185 *
186 * Compute |Q*C - Q*C| / |C|
187 *
188  CALL sgemm( 'N', 'N', m, n, m, -one, q, m, c, m, one, cf, m )
189  resid = slange( '1', m, n, cf, m, rwork )
190  IF( cnorm.GT.zero ) THEN
191  result( 3 ) = resid / (eps*max(1,m)*cnorm)
192  ELSE
193  result( 3 ) = zero
194  END IF
195 *
196 * Copy C into CF again
197 *
198  CALL slacpy( 'Full', m, n, c, m, cf, m )
199 *
200 * Apply Q to C as QT*C
201 *
202  CALL sgemqrt( 'L', 'T', m, n, k, nb, af, m, t, nb, cf, m,
203  $ work, info)
204 *
205 * Compute |QT*C - QT*C| / |C|
206 *
207  CALL sgemm( 'T', 'N', m, n, m, -one, q, m, c, m, one, cf, m )
208  resid = slange( '1', m, n, cf, m, rwork )
209  IF( cnorm.GT.zero ) THEN
210  result( 4 ) = resid / (eps*max(1,m)*cnorm)
211  ELSE
212  result( 4 ) = zero
213  END IF
214 *
215 * Generate random n-by-m matrix D and a copy DF
216 *
217  DO j=1,m
218  CALL slarnv( 2, iseed, n, d( 1, j ) )
219  END DO
220  dnorm = slange( '1', n, m, d, n, rwork)
221  CALL slacpy( 'Full', n, m, d, n, df, n )
222 *
223 * Apply Q to D as D*Q
224 *
225  CALL sgemqrt( 'R', 'N', n, m, k, nb, af, m, t, nb, df, n,
226  $ work, info)
227 *
228 * Compute |D*Q - D*Q| / |D|
229 *
230  CALL sgemm( 'N', 'N', n, m, m, -one, d, n, q, m, one, df, n )
231  resid = slange( '1', n, m, df, n, rwork )
232  IF( cnorm.GT.zero ) THEN
233  result( 5 ) = resid / (eps*max(1,m)*dnorm)
234  ELSE
235  result( 5 ) = zero
236  END IF
237 *
238 * Copy D into DF again
239 *
240  CALL slacpy( 'Full', n, m, d, n, df, n )
241 *
242 * Apply Q to D as D*QT
243 *
244  CALL sgemqrt( 'R', 'T', n, m, k, nb, af, m, t, nb, df, n,
245  $ work, info)
246 *
247 * Compute |D*QT - D*QT| / |D|
248 *
249  CALL sgemm( 'N', 'T', n, m, m, -one, d, n, q, m, one, df, n )
250  resid = slange( '1', n, m, df, n, rwork )
251  IF( cnorm.GT.zero ) THEN
252  result( 6 ) = resid / (eps*max(1,m)*dnorm)
253  ELSE
254  result( 6 ) = zero
255  END IF
256 *
257 * Deallocate all arrays
258 *
259  DEALLOCATE ( a, af, q, r, rwork, work, t, c, d, cf, df)
260 *
261  RETURN
subroutine sgeqrt(M, N, NB, A, LDA, T, LDT, WORK, INFO)
SGEQRT
Definition: sgeqrt.f:143
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
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
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
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:55
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:69
subroutine slarnv(IDIST, ISEED, N, X)
SLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition: slarnv.f:99
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 sgemqrt(SIDE, TRANS, M, N, K, NB, V, LDV, T, LDT, C, LDC, WORK, INFO)
SGEMQRT
Definition: sgemqrt.f:170
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: