📄 ranl_c.mht
字号:
From: <由 Microsoft Internet Explorer 5 保存>
Subject:
Date: Wed, 27 Sep 2006 22:49:00 +0800
MIME-Version: 1.0
Content-Type: text/html;
charset="gb2312"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.oxbad.com/DSP/maindoc/arithmetic_source/c/RANL.C
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<META content=3D"MSHTML 6.00.2900.2963" name=3DGENERATOR></HEAD>
<BODY><PRE>/* ranl.c - linearly interpolated random generator of period =
D */
double ran(); /* uniform generator */
void cdelay2(); /* circular delay */
double ranl(D, u, q, iseed) /* usage: y =3D ranl(D, u, =
&q, &iseed); */
int D, *q; /* \(q\) is cycled =
modulo-\(D\) */
double *u; /* \(u\) =3D 2-dimensional =
array */
long *iseed; /* \(q\), iseed are passed by =
address */
{
double y;
int i;
i =3D (D - *q) % D; /* interpolation index =
*/
y =3D u[0] + (u[1] - u[0]) * i / D; /* linear interpolation =
*/
cdelay2(D-1, q); /* decrement \(q\) and =
wrap mod-\(D\) */
if (*q =3D=3D 0) { /* every \(D\) calls, =
*/
u[0] =3D u[1]; /* set new \(u[0]\) and =
*/
u[1] =3D ran(iseed) - 0.5; /* get new \(u[1]\) =
(zero mean) */
}
return y;
}
</PRE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -