From 7bb45e51e90dbdcf2b8ee3d1d50692b9d3e9f26e Mon Sep 17 00:00:00 2001 From: wolf Date: Tue, 3 Sep 2002 17:39:25 +0000 Subject: [PATCH] Remove vector2d, use Table. git-svn-id: https://svn.dealii.org/trunk@6357 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/Makefile | 5 +- tests/base/table.cc | 164 ++++++++++++++++++++++++++++++++++++ tests/base/table.checked | 56 ++++++++++++ tests/base/tensor.cc | 2 + tests/base/vector2d.cc | 63 -------------- tests/base/vector2d.checked | 10 --- 6 files changed, 225 insertions(+), 75 deletions(-) create mode 100644 tests/base/table.cc create mode 100644 tests/base/table.checked delete mode 100644 tests/base/vector2d.cc delete mode 100644 tests/base/vector2d.checked diff --git a/tests/base/Makefile b/tests/base/Makefile index 91ee243a6f..53fe68177d 100644 --- a/tests/base/Makefile +++ b/tests/base/Makefile @@ -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 index 0000000000..1e5e4b2028 --- /dev/null +++ b/tests/base/table.cc @@ -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 +#include +#include +#include +#include + +#include +#include + +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 Td(I,J,K); + Table<3,int> Ti(I,J,K); + + unsigned int index=0; + for (unsigned int i=0; i t(a); Tensor<2,dim> tt; Tensor<2,dim> result(b); + Assert (transpose(transpose(t)) == t, ExcInternalError()); + Assert (transpose(transpose(result)) == result, ExcInternalError()); Vector unrolled(9); diff --git a/tests/base/vector2d.cc b/tests/base/vector2d.cc deleted file mode 100644 index 90c27f5506..0000000000 --- a/tests/base/vector2d.cc +++ /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 -#include -#include -#include -#include - -#include -#include - -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 Td(3,3); - vector2d 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 index 64879da495..0000000000 --- a/tests/base/vector2d.checked +++ /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 -- 2.39.5