]> https://gitweb.dealii.org/ - dealii.git/commitdiff
kronecker product test
authorMichał Wichrowski <mtwichrowski@gmail.com>
Thu, 1 May 2025 18:42:57 +0000 (20:42 +0200)
committerMichał Wichrowski <mtwichrowski@gmail.com>
Thu, 1 May 2025 18:42:57 +0000 (20:42 +0200)
tests/lac/full_matrix_kronecker.cc [new file with mode: 0644]
tests/lac/full_matrix_kronecker.output [new file with mode: 0644]

diff --git a/tests/lac/full_matrix_kronecker.cc b/tests/lac/full_matrix_kronecker.cc
new file mode 100644 (file)
index 0000000..207ef7b
--- /dev/null
@@ -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 <deal.II/lac/full_matrix.h>
+
+#include "../tests.h"
+
+int
+main()
+{
+  initlog();
+  deallog << std::setprecision(2);
+  deallog << std::fixed;
+
+  dealii::FullMatrix<double> A(2, 2);
+  dealii::FullMatrix<double> B(2, 2);
+  dealii::FullMatrix<double> 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 (file)
index 0000000..12d3d3c
--- /dev/null
@@ -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 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.