SpECTRE Documentation Coverage Report
Current view: top level - DataStructures - ComplexModalVector.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 2.6 % 38 1
Test Date: 2026-10-22 17:29:42
Legend: Lines:     hit not hit

            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              : 
       8              : #include "DataStructures/VectorImpl.hpp"
       9              : #include "Utilities/TMPL.hpp"
      10              : 
      11              : /// \cond
      12              : class ModalVector;
      13              : class ComplexModalVector;
      14              : /// \endcond
      15              : 
      16              : namespace blaze {
      17            0 : DECLARE_GENERAL_VECTOR_BLAZE_TRAITS(ComplexModalVector);
      18              : }  // namespace blaze
      19              : 
      20              : /*!
      21              :  * \ingroup DataStructuresGroup
      22              :  * \brief A class for storing complex spectral coefficients on a spectral grid.
      23              :  *
      24              :  * \details A ComplexModalVector holds an array of spectral coefficients
      25              :  * represented as `std::complex<double>`s, and can be either owning (the array
      26              :  * is deleted when the ComplexModalVector goes out of scope) or non-owning,
      27              :  * meaning it just has a pointer to an array.
      28              :  *
      29              :  * Only basic mathematical operations are supported with
      30              :  * `ComplexModalVector`s. `ComplexModalVector`s may be added or subtracted and
      31              :  * may be added or subtracted with `ModalVector`s, and the following unary
      32              :  * operations are supported:
      33              :  * - conj
      34              :  * - imag (which returns a `ModalVector`)
      35              :  * - real (which returns a `ModalVector`)
      36              :  *
      37              :  * Also multiplication is supported with `std::complex<double>`s or doubles and
      38              :  * `ComplexModalVector`s, and `ComplexModalVector`s can be divided by
      39              :  * `std::complex<double>`s or `double`s. Multiplication is supported with
      40              :  * `ComplexDiagonalModalOperator`s and `ComplexModalVector`s.
      41              :  */
      42            1 : class ComplexModalVector
      43              :     : public VectorImpl<std::complex<double>, ComplexModalVector> {
      44              :  public:
      45            0 :   ComplexModalVector() = default;
      46            0 :   ComplexModalVector(const ComplexModalVector&) = default;
      47            0 :   ComplexModalVector(ComplexModalVector&&) = default;
      48            0 :   ComplexModalVector& operator=(const ComplexModalVector&) = default;
      49            0 :   ComplexModalVector& operator=(ComplexModalVector&&) = default;
      50            0 :   ~ComplexModalVector() = default;
      51              : 
      52            0 :   using BaseType = VectorImpl<std::complex<double>, ComplexModalVector>;
      53              : 
      54              :   using BaseType::operator=;
      55              :   using BaseType::VectorImpl;
      56              : };
      57              : 
      58              : namespace blaze {
      59              : template <>
      60            0 : struct TransposeFlag<ComplexModalVector>
      61              :     : BoolConstant<ComplexModalVector::transpose_flag> {};
      62              : template <>
      63            0 : struct AddTrait<ComplexModalVector, ComplexModalVector> {
      64            0 :   using Type = ComplexModalVector;
      65              : };
      66            0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexModalVector, ModalVector,
      67              :                                                AddTrait, ComplexModalVector);
      68              : template <>
      69            0 : struct SubTrait<ComplexModalVector, ComplexModalVector> {
      70            0 :   using Type = ComplexModalVector;
      71              : };
      72            0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexModalVector, ModalVector,
      73              :                                                SubTrait, ComplexModalVector);
      74            0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexModalVector,
      75              :                                                std::complex<double>, MultTrait,
      76              :                                                ComplexModalVector);
      77            0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ModalVector,
      78              :                                                std::complex<double>, MultTrait,
      79              :                                                ComplexModalVector);
      80            0 : BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(ComplexModalVector, double,
      81              :                                                MultTrait, ComplexModalVector);
      82              : template <>
      83              : struct DivTrait<ComplexModalVector, std::complex<double>> {
      84              :   using Type = ComplexModalVector;
      85              : };
      86              : template <>
      87            0 : struct DivTrait<ComplexModalVector, double> {
      88            0 :   using Type = ComplexModalVector;
      89              : };
      90              : 
      91              : template <typename Operator>
      92            0 : struct MapTrait<ComplexModalVector, Operator> {
      93              :   // Selectively allow unary operations for spectral coefficients
      94              :   static_assert(tmpl::list_contains_v<
      95              :                     tmpl::list<blaze::Conj,
      96              :                                // Following 3 reqd. by operator(+,+=), (-,-=),
      97              :                                // (-) w/doubles
      98              :                                blaze::Bind1st<blaze::Add, std::complex<double>>,
      99              :                                blaze::Bind2nd<blaze::Add, std::complex<double>>,
     100              :                                blaze::Bind1st<blaze::Sub, std::complex<double>>,
     101              :                                blaze::Bind2nd<blaze::Sub, std::complex<double>>,
     102              :                                blaze::Bind1st<blaze::Add, double>,
     103              :                                blaze::Bind2nd<blaze::Add, double>,
     104              :                                blaze::Bind1st<blaze::Sub, double>,
     105              :                                blaze::Bind2nd<blaze::Sub, double>>,
     106              :                     Operator>,
     107              :                 "Only unary operations permitted on a ComplexModalVector are:"
     108              :                 " conj, imag, real, abs");
     109            0 :   using Type = ComplexModalVector;
     110              : };
     111              : template <>
     112            0 : struct MapTrait<ComplexModalVector, blaze::Imag> {
     113            0 :   using Type = ModalVector;
     114              : };
     115              : template <>
     116            0 : struct MapTrait<ComplexModalVector, blaze::Real> {
     117            0 :   using Type = ModalVector;
     118              : };
     119              : template <>
     120            0 : struct MapTrait<ModalVector, blaze::Imag> {
     121            0 :   using Type = ModalVector;
     122              : };
     123              : template <>
     124            0 : struct MapTrait<ModalVector, blaze::Real> {
     125            0 :   using Type = ModalVector;
     126              : };
     127              : template <>
     128            0 : struct MapTrait<ComplexModalVector, blaze::Abs> {
     129            0 :   using Type = ModalVector;
     130              : };
     131              : template <>
     132            0 : struct MapTrait<ComplexModalVector, blaze::SqrAbs> {
     133            0 :   using Type = ModalVector;
     134              : };
     135              : 
     136              : template <typename Operator>
     137            0 : struct MapTrait<ComplexModalVector, ComplexModalVector, Operator> {
     138              :   // Forbid math operations in this specialization of BinaryMap traits for
     139              :   // ComplexModalVector that are unlikely to be used on spectral coefficients.
     140              :   // Currently no non-arithmetic binary operations are supported.
     141              :   static_assert(
     142              :       tmpl::list_contains_v<tmpl::list<>, Operator>,
     143              :       "This binary operation is not permitted on a ComplexModalVector.");
     144            0 :   using Type = ComplexModalVector;
     145              : };
     146              : }  // namespace blaze
     147              : 
     148              : /// \cond
     149              : DEFINE_STD_ARRAY_BINOP(ComplexModalVector, ComplexModalVector,
     150              :                        ComplexModalVector, operator+, std::plus<>())
     151              : DEFINE_STD_ARRAY_BINOP(ComplexModalVector, ComplexModalVector,
     152              :                        ComplexModalVector, operator-, std::minus<>())
     153              : DEFINE_STD_ARRAY_INPLACE_BINOP(ComplexModalVector,
     154              :                                ComplexModalVector, operator+=, std::plus<>())
     155              : DEFINE_STD_ARRAY_INPLACE_BINOP(ComplexModalVector,
     156              :                                ComplexModalVector, operator-=, std::minus<>())
     157              : /// \endcond
     158              : MAKE_WITH_VALUE_IMPL_DEFINITION_FOR(ComplexModalVector)
        

Generated by: LCOV version 2.0-1