Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <cmath> 7 : 8 : #include "DataStructures/VectorImpl.hpp" 9 : #include "Utilities/ForceInline.hpp" 10 : 11 : /// \cond 12 : class DataVector; 13 : /// \endcond 14 : 15 : namespace blaze { 16 0 : DECLARE_GENERAL_VECTOR_BLAZE_TRAITS(DataVector); 17 : } // namespace blaze 18 : 19 : /*! 20 : * \ingroup DataStructuresGroup 21 : * \brief Stores a collection of function values. 22 : * 23 : * \details Use DataVector to represent function values on the computational 24 : * domain. Note that interpreting the data also requires knowledge of the points 25 : * that these function values correspond to. 26 : * 27 : * A DataVector holds an array of contiguous data. The DataVector can be owning, 28 : * meaning the array is deleted when the DataVector goes out of scope, or 29 : * non-owning, meaning it just has a pointer to an array. 30 : * 31 : * Refer to the \ref DataStructuresGroup documentation for a list of other 32 : * available types. In particular, to represent a generic vector that supports 33 : * common vector and matrix operations and whose meaning may not be of function 34 : * values at points, use any of the 35 : * [Blaze vector types](https://bitbucket.org/blaze-lib/blaze/wiki/Vector%20Types) 36 : * instead. 37 : * 38 : * DataVectors support a variety of mathematical operations that are applicable 39 : * to nodal coefficients. In addition to common arithmetic operations such as 40 : * elementwise addition, subtraction, multiplication and division, the 41 : * elementwise operations on blaze vectors of doubles are supported. See 42 : * [blaze-wiki/Vector_Operations] 43 : * (https://bitbucket.org/blaze-lib/blaze/wiki/Vector%20Operations). 44 : * 45 : * In addition, the Heaviside step function `step_function` is supported for 46 : * DataVectors. 47 : */ 48 1 : class DataVector : public VectorImpl<double, DataVector> { 49 : public: 50 0 : DataVector() = default; 51 0 : DataVector(const DataVector&) = default; 52 0 : DataVector(DataVector&&) = default; 53 0 : DataVector& operator=(const DataVector&) = default; 54 0 : DataVector& operator=(DataVector&&) = default; 55 0 : ~DataVector() = default; 56 : 57 0 : using BaseType = VectorImpl<double, DataVector>; 58 : 59 : using BaseType::operator=; 60 : using BaseType::VectorImpl; 61 : }; 62 : 63 : // Specialize the Blaze type traits to correctly handle DataVector 64 : namespace blaze { 65 0 : VECTOR_BLAZE_TRAIT_SPECIALIZE_ARITHMETIC_TRAITS(DataVector); 66 0 : VECTOR_BLAZE_TRAIT_SPECIALIZE_ALL_MAP_TRAITS(DataVector); 67 : // Only specialize cross product for DataVector because it is unclear what a 68 : // cross product of other vector types is. This is why this is here and not in 69 : // VectorImpl.hpp 70 0 : BLAZE_TRAIT_SPECIALIZE_BINARY_TRAIT(DataVector, CrossTrait); 71 : } // namespace blaze 72 : 73 0 : SPECTRE_ALWAYS_INLINE auto fabs(const DataVector& t) { return abs(*t); } 74 : 75 : MAKE_STD_ARRAY_VECTOR_BINOPS(DataVector) 76 : 77 : MAKE_WITH_VALUE_IMPL_DEFINITION_FOR(DataVector)