iir1

MathSupplement.h
1
36 #ifndef IIR1_MATHSUPPLEMENT_H
37 #define IIR1_MATHSUPPLEMENT_H
38
39 #include "Common.h"
40
41 #include<complex>
42
43 #ifdef _MSC_VER
44 // Under Unix these have already default instantiations but not under Vis Studio
45 template class IIR_EXPORT std::complex<double>;
46 template class IIR_EXPORT std::complex<float>;
47 #endif
48
49 namespace Iir {
50
51 const double doublePi =3.1415926535897932384626433832795028841971;
52 const double doublePi_2 =1.5707963267948966192313216916397514420986;
53 const double doubleLn2 =0.69314718055994530941723212145818;
54 const double doubleLn10 =2.3025850929940456840179914546844;
55
56 typedef std::complex<double> complex_t;
57 typedef std::pair<complex_t, complex_t> complex_pair_t;
58
59 inline const complex_t infinity()
60 {
61 return complex_t (std::numeric_limits<double>::infinity());
62 }
63
64 template <typename Ty, typename To>
65 inline std::complex<Ty> addmul (const std::complex<Ty>& c,
66 Ty v,
67 const std::complex<To>& c1)
68 {
69 return std::complex <Ty> (
70 c.real() + v * c1.real(), c.imag() + v * c1.imag());
71 }
72
73 template <typename Ty>
74 inline Ty asinh (Ty x)
75 {
76 return log (x + std::sqrt (x * x + 1 ));
77 }
78
79 template <typename Ty>
80 inline bool is_nan (Ty v)
81 {
82 return !(v == v);
83 }
84
85 template <>
86 inline bool is_nan<complex_t> (complex_t v)
87 {
88 return Iir::is_nan (v.real()) || Iir::is_nan (v.imag());
89 }
90
91 }
92
93 #endif
Iir
Definition: Biquad.cpp:40