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

« back to all changes in this revision

Viewing changes to src/fill_z_matrix.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 <errno.h>
 
6
#include "yagi.h"
 
7
extern int errno;
 
8
/* We calculate the full Z matrix. Since the matrix is symmetrical, we only
 
9
need compute Z_i,j for j=1 to i. The function mutual, filles in Zji, when
 
10
we ask it to fill in Zij. */
 
11
 
 
12
void fill_z_matrix(double frequency, int driven, int parasitic, double **d, double **p, double **impedance)
 
13
{
 
14
 
 
15
        int i,j, elements=driven+parasitic;
 
16
        for(i=1;i<=elements;++i)                        /* for every antenna element */
 
17
        {
 
18
                for(j=1;j<=i;++j)     
 
19
                {
 
20
                        if(i==j)                                                                                        /* Need self impedance */
 
21
                        {
 
22
                                if(i<=driven)
 
23
                                {
 
24
                                        self_impedance(i, frequency, driven, parasitic, d, impedance);
 
25
                                }
 
26
                                else if (i > driven )                                     /* parasitic element */
 
27
                                {
 
28
                                        self_impedance(i, frequency, driven, parasitic, p, impedance);
 
29
                                }
 
30
                        }
 
31
                        else if (i != j)                /* need mutual impedance */
 
32
                        {
 
33
                                 mutual_impedance(i,j,frequency,driven,parasitic, d, p, impedance); 
 
34
                        }
 
35
                }
 
36
        }
 
37
 
 
38
#ifdef DEBUG
 
39
        if(errno)
 
40
        {
 
41
                fprintf(stderr,"Errno =%d in z.c\n", errno);
 
42
                exit(1);
 
43
        }
 
44
#endif
 
45
}