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

Generated by: LCOV version 1.14