]> git.rkrishnan.org Git - dttsp.git/blob - jDttSP/bufvec.h
Initial revision
[dttsp.git] / jDttSP / bufvec.h
1 /* bufvec.h
2
3 defs for vector and buffer data structures and utilities
4    
5 This file is part of a program that implements a Software-Defined Radio.
6
7 Copyright (C) 2004 by Frank Brickle, AB2KT and Bob McGwier, N4HY
8
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
23 The authors can be reached by email at
24
25 ab2kt@arrl.net
26 or
27 rwmcgwier@comcast.net
28
29 or by paper mail at
30
31 The DTTS Microwave Society
32 6 Kathleen Place
33 Bridgewater, NJ 08807
34 */
35
36 #ifndef _bufvec_h
37
38 #define _bufvec_h
39
40 #include <fromsys.h>
41 #include <datatypes.h>
42 #include <complex.h>
43 #include <cxops.h>
44
45 typedef struct _complex_buffer_desc {
46   COMPLEX *data;
47   int size, ovlp, want, have, done, mine;
48 } CXBuffer, *CXB;
49
50 /* all these should be OK rhs or lhs */
51
52 #define CXBbase(p) ((p)->data)
53 #define CXBdata(p, i) (CXBbase(p)[(i)])
54 #define CXBreal(p, i) (CXBbase(p)[(i)].re)
55 #define CXBimag(p, i) (CXBbase(p)[(i)].im)
56 #define CXBsize(p) ((p)->size)
57 #define CXBovlp(p) ((p)->ovlp)
58 #define CXBwant(p) ((p)->want)
59 #define CXBhave(p) ((p)->have)
60 #define CXBdone(p) ((p)->done)
61 #define CXBmine(p) ((p)->mine)
62
63 typedef struct _real_buffer_desc {
64   REAL *data;
65   int size, ovlp, want, have, done, mine;
66 } RLBuffer, *RLB;
67
68 #define RLBbase(p) ((p)->data)
69 #define RLBdata(p, i) (RLBbase(p)[(i)])
70 #define RLBsize(p) ((p)->size)
71 #define RLBovlp(p) ((p)->ovlp)
72 #define RLBwant(p) ((p)->want)
73 #define RLBhave(p) ((p)->have)
74 #define RLBdone(p) ((p)->done)
75 #define RLBmine(p) ((p)->mine)
76
77 extern char *safealloc(int count, int nbytes, char *tag);
78 extern void safefree(char *p);
79 extern REAL *newvec_REAL(int size, char *tag);
80 extern void delvec_REAL(REAL *vec);
81 extern IMAG *newvec_IMAG(int size, char *tag);
82 extern void delvec_IMAG(IMAG *vec);
83 extern COMPLEX *newvec_COMPLEX(int size, char *tag);
84 extern void delvec_COMPLEX(COMPLEX *buf);
85 extern void dump_REAL(FILE *fp, char *head, REAL *ptr, int beg, int fin);
86 extern void dump_IMAG(FILE *fp, char *head, IMAG *ptr, int beg, int fin);
87 extern void dump_CX(FILE *fp, char *head, COMPLEX *ptr, int beg, int fin);
88
89 extern CXB newCXB(int size, COMPLEX *base, char *tag);
90 extern void delCXB(CXB p);
91
92 extern RLB newRLB(int size, REAL *base, char *tag);
93 extern void delRLB(RLB p);
94
95 extern REAL normalize_vec_REAL(REAL *, int);
96 extern REAL normalize_vec_COMPLEX(COMPLEX *, int);
97
98 #endif
99