]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Added test for VectorView class
authorheltai <heltai@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 5 Apr 2009 22:55:59 +0000 (22:55 +0000)
committerheltai <heltai@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 5 Apr 2009 22:55:59 +0000 (22:55 +0000)
git-svn-id: https://svn.dealii.org/trunk@18554 0785d39b-7218-0410-832d-ea1e28bc413d

tests/lac/Makefile
tests/lac/vector_view.cc [new file with mode: 0644]
tests/lac/vector_view/cmp/generic [new file with mode: 0644]

index d2966ac58d54f786b55bce2ad108dd3b3a1166b7..4fd1b76b0186fd1246d89ee4048df75a85862cdf 100644 (file)
@@ -54,7 +54,8 @@ tests_x = vector-vector vector_memory \
        trace \
        print_formatted_* \
        bicgstab_early \
-       complex*
+       complex* \
+       vector_view*
 
 
 # from above list of regular expressions, generate the real set of
diff --git a/tests/lac/vector_view.cc b/tests/lac/vector_view.cc
new file mode 100644 (file)
index 0000000..703023e
--- /dev/null
@@ -0,0 +1,78 @@
+//----------------------------  solver.cc  ---------------------------
+//    $Id: vector-vector.cc 15661 2008-01-24 04:59:09Z kanschat $
+//    Version: $Name$ 
+//
+//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  solver.cc  ---------------------------
+
+
+#include "../tests.h"
+#include <base/logstream.h>
+#include <lac/vector.h>
+#include <lac/vector_view.h>
+#include <cmath>
+#include <fstream>
+#include <iomanip>
+
+const unsigned int N=10;
+unsigned int check_point = 0;
+
+template <typename number>
+void print (const Vector<number> &v) 
+{
+  for (unsigned int i=0; i<v.size(); ++i)
+    deallog << v(i) << '\t';
+  deallog << std::endl;
+}
+
+template<typename T>
+void fill( T &a) {
+    for(unsigned int i=0; i<a.size(); ++i)
+       a(i) = i;
+}
+
+int main()
+{
+  std::ofstream logfile("vector_view/output");
+  deallog << std::fixed;
+  deallog << std::setprecision(2);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+  
+  Vector<double>  v1(N);
+  fill(v1);
+  
+  deallog << "Vector" << std::endl;
+  print(v1);
+  VectorView<double> v2(N, v1.begin() );
+  deallog << "Vector View" << std::endl;
+  print(v2);
+  
+  v2(4) = 0;
+  deallog << "Modified element 4" << std::endl;
+  deallog << "Vector" << std::endl;
+  print(v1);
+  deallog << "Vector View" << std::endl;
+  print(v2);
+  
+  // Const vector. 
+  const Vector<double> v3(v1);
+  deallog << "const Vector" << std::endl;
+  print(v3);
+  VectorView<double> v4(N, v3.begin());
+  deallog << "const Vector View" << std::endl;
+  print(v4); 
+}
+
+  
diff --git a/tests/lac/vector_view/cmp/generic b/tests/lac/vector_view/cmp/generic
new file mode 100644 (file)
index 0000000..0d4e0c9
--- /dev/null
@@ -0,0 +1,14 @@
+
+DEAL::Vector
+DEAL::0        1.00    2.00    3.00    4.00    5.00    6.00    7.00    8.00    9.00    
+DEAL::Vector View
+DEAL::0        1.00    2.00    3.00    4.00    5.00    6.00    7.00    8.00    9.00    
+DEAL::Modified element 4
+DEAL::Vector
+DEAL::0        1.00    2.00    3.00    0       5.00    6.00    7.00    8.00    9.00    
+DEAL::Vector View
+DEAL::0        1.00    2.00    3.00    0       5.00    6.00    7.00    8.00    9.00    
+DEAL::const Vector
+DEAL::0        1.00    2.00    3.00    0       5.00    6.00    7.00    8.00    9.00    
+DEAL::const Vector View
+DEAL::0        1.00    2.00    3.00    0       5.00    6.00    7.00    8.00    9.00    

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.