From b51e3a0ae7c05d08f1ac2050a391da0d2e87891d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Wichrowski?= Date: Thu, 1 May 2025 20:42:57 +0200 Subject: [PATCH] kronecker product test --- tests/lac/full_matrix_kronecker.cc | 52 ++++++++++++++++++++++++++ tests/lac/full_matrix_kronecker.output | 6 +++ 2 files changed, 58 insertions(+) create mode 100644 tests/lac/full_matrix_kronecker.cc create mode 100644 tests/lac/full_matrix_kronecker.output diff --git a/tests/lac/full_matrix_kronecker.cc b/tests/lac/full_matrix_kronecker.cc new file mode 100644 index 0000000000..207ef7b67f --- /dev/null +++ b/tests/lac/full_matrix_kronecker.cc @@ -0,0 +1,52 @@ +// ------------------------------------------------------------------------ +// +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (C) 2005 - 2020 by the deal.II authors +// +// This file is part of the deal.II library. +// +// Part of the source code is dual licensed under Apache-2.0 WITH +// LLVM-exception OR LGPL-2.1-or-later. Detailed license information +// governing the source code and code contributions can be found in +// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. +// +// ------------------------------------------------------------------------ + +// Test that an assertion is thrown if output argument of FullMatrix::mmult() is +// also an input argument + +#include + +#include "../tests.h" + +int +main() +{ + initlog(); + deallog << std::setprecision(2); + deallog << std::fixed; + + dealii::FullMatrix A(2, 2); + dealii::FullMatrix B(2, 2); + dealii::FullMatrix C(4, 4); + + A(0, 0) = 1; + A(0, 1) = 2; + A(1, 0) = 3; + A(1, 1) = 4; + + B(0, 0) = 5; + B(0, 1) = 6; + B(1, 0) = 7; + B(1, 1) = 8; + + C.kronecker_product(A, B); + + + std::stringstream sstring; + sstring << "Result" << "\n"; + C.print_formatted(sstring, 4, true, 10, "0."); + deallog << sstring.str() << std::endl; + + return 0; +} diff --git a/tests/lac/full_matrix_kronecker.output b/tests/lac/full_matrix_kronecker.output new file mode 100644 index 0000000000..12d3d3cd10 --- /dev/null +++ b/tests/lac/full_matrix_kronecker.output @@ -0,0 +1,6 @@ + +DEAL::Result +5.0000e+00 6.0000e+00 1.0000e+01 1.2000e+01 +7.0000e+00 8.0000e+00 1.4000e+01 1.6000e+01 +1.5000e+01 1.8000e+01 2.0000e+01 2.4000e+01 +2.1000e+01 2.4000e+01 2.8000e+01 3.2000e+01 -- 2.39.5