iir1
Loading...
Searching...
No Matches
MathSupplement.h
1
35
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
45template class IIR_EXPORT std::complex<double>;
46template class IIR_EXPORT std::complex<float>;
47#endif
48
49namespace Iir {
50
51const double doublePi =3.1415926535897932384626433832795028841971;
52const double doublePi_2 =1.5707963267948966192313216916397514420986;
53const double doubleLn2 =0.69314718055994530941723212145818;
54const double doubleLn10 =2.3025850929940456840179914546844;
55
56typedef std::complex<double> complex_t;
57typedef std::pair<complex_t, complex_t> complex_pair_t;
58
59inline const complex_t infinity()
60{
61 return complex_t (std::numeric_limits<double>::infinity());
62}
63
64template <typename Ty, typename To>
65inline 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
73template <typename Ty>
74inline Ty asinh (Ty x)
75{
76 return log (x + std::sqrt (x * x + 1 ));
77}
78
79template <typename Ty>
80inline bool is_nan (Ty v)
81{
82 return !(v == v);
83}
84
85template <>
86inline 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
Definition Biquad.cpp:40