You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dlarge.f 4.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. *> \brief \b DLARGE
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. * Definition:
  9. * ===========
  10. *
  11. * SUBROUTINE DLARGE( N, A, LDA, ISEED, WORK, INFO )
  12. *
  13. * .. Scalar Arguments ..
  14. * INTEGER INFO, LDA, N
  15. * ..
  16. * .. Array Arguments ..
  17. * INTEGER ISEED( 4 )
  18. * DOUBLE PRECISION A( LDA, * ), WORK( * )
  19. * ..
  20. *
  21. *
  22. *> \par Purpose:
  23. * =============
  24. *>
  25. *> \verbatim
  26. *>
  27. *> DLARGE pre- and post-multiplies a real general n by n matrix A
  28. *> with a random orthogonal matrix: A = U*D*U'.
  29. *> \endverbatim
  30. *
  31. * Arguments:
  32. * ==========
  33. *
  34. *> \param[in] N
  35. *> \verbatim
  36. *> N is INTEGER
  37. *> The order of the matrix A. N >= 0.
  38. *> \endverbatim
  39. *>
  40. *> \param[in,out] A
  41. *> \verbatim
  42. *> A is DOUBLE PRECISION array, dimension (LDA,N)
  43. *> On entry, the original n by n matrix A.
  44. *> On exit, A is overwritten by U*A*U' for some random
  45. *> orthogonal matrix U.
  46. *> \endverbatim
  47. *>
  48. *> \param[in] LDA
  49. *> \verbatim
  50. *> LDA is INTEGER
  51. *> The leading dimension of the array A. LDA >= N.
  52. *> \endverbatim
  53. *>
  54. *> \param[in,out] ISEED
  55. *> \verbatim
  56. *> ISEED is INTEGER array, dimension (4)
  57. *> On entry, the seed of the random number generator; the array
  58. *> elements must be between 0 and 4095, and ISEED(4) must be
  59. *> odd.
  60. *> On exit, the seed is updated.
  61. *> \endverbatim
  62. *>
  63. *> \param[out] WORK
  64. *> \verbatim
  65. *> WORK is DOUBLE PRECISION array, dimension (2*N)
  66. *> \endverbatim
  67. *>
  68. *> \param[out] INFO
  69. *> \verbatim
  70. *> INFO is INTEGER
  71. *> = 0: successful exit
  72. *> < 0: if INFO = -i, the i-th argument had an illegal value
  73. *> \endverbatim
  74. *
  75. * Authors:
  76. * ========
  77. *
  78. *> \author Univ. of Tennessee
  79. *> \author Univ. of California Berkeley
  80. *> \author Univ. of Colorado Denver
  81. *> \author NAG Ltd.
  82. *
  83. *> \date December 2016
  84. *
  85. *> \ingroup double_matgen
  86. *
  87. * =====================================================================
  88. SUBROUTINE DLARGE( N, A, LDA, ISEED, WORK, INFO )
  89. *
  90. * -- LAPACK auxiliary routine (version 3.7.0) --
  91. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  92. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  93. * December 2016
  94. *
  95. * .. Scalar Arguments ..
  96. INTEGER INFO, LDA, N
  97. * ..
  98. * .. Array Arguments ..
  99. INTEGER ISEED( 4 )
  100. DOUBLE PRECISION A( LDA, * ), WORK( * )
  101. * ..
  102. *
  103. * =====================================================================
  104. *
  105. * .. Parameters ..
  106. DOUBLE PRECISION ZERO, ONE
  107. PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
  108. * ..
  109. * .. Local Scalars ..
  110. INTEGER I
  111. DOUBLE PRECISION TAU, WA, WB, WN
  112. * ..
  113. * .. External Subroutines ..
  114. EXTERNAL DGEMV, DGER, DLARNV, DSCAL, XERBLA
  115. * ..
  116. * .. Intrinsic Functions ..
  117. INTRINSIC MAX, SIGN
  118. * ..
  119. * .. External Functions ..
  120. DOUBLE PRECISION DNRM2
  121. EXTERNAL DNRM2
  122. * ..
  123. * .. Executable Statements ..
  124. *
  125. * Test the input arguments
  126. *
  127. INFO = 0
  128. IF( N.LT.0 ) THEN
  129. INFO = -1
  130. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  131. INFO = -3
  132. END IF
  133. IF( INFO.LT.0 ) THEN
  134. CALL XERBLA( 'DLARGE', -INFO )
  135. RETURN
  136. END IF
  137. *
  138. * pre- and post-multiply A by random orthogonal matrix
  139. *
  140. DO 10 I = N, 1, -1
  141. *
  142. * generate random reflection
  143. *
  144. CALL DLARNV( 3, ISEED, N-I+1, WORK )
  145. WN = DNRM2( N-I+1, WORK, 1 )
  146. WA = SIGN( WN, WORK( 1 ) )
  147. IF( WN.EQ.ZERO ) THEN
  148. TAU = ZERO
  149. ELSE
  150. WB = WORK( 1 ) + WA
  151. CALL DSCAL( N-I, ONE / WB, WORK( 2 ), 1 )
  152. WORK( 1 ) = ONE
  153. TAU = WB / WA
  154. END IF
  155. *
  156. * multiply A(i:n,1:n) by random reflection from the left
  157. *
  158. CALL DGEMV( 'Transpose', N-I+1, N, ONE, A( I, 1 ), LDA, WORK,
  159. $ 1, ZERO, WORK( N+1 ), 1 )
  160. CALL DGER( N-I+1, N, -TAU, WORK, 1, WORK( N+1 ), 1, A( I, 1 ),
  161. $ LDA )
  162. *
  163. * multiply A(1:n,i:n) by random reflection from the right
  164. *
  165. CALL DGEMV( 'No transpose', N, N-I+1, ONE, A( 1, I ), LDA,
  166. $ WORK, 1, ZERO, WORK( N+1 ), 1 )
  167. CALL DGER( N, N-I+1, -TAU, WORK( N+1 ), 1, WORK, 1, A( 1, I ),
  168. $ LDA )
  169. 10 CONTINUE
  170. RETURN
  171. *
  172. * End of DLARGE
  173. *
  174. END