LCOV - code coverage report
Current view: top level - src/Region - PRegion.hpp (source / functions) Coverage Total Hit
Test: report.info Lines: 70.0 % 30 21
Test Date: 2025-05-21 10:57:37 Functions: 87.5 % 16 14
Branches: 50.0 % 2 1

             Branch data     Line data    Source code
       1                 :             : //
       2                 :             : // Class PRegion
       3                 :             : //   PRegion represents a (possibly continuous) numeric interval.  It is
       4                 :             : //   similar to Index, with the following differences:
       5                 :             : //      1. It is templated on the data type; Index always uses integers
       6                 :             : //      2. A PRegion is defined between two endpoints A and B; the PRegion
       7                 :             : //         includes values X where A <= X < B (i.e., X in [A,B) )
       8                 :             : //      3. PRegion does not keep track of a base Index, and does not
       9                 :             : //         supply the plugBase operation.  It is not designed for use in
      10                 :             : //         Field operations like Index is, it is meant instead for use in
      11                 :             : //         Particle construction and usage.
      12                 :             : //
      13                 :             : //   PRegion<T>()      --> make a PRegion on [0,1)
      14                 :             : //   PRegion<T>(B)     --> make a PRegion on [0,B)
      15                 :             : //   PRegion<T>(A,B)   --> make a PRegion on [A,B)
      16                 :             : //
      17                 :             : #include <algorithm>
      18                 :             : #include <iostream>
      19                 :             : 
      20                 :             : #include "Utility/PAssert.h"
      21                 :             : 
      22                 :             : namespace ippl {
      23                 :             :     template <typename T>
      24                 :        2268 :     KOKKOS_FUNCTION PRegion<T>::PRegion()
      25                 :        2268 :         : PRegion(0, 1) {}
      26                 :             : 
      27                 :             :     template <typename T>
      28                 :             :     KOKKOS_FUNCTION PRegion<T>::PRegion(T b)
      29                 :             :         : PRegion(0, b) {}
      30                 :             : 
      31                 :             :     template <typename T>
      32                 :        3192 :     KOKKOS_FUNCTION PRegion<T>::PRegion(T a, T b)
      33                 :        3192 :         : a_m(a)
      34                 :        3192 :         , b_m(b) {
      35         [ -  + ]:        3192 :         PAssert(a_m < b_m);
      36                 :        3192 :     }
      37                 :             : 
      38                 :             :     template <typename T>
      39                 :         336 :     KOKKOS_FUNCTION PRegion<T>::PRegion(const PRegion<T>& pregion) {
      40                 :         336 :         a_m = pregion.a_m;
      41                 :         336 :         b_m = pregion.b_m;
      42                 :         336 :     }
      43                 :             : 
      44                 :             :     template <typename T>
      45                 :        2226 :     KOKKOS_INLINE_FUNCTION PRegion<T>& PRegion<T>::operator=(const PRegion<T>& pregion) {
      46                 :        2226 :         a_m = pregion.a_m;
      47                 :        2226 :         b_m = pregion.b_m;
      48                 :        2226 :         return *this;
      49                 :             :     }
      50                 :             : 
      51                 :             :     template <typename T>
      52                 :        5838 :     KOKKOS_INLINE_FUNCTION T PRegion<T>::min() const noexcept {
      53                 :        5838 :         return a_m;
      54                 :             :     }
      55                 :             : 
      56                 :             :     template <typename T>
      57                 :        5838 :     KOKKOS_INLINE_FUNCTION T PRegion<T>::max() const noexcept {
      58                 :        5838 :         return b_m;
      59                 :             :     }
      60                 :             : 
      61                 :             :     template <typename T>
      62                 :         462 :     KOKKOS_INLINE_FUNCTION T PRegion<T>::length() const noexcept {
      63                 :         462 :         return b_m - a_m;
      64                 :             :     }
      65                 :             : 
      66                 :             :     template <typename T>
      67                 :             :     KOKKOS_INLINE_FUNCTION bool PRegion<T>::empty() const noexcept {
      68                 :             :         return (a_m == b_m);
      69                 :             :     }
      70                 :             : 
      71                 :             :     template <typename T>
      72                 :           0 :     KOKKOS_INLINE_FUNCTION PRegion<T>& PRegion<T>::operator+=(T t) noexcept {
      73                 :           0 :         a_m += t;
      74                 :           0 :         b_m += t;
      75                 :           0 :         return *this;
      76                 :             :     }
      77                 :             : 
      78                 :             :     template <typename T>
      79                 :             :     KOKKOS_INLINE_FUNCTION PRegion<T>& PRegion<T>::operator-=(T t) noexcept {
      80                 :             :         a_m -= t;
      81                 :             :         b_m -= t;
      82                 :             :         return *this;
      83                 :             :     }
      84                 :             : 
      85                 :             :     template <typename T>
      86                 :             :     KOKKOS_INLINE_FUNCTION PRegion<T>& PRegion<T>::operator*=(T t) noexcept {
      87                 :             :         a_m *= t;
      88                 :             :         b_m *= t;
      89                 :             :         return *this;
      90                 :             :     }
      91                 :             : 
      92                 :             :     template <typename T>
      93                 :             :     KOKKOS_INLINE_FUNCTION PRegion<T>& PRegion<T>::operator/=(T t) noexcept {
      94                 :             :         if (t != 0) {
      95                 :             :             a_m /= t;
      96                 :             :             b_m /= t;
      97                 :             :         }
      98                 :             :         return *this;
      99                 :             :     }
     100                 :             : 
     101                 :             :     template <typename T>
     102                 :           0 :     inline std::ostream& operator<<(std::ostream& out, const PRegion<T>& r) {
     103                 :           0 :         out << '[' << r.min();
     104                 :           0 :         out << ',' << r.max();
     105                 :           0 :         out << ')';
     106                 :           0 :         return out;
     107                 :             :     }
     108                 :             : }  // namespace ippl
        

Generated by: LCOV version 2.0-1