mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-04 23:31:12 +00:00
beginning to fold in HOD code with jeremy tinker's approval
This commit is contained in:
parent
d8108d3a8e
commit
44cd0eb71f
95 changed files with 21950 additions and 0 deletions
24
c_tools/hod/gasdev.c
Normal file
24
c_tools/hod/gasdev.c
Normal file
|
@ -0,0 +1,24 @@
|
|||
#include <math.h>
|
||||
|
||||
float gasdev(long *idum)
|
||||
{
|
||||
float ran1(long *idum);
|
||||
static int iset=0;
|
||||
static float gset;
|
||||
float fac,rsq,v1,v2;
|
||||
|
||||
if (iset == 0) {
|
||||
do {
|
||||
v1=2.0*ran1(idum)-1.0;
|
||||
v2=2.0*ran1(idum)-1.0;
|
||||
rsq=v1*v1+v2*v2;
|
||||
} while (rsq >= 1.0 || rsq == 0.0);
|
||||
fac=sqrt(-2.0*log(rsq)/rsq);
|
||||
gset=v1*fac;
|
||||
iset=1;
|
||||
return v2*fac;
|
||||
} else {
|
||||
iset=0;
|
||||
return gset;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue