LCOV - code coverage report
Current view: top level - elsa/core - elsaDefines.h (source / functions) Hit Total Coverage
Test: coverage-all.lcov Lines: 0 1 0.0 %
Date: 2022-08-25 03:05:39 Functions: 0 0 -

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <complex>
       4             : #include <cstddef>
       5             : #include <Eigen/Core>
       6             : #include <Eigen/Geometry>
       7             : #include <type_traits>
       8             : 
       9             : #ifdef ELSA_CUDA_VECTOR
      10             : #include <thrust/complex.h>
      11             : #endif
      12             : 
      13             : #include "Complex.h"
      14             : 
      15             : namespace elsa
      16             : {
      17             :     using real_t = float;              ///< global type for real numbers
      18             :     using complex_t = complex<real_t>; ///< global type for complex numbers
      19             :     using index_t = std::ptrdiff_t;    ///< global type for indices
      20             : 
      21             :     /// global type for vectors of real numbers
      22             :     using RealVector_t = Eigen::Matrix<real_t, Eigen::Dynamic, 1>;
      23             : 
      24             :     /// global type for vectors of complex numbers
      25             :     using ComplexVector_t = Eigen::Matrix<complex_t, Eigen::Dynamic, 1>;
      26             : 
      27             :     /// global type for vectors of indices
      28             :     using IndexVector_t = Eigen::Matrix<index_t, Eigen::Dynamic, 1>;
      29             : 
      30             :     /// global type for vectors of booleans
      31             :     using BooleanVector_t = Eigen::Matrix<bool, Eigen::Dynamic, 1>;
      32             : 
      33             :     /// global type for vectors of data_t
      34             :     template <typename data_t>
      35             :     using Vector_t = Eigen::Matrix<data_t, Eigen::Dynamic, 1>;
      36             : 
      37             :     /// global type for matrices of real numbers
      38             :     using RealMatrix_t = Eigen::Matrix<real_t, Eigen::Dynamic, Eigen::Dynamic>;
      39             : 
      40             :     /// global type alias for rays
      41             :     using RealRay_t = Eigen::ParametrizedLine<real_t, Eigen::Dynamic>;
      42             : 
      43             :     /// global type alias for rays
      44             :     template <typename data_t>
      45             :     using Ray_t = Eigen::ParametrizedLine<data_t, Eigen::Dynamic>;
      46             : 
      47             :     /// template global constexpr for the number pi
      48             :     template <typename T>
      49             :     constexpr auto pi = static_cast<T>(3.14159265358979323846);
      50             : 
      51             :     /// global constexpr for the number pi
      52             :     constexpr auto pi_t = pi<real_t>;
      53             : 
      54             :     /// various values of the different norms of the Fourier transforms
      55             :     enum class FFTNorm { FORWARD, ORTHO, BACKWARD };
      56             : 
      57             :     /// type of the DataHandler used to store the actual data
      58             :     enum class DataHandlerType {
      59             :         CPU,     ///< data is stored as an Eigen::Matrix in CPU main memory
      60             :         MAP_CPU, ///< data is not explicitly stored, but using an Eigen::Map to refer to other
      61             :         GPU,     ///< data is stored as an raw array in the GPU memory
      62             :         MAP_GPU  ///< data is not explicitley stored but mapped through a pointer
      63             :     };
      64             : 
      65             : #ifdef ELSA_CUDA_VECTOR
      66             :     constexpr DataHandlerType defaultHandlerType = DataHandlerType::GPU;
      67             : #else
      68             :     constexpr DataHandlerType defaultHandlerType = DataHandlerType::CPU;
      69             : #endif
      70             : 
      71             :     /// base case for deducing floating point type of std::complex
      72             :     template <typename T>
      73             :     struct GetFloatingPointType {
      74             :         using type = T;
      75             :     };
      76             : 
      77             :     /// partial specialization to derive correct floating point type
      78             :     template <typename T>
      79             :     struct GetFloatingPointType<complex<T>> {
      80             :         using type = T;
      81             :     };
      82             : 
      83             :     /// helper typedef to facilitate usage
      84             :     template <typename T>
      85             :     using GetFloatingPointType_t = typename GetFloatingPointType<T>::type;
      86             : 
      87             :     /// Remove cv qualifiers as well as reference of given type
      88             :     // TODO: Replace with std::remove_cv_ref_t when C++20 available
      89             :     template <typename T>
      90             :     struct RemoveCvRef {
      91             :         using type = std::remove_cv_t<std::remove_reference_t<T>>;
      92             :     };
      93             : 
      94             :     /// Helper to make type available
      95             :     template <class T>
      96             :     using RemoveCvRef_t = typename RemoveCvRef<T>::type;
      97             : 
      98             :     /// Predicate to check if of complex type
      99             :     template <typename T>
     100             :     constexpr bool isComplex = std::is_same<RemoveCvRef_t<T>, complex<float>>::value
     101             :                                || std::is_same<RemoveCvRef_t<T>, complex<double>>::value;
     102             : } // namespace elsa
     103             : 
     104             : /*
     105             :  * Branch prediction tuning.
     106             :  * the expression is expected to be true (=likely) or false (=unlikely).
     107             :  *
     108             :  * btw, this implementation was taken from the Linux kernel.
     109             :  */
     110             : #if defined(__GNUC__) || defined(__clang__)
     111             : #define likely(x) __builtin_expect(!!(x), 1)
     112           0 : #define unlikely(x) __builtin_expect(!!(x), 0)
     113             : #else
     114             : #define likely(x) (x)
     115             : #define unlikely(x) (x)
     116             : #endif

Generated by: LCOV version 1.14