Line data Source code
1 0 : // 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/TMPL.hpp" 9 : 10 : /// \cond 11 : class ModalVector; 12 : class DiagonalModalOperator; 13 : /// \endcond 14 : 15 : namespace blaze { 16 0 : DECLARE_GENERAL_VECTOR_BLAZE_TRAITS(DiagonalModalOperator); 17 : } // namespace blaze 18 : 19 : /*! 20 : * \ingroup DataStructuresGroup 21 : * \brief A class for an element-wise multiplier of modal coefficients. 22 : * 23 : * \details A `DiagonalModalOperator` holds an array of factors to multiply by 24 : * spectral coefficients, and can be either owning (the array is deleted when 25 : * the `DiagonalModalOperator` goes out of scope) or non-owning, meaning it just 26 : * has a pointer to an array. 27 : * 28 : * `DiagonalModalOperator`s are intended to represent a diagonal matrix that can 29 : * operate (via the `*` operator) on spectral coefficients represented by 30 : * `ModalVector`s easily. Only basic mathematical operations are supported with 31 : * `DiagonalModalOperator`s. `DiagonalModalOperator`s may be added, subtracted, 32 : * multiplied, or divided, and may be multiplied with a `ModalVector`, which 33 : * results in a new `ModalVector`. This multiplication is commutative, 34 : * supporting the interpretation of the `ModalVector` as either a 'row' or a 35 : * 'column' vector. 36 : * 37 : * Also, addition, subtraction, multiplication and division of 38 : * `DiagonalModalOperator`s with doubles is supported. 39 : */ 40 1 : class DiagonalModalOperator : public VectorImpl<double, DiagonalModalOperator> { 41 : public: 42 0 : DiagonalModalOperator() = default; 43 0 : DiagonalModalOperator(const DiagonalModalOperator&) = default; 44 0 : DiagonalModalOperator(DiagonalModalOperator&&) = default; 45 0 : DiagonalModalOperator& operator=(const DiagonalModalOperator&) = default; 46 0 : DiagonalModalOperator& operator=(DiagonalModalOperator&&) = default; 47 0 : ~DiagonalModalOperator() = default; 48 : 49 0 : using BaseType = VectorImpl<double, DiagonalModalOperator>; 50 : 51 : using BaseType::operator=; 52 : using BaseType::VectorImpl; 53 : }; 54 : 55 : namespace blaze { 56 0 : VECTOR_BLAZE_TRAIT_SPECIALIZE_ARITHMETIC_TRAITS(DiagonalModalOperator); 57 0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ModalVector, 58 : DiagonalModalOperator, 59 : MultTrait, ModalVector); 60 : 61 : template <typename Operator> 62 0 : struct MapTrait<DiagonalModalOperator, Operator> { 63 : // Selectively allow unary operations for spectral coefficient operators 64 : static_assert( 65 : tmpl::list_contains_v< 66 : tmpl::list<blaze::Bind1st<blaze::Add, double>, 67 : blaze::Bind2nd<blaze::Add, double>, 68 : blaze::Bind1st<blaze::Div, double>, 69 : blaze::Bind2nd<blaze::Div, double>, 70 : blaze::Bind1st<blaze::Sub, double>, 71 : blaze::Bind2nd<blaze::Sub, double>, 72 : blaze::Bind1st<blaze::Add, std::complex<double>>, 73 : blaze::Bind2nd<blaze::Add, std::complex<double>>, 74 : blaze::Bind1st<blaze::Div, std::complex<double>>, 75 : blaze::Bind2nd<blaze::Div, std::complex<double>>, 76 : blaze::Bind1st<blaze::Sub, std::complex<double>>, 77 : blaze::Bind2nd<blaze::Sub, std::complex<double>>>, 78 : Operator>, 79 : "This unary operation is not permitted on a DiagonalModalOperator"); 80 0 : using Type = DiagonalModalOperator; 81 : }; 82 : 83 : template <typename Operator> 84 0 : struct MapTrait<DiagonalModalOperator, DiagonalModalOperator, Operator> { 85 : // Forbid math operations in this specialization of BinaryMap traits for 86 : // DiagonalModalOperator that are unlikely to be used on spectral 87 : // coefficients. Currently no non-arithmetic binary operations are supported. 88 : static_assert( 89 : tmpl::list_contains_v<tmpl::list<>, Operator>, 90 : "This binary operation is not permitted on a DiagonalModalOperator."); 91 0 : using Type = DiagonalModalOperator; 92 : }; 93 : } // namespace blaze 94 : 95 : MAKE_STD_ARRAY_VECTOR_BINOPS(DiagonalModalOperator) 96 : 97 : MAKE_WITH_VALUE_IMPL_DEFINITION_FOR(DiagonalModalOperator)