iir1
Types.h
1 
36 #ifndef IIR1_TYPES_H
37 #define IIR1_TYPES_H
38 
39 #include "Common.h"
40 #include "MathSupplement.h"
41 
42 namespace Iir {
43 
47  struct DllExport ComplexPair : complex_pair_t
48  {
49  ComplexPair() = default;
50 
51  explicit ComplexPair (const complex_t& c1)
52  : complex_pair_t (c1, 0.)
53  {
54  if (!isReal()) throw_invalid_argument("A single complex number needs to be real.");
55  }
56 
57  ComplexPair (const complex_t& c1,
58  const complex_t& c2)
59  : complex_pair_t (c1, c2)
60  {
61  }
62 
63  bool isConjugate () const
64  {
65  return second == std::conj (first);
66  }
67 
68  bool isReal () const
69  {
70  return first.imag() == 0 && second.imag() == 0;
71  }
72 
77  bool isMatchedPair () const
78  {
79  if (first.imag() != 0)
80  return second == std::conj (first);
81  else
82  return second.imag () == 0 &&
83  second.real () != 0 &&
84  first.real () != 0;
85  }
86 
87  bool is_nan () const
88  {
89  return Iir::is_nan (first) || Iir::is_nan (second);
90  }
91  };
92 
93 
97  struct DllExport PoleZeroPair
98  {
99  ComplexPair poles = ComplexPair();
100  ComplexPair zeros = ComplexPair();
101 
102  PoleZeroPair () = default;
103 
104  // single pole/zero
105  PoleZeroPair (const complex_t& p, const complex_t& z)
106  : poles (p), zeros (z)
107  {
108  }
109 
110  // pole/zero pair
111  PoleZeroPair (const complex_t& p1, const complex_t& z1,
112  const complex_t& p2, const complex_t& z2)
113  : poles (p1, p2)
114  , zeros (z1, z2)
115  {
116  }
117 
118  bool isSinglePole () const
119  {
120  return poles.second == 0. && zeros.second == 0.;
121  }
122 
123  bool is_nan () const
124  {
125  return poles.is_nan() || zeros.is_nan();
126  }
127  };
128 
129 
133  enum Kind
134  {
135  kindLowPass,
136  kindHighPass,
137  kindBandPass,
138  kindBandStop,
139  kindLowShelf,
140  kindHighShelf,
141  kindBandShelf,
142  kindOther
143  };
144 
145 }
146 
147 #endif
Definition: Biquad.cpp:40
Kind
Definition: Types.h:134
Definition: Types.h:48
bool isMatchedPair() const
Definition: Types.h:77
Definition: Types.h:98