cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
mul.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_COMPLEX_FUNCTIONS_MUL_H
4#define pRC_CORE_COMPLEX_FUNCTIONS_MUL_H
5
8
9namespace pRC
10{
11 template<class TA, class TB, If<IsInvocable<Mul, TA, TB>> = 0,
12 If<IsInvocable<Add, TA, TB>> = 0, If<IsInvocable<Sub, TA, TB>> = 0>
13 static inline constexpr auto operator*(Complex<TA> const &a,
14 Complex<TB> const &b)
15 {
16 auto const real = a.real() * b.real() - a.imag() * b.imag();
17 auto const imag = a.real() * b.imag() + a.imag() * b.real();
18
19 return Complex(real, imag);
20 }
21
22 template<class TA, class TB, If<IsValue<TB>> = 0,
23 If<IsInvocable<Mul, TA, TB>> = 0>
24 static inline constexpr auto operator*(Complex<TA> const &a, TB const &b)
25 {
26 auto const real = a.real() * b;
27 auto const imag = a.imag() * b;
28
29 return Complex(real, imag);
30 }
31
32 template<class TA, class TB, If<IsValue<TA>> = 0,
33 If<IsInvocable<Mul, TA, TB>> = 0>
34 static inline constexpr auto operator*(TA const &a, Complex<TB> const &b)
35 {
36 auto const real = a * b.real();
37 auto const imag = a * b.imag();
38
39 return Complex(real, imag);
40 }
41}
42#endif // pRC_CORE_COMPLEX_FUNCTIONS_MUL_H
Definition complex.hpp:26
constexpr decltype(auto) real() &&
Definition complex.hpp:125
constexpr decltype(auto) imag() &&
Definition complex.hpp:145
Definition cholesky.hpp:18
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
static constexpr decltype(auto) imag(X &&a)
Definition imag.hpp:11
static constexpr decltype(auto) real(X &&a)
Definition real.hpp:11
static constexpr auto operator*(JacobiRotation< TA > const &a, JacobiRotation< TB > const &b)
Definition jacobi_rotation.hpp:311
Complex(T const &) -> Complex< T >