Skip to content
Snippets Groups Projects
Select Git revision
  • 53bc01a0c53df9cdf47631060e619e7274d9483e
  • develop default protected
  • feature/gmsh-reader
  • origin/stage/bouguettaia
  • feature/kinetic-schemes
  • feature/reconstruction
  • feature/local-dt-fsi
  • feature/composite-scheme-sources
  • feature/composite-scheme-other-fluxes
  • feature/serraille
  • feature/variational-hydro
  • feature/composite-scheme
  • hyperplastic
  • feature/polynomials
  • feature/gks
  • feature/implicit-solver-o2
  • feature/coupling_module
  • feature/implicit-solver
  • feature/merge-local-dt-fsi
  • master protected
  • feature/escobar-smoother
  • 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

userdoc.org

Blame
  • test_TinyMatrix.cpp 7.60 KiB
    #include <catch2/catch_approx.hpp>
    #include <catch2/catch_test_macros.hpp>
    #include <catch2/matchers/catch_matchers_all.hpp>
    
    #include <Kokkos_Core.hpp>
    
    #include <utils/PugsAssert.hpp>
    #include <utils/Types.hpp>
    
    #include <algebra/TinyMatrix.hpp>
    
    // Instantiate to ensure full coverage is performed
    template class TinyMatrix<1, int>;
    template class TinyMatrix<2, int>;
    template class TinyMatrix<3, int>;
    template class TinyMatrix<4, double>;
    
    // clazy:excludeall=non-pod-global-static
    
    TEST_CASE("TinyMatrix", "[algebra]")
    {
      TinyMatrix<3, int> A(1, 2, 3, 4, 5, 6, 7, 8, 9);
      REQUIRE(((A(0, 0) == 1) and (A(0, 1) == 2) and (A(0, 2) == 3) and (A(1, 0) == 4) and (A(1, 1) == 5) and
               (A(1, 2) == 6) and (A(2, 0) == 7) and (A(2, 1) == 8) and (A(2, 2) == 9)));
    
      TinyMatrix<3, int> B(6, 5, 3, 8, 34, 6, 35, 6, 7);
      SECTION("checking for opposed matrix")
      {
        const TinyMatrix<3, int> minus_A = -A;
        REQUIRE(((minus_A(0, 0) == -1) and (minus_A(0, 1) == -2) and (minus_A(0, 2) == -3) and (minus_A(1, 0) == -4) and
                 (minus_A(1, 1) == -5) and (minus_A(1, 2) == -6) and (minus_A(2, 0) == -7) and (minus_A(2, 1) == -8) and
                 (minus_A(2, 2) == -9)));
      }
      SECTION("checking for equality and difference tests")
      {
        const TinyMatrix<3, int> copy_A = A;
        REQUIRE(((copy_A(0, 0) == 1) and (copy_A(0, 1) == 2) and (copy_A(0, 2) == 3) and (copy_A(1, 0) == 4) and
                 (copy_A(1, 1) == 5) and (copy_A(1, 2) == 6) and (copy_A(2, 0) == 7) and (copy_A(2, 1) == 8) and
                 (copy_A(2, 2) == 9)));
        REQUIRE(copy_A == A);
        REQUIRE_FALSE(copy_A != A);
    
        TinyMatrix<3, int> affected_A;
        affected_A = A;
        REQUIRE(affected_A == A);
        REQUIRE_FALSE(affected_A != A);
    
        REQUIRE(A != B);
        REQUIRE_FALSE(A == B);
      }
    
      SECTION("checking for scalar left product")
      {
        const int a                 = 2;
        const TinyMatrix<3, int> aA = a * A;
    
        REQUIRE(aA == TinyMatrix<3, int>(2, 4, 6, 8, 10, 12, 14, 16, 18));
      }
    
      SECTION("checking for scalar seft product")
      {
        const int a               = 2;
        TinyMatrix<3, int> copy_A = A;
    
        REQUIRE((copy_A *= a) == TinyMatrix<3, int>(2, 4, 6, 8, 10, 12, 14, 16, 18));
      }
    
      SECTION("checking for null matrix management")
      {
        TinyMatrix<3, int> Z = zero;