LCOV - code coverage report
Current view: top level - src/Types - Vector.h (source / functions) Coverage Total Hit
Test: report.info Lines: 100.0 % 3 3
Test Date: 2025-05-21 12:58:26 Functions: 76.1 % 218 166
Branches: 60.0 % 10 6

             Branch data     Line data    Source code
       1                 :             : //
       2                 :             : // Class Vector
       3                 :             : //   Vector class used for vector fields and particle attributes like the coordinate.
       4                 :             : //
       5                 :             : #ifndef IPPL_Vector_H
       6                 :             : #define IPPL_Vector_H
       7                 :             : 
       8                 :             : #include <initializer_list>
       9                 :             : 
      10                 :             : #include "Expression/IpplExpressions.h"
      11                 :             : 
      12                 :             : namespace ippl {
      13                 :             :     /*!
      14                 :             :      * @file Vector.h
      15                 :             :      */
      16                 :             : 
      17                 :             :     /*!
      18                 :             :      * @class Vector
      19                 :             :      * @tparam T intrinsic vector data type
      20                 :             :      * @tparam Dim vector dimension
      21                 :             :      */
      22                 :             :     template <typename T, unsigned Dim>
      23                 :             :     class Vector : public detail::Expression<Vector<T, Dim>, sizeof(T) * Dim> {
      24                 :             :     public:
      25                 :             :         typedef T value_type;
      26                 :             :         static constexpr unsigned dim = Dim;
      27                 :             : 
      28                 :             :         KOKKOS_FUNCTION
      29                 :    30285798 :         Vector()
      30   [ +  -  +  - ]:    30285798 :             : Vector(value_type(0)) {}
                 [ +  - ]
      31                 :             : 
      32                 :             :         template <typename... Args,
      33                 :             :                   typename std::enable_if<sizeof...(Args) == Dim, bool>::type = true>
      34                 :             :         explicit KOKKOS_FUNCTION Vector(const Args&... args);
      35                 :             : 
      36                 :             :         template <typename E, size_t N>
      37                 :             :         KOKKOS_FUNCTION Vector(const detail::Expression<E, N>& expr);
      38                 :             : 
      39                 :             :         KOKKOS_DEFAULTED_FUNCTION
      40                 :             :         Vector(const Vector<T, Dim>& v) = default;
      41                 :             : 
      42                 :             :         KOKKOS_FUNCTION
      43                 :             :         Vector(const T& val);
      44                 :             : 
      45                 :             :         Vector(const std::array<T, Dim>& a);
      46                 :             : 
      47                 :             :         Vector(const std::array<std::vector<T>, Dim>& a);
      48                 :             : 
      49                 :             :         /*!
      50                 :             :          * @param list of values
      51                 :             :          */
      52                 :             :         KOKKOS_FUNCTION
      53                 :             :         Vector(const std::initializer_list<T>& list);
      54                 :             : 
      55                 :             :         KOKKOS_FUNCTION
      56   [ +  -  +  + ]:   195711822 :         ~Vector() {}
      57                 :             : 
      58                 :             :         // Get and Set Operations
      59                 :             :         KOKKOS_INLINE_FUNCTION value_type& operator[](unsigned int i);
      60                 :             : 
      61                 :             :         KOKKOS_INLINE_FUNCTION value_type operator[](unsigned int i) const;
      62                 :             : 
      63                 :             :         KOKKOS_INLINE_FUNCTION value_type& operator()(unsigned int i);
      64                 :             : 
      65                 :             :         KOKKOS_INLINE_FUNCTION value_type operator()(unsigned int i) const;
      66                 :             : 
      67                 :             :         // Assignment Operators
      68                 :             :         template <typename E, size_t N>
      69                 :             :         KOKKOS_INLINE_FUNCTION Vector<T, Dim>& operator=(const detail::Expression<E, N>& expr);
      70                 :             : 
      71                 :             :         template <typename E, size_t N>
      72                 :             :         KOKKOS_INLINE_FUNCTION Vector<T, Dim>& operator+=(const detail::Expression<E, N>& expr);
      73                 :             : 
      74                 :             :         template <typename E, size_t N>
      75                 :             :         KOKKOS_INLINE_FUNCTION Vector<T, Dim>& operator-=(const detail::Expression<E, N>& expr);
      76                 :             : 
      77                 :             :         template <typename E, size_t N>
      78                 :             :         KOKKOS_INLINE_FUNCTION Vector<T, Dim>& operator*=(const detail::Expression<E, N>& expr);
      79                 :             : 
      80                 :             :         template <typename E, size_t N>
      81                 :             :         KOKKOS_INLINE_FUNCTION Vector<T, Dim>& operator/=(const detail::Expression<E, N>& expr);
      82                 :             : 
      83                 :             :         KOKKOS_INLINE_FUNCTION Vector<T, Dim>& operator+=(const T& val);
      84                 :             : 
      85                 :             :         KOKKOS_INLINE_FUNCTION Vector<T, Dim>& operator-=(const T& val);
      86                 :             : 
      87                 :             :         KOKKOS_INLINE_FUNCTION Vector<T, Dim>& operator*=(const T& val);
      88                 :             : 
      89                 :             :         KOKKOS_INLINE_FUNCTION Vector<T, Dim>& operator/=(const T& val);
      90                 :             : 
      91                 :             :         using iterator       = T*;
      92                 :             :         using const_iterator = const T*;
      93                 :             :         KOKKOS_INLINE_FUNCTION constexpr iterator begin();
      94                 :             :         KOKKOS_INLINE_FUNCTION constexpr iterator end();
      95                 :             :         KOKKOS_INLINE_FUNCTION constexpr const_iterator begin() const;
      96                 :             :         KOKKOS_INLINE_FUNCTION constexpr const_iterator end() const;
      97                 :             : 
      98                 :             :         KOKKOS_INLINE_FUNCTION T dot(const Vector<T, Dim>& rhs) const;
      99                 :             : 
     100                 :             :         // Needs to be public to be a standard-layout type
     101                 :             :         // private:
     102                 :             :         T data_m[Dim];
     103                 :             :     };
     104                 :             : 
     105                 :             :     template <typename T, unsigned Dim>
     106                 :             :     KOKKOS_INLINE_FUNCTION Vector<T, Dim> min(const Vector<T, Dim>& a, const Vector<T, Dim>& b);
     107                 :             :     template <typename T, unsigned Dim>
     108                 :             :     KOKKOS_INLINE_FUNCTION Vector<T, Dim> max(const Vector<T, Dim>& a, const Vector<T, Dim>& b);
     109                 :             : }  // namespace ippl
     110                 :             : 
     111                 :             : #include "Vector.hpp"
     112                 :             : 
     113                 :             : #endif
        

Generated by: LCOV version 2.0-1