My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
qf_filter.h
Go to the documentation of this file.
1 /***************************************************************************
2  qf_filter.h
3  ----------------
4  begin : Mon Jan 02 2006
5  copyright : (C) 2006 by Vincent Habchi, F5RCS
6  email : 10.50@free.fr
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef _QF_FILTER_H
19 #define _QF_FILTER_H
20 
21 // Header for filter
22 
24 {
29 };
30 
31 typedef enum qf_filter_type qft;
32 
34 {
41 };
42 
43 typedef enum qf_filter_kind qfk;
44 
46 {
47  CAP,
48  IND,
50 };
51 
52 typedef enum qf_ctype qfct;
53 
54 struct qf_comp
55 {
58  unsigned node1;
59  unsigned node2;
60 };
61 
62 typedef struct qf_comp qfc;
63 
64 // Generic filter class
65 
66 class qf_filter
67 {
68  protected:
69  const qft type; // Lowpass, highpass...
70  const qfk kind; // Butterworth, Chebichev...
71  unsigned ord; // Order of filter
72 
73  const qf_double_t fc; // Cutoff / Center
74  qf_double_t bw; // Bandwidth
75  const qf_double_t imp; // Terminating impedance
76  qf_double_t fstart; // Start frequency
77  qf_double_t fstop; // Stop frequency
78 
79  // Polynomial description
80 
81  qf_poly E; // H(w) = E(w)/P(w)
82  qf_poly F; // D(w) = F(w)/P(w)
84 
85  qf_poly BN; // B(w) susceptance of filter
86  qf_poly BD; // B(w) susceptance of filter
87 
88  unsigned ncomp; // Number of components
89  qfc * Comp; // Table of components
90 
91 public:
92  qf_filter (void); // Default init
93  qf_filter (int); // Init
94  qf_filter (qfk, qft);
95  qf_filter (int, qfk, qft);
97  virtual ~qf_filter (void); // Exit
98 
99  // Common routines to perform extraction of poles and zeros
100 
101  // This one extracts a finite pole of transmission
103 
104  int order (void) { return ord; }
105 
106  virtual void synth (qft) = 0; // Synthesize filter
107 
108  std::string to_qucs (void); // Outputs Qucs
109  std::string to_spice (void); // Outputs SPICE
110  void dump_qucs (void); // Outputs Qucs to std::cout
111  void dump_spice (void); // Outputs SPICE to std::cout
112  void dump_cout (void); // Outputs to std::cout
113 
114 private:
115  std::string num2str (qf_double_t);
116 };
117 
118 #endif // _QF_FILTER_H