]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Added tests for lac/ProductMatrix
authordakshina.ilangova <dakshina.ilangova@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 8 Mar 2014 19:44:15 +0000 (19:44 +0000)
committerdakshina.ilangova <dakshina.ilangova@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 8 Mar 2014 19:44:15 +0000 (19:44 +0000)
git-svn-id: https://svn.dealii.org/trunk@32628 0785d39b-7218-0410-832d-ea1e28bc413d

16 files changed:
tests/lac/product_matrix_01.cc [new file with mode: 0644]
tests/lac/product_matrix_01.output [new file with mode: 0644]
tests/lac/product_matrix_02.cc [new file with mode: 0644]
tests/lac/product_matrix_02.output [new file with mode: 0644]
tests/lac/product_matrix_03.cc [new file with mode: 0644]
tests/lac/product_matrix_03.output [new file with mode: 0644]
tests/lac/product_matrix_04.cc [new file with mode: 0644]
tests/lac/product_matrix_04.output [new file with mode: 0644]
tests/lac/product_matrix_05.cc [new file with mode: 0644]
tests/lac/product_matrix_05.output [new file with mode: 0644]
tests/lac/product_matrix_06.cc [new file with mode: 0644]
tests/lac/product_matrix_06.output [new file with mode: 0644]
tests/lac/product_matrix_07.cc [new file with mode: 0644]
tests/lac/product_matrix_07.output [new file with mode: 0644]
tests/lac/product_matrix_08.cc [new file with mode: 0644]
tests/lac/product_matrix_08.output [new file with mode: 0644]

diff --git a/tests/lac/product_matrix_01.cc b/tests/lac/product_matrix_01.cc
new file mode 100644 (file)
index 0000000..683410b
--- /dev/null
@@ -0,0 +1,90 @@
+// ---------------------------------------------------------------------
+// $Id: product_matrix_01.cc 32491 2014-02-14 20:52:51Z bangerth $
+//
+// Copyright (C) 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// Check ProductMatrix::constructor1
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/matrix_lib.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+#include <fstream>
+#include <iomanip>
+#include <cmath>
+
+template<typename number>
+  void
+  checkConstructor1(FullMatrix<number> &A, FullMatrix<number> &B)
+  {
+    deallog << "Init with empty constructor" << std::endl;
+    GrowingVectorMemory < Vector<number> > mem;
+    ProductMatrix < Vector<number> > P;
+    P.initialize(A, B, mem);
+
+    deallog << "Multiplying with all ones vector" << std::endl;
+    Vector<number> V(B.n());
+    for (unsigned int i = 0; i < V.size(); ++i)
+      V(i) = 1;
+
+    Vector<number> O(A.m());
+
+    P.vmult(O, V);
+
+    // Check the dimensions of the result matrix
+    Assert(A.m() == O.size(), ExcInternalError());
+    deallog << "Dimensions of result vector verified" << std::endl;
+
+    // Verifying results with Method 2: O=(A*B)*V
+    FullMatrix<number> AB_Product(A.m(), B.n());
+    Vector<number> O_(A.m());
+
+    A.mmult(AB_Product, B, false);
+    AB_Product.vmult(O_, V);
+
+    Assert(O == O_, ExcInternalError());
+    deallog << "Result vector data verified" << std::endl;
+
+    for (unsigned int i = 0; i < O.size(); ++i)
+      deallog << O(i) << '\t';
+    deallog << std::endl;
+  }
+
+int
+main()
+{
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  const double Adata[] =
+    { 2, 3, 4, 5 };
+
+  const double Bdata[] =
+    { 0, 1, 2, 3 };
+
+  FullMatrix<double> A(2, 2);
+  FullMatrix<double> B(2, 2);
+
+  A.fill(Adata);
+  B.fill(Bdata);
+
+  checkConstructor1<double>(A, B);
+
+}
diff --git a/tests/lac/product_matrix_01.output b/tests/lac/product_matrix_01.output
new file mode 100644 (file)
index 0000000..33dd94a
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Init with empty constructor
+DEAL::Multiplying with all ones vector
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::17.0000  29.0000 
diff --git a/tests/lac/product_matrix_02.cc b/tests/lac/product_matrix_02.cc
new file mode 100644 (file)
index 0000000..5fdc7b8
--- /dev/null
@@ -0,0 +1,89 @@
+// ---------------------------------------------------------------------
+// $Id: product_matrix_01.cc 32491 2014-02-14 20:52:51Z bangerth $
+//
+// Copyright (C) 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// Check ProductMatrix::constructor2
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/matrix_lib.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+#include <fstream>
+#include <iomanip>
+#include <cmath>
+
+template<typename number>
+  void
+  checkConstructor2(FullMatrix<number> &A, FullMatrix<number> &B)
+  {
+    deallog << "Init with vector memory. Delayed reinit" << std::endl;
+    GrowingVectorMemory < Vector<number> > mem;
+    ProductMatrix < Vector<number> > P(mem);
+    P.reinit(A, B);
+
+    deallog << "Multiplying with all ones vector" << std::endl;
+    Vector<number> V(B.n());
+    for (unsigned int i = 0; i < V.size(); ++i)
+      V(i) = 1;
+    Vector<number> O(A.m());
+
+    P.vmult(O, V);
+
+    // Check the dimensions of the result matrix
+    Assert(A.m() == O.size(), ExcInternalError());
+    deallog << "Dimensions of result vector verified" << std::endl;
+
+    // Verifying results with Method 2: O=(A*B)*V
+    FullMatrix<number> AB_Product(A.m(), B.n());
+    Vector<number> O_(A.m());
+
+    A.mmult(AB_Product, B, false);
+    AB_Product.vmult(O_, V);
+
+    Assert(O == O_, ExcInternalError());
+    deallog << "Result vector data verified" << std::endl;
+
+    for (unsigned int i = 0; i < O.size(); ++i)
+      deallog << O(i) << '\t';
+    deallog << std::endl;
+  }
+
+int
+main()
+{
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  const double Adata[] =
+    { 2, 3, 4, 5 };
+
+  const double Bdata[] =
+    { 0, 1, 2, 3 };
+
+  FullMatrix<double> A(2, 2);
+  FullMatrix<double> B(2, 2);
+
+  A.fill(Adata);
+  B.fill(Bdata);
+
+  checkConstructor2<double>(A, B);
+
+}
diff --git a/tests/lac/product_matrix_02.output b/tests/lac/product_matrix_02.output
new file mode 100644 (file)
index 0000000..26b5a6b
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Init with vector memory. Delayed reinit
+DEAL::Multiplying with all ones vector
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::17.0000  29.0000 
diff --git a/tests/lac/product_matrix_03.cc b/tests/lac/product_matrix_03.cc
new file mode 100644 (file)
index 0000000..13dc09e
--- /dev/null
@@ -0,0 +1,88 @@
+// ---------------------------------------------------------------------
+// $Id: product_matrix_01.cc 32491 2014-02-14 20:52:51Z bangerth $
+//
+// Copyright (C) 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// Check ProductMatrix::constructor3
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/matrix_lib.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+#include <fstream>
+#include <iomanip>
+#include <cmath>
+
+template<typename number>
+  void
+  checkConstructor3(FullMatrix<number> &A, FullMatrix<number> &B)
+  {
+    deallog << "Init with vector memory, matrix 1 and matrix 2" << std::endl;
+    GrowingVectorMemory < Vector<number> > mem;
+    ProductMatrix < Vector<number> > P(A, B, mem);
+
+    deallog << "Multiplying with all ones vector" << std::endl;
+    Vector<number> V(B.n());
+    for (unsigned int i = 0; i < V.size(); ++i)
+      V(i) = 1;
+    Vector<number> O(A.m());
+
+    P.vmult(O, V);
+
+    // Check the dimensions of the result matrix
+    Assert(A.m() == O.size(), ExcInternalError());
+    deallog << "Dimensions of result vector verified" << std::endl;
+
+    // Verifying results with Method 2: O=(A*B)*V
+    FullMatrix<number> AB_Product(A.m(), B.n());
+    Vector<number> O_(A.m());
+
+    A.mmult(AB_Product, B, false);
+    AB_Product.vmult(O_, V);
+
+    Assert(O == O_, ExcInternalError());
+    deallog << "Result vector data verified" << std::endl;
+
+    for (unsigned int i = 0; i < O.size(); ++i)
+      deallog << O(i) << '\t';
+    deallog << std::endl;
+  }
+
+int
+main()
+{
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  const double Adata[] =
+    { 2, 3, 4, 5 };
+
+  const double Bdata[] =
+    { 0, 1, 2, 3 };
+
+  FullMatrix<double> A(2, 2);
+  FullMatrix<double> B(2, 2);
+
+  A.fill(Adata);
+  B.fill(Bdata);
+
+  checkConstructor3<double>(A, B);
+
+}
diff --git a/tests/lac/product_matrix_03.output b/tests/lac/product_matrix_03.output
new file mode 100644 (file)
index 0000000..0962751
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Init with vector memory, matrix 1 and matrix 2
+DEAL::Multiplying with all ones vector
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::17.0000  29.0000 
diff --git a/tests/lac/product_matrix_04.cc b/tests/lac/product_matrix_04.cc
new file mode 100644 (file)
index 0000000..8ab726e
--- /dev/null
@@ -0,0 +1,89 @@
+// ---------------------------------------------------------------------
+// $Id: product_matrix_01.cc 32491 2014-02-14 20:52:51Z bangerth $
+//
+// Copyright (C) 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// Check ProductMatrix::vmult
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/matrix_lib.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+#include <fstream>
+#include <iomanip>
+#include <cmath>
+
+template<typename number>
+  void
+  checkVmult(FullMatrix<number> &A, FullMatrix<number> &B, Vector<number> &V)
+  {
+    deallog << "vmult" << std::endl;
+
+    GrowingVectorMemory < Vector<number> > mem;
+    ProductMatrix < Vector<number> > P(A, B, mem);
+
+    Vector<number> O(A.m());
+
+    P.vmult(O, V);
+
+    // Check the dimensions of the result matrix
+    Assert(A.m() == O.size(), ExcInternalError());
+    deallog << "Dimensions of result vector verified" << std::endl;
+
+    // Verifying results with Method 2: O=(A*B)*V
+    FullMatrix<number> AB_Product(A.m(), B.n());
+    Vector<number> O_(A.m());
+
+    A.mmult(AB_Product, B, false);
+    AB_Product.vmult(O_, V);
+
+    Assert(O == O_, ExcInternalError());
+    deallog << "Result vector data verified" << std::endl;
+
+    for (unsigned int i = 0; i < O.size(); ++i)
+      deallog << O(i) << '\t';
+    deallog << std::endl;
+  }
+
+int
+main()
+{
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  const double Adata[] =
+    { 2, 3, 4, 5 };
+
+  const double Bdata[] =
+    { 0, 1, 2, 3 };
+
+  FullMatrix<double> A(2, 2);
+  FullMatrix<double> B(2, 2);
+
+  A.fill(Adata);
+  B.fill(Bdata);
+
+  Vector<double> V(2);
+  V(0) = 1;
+  V(1) = 2;
+
+  checkVmult<double>(A, B, V);
+
+}
diff --git a/tests/lac/product_matrix_04.output b/tests/lac/product_matrix_04.output
new file mode 100644 (file)
index 0000000..a557714
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::vmult
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::28.0000  48.0000 
diff --git a/tests/lac/product_matrix_05.cc b/tests/lac/product_matrix_05.cc
new file mode 100644 (file)
index 0000000..0e15351
--- /dev/null
@@ -0,0 +1,96 @@
+// ---------------------------------------------------------------------
+// $Id: product_matrix_01.cc 32491 2014-02-14 20:52:51Z bangerth $
+//
+// Copyright (C) 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// Check ProductMatrix::vmult_add
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/matrix_lib.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+#include <fstream>
+#include <iomanip>
+#include <cmath>
+
+template<typename number>
+  void
+  checkVmult_add(FullMatrix<number> &A, FullMatrix<number> &B,
+      Vector<number> &V)
+  {
+    deallog << "vmult_add" << std::endl;
+    GrowingVectorMemory < Vector<number> > mem;
+    ProductMatrix < Vector<number> > P(A, B, mem);
+
+    deallog
+        << "Result vector set to all ones and to be added with product result vector"
+        << std::endl;
+    Vector<number> O(V.size());
+    for (unsigned int i = 0; i < O.size(); ++i)
+      O(i) = 1;
+
+    P.vmult_add(O, V);
+
+    // Check the dimensions of the result matrix
+    Assert(A.m() == O.size(), ExcInternalError());
+    deallog << "Dimensions of result vector verified" << std::endl;
+
+    // Verifying results with Method 2: O=(A*B)*V
+    FullMatrix<number> AB_Product(A.m(), B.n());
+    Vector<number> O_(A.m());
+    for (unsigned int i = 0; i < O_.size(); ++i)
+      O_(i) = 1;
+
+    A.mmult(AB_Product, B, false);
+    AB_Product.vmult_add(O_, V);
+
+    Assert(O == O_, ExcInternalError());
+    deallog << "Result vector data verified" << std::endl;
+
+    for (unsigned int i = 0; i < O.size(); ++i)
+      deallog << O(i) << '\t';
+    deallog << std::endl;
+  }
+
+int
+main()
+{
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  const double Adata[] =
+    { 2, 3, 4, 5 };
+
+  const double Bdata[] =
+    { 0, 1, 2, 3 };
+
+  FullMatrix<double> A(2, 2);
+  FullMatrix<double> B(2, 2);
+
+  A.fill(Adata);
+  B.fill(Bdata);
+
+  Vector<double> V(2);
+  V(0) = 1;
+  V(1) = 2;
+
+  checkVmult_add<double>(A, B, V);
+
+}
diff --git a/tests/lac/product_matrix_05.output b/tests/lac/product_matrix_05.output
new file mode 100644 (file)
index 0000000..836a996
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::vmult_add
+DEAL::Result vector set to all ones and to be added with product result vector
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::29.0000  49.0000 
diff --git a/tests/lac/product_matrix_06.cc b/tests/lac/product_matrix_06.cc
new file mode 100644 (file)
index 0000000..a53732a
--- /dev/null
@@ -0,0 +1,88 @@
+// ---------------------------------------------------------------------
+// $Id: product_matrix_01.cc 32491 2014-02-14 20:52:51Z bangerth $
+//
+// Copyright (C) 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// Check ProductMatrix::Tvmult
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/matrix_lib.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+#include <fstream>
+#include <iomanip>
+#include <cmath>
+
+template<typename number>
+  void
+  checkTvmult(FullMatrix<number> &A, FullMatrix<number> &B, Vector<number> &V)
+  {
+    deallog << "Tvmult" << std::endl;
+    GrowingVectorMemory < Vector<number> > mem;
+    ProductMatrix < Vector<number> > P(A, B, mem);
+
+    Vector<number> O(V.size());
+
+    P.Tvmult(O, V);
+
+    // Check the dimensions of the result matrix
+    Assert(A.m() == O.size(), ExcInternalError());
+    deallog << "Dimensions of result vector verified" << std::endl;
+
+    // Verifying results with Method 2: O=(A*B)*V
+    FullMatrix<number> AB_Product(A.m(), B.n());
+    Vector<number> O_(A.m());
+
+    A.mmult(AB_Product, B, false);
+    AB_Product.Tvmult(O_, V);
+
+    Assert(O == O_, ExcInternalError());
+    deallog << "Result vector data verified" << std::endl;
+
+    for (unsigned int i = 0; i < O.size(); ++i)
+      deallog << O(i) << '\t';
+    deallog << std::endl;
+  }
+
+int
+main()
+{
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  const double Adata[] =
+    { 2, 3, 4, 5 };
+
+  const double Bdata[] =
+    { 0, 1, 2, 3 };
+
+  FullMatrix<double> A(2, 2);
+  FullMatrix<double> B(2, 2);
+
+  A.fill(Adata);
+  B.fill(Bdata);
+
+  Vector<double> V(2);
+  V(0) = 1;
+  V(1) = 2;
+
+  checkTvmult<double>(A, B, V);
+
+}
diff --git a/tests/lac/product_matrix_06.output b/tests/lac/product_matrix_06.output
new file mode 100644 (file)
index 0000000..beec1ee
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::Tvmult
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::26.0000  49.0000 
diff --git a/tests/lac/product_matrix_07.cc b/tests/lac/product_matrix_07.cc
new file mode 100644 (file)
index 0000000..2301e73
--- /dev/null
@@ -0,0 +1,96 @@
+// ---------------------------------------------------------------------
+// $Id: product_matrix_01.cc 32491 2014-02-14 20:52:51Z bangerth $
+//
+// Copyright (C) 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// Check ProductMatrix::Tvmult_add
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/matrix_lib.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+#include <fstream>
+#include <iomanip>
+#include <cmath>
+
+template<typename number>
+  void
+  checkTvmult_add(FullMatrix<number> &A, FullMatrix<number> &B,
+      Vector<number> &V)
+  {
+    deallog << "Tvmult_add" << std::endl;
+    GrowingVectorMemory < Vector<number> > mem;
+    ProductMatrix < Vector<number> > P(A, B, mem);
+
+    deallog
+        << "Result vector set to all ones and to be added with product result vector"
+        << std::endl;
+    Vector<number> O(V.size());
+    for (unsigned int i = 0; i < O.size(); ++i)
+      O(i) = 1;
+
+    P.Tvmult_add(O, V);
+
+    // Check the dimensions of the result matrix
+    Assert(A.m() == O.size(), ExcInternalError());
+    deallog << "Dimensions of result vector verified" << std::endl;
+
+    // Verifying results with Method 2: O=(A*B)*V
+    FullMatrix<number> AB_Product(A.m(), B.n());
+    Vector<number> O_(A.m());
+    for (unsigned int i = 0; i < O_.size(); ++i)
+      O_(i) = 1;
+
+    A.mmult(AB_Product, B, false);
+    AB_Product.Tvmult_add(O_, V);
+
+    Assert(O == O_, ExcInternalError());
+    deallog << "Result vector data verified" << std::endl;
+
+    for (unsigned int i = 0; i < O.size(); ++i)
+      deallog << O(i) << '\t';
+    deallog << std::endl;
+  }
+
+int
+main()
+{
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  const double Adata[] =
+    { 2, 3, 4, 5 };
+
+  const double Bdata[] =
+    { 0, 1, 2, 3 };
+
+  FullMatrix<double> A(2, 2);
+  FullMatrix<double> B(2, 2);
+
+  A.fill(Adata);
+  B.fill(Bdata);
+
+  Vector<double> V(2);
+  V(0) = 1;
+  V(1) = 2;
+
+  checkTvmult_add<double>(A, B, V);
+
+}
diff --git a/tests/lac/product_matrix_07.output b/tests/lac/product_matrix_07.output
new file mode 100644 (file)
index 0000000..3c23231
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Tvmult_add
+DEAL::Result vector set to all ones and to be added with product result vector
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::27.0000  50.0000 
diff --git a/tests/lac/product_matrix_08.cc b/tests/lac/product_matrix_08.cc
new file mode 100644 (file)
index 0000000..1e0d194
--- /dev/null
@@ -0,0 +1,135 @@
+// ---------------------------------------------------------------------
+// $Id: product_matrix_01.cc 32491 2014-02-14 20:52:51Z bangerth $
+//
+// Copyright (C) 2014 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// Check ProductMatrix::clear
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/matrix_lib.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+#include <fstream>
+#include <iomanip>
+#include <cmath>
+
+template<typename number>
+  void
+  checkClear(FullMatrix<number> &A, FullMatrix<number> &B,
+      FullMatrix<number> &C, FullMatrix<number> &D)
+  {
+    deallog << "clear" << std::endl;
+    deallog << "Init with vector memory, matrix 1 and matrix 2" << std::endl;
+    GrowingVectorMemory < Vector<number> > mem;
+    ProductMatrix < Vector<number> > P(A, B, mem);
+
+    deallog << "Multiplying with all ones vector" << std::endl;
+    Vector<number> V(B.n());
+    for (unsigned int i = 0; i < V.size(); ++i)
+      V(i) = 1;
+
+    Vector<number> O(A.m());
+
+    P.vmult(O, V);
+
+    // Check the dimensions of the result vector
+    Assert(A.m() == O.size(), ExcInternalError());
+    deallog << "Dimensions of result vector verified" << std::endl;
+
+    // Verifying results with Method 2: O=(A*B)*V
+    FullMatrix<number> AB_Product(A.m(), B.n());
+    Vector<number> O_(A.m());
+
+    A.mmult(AB_Product, B, false);
+    AB_Product.vmult(O_, V);
+
+    Assert(O == O_, ExcInternalError());
+    deallog << "Result vector data verified" << std::endl;
+
+    for (unsigned int i = 0; i < O.size(); ++i)
+      deallog << O(i) << '\t';
+    deallog << std::endl;
+
+    deallog << "Clearing product matrix" << std::endl;
+    P.clear();
+
+    deallog << "Reinitializing product matrix with matrix 3 and matrix 4"
+        << std::endl;
+    P.reinit(C, D);
+
+    deallog << "Multiplying with all ones vector" << std::endl;
+    Vector<number> _V(D.n());
+    for (unsigned int i = 0; i < _V.size(); ++i)
+      _V(i) = 1;
+
+    Vector<number> _O(C.m());
+
+    P.vmult(_O, _V);
+
+    // Check the dimensions of the result vector
+    Assert(C.m() == _O.size(), ExcInternalError());
+    deallog << "Dimensions of result vector verified" << std::endl;
+
+    // Verifying results with Method 2: _O=(C*D)*_V
+    FullMatrix<number> CD_Product(C.m(), D.n());
+    Vector<number> _O_(C.m());
+
+    C.mmult(CD_Product, D, false);
+    CD_Product.vmult(_O_, _V);
+
+    Assert(_O == _O_, ExcInternalError());
+    deallog << "Result vector data verified" << std::endl;
+
+    for (unsigned int i = 0; i < _O.size(); ++i)
+      deallog << _O(i) << '\t';
+    deallog << std::endl;
+  }
+
+int
+main()
+{
+  std::ofstream logfile("output");
+  deallog << std::fixed;
+  deallog << std::setprecision(4);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  const double Adata[] =
+    { 2, 3, 4, 5 };
+
+  const double Bdata[] =
+    { 0, 1, 2, 3 };
+
+  const double Cdata[] =
+    { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+
+  const double Ddata[] =
+    { 10, 11, 12, 13, 14, 15, 16, 17, 18 };
+
+  FullMatrix<double> A(2, 2);
+  FullMatrix<double> B(2, 2);
+  FullMatrix<double> C(3, 3);
+  FullMatrix<double> D(3, 3);
+
+  A.fill(Adata);
+  B.fill(Bdata);
+  C.fill(Cdata);
+  D.fill(Ddata);
+
+  checkClear<double>(A, B, C, D);
+
+}
diff --git a/tests/lac/product_matrix_08.output b/tests/lac/product_matrix_08.output
new file mode 100644 (file)
index 0000000..c0d2309
--- /dev/null
@@ -0,0 +1,13 @@
+
+DEAL::clear
+DEAL::Init with vector memory, matrix 1 and matrix 2
+DEAL::Multiplying with all ones vector
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::17.0000  29.0000 
+DEAL::Clearing product matrix
+DEAL::Reinitializing product matrix with matrix 3 and matrix 4
+DEAL::Multiplying with all ones vector
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::270.0000 648.0000        1026.0000       

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.