DiagonalModalOperator.hpp
1 // Distributed under the MIT License.
2 // See LICENSE.txt for details.
3 
4 #pragma once
5 
6 #include "DataStructures/DataVector.hpp" // IWYU pragma: keep
7 #include "DataStructures/VectorImpl.hpp"
8 #include "Utilities/PointerVector.hpp" // IWYU pragma: keep
9 #include "Utilities/TMPL.hpp"
10 
11 /// \cond
12 class ModalVector;
13 /// \endcond
14 
15 // IWYU pragma: no_include <blaze/math/expressions/DVecMapExpr.h>
16 // IWYU pragma: no_include <blaze/math/typetraits/IsVector.h>
17 
18 /*!
19  * \ingroup DataStructuresGroup
20  * \brief A class for an element-wise multiplier of modal coefficients.
21  *
22  * \details A `DiagonalModalOperator` holds an array of factors to multiply by
23  * spectral coefficients, and can be either owning (the array is deleted when
24  * the `DiagonalModalOperator` goes out of scope) or non-owning, meaning it just
25  * has a pointer to an array.
26  *
27  * `DiagonalModalOperator`s are intended to represent a diagonal matrix that can
28  * operate (via the `*` operator) on spectral coefficients represented by
29  * `ModalVector`s easily. Only basic mathematical operations are supported with
30  * `DiagonalModalOperator`s. `DiagonalModalOperator`s may be added, subtracted,
31  * multiplied, or divided, and may be multiplied with a `ModalVector`, which
32  * results in a new `ModalVector`. This multiplication is commutative,
33  * supporting the interpretation of the `ModalVector` as either a 'row' or a
34  * 'column' vector.
35  *
36  * Also, addition, subtraction, multiplication and division of
37  * `DiagonalModalOperator`s with doubles is supported.
38  */
39 class DiagonalModalOperator : public VectorImpl<double, DiagonalModalOperator> {
40  public:
43 
45 };
46 
47 namespace blaze {
51  MultTrait);
52 
53 #if ((BLAZE_MAJOR_VERSION == 3) && (BLAZE_MINOR_VERSION <= 3))
54 template <typename Operator>
55 struct UnaryMapTrait<DiagonalModalOperator, Operator> {
56  // Selectively allow unary operations for spectral coefficient operators
57  static_assert(
58  tmpl::list_contains_v<
59  tmpl::list<
60  // these traits are required for operators acting with doubles
65  Operator>,
66  "This unary operation is not permitted on a DiagonalModalOperator");
67  using Type = DiagonalModalOperator;
68 };
69 
70 template <typename Operator>
71 struct BinaryMapTrait<DiagonalModalOperator, DiagonalModalOperator, Operator> {
72  // Forbid math operations in this specialization of BinaryMap traits for
73  // DiagonalModalOperator that are unlikely to be used on spectral
74  // coefficients. Currently no non-arithmetic binary operations are supported.
75  static_assert(
76  tmpl::list_contains_v<tmpl::list<>, Operator>,
77  "This binary operation is not permitted on a DiagonalModalOperator.");
78  using Type = DiagonalModalOperator;
79 };
80 #else
81 template <typename Operator>
82 struct MapTrait<DiagonalModalOperator, Operator> {
83  // Selectively allow unary operations for spectral coefficient operators
84  static_assert(
85  tmpl::list_contains_v<
86  tmpl::list<
87  // these traits are required for operators acting with doubles
92  Operator>,
93  "This unary operation is not permitted on a DiagonalModalOperator");
94  using Type = DiagonalModalOperator;
95 };
96 
97 template <typename Operator>
98 struct MapTrait<DiagonalModalOperator, DiagonalModalOperator, Operator> {
99  // Forbid math operations in this specialization of BinaryMap traits for
100  // DiagonalModalOperator that are unlikely to be used on spectral
101  // coefficients. Currently no non-arithmetic binary operations are supported.
102  static_assert(
103  tmpl::list_contains_v<tmpl::list<>, Operator>,
104  "This binary operation is not permitted on a DiagonalModalOperator.");
105  using Type = DiagonalModalOperator;
106 };
107 #endif // ((BLAZE_MAJOR_VERSION == 3) && (BLAZE_MINOR_VERSION <= 3))
108 } // namespace blaze
109 
111 
Definition: PointerVector.hpp:393
Definition: PointerVector.hpp:418
#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
A class for storing spectral coefficients on a spectral grid.
Definition: ModalVector.hpp:30
Defines class PointerVector.
Definition: PointerVector.hpp:349
A class for an element-wise multiplier of modal coefficients.
Definition: DiagonalModalOperator.hpp:39
Definition: ComplexDataVector.hpp:56
#define MAKE_WITH_VALUE_IMPL_DEFINITION_FOR(VECTOR_TYPE)
Defines the MakeWithValueImpl apply specialization.
Definition: VectorImpl.hpp:552
Definition: PointerVector.hpp:317
Wraps the template metaprogramming library used (brigand)
#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
#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