~ubuntu-branches/ubuntu/precise/yagiuda/precise

« back to all changes in this revision

Viewing changes to .pc/debian-changes-1.19-6.2/src/better.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
/* better.c This function compares new and old performance of a yagi to see if
 
9
its better. */ 
 
10
 
 
11
extern double vswr, Zo;
 
12
extern struct performance_data max;
 
13
extern int errno;
 
14
int is_it_better(int criteria,struct performance_data n, struct performance_data o) 
 
15
{
 
16
        double resistance_error;
 
17
        struct FCOMPLEX zi_new, zi_old;
 
18
 
 
19
        resistance_error=fabs(n.r - Zo) - fabs( o.r - Zo );
 
20
        zi_new.r=n.r;
 
21
        zi_old.r=o.r;
 
22
        zi_new.i=n.x;
 
23
        zi_old.i=o.x;
 
24
        /* printf("o=%.3lfdBi %.3f dB  %.4f:1\n", o.gain, o.fb, o.swr);
 
25
        printf("n=%.3lfdBi %.3f dB  %.4f:1\n\n", n.gain, n.fb, n.swr); */
 
26
        /* If the user add REASONABLE to the 'better' argument, the program
 
27
        will make some intelligent guesses about whats a reasonale antenna. This
 
28
        could for example avoid ignoring an antenna with 20dB gain but 1.02:1
 
29
        vswr, in favour of 15dB gain but 1.01 vswr. Usually we would consider
 
30
        (all other things equal) the former antenna better. Hence we wont 
 
31
        bother optimising beyond these */
 
32
 
 
33
        if( (criteria & REASONABLE) == REASONABLE)
 
34
        {
 
35
                if( (n.fb > max.fb) && (n.fb < o.fb))
 
36
                        n.fb=o.fb; 
 
37
 
 
38
                if( (fabs(n.r-Zo) < max.r) && 
 
39
                ( fabs(n.r-Zo) > fabs(o.r-Zo) ) )
 
40
                {
 
41
                        n.r=o.r;
 
42
                }
 
43
 
 
44
                if( (n.swr < max.swr) && (n.swr > o.swr) )
 
45
                        n.swr=o.swr;
 
46
                
 
47
                if( (fabs(n.x) < max.x) &&
 
48
                fabs(n.x) > fabs(o.x)  )
 
49
                        n.x=o.x;
 
50
 
 
51
                if( (n.sidelobe > max.sidelobe) && (n.sidelobe < o.sidelobe) )
 
52
                        n.sidelobe=o.sidelobe;
 
53
        }
 
54
        if( (criteria & GAIN) == GAIN)
 
55
        {
 
56
                if( n.gain < o.gain)
 
57
                        return(FALSE);
 
58
        }
 
59
        if( (criteria & FB) == FB)
 
60
        {
 
61
                if( n.fb < o.fb)
 
62
                        return(FALSE);
 
63
        }
 
64
        if( (criteria & RESISTANCE) == RESISTANCE)
 
65
        {
 
66
                resistance_error=fabs(n.r-Zo)-fabs(o.r-Zo);
 
67
                if(resistance_error > 0.0)
 
68
                        return(FALSE);
 
69
        }
 
70
        if( (criteria & REACTANCE) == REACTANCE)
 
71
        {
 
72
                if(fabs(n.x) > fabs(o.x))
 
73
                        return(FALSE);
 
74
        }
 
75
        if( (criteria & VSWR) == VSWR)
 
76
        {
 
77
                if( n.swr > o.swr)
 
78
                        return(FALSE);
 
79
        }
 
80
        if((criteria & SIDE_LOBE_LEVEL) == SIDE_LOBE_LEVEL)
 
81
        {
 
82
                if(n.sidelobe < o.sidelobe)
 
83
                        return(FALSE);
 
84
        }
 
85
#ifdef DEBUG
 
86
        if(errno)
 
87
        {
 
88
        fprintf(stderr,"Errno =%d in better.c\n", errno);
 
89
        exit(1);
 
90
        }
 
91
#endif
 
92
        return(TRUE);
 
93
}
 
94