~ubuntu-branches/ubuntu/maverick/yagiuda/maverick

« back to all changes in this revision

Viewing changes to src/reflection_coefficient.c

  • Committer: Bazaar Package Importer
  • Author(s): Joop Stakenborg
  • Date: 2005-08-22 20:20:13 UTC
  • Revision ID: james.westby@ubuntu.com-20050822202013-mhhxp4xirdxrdfx1
Tags: upstream-1.19
ImportĀ upstreamĀ versionĀ 1.19

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
extern int errno;
 
9
extern double Zo;
 
10
 
 
11
void reflection_coefficient(struct FCOMPLEX zi, double *magnitude, double *phase)
 
12
{
 
13
        struct FCOMPLEX zo, rho;
 
14
 
 
15
        /* reflection coefficient rho = (Zi-Zo)/(Zi+Zo) */
 
16
        zo.r=Zo;
 
17
        zo.i=0;
 
18
        rho=Cdiv(Csub(zi, zo), Cadd(zi,zo));
 
19
        *magnitude=Cabs(rho);
 
20
        *phase=atan2(rho.i,rho.r);
 
21
#ifdef DEBUG
 
22
        if(errno)
 
23
        {
 
24
        fprintf(stderr,"Errno =%d in refco.c \n", errno);
 
25
        exit(1);
 
26
        }
 
27
#endif
 
28
}