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 #include <errno.h>
9 extern double Zo;
10 
reflection_coefficient(struct FCOMPLEX zi,double * magnitude,double * phase)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 }
29