deal.II version GIT relicensing-2947-g2b65dfb0bb 2025-03-26 20:50:00+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: LGPL-2.1-or-later
4// Copyright (C) 2015 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_complex_overloads_h
16#define dealii_complex_overloads_h
17
18#include <deal.II/base/config.h>
19
20#include <complex>
21#include <type_traits>
22
23
25
26#ifndef DOXYGEN
27
28// Forward declarations
29template <typename T, typename U>
30struct ProductType;
31
32#endif
33
34#ifndef DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
35
65template <typename T, typename U>
66inline std::enable_if_t<
67 std::is_floating_point_v<T> && std::is_floating_point_v<U> &&
68 !std::is_same_v<T, U>,
69 typename ProductType<std::complex<T>, std::complex<U>>::type>
70operator*(const std::complex<T> &left, const std::complex<U> &right)
71{
72 using result_type =
73 typename ProductType<std::complex<T>, std::complex<U>>::type;
74 return static_cast<result_type>(left) * static_cast<result_type>(right);
75}
76
106template <typename T, typename U>
107inline std::enable_if_t<
108 std::is_floating_point_v<T> && std::is_floating_point_v<U> &&
109 !std::is_same_v<T, U>,
110 typename ProductType<std::complex<T>, std::complex<U>>::type>
111operator/(const std::complex<T> &left, const std::complex<U> &right)
112{
113 using result_type =
114 typename ProductType<std::complex<T>, std::complex<U>>::type;
115 return static_cast<result_type>(left) / static_cast<result_type>(right);
116}
117
147template <typename T, typename U>
148inline std::enable_if_t<std::is_floating_point_v<T> &&
149 std::is_floating_point_v<U> && !std::is_same_v<T, U>,
151operator*(const std::complex<T> &left, const U &right)
152{
153 using result_type = typename ProductType<std::complex<T>, U>::type;
154 return static_cast<result_type>(left) * static_cast<result_type>(right);
155}
156
186template <typename T, typename U>
187inline std::enable_if_t<std::is_floating_point_v<T> &&
188 std::is_floating_point_v<U> && !std::is_same_v<T, U>,
190operator/(const std::complex<T> &left, const U &right)
191{
192 using result_type = typename ProductType<std::complex<T>, U>::type;
193 return static_cast<result_type>(left) / static_cast<result_type>(right);
194}
195
225template <typename T, typename U>
226inline std::enable_if_t<std::is_floating_point_v<T> &&
227 std::is_floating_point_v<U> && !std::is_same_v<T, U>,
229operator*(const T &left, const std::complex<U> &right)
230{
231 using result_type = typename ProductType<T, std::complex<U>>::type;
232 return static_cast<result_type>(left) * static_cast<result_type>(right);
233}
234
264template <typename T, typename U>
265inline std::enable_if_t<std::is_floating_point_v<T> &&
266 std::is_floating_point_v<U> && !std::is_same_v<T, U>,
268operator/(const T &left, const std::complex<U> &right)
269{
270 using result_type = typename ProductType<T, std::complex<U>>::type;
271 return static_cast<result_type>(left) / static_cast<result_type>(right);
272}
273
274
275#endif /* DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS */
276
278
279#endif
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:40
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:41
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)