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