⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 random.c

📁 this the source code of audio compression standard LPC. It is coded by C.
💻 C
字号:
/***********************************************************************
*
*	RANDOM Version 49
*
***********************************************************************
*
*  Pseudo random number generator based on Knuth, Vol 2, p. 27.
*
* Function Return:
*  RANDOM - Integer variable, uniformly distributed over -32768 to 32767
*
* Warning:  This routine contains statements which are specific to VAX Fortran.
*		I'll try it anyway - Tiner
*/

#define MIDTAP 1
#define MAXTAP 4

int Rrandom ()
{
int the_random;
static short y[MAXTAP+1]={-21161, -8478, 30892,-10216, 16950};
static int j=MIDTAP, k=MAXTAP;

/*   The following is a 16 bit 2's complement addition,
*   with overflow checking disabled	*/

y[k] += y[j];

if(y[k] > 32767) /* to make 16 bit rollover to -/+ */
  y[k] = -(32768 - (y[k] & 32767));
if(y[k] < -32768)
  y[k] = y[k] & 32767;
	
the_random = y[k];
k--;
if (k < 0) k = MAXTAP;
j--;
if (j < 0) j = MAXTAP;

return(the_random);

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -