mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 14:30:36 +00:00
added some more operators
This commit is contained in:
parent
419256d348
commit
a53b33587e
1 changed files with 19 additions and 0 deletions
19
complex.hh
19
complex.hh
|
|
@ -53,6 +53,18 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
static constexpr bool operator == (Complex<T> a, Complex<T> b)
|
||||
{
|
||||
return a.real() == b.real() && a.imag() == b.imag();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static constexpr bool operator != (Complex<T> a, Complex<T> b)
|
||||
{
|
||||
return a.real() != b.real() || a.imag() != b.imag();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static constexpr Complex<T> operator + (Complex<T> a, Complex<T> b)
|
||||
{
|
||||
|
|
@ -95,6 +107,13 @@ static constexpr Complex<T> operator * (Complex<T> a, Complex<T> b)
|
|||
return Complex<T>(a.real() * b.real() - a.imag() * b.imag(), a.real() * b.imag() + a.imag() * b.real());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static constexpr Complex<T> operator / (T a, Complex<T> b)
|
||||
{
|
||||
return Complex<T>((a * b.real()) / (b.real() * b.real() + b.imag() * b.imag()),
|
||||
- (a * b.imag()) / (b.real() * b.real() + b.imag() * b.imag()));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static constexpr Complex<T> operator / (Complex<T> a, Complex<T> b)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue