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 IIR_EXPORT 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 isReal () const
64  {
65  return first.imag() == 0 && second.imag() == 0;
66  }
67 
72  bool isMatchedPair () const
73  {
74  if (first.imag() != 0)
75  return second == std::conj (first);
76  else
77  return second.imag () == 0 &&
78  second.real () != 0 &&
79  first.real () != 0;
80  }
81 
82  bool is_nan () const
83  {
84  return Iir::is_nan (first) || Iir::is_nan (second);
85  }
86  };
87 
88 
92  struct IIR_EXPORT PoleZeroPair
93  {
94  ComplexPair poles = ComplexPair();
95  ComplexPair zeros = ComplexPair();
96 
97  PoleZeroPair () = default;
98 
99  // single pole/zero
100  PoleZeroPair (const complex_t& p, const complex_t& z)
101  : poles (p), zeros (z)
102  {
103  }
104 
105  // pole/zero pair
106  PoleZeroPair (const complex_t& p1, const complex_t& z1,
107  const complex_t& p2, const complex_t& z2)
108  : poles (p1, p2)
109  , zeros (z1, z2)
110  {
111  }
112 
113  bool isSinglePole () const
114  {
115  return poles.second == 0. && zeros.second == 0.;
116  }
117 
118  bool is_nan () const
119  {
120  return poles.is_nan() || zeros.is_nan();
121  }
122  };
123 
124 
125 }
126 
127 #endif
Definition: Biquad.cpp:40
Definition: Types.h:48
bool isMatchedPair() const
Definition: Types.h:72
Definition: Types.h:93