mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 21:47:46 +00:00
Everywhere: Run clang-format
This commit is contained in:
parent
0376c127f6
commit
086969277e
1665 changed files with 8479 additions and 8479 deletions
36
AK/Complex.h
36
AK/Complex.h
|
@ -61,7 +61,7 @@ public:
|
|||
}
|
||||
|
||||
template<AK::Concepts::Arithmetic U>
|
||||
constexpr Complex<T>& operator=(const Complex<U>& other)
|
||||
constexpr Complex<T>& operator=(Complex<U> const& other)
|
||||
{
|
||||
m_real = other.real();
|
||||
m_imag = other.imag();
|
||||
|
@ -77,7 +77,7 @@ public:
|
|||
}
|
||||
|
||||
template<AK::Concepts::Arithmetic U>
|
||||
constexpr Complex<T> operator+=(const Complex<U>& x)
|
||||
constexpr Complex<T> operator+=(Complex<U> const& x)
|
||||
{
|
||||
m_real += x.real();
|
||||
m_imag += x.imag();
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
}
|
||||
|
||||
template<AK::Concepts::Arithmetic U>
|
||||
constexpr Complex<T> operator-=(const Complex<U>& x)
|
||||
constexpr Complex<T> operator-=(Complex<U> const& x)
|
||||
{
|
||||
m_real -= x.real();
|
||||
m_imag -= x.imag();
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
}
|
||||
|
||||
template<AK::Concepts::Arithmetic U>
|
||||
constexpr Complex<T> operator*=(const Complex<U>& x)
|
||||
constexpr Complex<T> operator*=(Complex<U> const& x)
|
||||
{
|
||||
const T real = m_real;
|
||||
m_real = real * x.real() - m_imag * x.imag();
|
||||
|
@ -124,7 +124,7 @@ public:
|
|||
}
|
||||
|
||||
template<AK::Concepts::Arithmetic U>
|
||||
constexpr Complex<T> operator/=(const Complex<U>& x)
|
||||
constexpr Complex<T> operator/=(Complex<U> const& x)
|
||||
{
|
||||
const T real = m_real;
|
||||
const T divisor = x.real() * x.real() + x.imag() * x.imag();
|
||||
|
@ -142,7 +142,7 @@ public:
|
|||
}
|
||||
|
||||
template<AK::Concepts::Arithmetic U>
|
||||
constexpr Complex<T> operator+(const Complex<U>& a)
|
||||
constexpr Complex<T> operator+(Complex<U> const& a)
|
||||
{
|
||||
Complex<T> x = *this;
|
||||
x += a;
|
||||
|
@ -158,7 +158,7 @@ public:
|
|||
}
|
||||
|
||||
template<AK::Concepts::Arithmetic U>
|
||||
constexpr Complex<T> operator-(const Complex<U>& a)
|
||||
constexpr Complex<T> operator-(Complex<U> const& a)
|
||||
{
|
||||
Complex<T> x = *this;
|
||||
x -= a;
|
||||
|
@ -174,7 +174,7 @@ public:
|
|||
}
|
||||
|
||||
template<AK::Concepts::Arithmetic U>
|
||||
constexpr Complex<T> operator*(const Complex<U>& a)
|
||||
constexpr Complex<T> operator*(Complex<U> const& a)
|
||||
{
|
||||
Complex<T> x = *this;
|
||||
x *= a;
|
||||
|
@ -190,7 +190,7 @@ public:
|
|||
}
|
||||
|
||||
template<AK::Concepts::Arithmetic U>
|
||||
constexpr Complex<T> operator/(const Complex<U>& a)
|
||||
constexpr Complex<T> operator/(Complex<U> const& a)
|
||||
{
|
||||
Complex<T> x = *this;
|
||||
x /= a;
|
||||
|
@ -206,13 +206,13 @@ public:
|
|||
}
|
||||
|
||||
template<AK::Concepts::Arithmetic U>
|
||||
constexpr bool operator==(const Complex<U>& a) const
|
||||
constexpr bool operator==(Complex<U> const& a) const
|
||||
{
|
||||
return (this->real() == a.real()) && (this->imag() == a.imag());
|
||||
}
|
||||
|
||||
template<AK::Concepts::Arithmetic U>
|
||||
constexpr bool operator!=(const Complex<U>& a) const
|
||||
constexpr bool operator!=(Complex<U> const& a) const
|
||||
{
|
||||
return !(*this == a);
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ private:
|
|||
|
||||
// reverse associativity operators for scalars
|
||||
template<AK::Concepts::Arithmetic T, AK::Concepts::Arithmetic U>
|
||||
constexpr Complex<T> operator+(const U& b, const Complex<T>& a)
|
||||
constexpr Complex<T> operator+(const U& b, Complex<T> const& a)
|
||||
{
|
||||
Complex<T> x = a;
|
||||
x += b;
|
||||
|
@ -242,7 +242,7 @@ constexpr Complex<T> operator+(const U& b, const Complex<T>& a)
|
|||
}
|
||||
|
||||
template<AK::Concepts::Arithmetic T, AK::Concepts::Arithmetic U>
|
||||
constexpr Complex<T> operator-(const U& b, const Complex<T>& a)
|
||||
constexpr Complex<T> operator-(const U& b, Complex<T> const& a)
|
||||
{
|
||||
Complex<T> x = a;
|
||||
x -= b;
|
||||
|
@ -250,7 +250,7 @@ constexpr Complex<T> operator-(const U& b, const Complex<T>& a)
|
|||
}
|
||||
|
||||
template<AK::Concepts::Arithmetic T, AK::Concepts::Arithmetic U>
|
||||
constexpr Complex<T> operator*(const U& b, const Complex<T>& a)
|
||||
constexpr Complex<T> operator*(const U& b, Complex<T> const& a)
|
||||
{
|
||||
Complex<T> x = a;
|
||||
x *= b;
|
||||
|
@ -258,7 +258,7 @@ constexpr Complex<T> operator*(const U& b, const Complex<T>& a)
|
|||
}
|
||||
|
||||
template<AK::Concepts::Arithmetic T, AK::Concepts::Arithmetic U>
|
||||
constexpr Complex<T> operator/(const U& b, const Complex<T>& a)
|
||||
constexpr Complex<T> operator/(const U& b, Complex<T> const& a)
|
||||
{
|
||||
Complex<T> x = a;
|
||||
x /= b;
|
||||
|
@ -272,15 +272,15 @@ template<AK::Concepts::Arithmetic T>
|
|||
static constinit Complex<T> complex_imag_unit = Complex<T>((T)0, (T)1);
|
||||
|
||||
template<AK::Concepts::Arithmetic T, AK::Concepts::Arithmetic U>
|
||||
static constexpr bool approx_eq(const Complex<T>& a, const Complex<U>& b, const double margin = 0.000001)
|
||||
static constexpr bool approx_eq(Complex<T> const& a, Complex<U> const& b, double const margin = 0.000001)
|
||||
{
|
||||
const auto x = const_cast<Complex<T>&>(a) - const_cast<Complex<U>&>(b);
|
||||
auto const x = const_cast<Complex<T>&>(a) - const_cast<Complex<U>&>(b);
|
||||
return x.magnitude() <= margin;
|
||||
}
|
||||
|
||||
// complex version of exp()
|
||||
template<AK::Concepts::Arithmetic T>
|
||||
static constexpr Complex<T> cexp(const Complex<T>& a)
|
||||
static constexpr Complex<T> cexp(Complex<T> const& a)
|
||||
{
|
||||
// FIXME: this can probably be faster and not use so many "expensive" trigonometric functions
|
||||
return exp(a.real()) * Complex<T>(cos(a.imag()), sin(a.imag()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue