--- /dev/null
+// ---------------------------------------------------------------------
+// $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>();
+}
--- /dev/null
+
+DEAL::Init with empty matrix
+DEAL::Is matrix empty:1
--- /dev/null
+// ---------------------------------------------------------------------
+// $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);
+}
--- /dev/null
+
+DEAL::Init with matrix A
+DEAL::Is matrix empty:0
--- /dev/null
+// ---------------------------------------------------------------------
+// $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);
+
+}
--- /dev/null
+
+DEAL::Init with matrix name
+DEAL::Is matrix empty:1
--- /dev/null
+// ---------------------------------------------------------------------
+// $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);
+}
--- /dev/null
+
+DEAL::Init with matrix name and matrix
+DEAL::Is matrix empty:0
--- /dev/null
+// ---------------------------------------------------------------------
+// $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);
+}
--- /dev/null
+
+DEAL::vmult
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::8.0000 14.0000
--- /dev/null
+// ---------------------------------------------------------------------
+// $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);
+}
--- /dev/null
+
+DEAL::Tvmult
+DEAL::Dimensions of result vector verified
+DEAL::Result vector data verified
+DEAL::10.0000 13.0000
--- /dev/null
+// ---------------------------------------------------------------------
+// $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);
+}
--- /dev/null
+
+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
--- /dev/null
+// ---------------------------------------------------------------------
+// $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);
+}
--- /dev/null
+
+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
--- /dev/null
+// ---------------------------------------------------------------------
+// $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);
+}
--- /dev/null
+
+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
--- /dev/null
+// ---------------------------------------------------------------------
+// $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);
+}
--- /dev/null
+
+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