Line data Source code
1 0 : // Distributed under the MIT License.
2 : // See LICENSE.txt for details.
3 :
4 : #pragma once
5 :
6 : #include <blaze/math/GroupTag.h>
7 : #include <complex>
8 : #include <cstddef>
9 : #include <functional>
10 :
11 : #include "DataStructures/DataVector.hpp"
12 : #include "DataStructures/VectorImpl.hpp"
13 : #include "Utilities/ConstantExpressions.hpp"
14 : #include "Utilities/ForceInline.hpp"
15 : #include "Utilities/StdArrayHelpers.hpp"
16 :
17 : /// \cond
18 : class ComplexDataVector;
19 : /// \endcond
20 :
21 : namespace blaze {
22 0 : DECLARE_GENERAL_VECTOR_BLAZE_TRAITS(ComplexDataVector);
23 : } // namespace blaze
24 :
25 : /*!
26 : * \ingroup DataStructuresGroup
27 : * \brief Stores a collection of complex function values.
28 : *
29 : * \details Use ComplexDataVector to represent function values on the
30 : * computational domain. Note that interpreting the data also requires knowledge
31 : * of the points that these function values correspond to.
32 : *
33 : * A ComplexDataVector holds an array of contiguous data. The ComplexDataVector
34 : * can be owning, meaning the array is deleted when the ComplexDataVector goes
35 : * out of scope, or non-owning, meaning it just has a pointer to an array.
36 : *
37 : * Refer to the \ref DataStructuresGroup documentation for a list of other
38 : * available types.
39 : *
40 : * ComplexDataVectors support a variety of mathematical operations that are
41 : * applicable contiguous data. In addition to common arithmetic operations such
42 : * as element-wise addition, subtraction, multiplication and division,
43 : * element-wise operations between `ComplexDataVector` and `DataVector` are
44 : * supported. See [blaze-wiki/Vector_Operations]
45 : * (https://bitbucket.org/blaze-lib/blaze/wiki/Vector%20Operations).
46 : *
47 : * in addition, support is provided for:
48 : * - abs (returns DataVector, as the result is real)
49 : * - conj
50 : * - imag (returns DataVector, as the result is real)
51 : * - real (returns DataVector, as the result is real)
52 : */
53 1 : class ComplexDataVector
54 : : public VectorImpl<std::complex<double>, ComplexDataVector> {
55 : public:
56 0 : ComplexDataVector() = default;
57 0 : ComplexDataVector(const ComplexDataVector&) = default;
58 0 : ComplexDataVector(ComplexDataVector&&) = default;
59 0 : ComplexDataVector& operator=(const ComplexDataVector&) = default;
60 0 : ComplexDataVector& operator=(ComplexDataVector&&) = default;
61 0 : ~ComplexDataVector() = default;
62 :
63 0 : using BaseType = VectorImpl<std::complex<double>, ComplexDataVector>;
64 :
65 : using BaseType::operator=;
66 : using BaseType::VectorImpl;
67 : };
68 :
69 : namespace blaze {
70 0 : VECTOR_BLAZE_TRAIT_SPECIALIZE_ARITHMETIC_TRAITS(ComplexDataVector);
71 0 : VECTOR_BLAZE_TRAIT_SPECIALIZE_ALL_MAP_TRAITS(ComplexDataVector);
72 : template <>
73 0 : struct MapTrait<ComplexDataVector, blaze::Real> {
74 0 : using Type = DataVector;
75 : };
76 : template <>
77 0 : struct MapTrait<ComplexDataVector, blaze::Imag> {
78 0 : using Type = DataVector;
79 : };
80 : template <>
81 0 : struct MapTrait<DataVector, blaze::Real> {
82 0 : using Type = DataVector;
83 : };
84 : template <>
85 0 : struct MapTrait<DataVector, blaze::Imag> {
86 0 : using Type = DataVector;
87 : };
88 : template <>
89 0 : struct MapTrait<ComplexDataVector, blaze::Abs> {
90 0 : using Type = DataVector;
91 : };
92 : template <>
93 0 : struct MapTrait<ComplexDataVector, blaze::SqrAbs> {
94 0 : using Type = DataVector;
95 : };
96 :
97 0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, DataVector,
98 : AddTrait, ComplexDataVector);
99 0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, DataVector,
100 : DivTrait, ComplexDataVector);
101 0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, DataVector,
102 : MultTrait, ComplexDataVector);
103 0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, DataVector,
104 : SubTrait, ComplexDataVector);
105 :
106 0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, double,
107 : AddTrait, ComplexDataVector);
108 0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, double,
109 : DivTrait, ComplexDataVector);
110 0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, double,
111 : MultTrait, ComplexDataVector);
112 0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexDataVector, double,
113 : SubTrait, ComplexDataVector);
114 :
115 0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(DataVector, std::complex<double>,
116 : AddTrait, ComplexDataVector);
117 0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(DataVector, std::complex<double>,
118 : DivTrait, ComplexDataVector);
119 0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(DataVector, std::complex<double>,
120 : MultTrait, ComplexDataVector);
121 0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(DataVector, std::complex<double>,
122 : SubTrait, ComplexDataVector);
123 :
124 : template <typename Operator>
125 0 : struct MapTrait<DataVector, ComplexDataVector, Operator> {
126 0 : using Type = ComplexDataVector;
127 : };
128 : template <typename Operator>
129 0 : struct MapTrait<ComplexDataVector, DataVector, Operator> {
130 0 : using Type = ComplexDataVector;
131 : };
132 : } // namespace blaze
133 :
134 : MAKE_STD_ARRAY_VECTOR_BINOPS(ComplexDataVector)
135 :
136 : /// \cond HIDDEN_SYMBOLS
137 : DEFINE_STD_ARRAY_BINOP(ComplexDataVector, ComplexDataVector,
138 : DataVector, operator+, std::plus<>())
139 : DEFINE_STD_ARRAY_BINOP(ComplexDataVector, DataVector,
140 : ComplexDataVector, operator+, std::plus<>())
141 : DEFINE_STD_ARRAY_BINOP(ComplexDataVector, ComplexDataVector, double, operator+,
142 : std::plus<>())
143 : DEFINE_STD_ARRAY_BINOP(ComplexDataVector, double, ComplexDataVector, operator+,
144 : std::plus<>())
145 :
146 : DEFINE_STD_ARRAY_BINOP(ComplexDataVector, ComplexDataVector,
147 : DataVector, operator-, std::minus<>())
148 : DEFINE_STD_ARRAY_BINOP(ComplexDataVector, DataVector,
149 : ComplexDataVector, operator-, std::minus<>())
150 : DEFINE_STD_ARRAY_BINOP(ComplexDataVector, ComplexDataVector, double, operator-,
151 : std::minus<>())
152 : DEFINE_STD_ARRAY_BINOP(ComplexDataVector, double, ComplexDataVector, operator-,
153 : std::minus<>())
154 :
155 : DEFINE_STD_ARRAY_INPLACE_BINOP(ComplexDataVector, DataVector, operator+=,
156 : std::plus<>())
157 : DEFINE_STD_ARRAY_INPLACE_BINOP(ComplexDataVector, DataVector, operator-=,
158 : std::minus<>())
159 : DEFINE_STD_ARRAY_INPLACE_BINOP(ComplexDataVector, double, operator+=,
160 : std::plus<>())
161 : DEFINE_STD_ARRAY_INPLACE_BINOP(ComplexDataVector, double, operator-=,
162 : std::minus<>())
163 : /// \endcond
164 :
165 : MAKE_WITH_VALUE_IMPL_DEFINITION_FOR(ComplexDataVector)
|