ComplexDataVector.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include <complex>
7 #include <cstddef>
8 #include <functional> // for std::reference_wrapper
9 
10 #include "DataStructures/DataVector.hpp"
11 #include "DataStructures/VectorImpl.hpp"
14 #include "Utilities/Requires.hpp"
16 
17 // IWYU pragma: no_forward_declare ConstantExpressions_detail::pow
18 
19 /*!
20  * \ingroup DataStructuresGroup
21  * \brief Stores a collection of complex function values.
22  *
23  * \details Use ComplexDataVector to represent function values on the
24  * computational domain. Note that interpreting the data also requires knowledge
25  * of the points that these function values correspond to.
26  *
27  * A ComplexDataVector holds an array of contiguous data. The ComplexDataVector
28  * can be owning, meaning the array is deleted when the ComplexDataVector goes
29  * out of scope, or non-owning, meaning it just has a pointer to an array.
30  *
31  * Refer to the \ref DataStructuresGroup documentation for a list of other
32  * available types.
33  *
34  * ComplexDataVectors support a variety of mathematical operations that are
35  * applicable contiguous data. In addition to common arithmetic operations such
36  * as element-wise addition, subtraction, multiplication and division,
37  * element-wise operations between `ComplexDataVector` and `DataVector` are
38  * supported. See [blaze-wiki/Vector_Operations]
39  * (https://bitbucket.org/blaze-lib/blaze/wiki/Vector%20Operations).
40  *
41  * in addition, support is provided for:
42  * - abs (returns DataVector, as the result is real)
43  * - conj
44  * - imag (returns DataVector, as the result is real)
45  * - real (returns DataVector, as the result is real)
46  */
48  : public VectorImpl<std::complex<double>, ComplexDataVector> {
49  public:
52 
54 };
55 
56 namespace blaze {
59 #if ((BLAZE_MAJOR_VERSION == 3) && (BLAZE_MINOR_VERSION <= 3))
60 template <>
61 struct UnaryMapTrait<ComplexDataVector, blaze::Real> {
62  using Type = DataVector;
63 };
64 template <>
65 struct UnaryMapTrait<ComplexDataVector, blaze::Imag> {
66  using Type = DataVector;
67 };
68 template <>
69 struct UnaryMapTrait<DataVector, blaze::Real> {
70  using Type = DataVector;
71 };
72 template <>
73 struct UnaryMapTrait<DataVector, blaze::Imag> {
74  using Type = DataVector;
75 };
76 template <>
77 struct UnaryMapTrait<ComplexDataVector, blaze::Abs> {
78  using Type = DataVector;
79 };
80 #else
81 template <>
82 struct MapTrait<ComplexDataVector, blaze::Real> {
83  using Type = DataVector;
84 };
85 template <>
86 struct MapTrait<ComplexDataVector, blaze::Imag> {
87  using Type = DataVector;
88 };
89 template <>
90 struct MapTrait<DataVector, blaze::Real> {
91  using Type = DataVector;
92 };
93 template <>
94 struct MapTrait<DataVector, blaze::Imag> {
95  using Type = DataVector;
96 };
97 template <>
98 struct MapTrait<ComplexDataVector, blaze::Abs> {
99  using Type = DataVector;
100 };
101 #endif // ((BLAZE_MAJOR_VERSION == 3) && (BLAZE_MINOR_VERSION <= 3))
102 
103 BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, DataVector,
104  AddTrait);
105 BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, DataVector,
106  DivTrait);
107 BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, DataVector,
108  MultTrait);
109 BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, DataVector,
110  SubTrait);
111 
112 BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, double,
113  AddTrait);
114 BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, double,
115  DivTrait);
116 BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, double,
117  MultTrait);
118 BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, double,
119  SubTrait);
120 
121 #if ((BLAZE_MAJOR_VERSION == 3) && (BLAZE_MINOR_VERSION <= 3))
122 template <typename Operator>
123 struct BinaryMapTrait<DataVector, ComplexDataVector, Operator> {
124  using Type = ComplexDataVector;
125 };
126 template <typename Operator>
127 struct BinaryMapTrait<ComplexDataVector, DataVector, Operator> {
128  using Type = ComplexDataVector;
129 };
130 #else
131 template <typename Operator>
132 struct MapTrait<DataVector, ComplexDataVector, Operator> {
133  using Type = ComplexDataVector;
134 };
135 template <typename Operator>
136 struct MapTrait<ComplexDataVector, DataVector, Operator> {
137  using Type = ComplexDataVector;
138 };
139 #endif // ((BLAZE_MAJOR_VERSION == 3) && (BLAZE_MINOR_VERSION <= 3))
140 } // namespace blaze
141 
143 
144 /// \cond HIDDEN_SYMBOLS
146  DataVector, operator+, std::plus<>())
148  ComplexDataVector, operator+, std::plus<>())
150  std::plus<>())
152  std::plus<>())
153 
155  DataVector, operator-, std::minus<>())
157  ComplexDataVector, operator-, std::minus<>())
159  std::minus<>())
161  std::minus<>())
162 
164  std::plus<>())
166  std::minus<>())
168  std::plus<>())
170  std::minus<>())
171 /// \endcond
172 
#define BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(VECTOR_TYPE, COMPATIBLE, BLAZE_MATH_TRAIT)
Instructs Blaze to provide the appropriate vector result type of an operator between VECTOR_TYPE and ...
Definition: VectorImpl.hpp:426
Base class template for various DataVector and related types.
Definition: VectorImpl.hpp:109
#define DEFINE_STD_ARRAY_INPLACE_BINOP(LTYPE, RTYPE, OP_FUNCTION_NAME, BINARY_OP)
Declares an in-place binary function on an array, intended for operations such as += ...
Definition: StdArrayHelpers.hpp:242
Defines the type alias Requires.
Definition: ComplexDataVector.hpp:56
#define MAKE_WITH_VALUE_IMPL_DEFINITION_FOR(VECTOR_TYPE)
Defines the MakeWithValueImpl apply specialization.
Definition: VectorImpl.hpp:552
Stores a collection of complex function values.
Definition: ComplexDataVector.hpp:47
#define VECTOR_BLAZE_TRAIT_SPECIALIZE_ALL_MAP_TRAITS(VECTOR_TYPE)
Instructs Blaze to provide the appropriate vector result type of Map operations (unary and binary) ac...
Definition: VectorImpl.hpp:486
Define simple functions for constant expressions.
Defines macro to always inline a function.
Stores a collection of function values.
Definition: DataVector.hpp:46
#define DEFINE_STD_ARRAY_BINOP(RESULT_TYPE, LTYPE, RTYPE, OP_FUNCTION_NAME, BINARY_OP)
Declares a binary function on an array, intended for binary operators such as +
Definition: StdArrayHelpers.hpp:213
#define MAKE_STD_ARRAY_VECTOR_BINOPS(VECTOR_TYPE)
Defines the set of binary operations often supported for std::array<VECTOR_TYPE, size>, for arbitrary size.
Definition: VectorImpl.hpp:504
Defines arithmetic operators for std::array and other helpful functions.
#define VECTOR_BLAZE_TRAIT_SPECIALIZE_ARITHMETIC_TRAITS(VECTOR_TYPE)
Instructs Blaze to provide the appropriate vector result type of arithmetic operations for VECTOR_TYP...
Definition: VectorImpl.hpp:450
#define MAKE_MATH_ASSIGN_EXPRESSION_ARITHMETIC(VECTOR_TYPE)
Defines MAKE_MATH_ASSIGN_EXPRESSION_POINTERVECTOR with all assignment arithmetic operations.
Definition: VectorImpl.hpp:535