-
Notifications
You must be signed in to change notification settings - Fork 214
/
Copy pathqf_filter.h
128 lines (95 loc) · 4.02 KB
/
qf_filter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/***************************************************************************
qf_filter.h
----------------
begin : Mon Jan 02 2006
copyright : (C) 2006 by Vincent Habchi, F5RCS
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
# ifndef _QF_FILTER_H
# define _QF_FILTER_H
# ifdef _QF_QUCSFILTER_TEST
# define PACKAGE_VERSION "Qf test"
# endif
# include <Q3TextStream>
using namespace std;
// Maximum order of any filter
const unsigned QF_MAX_ORD = 19;
// Structure used to represent 3 doubles
struct qf_trp {
qf_double_t v;
qf_double_t w1;
qf_double_t w2;
};
// Generic filter class
class qf_filter
{
friend class qf_zigzag;
protected :
qf_spec* Pspec; // Filter data
// Polynomial description
qf_poly E; // H(W) = E(W)/P(W)
qf_poly F; // D(W) = F(W)/P(W)
qf_poly P;
qf_poly BN; // B(W) susceptance of filter
qf_poly BD; // B(W) susceptance of filter
qf_poly BNc; // Copies of the former
qf_poly BDc;
qf_lcmp lcmp;
// Constructor and co
qf_filter (qf_spec*);
qf_filter (const qf_filter &);
// Calculates the susceptance of the normal filter out of its
// characteristic polynoms
void scptX1 (qf_poly&, qf_poly&, qf_poly&, qf_poly&);
void scptX2 (qf_poly&, qf_poly&, qf_poly&, qf_poly&);
void scptX3 (qf_poly&, qf_poly&, qf_poly&, qf_poly&);
// Common routines to perform extraction of poles and zeros
// This one extract a finite pole of transmission
bool pole_finite (qf_double_t, qf_double_t, qf_trp*);
// Those extract poles at infinity
bool pole_inf_c (qf_double_t&, qf_double_t);
bool pole_inf_l (qf_double_t&, qf_double_t);
// and poles at zero
bool pole_zero_c (qf_double_t&, qf_double_t);
bool pole_zero_l (qf_double_t&, qf_double_t);
// Synthesis of all types of ladder filters
bool synth_ladder (qf_double_t);
// Optimization routines
qf_double_t opt_error (qf_double_t&, qf_double_t&,
qf_double_t&, qf_double_t&);
void get_bounds (qf_double_t&, qf_double_t&,
qf_double_t&, qf_double_t&);
public:
virtual ~qf_filter (void) {}
bool islvoid (void) {return lcmp. isvoid ();}
void linit (void) {lcmp. init ();}
qf_cmp* lnext (void) {return lcmp. next ();}
// Every filter must provide a synth interface
virtual bool synth (void) = 0;
};
// Api for filters
struct qf_filter_api {
QString name;
unsigned id;
bool (* valid) (qf_spec*); // Validator
qf_filter* (* cons) (qf_spec*); // Constructor, returns transfer function
bool is_all_pole; // Is it an all pole filter?
bool forbid_orders; // Are some orders forbidden?
bool only_some_orders; // If only some orders are allowed
const char* f_ord_list; // Forbidden/Allowed order list
unsigned gen_flags; // General capacity
unsigned if_no_order; // Capacity if order is not specified
unsigned even; // Capacity for even orders
unsigned odd; // Capacity for odd orders
unsigned forbid_tform; // Incompatible transforms
};
extern struct qf_filter_api* qf_filter_apis [];
# endif // _QF_FILTER