Reference documentation for deal.II version 9.0.0
complex_overloads.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1998 - 2018 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_complex_overloads_h
17 #define dealii_complex_overloads_h
18 
19 #include <deal.II/base/config.h>
20 #include <deal.II/base/template_constraints.h>
21 
22 DEAL_II_NAMESPACE_OPEN
23 
24 // Forward declarations
25 template <typename T> struct EnableIfScalar;
26 template <typename T, typename U> struct ProductType;
27 
28 #ifndef DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS
29 
36 template <typename T, typename U>
37 typename ProductType<std::complex<T>, std::complex<U> >::type
38 inline
39 operator*(const std::complex<T> &left, const std::complex<U> &right)
40 {
41  typedef typename ProductType<std::complex<T>, std::complex<U> >::type result_type;
42  return static_cast<result_type>(left) * static_cast<result_type>(right);
43 }
44 
45 
54 template <typename T, typename U>
56 inline
57 operator*(const std::complex<T> &left, const U &right)
58 {
59  typedef typename ProductType<std::complex<T>, U>::type result_type;
60  return static_cast<result_type>(left) * static_cast<result_type>(right);
61 }
62 
63 
72 template <typename T, typename U>
73 typename ProductType<typename EnableIfScalar<T>::type, std::complex<U> >::type
74 inline
75 operator*(const T &left, const std::complex<U> &right)
76 {
77  typedef typename ProductType<std::complex<T>, U>::type result_type;
78  return static_cast<result_type>(left) * static_cast<result_type>(right);
79 }
80 #endif /* DEAL_II_HAVE_COMPLEX_OPERATOR_OVERLOADS */
81 
82 DEAL_II_NAMESPACE_CLOSE
83 
84 #endif
ProductType< std::complex< T >, typename EnableIfScalar< U >::type >::type operator*(const std::complex< T > &left, const U &right)
ProductType< typename EnableIfScalar< T >::type, std::complex< U > >::type operator*(const T &left, const std::complex< U > &right)
ProductType< std::complex< T >, std::complex< U > >::type operator*(const std::complex< T > &left, const std::complex< U > &right)