PLASMA  2.4.5
PLASMA - Parallel Linear Algebra for Scalable Multi-core Architectures
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
dqrt01.f
Go to the documentation of this file.
1  SUBROUTINE dqrt01( M, N, A, AF, Q, R, LDA, T, WORK, LWORK,
2  $ rwork, result )
3 *
4  include 'plasmaf.h'
5 *
6 * -- LAPACK test routine (version 3.1) --
7 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
8 * November 2006
9 *
10 * .. Scalar Arguments ..
11  INTEGER lda, lwork, m, n
12  INTEGER t( 2 )
13 * ..
14 * .. Array Arguments ..
15  DOUBLE PRECISION a( lda, * ), af( lda, * ), q( lda, * ),
16  $ r( lda, * ), result( * ), rwork( * ),
17  $ work( lwork )
18 * ..
19 *
20 * Purpose
21 * =======
22 *
23 * DQRT01 tests DGEQRF, which computes the QR factorization of an m-by-n
24 * matrix A, and partially tests DORGQR which forms the m-by-m
25 * orthogonal matrix Q.
26 *
27 * DQRT01 compares R with Q'*A, and checks that Q is orthogonal.
28 *
29 * Arguments
30 * =========
31 *
32 * M (input) INTEGER
33 * The number of rows of the matrix A. M >= 0.
34 *
35 * N (input) INTEGER
36 * The number of columns of the matrix A. N >= 0.
37 *
38 * A (input) DOUBLE PRECISION array, dimension (LDA,N)
39 * The m-by-n matrix A.
40 *
41 * AF (output) DOUBLE PRECISION array, dimension (LDA,N)
42 * Details of the QR factorization of A, as returned by DGEQRF.
43 * See DGEQRF for further details.
44 *
45 * Q (output) DOUBLE PRECISION array, dimension (LDA,M)
46 * The m-by-m orthogonal matrix Q.
47 *
48 * R (workspace) DOUBLE PRECISION array, dimension (LDA,max(M,N))
49 *
50 * LDA (input) INTEGER
51 * The leading dimension of the arrays A, AF, Q and R.
52 * LDA >= max(M,N).
53 *
54 * TAU (output) DOUBLE PRECISION array, dimension (min(M,N))
55 * The scalar factors of the elementary reflectors, as returned
56 * by DGEQRF.
57 *
58 * WORK (workspace) DOUBLE PRECISION array, dimension (LWORK)
59 *
60 * LWORK (input) INTEGER
61 * The dimension of the array WORK.
62 *
63 * RWORK (workspace) DOUBLE PRECISION array, dimension (M)
64 *
65 * RESULT (output) DOUBLE PRECISION array, dimension (2)
66 * The test ratios:
67 * RESULT(1) = norm( R - Q'*A ) / ( M * norm(A) * EPS )
68 * RESULT(2) = norm( I - Q'*Q ) / ( M * EPS )
69 *
70 * =====================================================================
71 *
72 * .. Parameters ..
73  DOUBLE PRECISION zero, one
74  parameter( zero = 0.0d+0, one = 1.0d+0 )
75  DOUBLE PRECISION rogue
76  parameter( rogue = -1.0d+10 )
77 * ..
78 * .. Local Scalars ..
79  INTEGER info, minmn
80  DOUBLE PRECISION anorm, eps, resid
81 * ..
82 * .. External Functions ..
83  DOUBLE PRECISION dlamch, dlange, dlansy
84  EXTERNAL dlamch, dlange, dlansy
85 * ..
86 * .. External Subroutines ..
87  EXTERNAL dgemm, dgeqrf, dlacpy, dlaset, dorgqr, dsyrk
88 * ..
89 * .. Intrinsic Functions ..
90  INTRINSIC dble, max, min
91 * ..
92 * .. Scalars in Common ..
93  CHARACTER*32 srnamt
94 * ..
95 * .. Common blocks ..
96  common / srnamc / srnamt
97 * ..
98 * .. Executable Statements ..
99 *
100  minmn = min( m, n )
101  eps = dlamch( 'Epsilon' )
102 *
103 * Copy the matrix A to the array AF.
104 *
105  CALL dlacpy( 'Full', m, n, a, lda, af, lda )
106 *,
107 * Factorize the matrix A in the array AF.
108 *
109  srnamt = 'DGEQRF'
110  CALL plasma_dgeqrf( m, n, af, lda, t, info )
111 *
112 * Copy details of Q
113 *
114  CALL dlaset( 'Full', m, n, zero, one, q, lda )
115 *
116 * Generate the m-by-m matrix Q
117 *
118  srnamt = 'DORGQR'
119  CALL plasma_dorgqr( m, n, minmn, af, lda, t, q, lda, info )
120 *
121 * Copy R
122 *
123  CALL dlaset( 'Full', n, n, zero, zero, r, lda )
124  CALL dlacpy( 'Upper', m, n, af, lda, r, lda )
125 *
126 * Compute R - Q'*A
127 *
128  CALL dgemm( 'Transpose', 'No transpose', n, n, m, -one, q, lda,
129  $ a, lda, one, r, lda )
130 *
131 * Compute norm( R - Q'*A ) / ( M * norm(A) * EPS ) .
132 *
133  anorm = dlange( '1', m, n, a, lda, rwork )
134  resid = dlange( '1', n, n, r, lda, rwork )
135 *
136  IF( anorm.GT.zero ) THEN
137  result( 1 ) = ( ( resid / dble( max( 1, m ) ) ) / anorm ) / eps
138  ELSE
139  result( 1 ) = zero
140  END IF
141 *
142 * Compute I - Q'*Q
143 *
144  CALL dlaset( 'Full', n, n, zero, one, r, lda )
145  CALL dsyrk( 'Upper', 'Transpose', n, m, one, q, lda, -one, r,
146  $ lda )
147 *
148 * Compute norm( I - Q'*Q ) / ( M * EPS ) .
149 *
150  resid = dlansy( '1', 'Upper', n, r, lda, rwork )
151 *
152  result( 2 ) = ( resid / dble( max( 1, n ) ) ) / eps
153 *
154  return
155 *
156 * End of DQRT01
157 *
158  END