1
/* -- translated by f2c (version 20050501).
2
You must link the resulting object file with libf2c:
3
on Microsoft Windows system, link with libf2c.lib;
4
on Linux or Unix systems, link with .../path/to/libf2c.a -lm
5
or, if you install libf2c.a in a standard place, with -lf2c -lm
6
-- in that order, at the end of the command line, as in
8
Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
10
http://www.netlib.org/f2c/libf2c.zip
14
#include "arpack_internal.h"
17
/* Subroutine */ int igraphdlarnv_(integer *idist, integer *iseed, integer *n,
20
/* System generated locals */
21
integer i__1, i__2, i__3;
23
/* Builtin functions */
24
double log(doublereal), sqrt(doublereal), cos(doublereal);
28
static doublereal u[128];
29
static integer il, iv, il2;
30
extern /* Subroutine */ int igraphdlaruv_(integer *, integer *, doublereal *);
33
/* -- LAPACK auxiliary routine (version 3.0) -- */
34
/* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd., */
35
/* Courant Institute, Argonne National Lab, and Rice University */
36
/* September 30, 1994 */
38
/* .. Scalar Arguments .. */
40
/* .. Array Arguments .. */
46
/* DLARNV returns a vector of n random real numbers from a uniform or */
47
/* normal distribution. */
52
/* IDIST (input) INTEGER */
53
/* Specifies the distribution of the random numbers: */
54
/* = 1: uniform (0,1) */
55
/* = 2: uniform (-1,1) */
56
/* = 3: normal (0,1) */
58
/* ISEED (input/output) INTEGER array, dimension (4) */
59
/* On entry, the seed of the random number generator; the array */
60
/* elements must be between 0 and 4095, and ISEED(4) must be */
62
/* On exit, the seed is updated. */
64
/* N (input) INTEGER */
65
/* The number of random numbers to be generated. */
67
/* X (output) DOUBLE PRECISION array, dimension (N) */
68
/* The generated random numbers. */
73
/* This routine calls the auxiliary routine DLARUV to generate random */
74
/* real numbers from a uniform (0,1) distribution, in batches of up to */
75
/* 128 using vectorisable code. The Box-Muller method is used to */
76
/* transform numbers from a uniform to a normal distribution. */
78
/* ===================================================================== */
80
/* .. Parameters .. */
82
/* .. Local Scalars .. */
84
/* .. Local Arrays .. */
86
/* .. Intrinsic Functions .. */
88
/* .. External Subroutines .. */
90
/* .. Executable Statements .. */
92
/* Parameter adjustments */
98
for (iv = 1; iv <= i__1; iv += 64) {
100
i__2 = 64, i__3 = *n - iv + 1;
108
/* Call DLARUV to generate IL2 numbers from a uniform (0,1) */
109
/* distribution (IL2 <= LV) */
111
igraphdlaruv_(&iseed[1], &il2, u);
115
/* Copy generated numbers */
118
for (i__ = 1; i__ <= i__2; ++i__) {
119
x[iv + i__ - 1] = u[i__ - 1];
122
} else if (*idist == 2) {
124
/* Convert generated numbers to uniform (-1,1) distribution */
127
for (i__ = 1; i__ <= i__2; ++i__) {
128
x[iv + i__ - 1] = u[i__ - 1] * 2. - 1.;
131
} else if (*idist == 3) {
133
/* Convert generated numbers to normal (0,1) distribution */
136
for (i__ = 1; i__ <= i__2; ++i__) {
137
x[iv + i__ - 1] = sqrt(log(u[(i__ << 1) - 2]) * -2.) * cos(u[(
138
i__ << 1) - 1] * 6.2831853071795864769252867663);
148
} /* igraphdlarnv_ */