LAPACK  3.10.0 LAPACK: Linear Algebra PACKage

## ◆ sqrt15()

 subroutine sqrt15 ( integer SCALE, integer RKSEL, integer M, integer N, integer NRHS, real, dimension( lda, * ) A, integer LDA, real, dimension( ldb, * ) B, integer LDB, real, dimension( * ) S, integer RANK, real NORMA, real NORMB, integer, dimension( 4 ) ISEED, real, dimension( lwork ) WORK, integer LWORK )

SQRT15

Purpose:
``` SQRT15 generates a matrix with full or deficient rank and of various
norms.```
Parameters
 [in] SCALE ``` SCALE is INTEGER SCALE = 1: normally scaled matrix SCALE = 2: matrix scaled up SCALE = 3: matrix scaled down``` [in] RKSEL ``` RKSEL is INTEGER RKSEL = 1: full rank matrix RKSEL = 2: rank-deficient matrix``` [in] M ``` M is INTEGER The number of rows of the matrix A.``` [in] N ``` N is INTEGER The number of columns of A.``` [in] NRHS ``` NRHS is INTEGER The number of columns of B.``` [out] A ``` A is REAL array, dimension (LDA,N) The M-by-N matrix A.``` [in] LDA ``` LDA is INTEGER The leading dimension of the array A.``` [out] B ``` B is REAL array, dimension (LDB, NRHS) A matrix that is in the range space of matrix A.``` [in] LDB ``` LDB is INTEGER The leading dimension of the array B.``` [out] S ``` S is REAL array, dimension MIN(M,N) Singular values of A.``` [out] RANK ``` RANK is INTEGER number of nonzero singular values of A.``` [out] NORMA ``` NORMA is REAL one-norm of A.``` [out] NORMB ``` NORMB is REAL one-norm of B.``` [in,out] ISEED ``` ISEED is integer array, dimension (4) seed for random number generator.``` [out] WORK ` WORK is REAL array, dimension (LWORK)` [in] LWORK ``` LWORK is INTEGER length of work space required. LWORK >= MAX(M+MIN(M,N),NRHS*MIN(M,N),2*N+M)```

Definition at line 146 of file sqrt15.f.

148 *
149 * -- LAPACK test routine --
150 * -- LAPACK is a software package provided by Univ. of Tennessee, --
151 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
152 *
153 * .. Scalar Arguments ..
154  INTEGER LDA, LDB, LWORK, M, N, NRHS, RANK, RKSEL, SCALE
155  REAL NORMA, NORMB
156 * ..
157 * .. Array Arguments ..
158  INTEGER ISEED( 4 )
159  REAL A( LDA, * ), B( LDB, * ), S( * ), WORK( LWORK )
160 * ..
161 *
162 * =====================================================================
163 *
164 * .. Parameters ..
165  REAL ZERO, ONE, TWO, SVMIN
166  parameter( zero = 0.0e0, one = 1.0e0, two = 2.0e0,
167  \$ svmin = 0.1e0 )
168 * ..
169 * .. Local Scalars ..
170  INTEGER INFO, J, MN
171  REAL BIGNUM, EPS, SMLNUM, TEMP
172 * ..
173 * .. Local Arrays ..
174  REAL DUMMY( 1 )
175 * ..
176 * .. External Functions ..
177  REAL SASUM, SLAMCH, SLANGE, SLARND, SNRM2
178  EXTERNAL sasum, slamch, slange, slarnd, snrm2
179 * ..
180 * .. External Subroutines ..
181  EXTERNAL sgemm, slaord, slarf, slarnv, slaror, slascl,
182  \$ slaset, sscal, xerbla
183 * ..
184 * .. Intrinsic Functions ..
185  INTRINSIC abs, max, min
186 * ..
187 * .. Executable Statements ..
188 *
189  mn = min( m, n )
190  IF( lwork.LT.max( m+mn, mn*nrhs, 2*n+m ) ) THEN
191  CALL xerbla( 'SQRT15', 16 )
192  RETURN
193  END IF
194 *
195  smlnum = slamch( 'Safe minimum' )
196  bignum = one / smlnum
197  eps = slamch( 'Epsilon' )
198  smlnum = ( smlnum / eps ) / eps
199  bignum = one / smlnum
200 *
201 * Determine rank and (unscaled) singular values
202 *
203  IF( rksel.EQ.1 ) THEN
204  rank = mn
205  ELSE IF( rksel.EQ.2 ) THEN
206  rank = ( 3*mn ) / 4
207  DO 10 j = rank + 1, mn
208  s( j ) = zero
209  10 CONTINUE
210  ELSE
211  CALL xerbla( 'SQRT15', 2 )
212  END IF
213 *
214  IF( rank.GT.0 ) THEN
215 *
216 * Nontrivial case
217 *
218  s( 1 ) = one
219  DO 30 j = 2, rank
220  20 CONTINUE
221  temp = slarnd( 1, iseed )
222  IF( temp.GT.svmin ) THEN
223  s( j ) = abs( temp )
224  ELSE
225  GO TO 20
226  END IF
227  30 CONTINUE
228  CALL slaord( 'Decreasing', rank, s, 1 )
229 *
230 * Generate 'rank' columns of a random orthogonal matrix in A
231 *
232  CALL slarnv( 2, iseed, m, work )
233  CALL sscal( m, one / snrm2( m, work, 1 ), work, 1 )
234  CALL slaset( 'Full', m, rank, zero, one, a, lda )
235  CALL slarf( 'Left', m, rank, work, 1, two, a, lda,
236  \$ work( m+1 ) )
237 *
238 * workspace used: m+mn
239 *
240 * Generate consistent rhs in the range space of A
241 *
242  CALL slarnv( 2, iseed, rank*nrhs, work )
243  CALL sgemm( 'No transpose', 'No transpose', m, nrhs, rank, one,
244  \$ a, lda, work, rank, zero, b, ldb )
245 *
246 * work space used: <= mn *nrhs
247 *
248 * generate (unscaled) matrix A
249 *
250  DO 40 j = 1, rank
251  CALL sscal( m, s( j ), a( 1, j ), 1 )
252  40 CONTINUE
253  IF( rank.LT.n )
254  \$ CALL slaset( 'Full', m, n-rank, zero, zero, a( 1, rank+1 ),
255  \$ lda )
256  CALL slaror( 'Right', 'No initialization', m, n, a, lda, iseed,
257  \$ work, info )
258 *
259  ELSE
260 *
261 * work space used 2*n+m
262 *
263 * Generate null matrix and rhs
264 *
265  DO 50 j = 1, mn
266  s( j ) = zero
267  50 CONTINUE
268  CALL slaset( 'Full', m, n, zero, zero, a, lda )
269  CALL slaset( 'Full', m, nrhs, zero, zero, b, ldb )
270 *
271  END IF
272 *
273 * Scale the matrix
274 *
275  IF( scale.NE.1 ) THEN
276  norma = slange( 'Max', m, n, a, lda, dummy )
277  IF( norma.NE.zero ) THEN
278  IF( scale.EQ.2 ) THEN
279 *
280 * matrix scaled up
281 *
282  CALL slascl( 'General', 0, 0, norma, bignum, m, n, a,
283  \$ lda, info )
284  CALL slascl( 'General', 0, 0, norma, bignum, mn, 1, s,
285  \$ mn, info )
286  CALL slascl( 'General', 0, 0, norma, bignum, m, nrhs, b,
287  \$ ldb, info )
288  ELSE IF( scale.EQ.3 ) THEN
289 *
290 * matrix scaled down
291 *
292  CALL slascl( 'General', 0, 0, norma, smlnum, m, n, a,
293  \$ lda, info )
294  CALL slascl( 'General', 0, 0, norma, smlnum, mn, 1, s,
295  \$ mn, info )
296  CALL slascl( 'General', 0, 0, norma, smlnum, m, nrhs, b,
297  \$ ldb, info )
298  ELSE
299  CALL xerbla( 'SQRT15', 1 )
300  RETURN
301  END IF
302  END IF
303  END IF
304 *
305  norma = sasum( mn, s, 1 )
306  normb = slange( 'One-norm', m, nrhs, b, ldb, dummy )
307 *
308  RETURN
309 *
310 * End of SQRT15
311 *
subroutine slascl(TYPE, KL, KU, CFROM, CTO, M, N, A, LDA, INFO)
SLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition: slascl.f:143
subroutine slarnv(IDIST, ISEED, N, X)
SLARNV returns a vector of random numbers from a uniform or normal distribution.
Definition: slarnv.f:97
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 xerbla(SRNAME, INFO)
XERBLA
Definition: xerbla.f:60
subroutine slaror(SIDE, INIT, M, N, A, LDA, ISEED, X, INFO)
SLAROR
Definition: slaror.f:146
real function slarnd(IDIST, ISEED)
SLARND
Definition: slarnd.f:73
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
subroutine slarf(SIDE, M, N, V, INCV, TAU, C, LDC, WORK)
SLARF applies an elementary reflector to a general rectangular matrix.
Definition: slarf.f:124
subroutine sscal(N, SA, SX, INCX)
SSCAL
Definition: sscal.f:79
real(wp) function snrm2(n, x, incx)
SNRM2
Definition: snrm2.f90:89
real function sasum(N, SX, INCX)
SASUM
Definition: sasum.f:72
subroutine sgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
SGEMM
Definition: sgemm.f:187
subroutine slaord(JOB, N, X, INCX)
SLAORD
Definition: slaord.f:73
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: