]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Remove vector2d, use Table.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 3 Sep 2002 17:39:25 +0000 (17:39 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 3 Sep 2002 17:39:25 +0000 (17:39 +0000)
git-svn-id: https://svn.dealii.org/trunk@6357 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/Makefile
tests/base/table.cc [new file with mode: 0644]
tests/base/table.checked [new file with mode: 0644]
tests/base/tensor.cc
tests/base/vector2d.cc [deleted file]
tests/base/vector2d.checked [deleted file]

index 91ee243a6f56751281c22963ad71831b8bba1029..53fe68177d6fe581bc521b8b9a8277b6b0a98a82 100644 (file)
@@ -25,13 +25,14 @@ polynomial_test.exe: polynomial_test.go abort.go $(lib-base.g)
 polynomial1d.exe   : polynomial1d.go             $(lib-base.g)
 quadrature_test.exe: quadrature_test.go          $(libraries)
 reference.exe      : reference.go abort.go       $(libraries)
+table.exe          : table.go                    $(libraries)
 tensor.exe         : tensor.go                   $(libraries)
 timer.exe          : timer.go                    $(libraries)
-vector2d.exe       : vector2d.go                 $(libraries)
 auto_derivative_function.exe        : auto_derivative_function.go            $(libraries)
 
 
-tests = logtest reference quadrature_test tensor timer polynomial1d polynomial_test auto_derivative_function vector2d
+tests = logtest reference quadrature_test table tensor \
+        timer polynomial1d polynomial_test auto_derivative_function
 
 ############################################################
 
diff --git a/tests/base/table.cc b/tests/base/table.cc
new file mode 100644 (file)
index 0000000..1e5e4b2
--- /dev/null
@@ -0,0 +1,164 @@
+//----------------------------  $RCSfile$  ---------------------------
+//    $Id$
+//    Version: $Name$
+//
+//    Copyright (C) 1998, 1999, 2000, 2001, 2002 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.
+//
+//----------------------------  $RCSfile$  ---------------------------
+
+// check equivalence of operator[] and operator() on table objects
+
+
+#include <cmath>
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <cstdlib>
+
+#include <base/logstream.h>
+#include <base/table.h>
+
+const int entries[] = { 11,12,13,21,
+                        22,23,31,32,
+                        33,58,65,78,
+                        80,83,87,91,
+                        1, 2, 3, 4,
+                        6, 8, 10, 14};
+
+int
+main ()
+{
+  std::ofstream logfile("table.output");
+  logfile.setf(std::ios::fixed);
+  logfile.precision(3);
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+                                   // first check: a square table
+  if (true)
+    {
+      Table<2,double> Td(3,3);
+      Table<2,int> Ti(3,3);
+  
+      for (unsigned int i=0; i<9; ++i)
+        {
+          Td[i/3][i%3] = entries[i];
+          Ti[i/3][i%3] = entries[i];
+        };
+      
+      for (unsigned int i=0; i<3; ++i)
+        for (unsigned int j=0; j<3; ++j)
+          {
+            Assert (Td[i][j] == Td(i,j), ExcInternalError());
+            Assert (Ti[i][j] == Ti(i,j), ExcInternalError());
+            Assert (Ti[i][j] == Td(i,j), ExcInternalError());
+            
+            Assert (*(Td[i].begin()+j) == Td(i,j), ExcInternalError());
+            Assert (*(Ti[i].begin()+j) == Ti(i,j), ExcInternalError());
+            Assert (*(Ti[i].begin()+j) == Td(i,j), ExcInternalError());
+            
+            Assert (Td[i].begin()+j == &Td(i,j), ExcInternalError());
+            Assert (Ti[i].begin()+j == &Ti(i,j), ExcInternalError());
+            
+            logfile << i << " " << j << " " << Td[i][j] << " ok" << std::endl;
+          };
+    };
+  
+                                   // second check: a rectangular table
+  if (true)
+    {
+      Table<2,double> Td(4,3);
+      Table<2,int> Ti(4,3);
+  
+      for (unsigned int i=0; i<12; ++i)
+        {
+          Td(i/3,i%3) = entries[i];
+          Ti(i/3,i%3) = entries[i];
+        };
+      
+      for (unsigned int i=0; i<4; ++i)
+        for (unsigned int j=0; j<3; ++j)
+          {
+            Assert (Td[i][j] == Td(i,j), ExcInternalError());
+            Assert (Ti[i][j] == Ti(i,j), ExcInternalError());
+            Assert (Ti[i][j] == Td(i,j), ExcInternalError());
+            
+            Assert (*(Td[i].begin()+j) == Td(i,j), ExcInternalError());
+            Assert (*(Ti[i].begin()+j) == Ti(i,j), ExcInternalError());
+            Assert (*(Ti[i].begin()+j) == Td(i,j), ExcInternalError());
+            
+            Assert (Td[i].begin()+j == &Td(i,j), ExcInternalError());
+            Assert (Ti[i].begin()+j == &Ti(i,j), ExcInternalError());
+            
+            logfile << i << " " << j << " " << Td[i][j] << " ok" << std::endl;
+          };
+    };
+
+
+                                   // third check: a 1d-table
+  if (true)
+    {
+      const unsigned int N=10;
+      Table<1,double> Td(N);
+      Table<1,int> Ti(N);
+  
+      for (unsigned int i=0; i<N; ++i)
+        {
+          Td(i) = entries[i];
+          Ti(i) = entries[i];
+        };
+      
+      for (unsigned int i=0; i<N; ++i)
+        {
+          Assert (Td[i] == Td(i), ExcInternalError());
+          Assert (Ti[i] == Ti(i), ExcInternalError());
+          Assert (Ti[i] == Td(i), ExcInternalError());
+          
+          logfile << i << " " << Td[i] << " ok" << std::endl;
+        };
+    };
+  
+                                   // fourth check: a 3d-table
+  if (true)
+    {
+      const unsigned int I=4, J=3, K=2;
+      Table<3,double> Td(I,J,K);
+      Table<3,int> Ti(I,J,K);
+
+      unsigned int index=0;
+      for (unsigned int i=0; i<I; ++i)
+        for (unsigned int j=0; j<J; ++j)
+          for (unsigned int k=0; k<K; ++k, ++index)
+            {
+              Td(i,j,k) = entries[index];
+              Ti(i,j,k) = entries[index];
+            };
+      
+      for (unsigned int i=0; i<I; ++i)
+        for (unsigned int j=0; j<J; ++j)
+          for (unsigned int k=0; k<K; ++k)
+          {
+            Assert (Td[i][j][k] == Td(i,j,k), ExcInternalError());
+            Assert (Ti[i][j][k] == Ti(i,j,k), ExcInternalError());
+            Assert (Ti[i][j][k] == Td(i,j,k), ExcInternalError());
+            
+            Assert (*(Td[i][j].begin()+k) == Td(i,j,k), ExcInternalError());
+            Assert (*(Ti[i][j].begin()+k) == Ti(i,j,k), ExcInternalError());
+            Assert (*(Ti[i][j].begin()+k) == Td(i,j,k), ExcInternalError());
+            
+            Assert (Td[i][j].begin()+k == &Td(i,j,k), ExcInternalError());
+            Assert (Ti[i][j].begin()+k == &Ti(i,j,k), ExcInternalError());
+            
+            logfile << i << " " << j << " " << k << " "
+                    << Td[i][j][k] << " ok" << std::endl;
+          };
+    };
+};
+
+
+      
diff --git a/tests/base/table.checked b/tests/base/table.checked
new file mode 100644 (file)
index 0000000..ee7f604
--- /dev/null
@@ -0,0 +1,56 @@
+
+0 0 11.000 ok
+0 1 12.000 ok
+0 2 13.000 ok
+1 0 21.000 ok
+1 1 22.000 ok
+1 2 23.000 ok
+2 0 31.000 ok
+2 1 32.000 ok
+2 2 33.000 ok
+0 0 11.000 ok
+0 1 12.000 ok
+0 2 13.000 ok
+1 0 21.000 ok
+1 1 22.000 ok
+1 2 23.000 ok
+2 0 31.000 ok
+2 1 32.000 ok
+2 2 33.000 ok
+3 0 58.000 ok
+3 1 65.000 ok
+3 2 78.000 ok
+0 11.000 ok
+1 12.000 ok
+2 13.000 ok
+3 21.000 ok
+4 22.000 ok
+5 23.000 ok
+6 31.000 ok
+7 32.000 ok
+8 33.000 ok
+9 58.000 ok
+0 0 0 11.000 ok
+0 0 1 12.000 ok
+0 1 0 13.000 ok
+0 1 1 21.000 ok
+0 2 0 22.000 ok
+0 2 1 23.000 ok
+1 0 0 31.000 ok
+1 0 1 32.000 ok
+1 1 0 33.000 ok
+1 1 1 58.000 ok
+1 2 0 65.000 ok
+1 2 1 78.000 ok
+2 0 0 80.000 ok
+2 0 1 83.000 ok
+2 1 0 87.000 ok
+2 1 1 91.000 ok
+2 2 0 1.000 ok
+2 2 1 2.000 ok
+3 0 0 3.000 ok
+3 0 1 4.000 ok
+3 1 0 6.000 ok
+3 1 1 8.000 ok
+3 2 0 10.000 ok
+3 2 1 14.000 ok
index f0f7a137e1ed3081f719d935865fb1b68065e4ef..a9714866cedb458392cf739838c946d8e9c76845 100644 (file)
@@ -32,6 +32,8 @@ int main ()
   Tensor<2,dim> t(a);
   Tensor<2,dim> tt;
   Tensor<2,dim> result(b);
+  Assert (transpose(transpose(t)) == t, ExcInternalError());
+  Assert (transpose(transpose(result)) == result, ExcInternalError());
 
   Vector<double> unrolled(9);
   
diff --git a/tests/base/vector2d.cc b/tests/base/vector2d.cc
deleted file mode 100644 (file)
index 90c27f5..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-//----------------------------  $RCSfile$  ---------------------------
-//    $Id$
-//    Version: $Name$
-//
-//    Copyright (C) 1998, 1999, 2000, 2001, 2002 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.
-//
-//----------------------------  $RCSfile$  ---------------------------
-
-
-#include <cmath>
-#include <fstream>
-#include <iostream>
-#include <iomanip>
-#include <cstdlib>
-
-#include <base/logstream.h>
-#include <base/vector2d.h>
-
-const int entries[9] = { 11,12,13,21,22,23,31,32,33 };
-
-int
-main ()
-{
-  std::ofstream logfile("vector2d.output");
-  logfile.setf(std::ios::fixed);
-  logfile.precision(3);
-  deallog.attach(logfile);
-  deallog.depth_console(0);
-
-  vector2d<double> Td(3,3);
-  vector2d<int> Ti(3,3);
-  
-  for (unsigned int i=0; i<9; ++i)
-    {
-      Td[i/3][i%3] = entries[i];
-      Ti[i/3][i%3] = entries[i];
-    };
-
-  for (unsigned int i=0; i<3; ++i)
-    for (unsigned int j=0; j<3; ++j)
-      {
-       Assert (Td[i][j] == Td(i,j), ExcInternalError());
-       Assert (Ti[i][j] == Ti(i,j), ExcInternalError());
-       Assert (Ti[i][j] == Td(i,j), ExcInternalError());
-
-       Assert (*(Td[i].begin()+j) == Td(i,j), ExcInternalError());
-       Assert (*(Ti[i].begin()+j) == Ti(i,j), ExcInternalError());
-       Assert (*(Ti[i].begin()+j) == Td(i,j), ExcInternalError());
-
-       Assert (Td[i].begin()+j == &Td(i,j), ExcInternalError());
-       Assert (Ti[i].begin()+j == &Ti(i,j), ExcInternalError());
-       
-       logfile << i << " " << j << " " << Td[i][j] << " ok" << std::endl;
-      };
-};
-
-
-      
diff --git a/tests/base/vector2d.checked b/tests/base/vector2d.checked
deleted file mode 100644 (file)
index 64879da..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-
-0 0 11.000 ok
-0 1 12.000 ok
-0 2 13.000 ok
-1 0 21.000 ok
-1 1 22.000 ok
-1 2 23.000 ok
-2 0 31.000 ok
-2 1 32.000 ok
-2 2 33.000 ok

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.