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.

zlarnd.f 3.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. *> \brief \b ZLARND
  2. *
  3. * =========== DOCUMENTATION ===========
  4. *
  5. * Online html documentation available at
  6. * http://www.netlib.org/lapack/explore-html/
  7. *
  8. * Definition:
  9. * ===========
  10. *
  11. * COMPLEX*16 FUNCTION ZLARND( IDIST, ISEED )
  12. *
  13. * .. Scalar Arguments ..
  14. * INTEGER IDIST
  15. * ..
  16. * .. Array Arguments ..
  17. * INTEGER ISEED( 4 )
  18. * ..
  19. *
  20. *
  21. *> \par Purpose:
  22. * =============
  23. *>
  24. *> \verbatim
  25. *>
  26. *> ZLARND returns a random complex number from a uniform or normal
  27. *> distribution.
  28. *> \endverbatim
  29. *
  30. * Arguments:
  31. * ==========
  32. *
  33. *> \param[in] IDIST
  34. *> \verbatim
  35. *> IDIST is INTEGER
  36. *> Specifies the distribution of the random numbers:
  37. *> = 1: real and imaginary parts each uniform (0,1)
  38. *> = 2: real and imaginary parts each uniform (-1,1)
  39. *> = 3: real and imaginary parts each normal (0,1)
  40. *> = 4: uniformly distributed on the disc abs(z) <= 1
  41. *> = 5: uniformly distributed on the circle abs(z) = 1
  42. *> \endverbatim
  43. *>
  44. *> \param[in,out] ISEED
  45. *> \verbatim
  46. *> ISEED is INTEGER array, dimension (4)
  47. *> On entry, the seed of the random number generator; the array
  48. *> elements must be between 0 and 4095, and ISEED(4) must be
  49. *> odd.
  50. *> On exit, the seed is updated.
  51. *> \endverbatim
  52. *
  53. * Authors:
  54. * ========
  55. *
  56. *> \author Univ. of Tennessee
  57. *> \author Univ. of California Berkeley
  58. *> \author Univ. of Colorado Denver
  59. *> \author NAG Ltd.
  60. *
  61. *> \date December 2016
  62. *
  63. *> \ingroup complex16_matgen
  64. *
  65. *> \par Further Details:
  66. * =====================
  67. *>
  68. *> \verbatim
  69. *>
  70. *> This routine calls the auxiliary routine DLARAN to generate a random
  71. *> real number from a uniform (0,1) distribution. The Box-Muller method
  72. *> is used to transform numbers from a uniform to a normal distribution.
  73. *> \endverbatim
  74. *>
  75. * =====================================================================
  76. COMPLEX*16 FUNCTION ZLARND( IDIST, ISEED )
  77. *
  78. * -- LAPACK auxiliary routine (version 3.7.0) --
  79. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  80. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  81. * December 2016
  82. *
  83. * .. Scalar Arguments ..
  84. INTEGER IDIST
  85. * ..
  86. * .. Array Arguments ..
  87. INTEGER ISEED( 4 )
  88. * ..
  89. *
  90. * =====================================================================
  91. *
  92. * .. Parameters ..
  93. DOUBLE PRECISION ZERO, ONE, TWO
  94. PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, TWO = 2.0D+0 )
  95. DOUBLE PRECISION TWOPI
  96. PARAMETER ( TWOPI = 6.2831853071795864769252867663D+0 )
  97. * ..
  98. * .. Local Scalars ..
  99. DOUBLE PRECISION T1, T2
  100. * ..
  101. * .. External Functions ..
  102. DOUBLE PRECISION DLARAN
  103. EXTERNAL DLARAN
  104. * ..
  105. * .. Intrinsic Functions ..
  106. INTRINSIC DCMPLX, EXP, LOG, SQRT
  107. * ..
  108. * .. Executable Statements ..
  109. *
  110. * Generate a pair of real random numbers from a uniform (0,1)
  111. * distribution
  112. *
  113. T1 = DLARAN( ISEED )
  114. T2 = DLARAN( ISEED )
  115. *
  116. IF( IDIST.EQ.1 ) THEN
  117. *
  118. * real and imaginary parts each uniform (0,1)
  119. *
  120. ZLARND = DCMPLX( T1, T2 )
  121. ELSE IF( IDIST.EQ.2 ) THEN
  122. *
  123. * real and imaginary parts each uniform (-1,1)
  124. *
  125. ZLARND = DCMPLX( TWO*T1-ONE, TWO*T2-ONE )
  126. ELSE IF( IDIST.EQ.3 ) THEN
  127. *
  128. * real and imaginary parts each normal (0,1)
  129. *
  130. ZLARND = SQRT( -TWO*LOG( T1 ) )*EXP( DCMPLX( ZERO, TWOPI*T2 ) )
  131. ELSE IF( IDIST.EQ.4 ) THEN
  132. *
  133. * uniform distribution on the unit disc abs(z) <= 1
  134. *
  135. ZLARND = SQRT( T1 )*EXP( DCMPLX( ZERO, TWOPI*T2 ) )
  136. ELSE IF( IDIST.EQ.5 ) THEN
  137. *
  138. * uniform distribution on the unit circle abs(z) = 1
  139. *
  140. ZLARND = EXP( DCMPLX( ZERO, TWOPI*T2 ) )
  141. END IF
  142. RETURN
  143. *
  144. * End of ZLARND
  145. *
  146. END