--- /dev/null
+// ---------------------------------------------------------------------
+// $Id: vector_view_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 1998 - 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 VectorView::checkReadOnlyConstructor
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/vector_view.h>
+#include <cmath>
+#include <fstream>
+#include <iomanip>
+
+template<typename number>
+ void
+ checkReadOnlyConstructor(const Vector<number> &V)
+ {
+ deallog << "Read-only constructor" << std::endl;
+ VectorView<number> VV(V.size(), V.begin());
+
+ deallog << "Printing Vector<number>" << std::endl;
+ for (unsigned int i = 0; i < V.size(); ++i)
+ deallog << V(i) << '\t';
+ deallog << std::endl;
+
+ deallog << "Printing VectorView<number> pointing to Vector<number>"
+ << std::endl;
+ for (unsigned int i = 0; i < VV.size(); ++i)
+ deallog << VV(i) << '\t';
+ deallog << std::endl;
+
+ /* deallog << "Incrementing Vector<number> elements using Read-only handle of VectorView<number>" << std::endl;
+ deallog << "Function fails beyond this point" << std::endl;
+ for (unsigned int i=0; i<VV.size(); ++i)
+ VV(i)=VV(i)+1; */
+ }
+
+int
+main()
+{
+ std::ofstream logfile("output");
+ deallog << std::fixed;
+ deallog << std::setprecision(2);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ Vector<double> V1(5);
+ V1(0) = 1;
+ V1(1) = 2;
+ V1(2) = 3;
+ V1(3) = 4;
+ V1(4) = 5;
+
+ const Vector<double> V2(V1);
+
+ checkReadOnlyConstructor<double>(V2);
+}
+
--- /dev/null
+
+DEAL::Read-only constructor
+DEAL::Printing Vector<number>
+DEAL::1.00 2.00 3.00 4.00 5.00
+DEAL::Printing VectorView<number> pointing to Vector<number>
+DEAL::1.00 2.00 3.00 4.00 5.00
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id: vector_view_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 1998 - 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 VectorView::checkReinit1
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/vector_view.h>
+#include <cmath>
+#include <fstream>
+#include <iomanip>
+
+template<typename number, typename size_type>
+ void
+ checkReinit1(const size_type N, const bool fast = false)
+ {
+ deallog << "Reinit with const size and fast" << std::endl;
+
+ deallog
+ << "Creating Vector<number> of size N+10 and filling with values 1 to N+10"
+ << std::endl;
+
+ Vector < number > V(N + 10);
+ for (unsigned int i = 0; i < V.size(); i++)
+ V(i) = i + 1;
+
+ deallog
+ << "Creating VectorView<number> of size N+10 pointing to Vector<number>"
+ << std::endl;
+ VectorView<number> VV(V.size(), V.begin());
+
+ deallog << "Printing Vector<number>" << std::endl;
+ for (unsigned int i = 0; i < V.size(); ++i)
+ deallog << V(i) << '\t';
+ deallog << std::endl;
+
+ deallog << "Printing VectorView<number> pointing to Vector<number>"
+ << std::endl;
+ for (unsigned int i = 0; i < VV.size(); ++i)
+ deallog << VV(i) << '\t';
+ deallog << std::endl;
+
+ deallog << "Reinit VectorView<number> to size N from N+10 with fast="
+ << fast << std::endl;
+ VV.reinit(N, fast);
+
+ deallog << "Printing Vector<number>" << std::endl;
+ for (unsigned int i = 0; i < V.size(); ++i)
+ deallog << V(i) << '\t';
+ deallog << std::endl;
+
+ deallog << "Printing VectorView<number> pointing to Vector<number>"
+ << std::endl;
+ for (unsigned int i = 0; i < VV.size(); ++i)
+ deallog << VV(i) << '\t';
+ deallog << std::endl;
+ }
+
+int
+main()
+{
+ std::ofstream logfile("output");
+ deallog << std::fixed;
+ deallog << std::setprecision(2);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ checkReinit1<double, int>(10, false);
+ checkReinit1<double, int>(10, true);
+}
+
--- /dev/null
+
+DEAL::Reinit with const size and fast
+DEAL::Creating Vector<number> of size N+10 and filling with values 1 to N+10
+DEAL::Creating VectorView<number> of size N+10 pointing to Vector<number>
+DEAL::Printing Vector<number>
+DEAL::1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00
+DEAL::Printing VectorView<number> pointing to Vector<number>
+DEAL::1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00
+DEAL::Reinit VectorView<number> to size N from N+10 with fast=0
+DEAL::Printing Vector<number>
+DEAL::0 0 0 0 0 0 0 0 0 0 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00
+DEAL::Printing VectorView<number> pointing to Vector<number>
+DEAL::0 0 0 0 0 0 0 0 0 0
+DEAL::Reinit with const size and fast
+DEAL::Creating Vector<number> of size N+10 and filling with values 1 to N+10
+DEAL::Creating VectorView<number> of size N+10 pointing to Vector<number>
+DEAL::Printing Vector<number>
+DEAL::1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00
+DEAL::Printing VectorView<number> pointing to Vector<number>
+DEAL::1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00
+DEAL::Reinit VectorView<number> to size N from N+10 with fast=1
+DEAL::Printing Vector<number>
+DEAL::1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00 11.00 12.00 13.00 14.00 15.00 16.00 17.00 18.00 19.00 20.00
+DEAL::Printing VectorView<number> pointing to Vector<number>
+DEAL::1.00 2.00 3.00 4.00 5.00 6.00 7.00 8.00 9.00 10.00
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id: vector_view_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 1998 - 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 VectorView::checkReinit3
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/vector_view.h>
+#include <cmath>
+#include <fstream>
+#include <iomanip>
+
+template<typename number>
+ void
+ checkReinit3(const Vector<number> &V)
+ {
+ deallog
+ << "Reinit a ReadOnly VectorView<number> with const Vector<number> and const size"
+ << std::endl;
+
+ deallog
+ << "Creating dummy Vector<number> of size V.size() and filling with zeros"
+ << std::endl;
+
+ Vector<number> _V(V.size());
+ for (unsigned int i = 0; i < _V.size(); i++)
+ _V(i) = 0;
+
+ deallog << "Creating VectorView<number> pointing to dummy Vector<number>"
+ << std::endl;
+ VectorView<number> VV(_V.size(), _V.begin());
+
+ deallog << "Printing dummy Vector<number>" << std::endl;
+ for (unsigned int i = 0; i < _V.size(); ++i)
+ deallog << _V(i) << '\t';
+ deallog << std::endl;
+
+ deallog << "Printing VectorView<number> pointing to dummy Vector<number>"
+ << std::endl;
+ for (unsigned int i = 0; i < VV.size(); ++i)
+ deallog << VV(i) << '\t';
+ deallog << std::endl;
+
+ deallog << "Reinit VectorView<number> to half of Vector<number>"
+ << std::endl;
+ VV.reinit(V.size() / 2, V.begin());
+
+ deallog << "Printing Vector<number>" << std::endl;
+ for (unsigned int i = 0; i < V.size(); ++i)
+ deallog << V(i) << '\t';
+ deallog << std::endl;
+
+ deallog << "Printing VectorView<number> pointing to half of Vector<number>"
+ << std::endl;
+ for (unsigned int i = 0; i < VV.size(); ++i)
+ deallog << VV(i) << '\t';
+ deallog << std::endl;
+
+ /* deallog << "Incrementing Vector<number> elements using Read-only handle of VectorView<number>" << std::endl;
+ deallog << "Function fails beyond this point" << std::endl;
+ for (unsigned int i=0; i<VV.size(); ++i)
+ VV(i)=VV(i)+1; */
+ }
+
+int
+main()
+{
+ std::ofstream logfile("output");
+ deallog << std::fixed;
+ deallog << std::setprecision(2);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ Vector<double> V1(5);
+ V1(0) = 1;
+ V1(1) = 2;
+ V1(2) = 3;
+ V1(3) = 4;
+ V1(4) = 5;
+
+ const Vector<double> V2(V1);
+
+ checkReinit3<double>(V2);
+}
+
--- /dev/null
+
+DEAL::Reinit a ReadOnly VectorView<number> with const Vector<number> and const size
+DEAL::Creating dummy Vector<number> of size V.size() and filling with zeros
+DEAL::Creating VectorView<number> pointing to dummy Vector<number>
+DEAL::Printing dummy Vector<number>
+DEAL::0 0 0 0 0
+DEAL::Printing VectorView<number> pointing to dummy Vector<number>
+DEAL::0 0 0 0 0
+DEAL::Reinit VectorView<number> to half of Vector<number>
+DEAL::Printing Vector<number>
+DEAL::1.00 2.00 3.00 4.00 5.00
+DEAL::Printing VectorView<number> pointing to half of Vector<number>
+DEAL::1.00 2.00
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id: vector_view_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 1998 - 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 VectorView::checkReinit2
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/vector_view.h>
+#include <cmath>
+#include <fstream>
+#include <iomanip>
+
+template<typename number>
+ void
+ checkReinit2(Vector<number> &V)
+ {
+ deallog
+ << "Reinit a ReadWrite VectorView<number> with Vector<number> and const size"
+ << std::endl;
+
+ deallog
+ << "Creating dummy Vector<number> of size V.size() and filling with zeros"
+ << std::endl;
+
+ Vector<number> _V(V.size());
+ for (unsigned int i = 0; i < _V.size(); i++)
+ _V(i) = 0;
+
+ deallog << "Creating VectorView<number> pointing to dummy Vector<number>"
+ << std::endl;
+ VectorView<number> VV(_V.size(), _V.begin());
+
+ deallog << "Printing dummy Vector<number>" << std::endl;
+ for (unsigned int i = 0; i < _V.size(); ++i)
+ deallog << _V(i) << '\t';
+ deallog << std::endl;
+
+ deallog << "Printing VectorView<number> pointing to dummy Vector<number>"
+ << std::endl;
+ for (unsigned int i = 0; i < VV.size(); ++i)
+ deallog << VV(i) << '\t';
+ deallog << std::endl;
+
+ deallog << "Reinit VectorView<number> to half of Vector<number>"
+ << std::endl;
+ VV.reinit(V.size() / 2, V.begin());
+
+ deallog << "Printing Vector<number>" << std::endl;
+ for (unsigned int i = 0; i < V.size(); ++i)
+ deallog << V(i) << '\t';
+ deallog << std::endl;
+
+ deallog << "Printing VectorView<number> pointing to half of Vector<number>"
+ << std::endl;
+ for (unsigned int i = 0; i < VV.size(); ++i)
+ deallog << VV(i) << '\t';
+ deallog << std::endl;
+
+ deallog
+ << "Incrementing Vector<number> elements using Read-write handle of VectorView<number>"
+ << std::endl;
+ for (unsigned int i = 0; i < VV.size(); ++i)
+ VV(i) = VV(i) + 1;
+
+ deallog << "Printing modified Vector<number>" << std::endl;
+ for (unsigned int i = 0; i < V.size(); ++i)
+ deallog << V(i) << '\t';
+ deallog << std::endl;
+ }
+
+int
+main()
+{
+ std::ofstream logfile("output");
+ deallog << std::fixed;
+ deallog << std::setprecision(2);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ Vector<double> V1(5);
+ V1(0) = 1;
+ V1(1) = 2;
+ V1(2) = 3;
+ V1(3) = 4;
+ V1(4) = 5;
+
+ checkReinit2<double>(V1);
+}
+
--- /dev/null
+
+DEAL::Reinit a ReadWrite VectorView<number> with Vector<number> and const size
+DEAL::Creating dummy Vector<number> of size V.size() and filling with zeros
+DEAL::Creating VectorView<number> pointing to dummy Vector<number>
+DEAL::Printing dummy Vector<number>
+DEAL::0 0 0 0 0
+DEAL::Printing VectorView<number> pointing to dummy Vector<number>
+DEAL::0 0 0 0 0
+DEAL::Reinit VectorView<number> to half of Vector<number>
+DEAL::Printing Vector<number>
+DEAL::1.00 2.00 3.00 4.00 5.00
+DEAL::Printing VectorView<number> pointing to half of Vector<number>
+DEAL::1.00 2.00
+DEAL::Incrementing Vector<number> elements using Read-write handle of VectorView<number>
+DEAL::Printing modified Vector<number>
+DEAL::2.00 3.00 3.00 4.00 5.00
--- /dev/null
+// ---------------------------------------------------------------------
+// $Id: vector_view_01.cc 2014-03-14 dilangov $
+//
+// Copyright (C) 1998 - 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 VectorView::checkReadWriteConstructor
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/vector.h>
+#include <deal.II/lac/vector_view.h>
+#include <cmath>
+#include <fstream>
+#include <iomanip>
+
+template<typename number>
+ void
+ checkReadWriteConstructor(Vector<number> &V)
+ {
+ deallog << "Read-write constructor" << std::endl;
+ VectorView<number> VV(V.size(), V.begin());
+
+ deallog << "Printing Vector<number>" << std::endl;
+ for (unsigned int i = 0; i < V.size(); ++i)
+ deallog << V(i) << '\t';
+ deallog << std::endl;
+
+ deallog << "Printing VectorView<number> pointing to Vector<number>"
+ << std::endl;
+ for (unsigned int i = 0; i < VV.size(); ++i)
+ deallog << VV(i) << '\t';
+ deallog << std::endl;
+
+ deallog
+ << "Incrementing Vector<number> elements using Read-write handle of VectorView<number>"
+ << std::endl;
+ for (unsigned int i = 0; i < VV.size(); ++i)
+ VV(i) = VV(i) + 1;
+
+ deallog << "Printing modified Vector<number>" << std::endl;
+ for (unsigned int i = 0; i < V.size(); ++i)
+ deallog << V(i) << '\t';
+ deallog << std::endl;
+ }
+
+int
+main()
+{
+ std::ofstream logfile("output");
+ deallog << std::fixed;
+ deallog << std::setprecision(2);
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+ deallog.threshold_double(1.e-10);
+
+ Vector<double> V1(5);
+ V1(0) = 1;
+ V1(1) = 2;
+ V1(2) = 3;
+ V1(3) = 4;
+ V1(4) = 5;
+
+ checkReadWriteConstructor<double>(V1);
+}
+
--- /dev/null
+
+DEAL::Read-write constructor
+DEAL::Printing Vector<number>
+DEAL::1.00 2.00 3.00 4.00 5.00
+DEAL::Printing VectorView<number> pointing to Vector<number>
+DEAL::1.00 2.00 3.00 4.00 5.00
+DEAL::Incrementing Vector<number> elements using Read-write handle of VectorView<number>
+DEAL::Printing modified Vector<number>
+DEAL::2.00 3.00 4.00 5.00 6.00