LAPACK 3.11.0 LAPACK: Linear Algebra PACKage
Searching...
No Matches

## ◆ sort01()

 subroutine sort01 ( character ROWCOL, integer M, integer N, real, dimension( ldu, * ) U, integer LDU, real, dimension( * ) WORK, integer LWORK, real RESID )

SORT01

Purpose:
``` SORT01 checks that the matrix U is orthogonal by computing the ratio

RESID = norm( I - U*U' ) / ( n * EPS ), if ROWCOL = 'R',
or
RESID = norm( I - U'*U ) / ( m * EPS ), if ROWCOL = 'C'.

Alternatively, if there isn't sufficient workspace to form
I - U*U' or I - U'*U, the ratio is computed as

RESID = abs( I - U*U' ) / ( n * EPS ), if ROWCOL = 'R',
or
RESID = abs( I - U'*U ) / ( m * EPS ), if ROWCOL = 'C'.

where EPS is the machine precision.  ROWCOL is used only if m = n;
if m > n, ROWCOL is assumed to be 'C', and if m < n, ROWCOL is
assumed to be 'R'.```
Parameters
 [in] ROWCOL ``` ROWCOL is CHARACTER Specifies whether the rows or columns of U should be checked for orthogonality. Used only if M = N. = 'R': Check for orthogonal rows of U = 'C': Check for orthogonal columns of U``` [in] M ``` M is INTEGER The number of rows of the matrix U.``` [in] N ``` N is INTEGER The number of columns of the matrix U.``` [in] U ``` U is REAL array, dimension (LDU,N) The orthogonal matrix U. U is checked for orthogonal columns if m > n or if m = n and ROWCOL = 'C'. U is checked for orthogonal rows if m < n or if m = n and ROWCOL = 'R'.``` [in] LDU ``` LDU is INTEGER The leading dimension of the array U. LDU >= max(1,M).``` [out] WORK ` WORK is REAL array, dimension (LWORK)` [in] LWORK ``` LWORK is INTEGER The length of the array WORK. For best performance, LWORK should be at least N*(N+1) if ROWCOL = 'C' or M*(M+1) if ROWCOL = 'R', but the test will be done even if LWORK is 0.``` [out] RESID ``` RESID is REAL RESID = norm( I - U * U' ) / ( n * EPS ), if ROWCOL = 'R', or RESID = norm( I - U' * U ) / ( m * EPS ), if ROWCOL = 'C'.```

Definition at line 115 of file sort01.f.

116*
117* -- LAPACK test routine --
118* -- LAPACK is a software package provided by Univ. of Tennessee, --
119* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
120*
121* .. Scalar Arguments ..
122 CHARACTER ROWCOL
123 INTEGER LDU, LWORK, M, N
124 REAL RESID
125* ..
126* .. Array Arguments ..
127 REAL U( LDU, * ), WORK( * )
128* ..
129*
130* =====================================================================
131*
132* .. Parameters ..
133 REAL ZERO, ONE
134 parameter( zero = 0.0e+0, one = 1.0e+0 )
135* ..
136* .. Local Scalars ..
137 CHARACTER TRANSU
138 INTEGER I, J, K, LDWORK, MNMIN
139 REAL EPS, TMP
140* ..
141* .. External Functions ..
142 LOGICAL LSAME
143 REAL SDOT, SLAMCH, SLANSY
144 EXTERNAL lsame, sdot, slamch, slansy
145* ..
146* .. External Subroutines ..
147 EXTERNAL slaset, ssyrk
148* ..
149* .. Intrinsic Functions ..
150 INTRINSIC max, min, real
151* ..
152* .. Executable Statements ..
153*
154 resid = zero
155*
156* Quick return if possible
157*
158 IF( m.LE.0 .OR. n.LE.0 )
159 \$ RETURN
160*
161 eps = slamch( 'Precision' )
162 IF( m.LT.n .OR. ( m.EQ.n .AND. lsame( rowcol, 'R' ) ) ) THEN
163 transu = 'N'
164 k = n
165 ELSE
166 transu = 'T'
167 k = m
168 END IF
169 mnmin = min( m, n )
170*
171 IF( ( mnmin+1 )*mnmin.LE.lwork ) THEN
172 ldwork = mnmin
173 ELSE
174 ldwork = 0
175 END IF
176 IF( ldwork.GT.0 ) THEN
177*
178* Compute I - U*U' or I - U'*U.
179*
180 CALL slaset( 'Upper', mnmin, mnmin, zero, one, work, ldwork )
181 CALL ssyrk( 'Upper', transu, mnmin, k, -one, u, ldu, one, work,
182 \$ ldwork )
183*
184* Compute norm( I - U*U' ) / ( K * EPS ) .
185*
186 resid = slansy( '1', 'Upper', mnmin, work, ldwork,
187 \$ work( ldwork*mnmin+1 ) )
188 resid = ( resid / real( k ) ) / eps
189 ELSE IF( transu.EQ.'T' ) THEN
190*
191* Find the maximum element in abs( I - U'*U ) / ( m * EPS )
192*
193 DO 20 j = 1, n
194 DO 10 i = 1, j
195 IF( i.NE.j ) THEN
196 tmp = zero
197 ELSE
198 tmp = one
199 END IF
200 tmp = tmp - sdot( m, u( 1, i ), 1, u( 1, j ), 1 )
201 resid = max( resid, abs( tmp ) )
202 10 CONTINUE
203 20 CONTINUE
204 resid = ( resid / real( m ) ) / eps
205 ELSE
206*
207* Find the maximum element in abs( I - U*U' ) / ( n * EPS )
208*
209 DO 40 j = 1, m
210 DO 30 i = 1, j
211 IF( i.NE.j ) THEN
212 tmp = zero
213 ELSE
214 tmp = one
215 END IF
216 tmp = tmp - sdot( n, u( j, 1 ), ldu, u( i, 1 ), ldu )
217 resid = max( resid, abs( tmp ) )
218 30 CONTINUE
219 40 CONTINUE
220 resid = ( resid / real( n ) ) / eps
221 END IF
222 RETURN
223*
224* End of SORT01
225*
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
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:53
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
real function sdot(N, SX, INCX, SY, INCY)
SDOT
Definition: sdot.f:82
subroutine ssyrk(UPLO, TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC)
SSYRK
Definition: ssyrk.f:169
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:68
Here is the call graph for this function:
Here is the caller graph for this function: