From 12e785d364d2448dfb32070190c24e23a54b935d Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 6 Nov 2007 21:20:29 +0000 Subject: [PATCH] Implement complex-valued block vectors. git-svn-id: https://svn.dealii.org/trunk@15454 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/block_vector.h | 3 +- deal.II/lac/include/lac/block_vector_base.h | 48 ++- deal.II/lac/source/block_vector.cc | 23 +- tests/lac/Makefile | 34 +- tests/lac/complex_block_vector.cc | 230 +++++++++++ tests/lac/complex_block_vector/cmp/generic | 44 +++ .../cmp/mips-sgi-irix6.5+MIPSpro7.4 | 70 ++++ tests/lac/complex_block_vector_iterator.cc | 360 ++++++++++++++++++ .../complex_block_vector_iterator/cmp/generic | 20 + .../lac/complex_block_vector_vector_assign.cc | 110 ++++++ .../cmp/generic | 2 + 11 files changed, 918 insertions(+), 26 deletions(-) create mode 100644 tests/lac/complex_block_vector.cc create mode 100644 tests/lac/complex_block_vector/cmp/generic create mode 100644 tests/lac/complex_block_vector/cmp/mips-sgi-irix6.5+MIPSpro7.4 create mode 100644 tests/lac/complex_block_vector_iterator.cc create mode 100644 tests/lac/complex_block_vector_iterator/cmp/generic create mode 100644 tests/lac/complex_block_vector_vector_assign.cc create mode 100644 tests/lac/complex_block_vector_vector_assign/cmp/generic diff --git a/deal.II/lac/include/lac/block_vector.h b/deal.II/lac/include/lac/block_vector.h index 0ff8b713b7..26189d0f4f 100644 --- a/deal.II/lac/include/lac/block_vector.h +++ b/deal.II/lac/include/lac/block_vector.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -64,6 +64,7 @@ class BlockVector : public BlockVectorBase > * class. */ typedef typename BaseClass::value_type value_type; + typedef typename BaseClass::real_type real_type; typedef typename BaseClass::pointer pointer; typedef typename BaseClass::const_pointer const_pointer; typedef typename BaseClass::reference reference; diff --git a/deal.II/lac/include/lac/block_vector_base.h b/deal.II/lac/include/lac/block_vector_base.h index 094191ae66..f7c030a784 100644 --- a/deal.II/lac/include/lac/block_vector_base.h +++ b/deal.II/lac/include/lac/block_vector_base.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -651,8 +651,7 @@ namespace internal * @author Wolfgang Bangerth, Guido Kanschat, 1999, 2000, 2001, 2002, 2004 */ template -class BlockVectorBase - : public Subscriptor +class BlockVectorBase : public Subscriptor { public: /** @@ -681,6 +680,27 @@ class BlockVectorBase typedef std::size_t size_type; + /** + * Declare a type that has holds + * real-valued numbers with the + * same precision as the template + * argument to this class. If the + * template argument of this + * class is a real data type, + * then real_type equals the + * template argument. If the + * template argument is a + * std::complex type then + * real_type equals the type + * underlying the complex + * numbers. + * + * This typedef is used to + * represent the return type of + * norms. + */ + typedef typename BlockType::real_type real_type; + /** * Default constructor. */ @@ -826,7 +846,7 @@ class BlockVectorBase /** * Return square of the $l_2$-norm. */ - value_type norm_sqr () const; + real_type norm_sqr () const; /** * Return the mean value of the elements @@ -838,21 +858,21 @@ class BlockVectorBase * Return the $l_1$-norm of the vector, * i.e. the sum of the absolute values. */ - value_type l1_norm () const; + real_type l1_norm () const; /** * Return the $l_2$-norm of the vector, * i.e. the square root of the sum of * the squares of the elements. */ - value_type l2_norm () const; + real_type l2_norm () const; /** * Return the maximum absolute value of * the elements of this vector, which is * the $l_\infty$-norm of a vector. */ - value_type linfty_norm () const; + real_type linfty_norm () const; /** * Return whether the vector contains only @@ -1752,10 +1772,10 @@ operator * (const BlockVectorBase& v) const template -typename BlockVectorBase::value_type +typename BlockVectorBase::real_type BlockVectorBase::norm_sqr () const { - value_type sum = 0.; + real_type sum = 0.; for (unsigned int i=0;i::mean_value () const template -typename BlockVectorBase::value_type +typename BlockVectorBase::real_type BlockVectorBase::l1_norm () const { - value_type sum = 0.; + real_type sum = 0.; for (unsigned int i=0;i::l1_norm () const template -typename BlockVectorBase::value_type +typename BlockVectorBase::real_type BlockVectorBase::l2_norm () const { return std::sqrt(norm_sqr()); @@ -1800,10 +1820,10 @@ BlockVectorBase::l2_norm () const template -typename BlockVectorBase::value_type +typename BlockVectorBase::real_type BlockVectorBase::linfty_norm () const { - value_type sum = 0.; + real_type sum = 0.; for (unsigned int i=0;i; template class BlockVector; @@ -34,5 +34,24 @@ template void BlockVector::reinit(const BlockVector&, template void BlockVector::reinit(const BlockVector&, const bool); +// explicit instantiations for complex data types +template class BlockVector >; +template class BlockVector >; + +#ifndef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG +template BlockVector >::BlockVector (const BlockVector > &); +template BlockVector >::BlockVector (const BlockVector > &); +#endif + +template void BlockVector >::reinit >(const BlockVector >&, + const bool); +template void BlockVector >::reinit >(const BlockVector >&, + const bool); + +template void BlockVector >::reinit >(const BlockVector >&, + const bool); +template void BlockVector >::reinit >(const BlockVector >&, + const bool); + DEAL_II_NAMESPACE_CLOSE diff --git a/tests/lac/Makefile b/tests/lac/Makefile index cc6a7ae70c..7a80bdd012 100644 --- a/tests/lac/Makefile +++ b/tests/lac/Makefile @@ -21,17 +21,33 @@ default: run-tests ############################################################ tests_x = vector-vector \ - full_matrix householder \ - tridiagonal_matrix tridiagonal_matrix_sym \ - sparsity_pattern sparse_matrices matrices \ + full_matrix \ + householder \ + tridiagonal_matrix \ + tridiagonal_matrix_sym \ + sparsity_pattern \ + sparse_matrices matrices \ block_sparsity_pattern_01 \ - block_indices block_vector block_vector_* block_matrices \ - matrix_lib matrix_out pointer_matrix pointer_matrix_vector \ - solver eigen filtered_matrix \ - sparse_ilu sparse_ilu_t lapack_fill block_minres \ - identity_matrix* trace \ + block_indices \ + block_vector \ + block_vector_* \ + block_matrices \ + matrix_lib \ + matrix_out \ + pointer_matrix \ + pointer_matrix_vector \ + solver \ + eigen \ + filtered_matrix \ + sparse_ilu \ + sparse_ilu_t \ + lapack_fill \ + block_minres \ + identity_matrix* \ + trace \ print_formatted_* \ - bicgstab_early + bicgstab_early \ + complex* # from above list of regular expressions, generate the real set of diff --git a/tests/lac/complex_block_vector.cc b/tests/lac/complex_block_vector.cc new file mode 100644 index 0000000000..291ca996a6 --- /dev/null +++ b/tests/lac/complex_block_vector.cc @@ -0,0 +1,230 @@ +//-------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007 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. +// +//-------------------------------------------------------------------- + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include + +void test () +{ + deallog.push("BlockIndices"); + + std::vector ivector(4); + ivector[0] = 3; + ivector[1] = 0; + ivector[2] = 1; + ivector[3] = 2; + + const std::vector vector_indices(ivector); + + BlockIndices i1(ivector); + BlockIndices i2 = i1; + BlockIndices i3; + // no output expected here + deallog.push("empty constructor"); + for (unsigned int i=0 ; ilocal"); + + unsigned int n = i1.total_size(); + for (unsigned int i=0;iglobal"); + for (unsigned int i=0 ; i > v1(vector_indices, &array[0], &array[6]); + for (unsigned int i=0; i l(&array[0], &array[6]); + BlockVector > v2(vector_indices, l.begin(), l.end()); + for (unsigned int i=0; i array[] = { std::complex(0,1), + std::complex(1,2), + std::complex(2,3), + std::complex(3,4), + std::complex(4,5), + std::complex(5,6) }; + BlockVector > v1(vector_indices, &array[0], &array[6]); + for (unsigned int i=0; i > l(&array[0], &array[6]); + BlockVector > v2(vector_indices, l.begin(), l.end()); + for (unsigned int i=0; i *old_cerr_buf = std::cerr.rdbuf(); +#else + streambuf *old_cerr_buf = std::cerr.rdbuf(); +#endif + std::cerr.rdbuf(logfile.rdbuf()); + + try + { + test (); + } + catch (std::exception &e) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << e.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + // abort + return 0; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + // abort + return 0; + }; + + std::cerr.rdbuf(old_cerr_buf); +} + diff --git a/tests/lac/complex_block_vector/cmp/generic b/tests/lac/complex_block_vector/cmp/generic new file mode 100644 index 0000000000..5b8ad08b4a --- /dev/null +++ b/tests/lac/complex_block_vector/cmp/generic @@ -0,0 +1,44 @@ + +DEAL:BlockIndices:global->local::0 0 0 0 0 0 0 +DEAL:BlockIndices:global->local::1 0 1 0 1 0 1 +DEAL:BlockIndices:global->local::2 0 2 0 2 0 2 +DEAL:BlockIndices:global->local::3 2 0 2 0 2 0 +DEAL:BlockIndices:global->local::4 3 0 3 0 3 0 +DEAL:BlockIndices:global->local::5 3 1 3 1 3 1 +DEAL:BlockIndices:local->global::0 0 0 +DEAL:BlockIndices:local->global::0 1 1 +DEAL:BlockIndices:local->global::0 2 2 +DEAL:BlockIndices:local->global::2 0 3 +DEAL:BlockIndices:local->global::3 0 4 +DEAL:BlockIndices:local->global::3 1 5 +DEAL:BlockIndices:reinit::0 0 0 +DEAL:BlockIndices:reinit::1 0 1 +DEAL:BlockIndices:reinit::2 0 2 +DEAL:BlockIndices:reinit::3 0 3 +DEAL:BlockIndices:reinit::4 0 4 +DEAL:BlockIndices:reinit::5 1 0 +DEAL:BlockIndices:reinit::6 1 1 +DEAL:BlockIndices:reinit::7 1 2 +DEAL:BlockIndices:reinit::8 3 0 +DEAL:BlockIndices:reinit::9 4 0 +DEAL:BlockIndices:reinit::10 4 1 +DEAL:BlockIndices:reinit::--- +DEAL:BlockIndices:reinit::0 0 0 +DEAL:BlockIndices:reinit::1 1 0 +DEAL:BlockIndices:reinit::2 1 1 +DEAL:BlockVector:Constructor with iterators::(0.000,0.000) (1.000,0.000) (2.000,0.000) (3.000,0.000) (4.000,0.000) (5.000,0.000) +DEAL:BlockVector:Constructor with iterators::0 0 (0.000,0.000) +DEAL:BlockVector:Constructor with iterators::0 1 (1.000,0.000) +DEAL:BlockVector:Constructor with iterators::0 2 (2.000,0.000) +DEAL:BlockVector:Constructor with iterators::2 0 (3.000,0.000) +DEAL:BlockVector:Constructor with iterators::3 0 (4.000,0.000) +DEAL:BlockVector:Constructor with iterators::3 1 (5.000,0.000) +DEAL:BlockVector:reinit block::(0.000,0.000) (1.000,0.000) (2.000,0.000) (0.000,0.000) (0.000,0.000) (0.000,0.000) (0.000,0.000) (0.000,0.000) (3.000,0.000) (4.000,0.000) (5.000,0.000) +DEAL:BlockVector:Constructor with iterators::(0.000,1.000) (1.000,2.000) (2.000,3.000) (3.000,4.000) (4.000,5.000) (5.000,6.000) +DEAL:BlockVector:Constructor with iterators::0 0 (0.000,1.000) +DEAL:BlockVector:Constructor with iterators::0 1 (1.000,2.000) +DEAL:BlockVector:Constructor with iterators::0 2 (2.000,3.000) +DEAL:BlockVector:Constructor with iterators::2 0 (3.000,4.000) +DEAL:BlockVector:Constructor with iterators::3 0 (4.000,5.000) +DEAL:BlockVector:Constructor with iterators::3 1 (5.000,6.000) +DEAL:BlockVector:reinit block::(0.000,1.000) (1.000,2.000) (2.000,3.000) (0.000,0.000) (0.000,0.000) (0.000,0.000) (0.000,0.000) (0.000,0.000) (3.000,4.000) (4.000,5.000) (5.000,6.000) diff --git a/tests/lac/complex_block_vector/cmp/mips-sgi-irix6.5+MIPSpro7.4 b/tests/lac/complex_block_vector/cmp/mips-sgi-irix6.5+MIPSpro7.4 new file mode 100644 index 0000000000..11f44354ca --- /dev/null +++ b/tests/lac/complex_block_vector/cmp/mips-sgi-irix6.5+MIPSpro7.4 @@ -0,0 +1,70 @@ + +DEAL:BlockIndices:global->local::0 0 0 0 0 0 0 +DEAL:BlockIndices:global->local::1 0 1 0 1 0 1 +DEAL:BlockIndices:global->local::2 0 2 0 2 0 2 +DEAL:BlockIndices:global->local::3 2 0 2 0 2 0 +DEAL:BlockIndices:global->local::4 3 0 3 0 3 0 +DEAL:BlockIndices:global->local::5 3 1 3 1 3 1 +DEAL:BlockIndices:local->global::0 0 0 +DEAL:BlockIndices:local->global::0 1 1 +DEAL:BlockIndices:local->global::0 2 2 +DEAL:BlockIndices:local->global::2 0 3 +DEAL:BlockIndices:local->global::3 0 4 +DEAL:BlockIndices:local->global::3 1 5 +DEAL:BlockIndices:reinit::0 0 0 +DEAL:BlockIndices:reinit::1 0 1 +DEAL:BlockIndices:reinit::2 0 2 +DEAL:BlockIndices:reinit::3 0 3 +DEAL:BlockIndices:reinit::4 0 4 +DEAL:BlockIndices:reinit::5 1 0 +DEAL:BlockIndices:reinit::6 1 1 +DEAL:BlockIndices:reinit::7 1 2 +DEAL:BlockIndices:reinit::8 3 0 +DEAL:BlockIndices:reinit::9 4 0 +DEAL:BlockIndices:reinit::10 4 1 +DEAL:BlockIndices:reinit::--- +DEAL:BlockIndices:reinit::0 0 0 +DEAL:BlockIndices:reinit::1 1 0 +DEAL:BlockIndices:reinit::2 1 1 +DEAL:BlockIndices::Range +-------------------------------------------------------- +An error occurred in file in function + (not available) +The violated condition was: + i in function + (not available) +The violated condition was: + index < start_indices[block+1]-start_indices[block] +The name and call sequence of the exception was: + ExcIndexRange (index, 0, start_indices[block+1]-start_indices[block]) +Additional Information: +Index 2 is not in [0,2[ +-------------------------------------------------------- +DEAL:BlockIndices::Abort!!! +-------------------------------------------------------- +An error occurred in file in function + (not available) +The violated condition was: + block < n_blocks +The name and call sequence of the exception was: + ExcIndexRange(block, 0, n_blocks) +Additional Information: +Index 2 is not in [0,2[ +-------------------------------------------------------- +DEAL:BlockIndices::Abort!!! +DEAL:BlockVector:Constructor with iterators::0.000 1.000 2.000 3.000 4.000 5.000 +DEAL:BlockVector:Constructor with iterators::0 0 0.000 +DEAL:BlockVector:Constructor with iterators::0 1 1.000 +DEAL:BlockVector:Constructor with iterators::0 2 2.000 +DEAL:BlockVector:Constructor with iterators::2 0 3.000 +DEAL:BlockVector:Constructor with iterators::3 0 4.000 +DEAL:BlockVector:Constructor with iterators::3 1 5.000 +DEAL:BlockVector:reinit block::0.000 1.000 2.000 0.000 0.000 0.000 0.000 0.000 3.000 4.000 5.000 diff --git a/tests/lac/complex_block_vector_iterator.cc b/tests/lac/complex_block_vector_iterator.cc new file mode 100644 index 0000000000..9a8d0f110c --- /dev/null +++ b/tests/lac/complex_block_vector_iterator.cc @@ -0,0 +1,360 @@ +//-------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007 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. +// +//-------------------------------------------------------------------- + + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +bool operator == (const BlockVector &v1, + const BlockVector &v2) +{ + if (v1.size() != v2.size()) + return false; + for (unsigned int i=0; i ivector(4); + ivector[0] = 2; + ivector[1] = 4; + ivector[2] = 3; + ivector[3] = 5; + + // Check 1: initialization via + // iterators + if (true) + { + BlockVector > v1(ivector); + BlockVector > v2(ivector); + + // initialize first vector with + // simple loop + for (unsigned int i=0; i(i,i+1); + // initialize other vector + // through iterators + BlockVector >::iterator p2 = v2.begin(); + for (unsigned int i=0; i(i,i+1); + Assert (p2==v2.end(), ExcInternalError()); + + // check that the two vectors are equal + deallog << "Check 1: " << (v1==v2 ? "true" : "false") << std::endl; + }; + + // Check 1: initialization via + // iterators + if (true) + { + BlockVector > v1(ivector); + + // initialize first vector with + // simple loop + for (unsigned int i=0; i(i,i+1); + // initialize other vector + // through iterators into first + // vector + BlockVector > v2(ivector, v1.begin(), v1.end()); + // check that the two vectors are equal + deallog << "Check 2: " << (v1==v2 ? "true" : "false") << std::endl; + }; + + // Check 3: loop forward and back + // and check that things are the + // same + if (true) + { + BlockVector > v1(ivector); + // initialize first vector with + // simple loop + for (unsigned int i=0; i(i,i+1); + + BlockVector >::iterator p1 = v1.begin(); + for (unsigned int i=0; i(i,i+1), ExcInternalError()); + + Assert (p1 == v1.end(), ExcInternalError()); + + // move back into allowable + // region + --p1; + + // check backwards + for (unsigned int i=0; i(v1.size()-i-1, v1.size()-i), ExcInternalError()); + + // if we came thus far, + // everything is alright + deallog << "Check 3: true" << std::endl; + }; + + + // Check 4: same, but this time + // with const iterators + if (true) + { + BlockVector > v1(ivector); + // initialize first vector with + // simple loop + for (unsigned int i=0; i >::const_iterator p1 = v1.begin(); + for (unsigned int i=0; i(i,0), ExcInternalError()); + + Assert (p1 == v1.end(), ExcInternalError()); + + // move back into allowable + // region + --p1; + + // check backwards + for (unsigned int i=0; i val = *p1; + const std::complex ref(v1.size()-i-1); + Assert (val==ref, ExcInternalError()); + }; + + // if we came thus far, + // everything is alright + deallog << "Check 4: true" << std::endl; + }; + + // Checks 5-14: use some standard + // algorithms + if (true) + { + BlockVector > v1(ivector); + // initialize first vector with + // simple loop + for (unsigned int i=0; i(v1.size()) ? + "true" : "false") + << std::endl; + + // check std::copy + BlockVector > v2(ivector); + std::copy (v1.begin(), v1.end(), v2.begin()); + deallog << "Check 6: " << (v1 == v2 ? "true" : "false") << std::endl; + + // check std::transform + std::transform (v1.begin(), v1.end(), v2.begin(), + std::bind2nd (std::multiplies >(), + 2.0)); + v2.scale (std::complex(1./2.)); + deallog << "Check 7: " << (v1 == v2 ? "true" : "false") << std::endl; + + + // check operators +/-, +=/-= + deallog << "Check 8: " + << (std::distance(v1.begin(), v1.begin()+3) == 3 ? + "true" : "false") + << std::endl; + deallog << "Check 9: " + << (std::distance(v1.end()-6, v1.end()) == 6 ? + "true" : "false") + << std::endl; + deallog << "Check 10: " + << (std::distance(v1.begin(), v1.end()) == (signed)v1.size() ? + "true" : "false") + << std::endl; + deallog << "Check 11: " + << (std::distance(v1.begin(), (v1.begin()+=7)) == 7 ? + "true" : "false") + << std::endl; + deallog << "Check 12: " + << (std::distance((v1.end()-=4), v1.end()) == 4 ? + "true" : "false") + << std::endl; + + // check advance + BlockVector >::iterator p2 = v1.begin(); + std::advance (p2, v1.size()); + deallog << "Check 13: " << (p2 == v1.end() ? "true" : "false") << std::endl; + + BlockVector >::const_iterator p3 = v1.begin(); + std::advance (p3, v1.size()); + deallog << "Check 14: " << (p3 == v1.end() ? "true" : "false") << std::endl; + }; + + // Check 15: initialization through + // iterators + if (true) + { + BlockVector > v1(ivector); + // initialize first vector with + // simple loop + for (unsigned int i=0; i > v2(v1.begin(), v1.end()); + + // and reverse way + BlockVector > v3(ivector, v2.begin(), v2.end()); + deallog << "Check 15: " << (v1==v3 ? "true" : "false") << std::endl; + }; + + // Check 16: initialization through + // iterators. variant with one + // constant object + if (true) + { + BlockVector > v1(ivector); + // initialize first vector with + // simple loop + for (unsigned int i=0; i > v2(v1.begin(), v1.end()); + + // and reverse way + BlockVector > v3(ivector, v2.begin(), v2.end()); + deallog << "Check 16: " << (v1==v3 ? "true" : "false") << std::endl; + }; + + // Check 17: initialization through + // iterators. variant with two + // constant object + if (true) + { + BlockVector > v1(ivector); + // initialize first vector with + // simple loop + for (unsigned int i=0; i > v2(v1.begin(), v1.end()); + + // and reverse way + const BlockVector > v3(ivector, v2.begin(), v2.end()); + deallog << "Check 17: " << (v1==v3 ? "true" : "false") << std::endl; + }; + + // Check 18: initialization through + // iterators. variant with three + // constant object + if (true) + { + BlockVector > v0(ivector); + // initialize first vector with + // simple loop + for (unsigned int i=0; i > v1 = v0; + + // initialize a normal vector + // from it + const Vector > v2(v1.begin(), v1.end()); + + // and reverse way + const BlockVector > v3(ivector, v2.begin(), v2.end()); + deallog << "Check 18: " << (v1==v3 ? "true" : "false") << std::endl; + }; + + // Check 19: operator[] + if (true) + { + BlockVector > v1(ivector); + for (unsigned int i=0; i >::iterator p = (v1.begin()+i); + for (unsigned int j=0; j(j), ExcInternalError()); + }; + + // if we came thus far, + // everything is alright + deallog << "Check 19: true" << std::endl; + }; +} + + + + + +int main () +{ + std::ofstream logfile("complex_block_vector_iterator/output"); + logfile.setf(std::ios::fixed); + logfile.precision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + test (); + } + catch (std::exception &e) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << e.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + // abort + return 2; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + // abort + return 3; + }; + + + return 0; +} + diff --git a/tests/lac/complex_block_vector_iterator/cmp/generic b/tests/lac/complex_block_vector_iterator/cmp/generic new file mode 100644 index 0000000000..ca8a9d55a1 --- /dev/null +++ b/tests/lac/complex_block_vector_iterator/cmp/generic @@ -0,0 +1,20 @@ + +DEAL::Check 1: true +DEAL::Check 2: true +DEAL::Check 3: true +DEAL::Check 4: true +DEAL::Check 5: true +DEAL::Check 6: true +DEAL::Check 7: true +DEAL::Check 8: true +DEAL::Check 9: true +DEAL::Check 10: true +DEAL::Check 11: true +DEAL::Check 12: true +DEAL::Check 13: true +DEAL::Check 14: true +DEAL::Check 15: true +DEAL::Check 16: true +DEAL::Check 17: true +DEAL::Check 18: true +DEAL::Check 19: true diff --git a/tests/lac/complex_block_vector_vector_assign.cc b/tests/lac/complex_block_vector_vector_assign.cc new file mode 100644 index 0000000000..cea3fcf795 --- /dev/null +++ b/tests/lac/complex_block_vector_vector_assign.cc @@ -0,0 +1,110 @@ +//-------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2006, 2007 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. +// +//-------------------------------------------------------------------- + +// check assignment between block vectors and regular vectors + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +bool operator == (const Vector1 &v1, + const Vector2 &v2) +{ + if (v1.size() != v2.size()) + return false; + for (unsigned int i=0; i ivector(4); + ivector[0] = 2; + ivector[1] = 4; + ivector[2] = 3; + ivector[3] = 5; + + BlockVector > v1(ivector); + Vector > v2(v1.size()); + + for (unsigned int i=0; i > v3 (ivector); + v3 = v2; + Assert (v3==v2, ExcInternalError()); + Assert (v3==v1, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + + + +int main () +{ + std::ofstream logfile("complex_block_vector_vector_assign/output"); + logfile.setf(std::ios::fixed); + logfile.precision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + test (); + } + catch (std::exception &e) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << e.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + // abort + return 2; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + // abort + return 3; + }; + + + return 0; +} + diff --git a/tests/lac/complex_block_vector_vector_assign/cmp/generic b/tests/lac/complex_block_vector_vector_assign/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/lac/complex_block_vector_vector_assign/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK -- 2.39.5