Skip to content
Snippets Groups Projects
Select Git revision
  • b24312838a4becbc6655ccef07a0829b8664b95f
  • develop default protected
  • feature/advection
  • feature/composite-scheme-other-fluxes
  • origin/stage/bouguettaia
  • save_clemence
  • feature/local-dt-fsi
  • feature/variational-hydro
  • feature/gmsh-reader
  • feature/reconstruction
  • feature/kinetic-schemes
  • feature/composite-scheme-sources
  • feature/serraille
  • feature/composite-scheme
  • hyperplastic
  • feature/polynomials
  • feature/gks
  • feature/implicit-solver-o2
  • feature/coupling_module
  • feature/implicit-solver
  • feature/merge-local-dt-fsi
  • v0.5.0 protected
  • v0.4.1 protected
  • v0.4.0 protected
  • v0.3.0 protected
  • v0.2.0 protected
  • v0.1.0 protected
  • Kidder
  • v0.0.4 protected
  • v0.0.3 protected
  • v0.0.2 protected
  • v0 protected
  • v0.0.1 protected
33 results

Messenger.hpp

Blame
  • TinyMatrix.hpp 14.29 KiB
    #ifndef TINY_MATRIX_HPP
    #define TINY_MATRIX_HPP
    
    #include <algebra/TinyVector.hpp>
    #include <utils/InvalidData.hpp>
    #include <utils/NaNHelper.hpp>
    #include <utils/PugsAssert.hpp>
    #include <utils/PugsMacros.hpp>
    #include <utils/Types.hpp>
    
    #include <iostream>
    
    template <size_t M, size_t N = M, typename T = double>
    class [[nodiscard]] TinyMatrix
    {
     public:
      inline static constexpr size_t Dimension       = M * N;
      inline static constexpr size_t NumberOfRows    = M;
      inline static constexpr size_t NumberOfColumns = N;
    
      using data_type = T;
    
     private:
      static_assert((M > 0), "TinyMatrix number of rows must be strictly positive");
      static_assert((N > 0), "TinyMatrix number of columns must be strictly positive");
    
      T m_values[M * N];
    
      PUGS_FORCEINLINE
      constexpr size_t
      _index(size_t i, size_t j) const noexcept   // LCOV_EXCL_LINE (due to forced inline)
      {
        return i * N + j;
      }
    
      template <typename... Args>
      PUGS_FORCEINLINE constexpr void
      _unpackVariadicInput(const T& t, Args&&... args) noexcept
      {
        m_values[M * N - 1 - sizeof...(args)] = t;
        if constexpr (sizeof...(args) > 0) {
          this->_unpackVariadicInput(std::forward<Args>(args)...);
        }
      }
    
      template <typename... Args>
      PUGS_FORCEINLINE constexpr void
      _unpackVariadicInput(const TinyVector<M, T>& t, Args&&... args) noexcept
      {
        for (size_t j = 0; j < M; ++j) {
          m_values[_index(j, N - 1 - sizeof...(args))] = t[j];
        }
        if constexpr (sizeof...(args) > 0) {
          this->_unpackVariadicInput(std::forward<Args>(args)...);
        }
      }
    
     public:
      [[nodiscard]] PUGS_INLINE constexpr bool
      isSquare() const noexcept
      {
        return M == N;
      }
    
      [[nodiscard]] PUGS_INLINE constexpr friend TinyMatrix<N, M, T>
      transpose(const TinyMatrix& A)
      {
        TinyMatrix<N, M, T> tA;
        for (size_t i = 0; i < M; ++i) {
          for (size_t j = 0; j < N; ++j) {