deal.II version GIT relicensing-6809-ge913b9bb34 2026-09-25 17:20:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
complex_overloads.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2015 - 2025 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_complex_overloads_h
14#define dealii_complex_overloads_h
15
16#include <deal.II/base/config.h>
17
18#include <complex>
19#include <type_traits>
20
21
23
24#ifndef DOXYGEN
25
26// Forward declarations
27template <typename T, typename U>
28struct ProductType;
29
30#endif
31
32#ifndef DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
33
63template <typename T, typename U>
64inline std::enable_if_t<
65 std::is_floating_point_v<T> && std::is_floating_point_v<U> &&
66 !std::is_same_v<T, U>,
67 typename ProductType<std::complex<T>, std::complex<U>>::type>
68operator*(const std::complex<T> &left, const std::complex<U> &right)
69{
70 using result_type =
71 typename ProductType<std::complex<T>, std::complex<U>>::type;
72 return static_cast<result_type>(left) * static_cast<result_type>(right);
73}
74
104template <typename T, typename U>
105inline std::enable_if_t<
106 std::is_floating_point_v<T> && std::is_floating_point_v<U> &&
107 !std::is_same_v<T, U>,
108 typename ProductType<std::complex<T>, std::complex<U>>::type>
109operator/(const std::complex<T> &left, const std::complex<U> &right)
110{
111 using result_type =
112 typename ProductType<std::complex<T>, std::complex<U>>::type;
113 return static_cast<result_type>(left) / static_cast<result_type>(right);
114}
115
145template <typename T, typename U>
146inline std::enable_if_t<std::is_floating_point_v<T> &&
147 std::is_floating_point_v<U> && !std::is_same_v<T, U>,
149operator*(const std::complex<T> &left, const U &right)
150{
151 using result_type = typename ProductType<std::complex<T>, U>::type;
152 return static_cast<result_type>(left) * static_cast<result_type>(right);
153}
154
184template <typename T, typename U>
185inline std::enable_if_t<std::is_floating_point_v<T> &&
186 std::is_floating_point_v<U> && !std::is_same_v<T, U>,
188operator/(const std::complex<T> &left, const U &right)
189{
190 using result_type = typename ProductType<std::complex<T>, U>::type;
191 return static_cast<result_type>(left) / static_cast<result_type>(right);
192}
193
223template <typename T, typename U>
224inline std::enable_if_t<std::is_floating_point_v<T> &&
225 std::is_floating_point_v<U> && !std::is_same_v<T, U>,
227operator*(const T &left, const std::complex<U> &right)
228{
229 using result_type = typename ProductType<T, std::complex<U>>::type;
230 return static_cast<result_type>(left) * static_cast<result_type>(right);
231}
232
262template <typename T, typename U>
263inline std::enable_if_t<std::is_floating_point_v<T> &&
264 std::is_floating_point_v<U> && !std::is_same_v<T, U>,
266operator/(const T &left, const std::complex<U> &right)
267{
268 using result_type = typename ProductType<T, std::complex<U>>::type;
269 return static_cast<result_type>(left) / static_cast<result_type>(right);
270}
271
272
273#endif /* DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS */
274
276
277#endif
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< std::complex< T >, std::complex< U > >::type > operator*(const std::complex< T > &left, const std::complex< U > &right)
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< T, std::complex< U > >::type > operator*(const T &left, const std::complex< U > &right)
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< std::complex< T >, U >::type > operator/(const std::complex< T > &left, const U &right)
typename internal::ProductTypeImpl< std::decay_t< T >, std::decay_t< U > >::type type
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< std::complex< T >, std::complex< U > >::type > operator/(const std::complex< T > &left, const std::complex< U > &right)
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< std::complex< T >, U >::type > operator*(const std::complex< T > &left, const U &right)
std::enable_if_t< std::is_floating_point_v< T > &&std::is_floating_point_v< U > &&!std::is_same_v< T, U >, typename ProductType< T, std::complex< U > >::type > operator/(const T &left, const std::complex< U > &right)