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

📄 gran2.cc.txt

📁 压缩文件中是Error Correction Coding - Mathematical Methods and Algorithms(Wiley 2005)作者:(Todd K. Moon )的配
💻 TXT
字号:
/**********************************************************************/
/* Generate two unit-variance Gaussian random numbers.
   This function calls rand(), so you can control the seed using
   void srand(unsigned int seed);

   Following Numerical Recipes
*/
/* Copyright 2004 by Todd K. Moon
 Permission is granted to use this program/data
 for educational/research only
*/

#include <stdlib.h>
#include <math.h>

void gran2(double &r1, double &r2)
{
   double rsq, v1, v2, fac;

   do {
	  v1 = 2*(rand()/(double)RAND_MAX) - 1;
	  v2 = 2*(rand()/(double)RAND_MAX) - 1;
	  rsq = v1*v1 + v2*v2;
   } while(rsq > 1 || rsq == 0);
   fac = sqrt(-2*log(rsq)/rsq);
   r1 = v1*fac;
   r2 = v2*fac;
}

⌨️ 快捷键说明

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