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