~ubuntu-branches/ubuntu/vivid/yagiuda/vivid

« back to all changes in this revision

Viewing changes to .pc/debian-changes-1.19-6.2/src/gaussian.c

  • Committer: Bazaar Package Importer
  • Author(s): Ralf Treinen
  • Date: 2010-08-25 22:19:13 UTC
  • Revision ID: james.westby@ubuntu.com-20100825221913-lgc7yuj3f7nqugpm
Tags: 1.19-7
* QA upload
* Source format 3.0 (quilt)
* patch optopt-declaration: fix declaration of optopt (closes: 593486).
  Thanks a lot to Jakub Wilk <jwilk@debian.org> for the patch!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifdef HAVE_STDLIB_H
 
2
#include <stdlib.h>
 
3
#endif
 
4
#include <stdio.h>
 
5
#include <math.h>
 
6
#include <errno.h>
 
7
#include "yagi.h"
 
8
 
 
9
extern int errno;
 
10
 
 
11
/* The function Gaussian (normal) distibuted  deviate with 0 mean
 
12
and unit standard deviation. This is used in yagi to as it best represents
 
13
the way mechanically the antenna elemnts will be placed */
 
14
 
 
15
double gaussian()
 
16
{
 
17
        double fac,r,x,y;
 
18
 
 
19
                do {
 
20
                        x=2.0*randreal()-1.0;
 
21
                        y=2.0*randreal()-1.0;
 
22
                        r=x*x+y*y;
 
23
                } while (r >= 1.0 || r==0.0);
 
24
                fac=sqrt(-2.0*log(r)/r);
 
25
 
 
26
#ifdef DEBUG
 
27
        if(errno)
 
28
        {
 
29
        fprintf(stderr,"Errno =%d in gaaussian.c\n", errno);
 
30
        exit(1);
 
31
        }
 
32
#endif
 
33
                return y*fac;
 
34
}