// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root // SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- // vi: set et ts=4 sw=2 sts=2: // include this first to see whether it includes all necessary headers itself #include #include #include #include #include #include #include using namespace Dune; template TestSuite test_matrix() { TestSuite test("test_matrix"); ScaledIdentityMatrix A(1); // Test for proper matrix sizes, both statically and dynamically static_assert(A.rows==n, "Incorrect number of rows"); static_assert(A.cols==n, "Incorrect number of columns"); test.check(A.rows==n) << "Incorrect number of rows"; test.check(A.cols==n) << "Incorrect number of columns"; test.check(A.rows()==n) << "Incorrect number of rows"; test.check(A.cols()==n) << "Incorrect number of columns"; FieldVector f; FieldVector v; // assign matrix A=2; // assign vector f = 1; v = 2; // matrix vector product A.umv(v,f); // matrix times scalar [[maybe_unused]] auto r1 = A * 23.; [[maybe_unused]] auto r2 = 42. * A; // test norms A.frobenius_norm(); A.frobenius_norm2(); A.infinity_norm(); A.infinity_norm_real(); // print matrix std::cout << A << std::endl; // print vector std::cout << f << std::endl; // Construction of FieldMatrix from ScaledIdentityMatrix FieldMatrix AFM = FieldMatrix(A); // Test whether we can add a ScaledIdentityMatrix to a FieldMatrix, // and vice versa const auto sum = A + AFM + A; // Is the sum correctly computed? for (std::size_t i=0; i, double, float>; // Construction of FieldMatrix from ScaledIdentityMatrix auto AFMOtherScalar = FieldMatrix(A); // Test whether we can add a ScaledIdentityMatrix to a FieldMatrix // with a different number type, and vice versa const auto sum2 = A + AFMOtherScalar + A; AFMOtherScalar += A; // Is the sum correctly computed? for (std::size_t i=0; i(42.0); // Test whether we can add a ScaledIdentityMatrix to a DiagonalMatrix // with a different number type, and vice versa const auto sum3 = A + ADMOtherScalar + A; ADMOtherScalar += A; // Is the sum correctly computed? for (std::size_t i=0; i()); test.subTest(test_matrix()); //test.subTest(test_matrix()); Does not compile with icc because there is no std::sqrt(int) std::fabs(int) test.subTest(test_matrix()); return test.exit(); }