]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Added tests for lac/PointerMatrix
authordakshina.ilangova <dakshina.ilangova@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 5 Apr 2014 19:31:21 +0000 (19:31 +0000)
committerdakshina.ilangova <dakshina.ilangova@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 5 Apr 2014 19:31:21 +0000 (19:31 +0000)
git-svn-id: https://svn.dealii.org/trunk@32719 0785d39b-7218-0410-832d-ea1e28bc413d

20 files changed:
tests/lac/pointer_matrix_01.cc [new file with mode: 0644]
tests/lac/pointer_matrix_01.output [new file with mode: 0644]
tests/lac/pointer_matrix_02.cc [new file with mode: 0644]
tests/lac/pointer_matrix_02.output [new file with mode: 0644]
tests/lac/pointer_matrix_03.cc [new file with mode: 0644]
tests/lac/pointer_matrix_03.output [new file with mode: 0644]
tests/lac/pointer_matrix_04.cc [new file with mode: 0644]
tests/lac/pointer_matrix_04.output [new file with mode: 0644]
tests/lac/pointer_matrix_05.cc [new file with mode: 0644]
tests/lac/pointer_matrix_05.output [new file with mode: 0644]
tests/lac/pointer_matrix_06.cc [new file with mode: 0644]
tests/lac/pointer_matrix_06.output [new file with mode: 0644]
tests/lac/pointer_matrix_07.cc [new file with mode: 0644]
tests/lac/pointer_matrix_07.output [new file with mode: 0644]
tests/lac/pointer_matrix_08.cc [new file with mode: 0644]
tests/lac/pointer_matrix_08.output [new file with mode: 0644]
tests/lac/pointer_matrix_09.cc [new file with mode: 0644]
tests/lac/pointer_matrix_09.output [new file with mode: 0644]
tests/lac/pointer_matrix_10.cc [new file with mode: 0644]
tests/lac/pointer_matrix_10.output [new file with mode: 0644]

diff --git a/tests/lac/pointer_matrix_01.cc b/tests/lac/pointer_matrix_01.cc
new file mode 100644 (file)
index 0000000..dc4a1bb
--- /dev/null
@@ -0,0 +1,46 @@
+// ---------------------------------------------------------------------
+// $Id: pointer_matrix_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 2006 - 2013 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 PointerMatrix:checkConstructor1
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/pointer_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+  void
+  checkConstructor1()
+  {
+    deallog << "Init with empty matrix" << std::endl;
+    PointerMatrix<FullMatrix<number>, Vector<number> > P;
+    deallog << "Is matrix empty:" << P.empty() << 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);
+
+  checkConstructor1<double>();
+}
diff --git a/tests/lac/pointer_matrix_01.output b/tests/lac/pointer_matrix_01.output
new file mode 100644 (file)
index 0000000..29ff7b7
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::Init with empty matrix
+DEAL::Is matrix empty:1
diff --git a/tests/lac/pointer_matrix_02.cc b/tests/lac/pointer_matrix_02.cc
new file mode 100644 (file)
index 0000000..2fd9975
--- /dev/null
@@ -0,0 +1,52 @@
+// ---------------------------------------------------------------------
+// $Id: pointer_matrix_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 2006 - 2013 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 PointerMatrix:checkConstructor2
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/pointer_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+  void
+  checkConstructor2(FullMatrix<number> &A)
+  {
+    deallog << "Init with matrix A" << std::endl;
+    PointerMatrix<FullMatrix<number>, Vector<number> > P(&A);
+    deallog << "Is matrix empty:" << P.empty() << 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 };
+
+  FullMatrix<double> A(2, 2);
+  A.fill(Adata);
+
+  checkConstructor2<double>(A);
+}
diff --git a/tests/lac/pointer_matrix_02.output b/tests/lac/pointer_matrix_02.output
new file mode 100644 (file)
index 0000000..4b02719
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::Init with matrix A
+DEAL::Is matrix empty:0
diff --git a/tests/lac/pointer_matrix_03.cc b/tests/lac/pointer_matrix_03.cc
new file mode 100644 (file)
index 0000000..0d66472
--- /dev/null
@@ -0,0 +1,49 @@
+// ---------------------------------------------------------------------
+// $Id: pointer_matrix_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 2006 - 2013 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 PointerMatrix:checkConstructor3
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/pointer_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+  void
+  checkConstructor3(char *name)
+  {
+    deallog << "Init with matrix name" << std::endl;
+    PointerMatrix<FullMatrix<number>, Vector<number> > P(name);
+    deallog << "Is matrix empty:" << P.empty() << 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);
+
+  char *name = "Matrix A";
+
+  checkConstructor3<double>(name);
+
+}
diff --git a/tests/lac/pointer_matrix_03.output b/tests/lac/pointer_matrix_03.output
new file mode 100644 (file)
index 0000000..b90ebcb
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::Init with matrix name
+DEAL::Is matrix empty:1
diff --git a/tests/lac/pointer_matrix_04.cc b/tests/lac/pointer_matrix_04.cc
new file mode 100644 (file)
index 0000000..2e8a5af
--- /dev/null
@@ -0,0 +1,54 @@
+// ---------------------------------------------------------------------
+// $Id: pointer_matrix_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 2006 - 2013 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 PointerMatrix:checkConstructor4
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/pointer_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+  void
+  checkConstructor4(const FullMatrix<number> &A, char *name)
+  {
+    deallog << "Init with matrix name and matrix" << std::endl;
+    PointerMatrix<FullMatrix<number>, Vector<number> > P(&A, name);
+    deallog << "Is matrix empty:" << P.empty() << 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 };
+
+  FullMatrix<double> A(2, 2);
+  A.fill(Adata);
+
+  char *name = "Matrix A";
+
+  checkConstructor4<double>(A, name);
+}
diff --git a/tests/lac/pointer_matrix_04.output b/tests/lac/pointer_matrix_04.output
new file mode 100644 (file)
index 0000000..eebc2cc
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::Init with matrix name and matrix
+DEAL::Is matrix empty:0
diff --git a/tests/lac/pointer_matrix_05.cc b/tests/lac/pointer_matrix_05.cc
new file mode 100644 (file)
index 0000000..32f667e
--- /dev/null
@@ -0,0 +1,74 @@
+// ---------------------------------------------------------------------
+// $Id: pointer_matrix_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 2006 - 2013 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 PointerMatrix:checkVmult
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/pointer_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+  void
+  checkVmult(FullMatrix<number> &A, Vector<number> &V, char *name =
+      "Test Matrix")
+  {
+    deallog << "vmult" << std::endl;
+
+    PointerMatrix<FullMatrix<number>, Vector<number> > P(&A, name);
+    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*V  
+    Vector<number> O_(A.m());
+    A.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 };
+
+  FullMatrix<double> A(2, 2);
+  A.fill(Adata);
+
+  Vector<double> V(2);
+  V(0) = 1;
+  V(1) = 2;
+
+  checkVmult<double>(A, V);
+}
diff --git a/tests/lac/pointer_matrix_05.output b/tests/lac/pointer_matrix_05.output
new file mode 100644 (file)
index 0000000..a867192
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::vmult
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::8.0000   14.0000 
diff --git a/tests/lac/pointer_matrix_06.cc b/tests/lac/pointer_matrix_06.cc
new file mode 100644 (file)
index 0000000..af35fd9
--- /dev/null
@@ -0,0 +1,74 @@
+// ---------------------------------------------------------------------
+// $Id: pointer_matrix_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 2006 - 2013 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 PointerMatrix:checkTvmult
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/pointer_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+  void
+  checkTvmult(FullMatrix<number> &A, Vector<number> &V, char *name =
+      "Test Matrix")
+  {
+    deallog << "Tvmult" << std::endl;
+
+    PointerMatrix<FullMatrix<number>, Vector<number> > P(&A, name);
+    Vector<number> O(A.m());
+    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 Transpose*V        
+    Vector<number> O_(A.m());
+    A.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 };
+
+  FullMatrix<double> A(2, 2);
+  A.fill(Adata);
+
+  Vector<double> V(2);
+  V(0) = 1;
+  V(1) = 2;
+
+  checkTvmult<double>(A, V);
+}
diff --git a/tests/lac/pointer_matrix_06.output b/tests/lac/pointer_matrix_06.output
new file mode 100644 (file)
index 0000000..510a561
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::Tvmult
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::10.0000  13.0000 
diff --git a/tests/lac/pointer_matrix_07.cc b/tests/lac/pointer_matrix_07.cc
new file mode 100644 (file)
index 0000000..98d8174
--- /dev/null
@@ -0,0 +1,83 @@
+// ---------------------------------------------------------------------
+// $Id: pointer_matrix_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 2006 - 2013 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 PointerMatrix:checkTvmult_add
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/pointer_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+  void
+  checkTvmult_add(FullMatrix<number> &A, Vector<number> &V, char *name =
+      "Test Matrix")
+  {
+    deallog << "Tvmult_add" << std::endl;
+
+    PointerMatrix<FullMatrix<number>, Vector<number> > P(&A, name);
+
+    deallog << "Result vector set to all ones and to be added with result"
+        << 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=O+A Transpose*V      
+    Vector<number> O_(V.size());
+    for (unsigned int i = 0; i < O_.size(); ++i)
+      O_(i) = 1;
+
+    A.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 };
+
+  FullMatrix<double> A(2, 2);
+  A.fill(Adata);
+
+  Vector<double> V(2);
+  V(0) = 1;
+  V(1) = 2;
+
+  checkTvmult_add<double>(A, V);
+}
diff --git a/tests/lac/pointer_matrix_07.output b/tests/lac/pointer_matrix_07.output
new file mode 100644 (file)
index 0000000..71e06a0
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::Tvmult_add
+DEAL::Result vector set to all ones and to be added with result
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::11.0000  14.0000 
diff --git a/tests/lac/pointer_matrix_08.cc b/tests/lac/pointer_matrix_08.cc
new file mode 100644 (file)
index 0000000..ad3d1b1
--- /dev/null
@@ -0,0 +1,83 @@
+// ---------------------------------------------------------------------
+// $Id: pointer_matrix_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 2006 - 2013 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 PointerMatrix:checkVmult_add
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/pointer_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+  void
+  checkVmult_add(FullMatrix<number> &A, Vector<number> &V, char *name =
+      "Test Matrix")
+  {
+    deallog << "vmult_add" << std::endl;
+
+    PointerMatrix<FullMatrix<number>, Vector<number> > P(&A, name);
+
+    deallog << "Result vector set to all ones and to be added with result"
+        << 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=O+A*V        
+    Vector<number> O_(V.size());
+    for (unsigned int i = 0; i < O_.size(); ++i)
+      O_(i) = 1;
+
+    A.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 };
+
+  FullMatrix<double> A(2, 2);
+  A.fill(Adata);
+
+  Vector<double> V(2);
+  V(0) = 1;
+  V(1) = 2;
+
+  checkVmult_add<double>(A, V);
+}
diff --git a/tests/lac/pointer_matrix_08.output b/tests/lac/pointer_matrix_08.output
new file mode 100644 (file)
index 0000000..654ff7f
--- /dev/null
@@ -0,0 +1,6 @@
+
+DEAL::vmult_add
+DEAL::Result vector set to all ones and to be added with result
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::9.0000   15.0000 
diff --git a/tests/lac/pointer_matrix_09.cc b/tests/lac/pointer_matrix_09.cc
new file mode 100644 (file)
index 0000000..5a27c25
--- /dev/null
@@ -0,0 +1,81 @@
+// ---------------------------------------------------------------------
+// $Id: pointer_matrix_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 2006 - 2013 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 PointerMatrix:checkClear
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/pointer_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+  void
+  checkClear(FullMatrix<number> &A)
+  {
+    deallog << "clear" << std::endl;
+    deallog << "Init with matrix 1" << std::endl;
+
+    PointerMatrix<FullMatrix<number>, Vector<number> > P(&A);
+
+    deallog << "Multiplying with all ones vector" << std::endl;
+    Vector<number> V(A.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*V
+    Vector<number> O_(A.m());
+    A.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 pointer matrix" << std::endl;
+    P.clear();
+
+    deallog << "Is matrix empty:" << P.empty() << 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 };
+
+  FullMatrix<double> A(2, 2);
+  A.fill(Adata);
+
+  checkClear(A);
+}
diff --git a/tests/lac/pointer_matrix_09.output b/tests/lac/pointer_matrix_09.output
new file mode 100644 (file)
index 0000000..0455e79
--- /dev/null
@@ -0,0 +1,9 @@
+
+DEAL::clear
+DEAL::Init with matrix 1
+DEAL::Multiplying with all ones vector
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::5.0000   9.0000  
+DEAL::Clearing pointer matrix
+DEAL::Is matrix empty:1
diff --git a/tests/lac/pointer_matrix_10.cc b/tests/lac/pointer_matrix_10.cc
new file mode 100644 (file)
index 0000000..b4489cd
--- /dev/null
@@ -0,0 +1,113 @@
+// ---------------------------------------------------------------------
+// $Id: pointer_matrix_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 2006 - 2013 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 PointerMatrix:checkAssign
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/pointer_matrix.h>
+#include <deal.II/lac/full_matrix.h>
+#include <deal.II/lac/vector.h>
+
+template<typename number>
+  void
+  checkAssign(FullMatrix<number> &A, FullMatrix<number> &B)
+  {
+    deallog << "=" << std::endl;
+    deallog << "Init with matrix 1" << std::endl;
+
+    PointerMatrix<FullMatrix<number>, Vector<number> > P(&A);
+
+    deallog << "Multiplying with all ones vector" << std::endl;
+    Vector<number> V(A.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*V
+    Vector<number> O_(A.m());
+    A.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 pointer matrix" << std::endl;
+    P.clear();
+
+    deallog << "Is matrix empty:" << P.empty() << std::endl;
+
+    deallog << "Assigning pointer matrix to matrix 2" << std::endl;
+
+    P = &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> OU(B.m());
+    P.vmult(OU, V_);
+
+    // Check the dimensions of the result vector
+    Assert(B.m() == OU.size(), ExcInternalError());
+    deallog << "Dimensions of result vector verified" << std::endl;
+
+    // Verifying results with Method 2: O=B*V
+    Vector<number> OU_(B.m());
+    B.vmult(OU_, V_);
+
+    Assert(OU == OU_, ExcInternalError());
+    deallog << "Result vector data verified" << std::endl;
+
+    for (unsigned int i = 0; i < OU.size(); ++i)
+      deallog << OU(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[] =
+    { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+
+  FullMatrix<double> A(2, 2);
+  A.fill(Adata);
+  FullMatrix<double> B(3, 3);
+  B.fill(Bdata);
+
+  checkAssign(A, B);
+}
diff --git a/tests/lac/pointer_matrix_10.output b/tests/lac/pointer_matrix_10.output
new file mode 100644 (file)
index 0000000..6b39ca3
--- /dev/null
@@ -0,0 +1,14 @@
+
+DEAL::=
+DEAL::Init with matrix 1
+DEAL::Multiplying with all ones vector
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::5.0000   9.0000  
+DEAL::Clearing pointer matrix
+DEAL::Is matrix empty:1
+DEAL::Assigning pointer matrix to matrix 2
+DEAL::Multiplying with all ones vector
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::6.0000   15.0000 24.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.