From: bangerth Date: Mon, 5 Nov 2007 03:43:52 +0000 (+0000) Subject: Implement the ability for Vector to work on std::complex vectors. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42e8b2de2d51ba9e78998236b56777b3652ce569;p=dealii-svn.git Implement the ability for Vector to work on std::complex vectors. git-svn-id: https://svn.dealii.org/trunk@15443 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/vector.h b/deal.II/lac/include/lac/vector.h index 40014ecb15..daaaa7ca8b 100644 --- a/deal.II/lac/include/lac/vector.h +++ b/deal.II/lac/include/lac/vector.h @@ -71,14 +71,15 @@ class Vector : public Subscriptor * those in the C++ standard libraries * vector<...> class. */ - typedef Number value_type; - typedef value_type *pointer; - typedef const value_type *const_pointer; - typedef value_type *iterator; - typedef const value_type *const_iterator; - typedef value_type &reference; - typedef const value_type &const_reference; - typedef size_t size_type; + typedef Number value_type; + typedef typename numbers::NumberTraits::real_type real_type; + typedef value_type *pointer; + typedef const value_type *const_pointer; + typedef value_type *iterator; + typedef const value_type *const_iterator; + typedef value_type &reference; + typedef const value_type &const_reference; + typedef size_t size_type; /** @@ -389,7 +390,7 @@ class Vector : public Subscriptor /** * Return square of the $l_2$-norm. */ - Number norm_sqr () const; + real_type norm_sqr () const; /** * Mean value of the elements of @@ -401,14 +402,14 @@ class Vector : public Subscriptor * $l_1$-norm of the vector. * The sum of the absolute values. */ - Number l1_norm () const; + real_type l1_norm () const; /** * $l_2$-norm of the vector. The * square root of the sum of the * squares of the elements. */ - Number l2_norm () const; + real_type l2_norm () const; /** * $l_p$-norm of the vector. The @@ -416,13 +417,13 @@ class Vector : public Subscriptor * powers of the absolute values * of the elements. */ - Number lp_norm (const Number p) const; + real_type lp_norm (const real_type p) const; /** * Maximum absolute value of the * elements. */ - Number linfty_norm () const; + real_type linfty_norm () const; /** * Return dimension of the vector. @@ -446,15 +447,21 @@ class Vector : public Subscriptor * used, for example, to check whether * refinement indicators are really all * positive (or zero). + * + * The function obviously only makes + * sense if the template argument of this + * class is a real type. If it is a + * complex type, then an exception is + * thrown. */ bool is_non_negative () const; /** - * Make the @p Vector class a bit like the - * vector<> class of the C++ standard - * library by returning iterators to - * the start and end of the elements of this - * vector. + * Make the @p Vector class a bit like + * the vector<> class of the C++ + * standard library by returning + * iterators to the start and end of the + * elements of this vector. */ iterator begin (); @@ -660,7 +667,11 @@ class Vector : public Subscriptor */ //@{ /** - * Output of vector in user-defined format. + * Output of vector in user-defined + * format. For complex-valued vectors, + * the format should include specifiers + * for both the real and imaginary + * parts. */ void print (const char* format = 0) const; @@ -956,9 +967,9 @@ Vector::operator /= (const Number factor) { Assert (numbers::is_finite(factor), ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)")); - Assert (factor != 0., ExcZero() ); + Assert (factor != Number(0.), ExcZero() ); - *this *= (1./factor); + this->operator *= (Number(1.)/factor); return *this; } diff --git a/deal.II/lac/include/lac/vector.templates.h b/deal.II/lac/include/lac/vector.templates.h index 3cea6f17f2..f2b23a2672 100644 --- a/deal.II/lac/include/lac/vector.templates.h +++ b/deal.II/lac/include/lac/vector.templates.h @@ -15,6 +15,7 @@ #include +#include #include #include @@ -30,36 +31,54 @@ DEAL_II_NAMESPACE_OPEN -/* - Note that in this file, we use std::fabs, std::sqrt, etc - everywhere. The reason is that we want to use those version of these - functions that take a variable of the template type "Number", rather - than the C standard function which accepts and returns a double. The - C++ standard library therefore offers overloaded versions of these - functions taking floats, or long doubles, with the importance on the - additional accuracy when using long doubles. - */ - namespace internal { - namespace VectorHelper + template + bool is_non_negative (const T &t) { - template - inline Number sqr (const Number x) - { - Assert (numbers::is_finite(x), - ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)")); - return x*x; - } + return t >= 0; + } + + + template + bool is_non_negative (const std::complex &) + { + Assert (false, + ExcMessage ("Complex numbers do not have an ordering.")); + + return false; } -} + template + void print (const T &t, + const char *format) + { + if (format != 0) + std::printf (format, t); + else + std::printf (" %5.2f", double(t)); + } + + + + template + void print (const std::complex &t, + const char *format) + { + if (format != 0) + std::printf (format, t.real(), t.imag()); + else + std::printf (" %5.2f+%5.2fi", + double(t.real()), double(t.imag())); + } +} template Vector::Vector (const Vector& v) - : Subscriptor(), + : + Subscriptor(), vec_size(v.size()), max_vec_size(v.size()), val(0) @@ -78,7 +97,8 @@ Vector::Vector (const Vector& v) template template Vector::Vector (const Vector& v) - : Subscriptor(), + : + Subscriptor(), vec_size(v.size()), max_vec_size(v.size()), val(0) @@ -97,7 +117,8 @@ Vector::Vector (const Vector& v) template Vector::Vector (const PETScWrappers::Vector &v) - : Subscriptor(), + : + Subscriptor(), vec_size(v.size()), max_vec_size(v.size()), val(0) @@ -126,7 +147,8 @@ Vector::Vector (const PETScWrappers::Vector &v) template Vector::Vector (const PETScWrappers::MPI::Vector &v) - : Subscriptor(), + : + Subscriptor(), vec_size(0), max_vec_size(0), val(0) @@ -146,7 +168,8 @@ Vector::Vector (const PETScWrappers::MPI::Vector &v) template template -void Vector::reinit (const Vector& v, const bool fast) +void Vector::reinit (const Vector& v, + const bool fast) { reinit (v.size(), fast); } @@ -157,9 +180,9 @@ template void Vector::swap (Vector &v) { - std::swap (vec_size, v.vec_size); + std::swap (vec_size, v.vec_size); std::swap (max_vec_size, v.max_vec_size); - std::swap (val, v.val); + std::swap (val, v.val); } @@ -169,11 +192,9 @@ bool Vector::all_zero () const { Assert (vec_size!=0, ExcEmptyObject()); - - const_iterator p = begin(), - e = end(); - while (p!=e) - if (*p++ != 0.0) + + for (unsigned int i=0; i::is_non_negative () const { Assert (vec_size!=0, ExcEmptyObject()); - const_iterator p = begin(), - e = end(); - while (p!=e) - if (*p++ < 0.0) + for (unsigned int i=0; i::operator * (const Vector& v) const if (PointerComparison::equal (this, &v)) return norm_sqr(); - Assert (vec_size == v.size(), ExcDimensionMismatch(vec_size, v.size())); + Assert (vec_size == v.size(), + ExcDimensionMismatch(vec_size, v.size())); - Number sum0 = 0, - sum1 = 0, - sum2 = 0, - sum3 = 0; - - // use modern processors better by - // allowing pipelined commands to be - // executed in parallel - const_iterator ptr = begin(), - eptr = ptr + (vec_size/4)*4; - typename Vector::const_iterator vptr = v.begin(); - while (ptr!=eptr) - { - sum0 += (*ptr++ * *vptr++); - sum1 += (*ptr++ * *vptr++); - sum2 += (*ptr++ * *vptr++); - sum3 += (*ptr++ * *vptr++); - }; - // add up remaining elements - while (ptr != end()) - sum0 += *ptr++ * *vptr++; + Number sum = 0; + + // multiply the two vectors. we have to + // convert the elements of u to the type of + // the result vector. this is necessary + // because + // operator*(complex,complex) + // is not defined by default + for (unsigned int i=0; i::conjugate(val[i]) * Number(v.val[i]); - return sum0+sum1+sum2+sum3; + return sum; } template -Number Vector::norm_sqr () const +typename Vector::real_type +Vector::norm_sqr () const { Assert (vec_size!=0, ExcEmptyObject()); - Number sum0 = 0, - sum1 = 0, - sum2 = 0, - sum3 = 0; - - // use modern processors better by - // allowing pipelined commands to be - // executed in parallel - const_iterator ptr = begin(), - eptr = ptr + (vec_size/4)*4; - while (ptr!=eptr) - { - sum0 += internal::VectorHelper::sqr(*ptr++); - sum1 += internal::VectorHelper::sqr(*ptr++); - sum2 += internal::VectorHelper::sqr(*ptr++); - sum3 += internal::VectorHelper::sqr(*ptr++); - }; - // add up remaining elements - while (ptr != end()) - sum0 += internal::VectorHelper::sqr(*ptr++); + real_type sum = 0; + + for (unsigned int i=0; i::abs_square(val[i]); - return sum0+sum1+sum2+sum3; + return sum; } @@ -268,123 +263,69 @@ Number Vector::mean_value () const { Assert (vec_size!=0, ExcEmptyObject()); - Number sum0 = 0, - sum1 = 0, - sum2 = 0, - sum3 = 0; - - // use modern processors better by - // allowing pipelined commands to be - // executed in parallel - const_iterator ptr = begin(), - eptr = ptr + (vec_size/4)*4; - while (ptr!=eptr) - { - sum0 += *ptr++; - sum1 += *ptr++; - sum2 += *ptr++; - sum3 += *ptr++; - }; - // add up remaining elements - while (ptr != end()) - sum0 += *ptr++; + Number sum = 0; + + for (unsigned int i=0; i -Number Vector::l1_norm () const +typename Vector::real_type +Vector::l1_norm () const { Assert (vec_size!=0, ExcEmptyObject()); - Number sum0 = 0, - sum1 = 0, - sum2 = 0, - sum3 = 0; - - // use modern processors better by - // allowing pipelined commands to be - // executed in parallel - const_iterator ptr = begin(), - eptr = ptr + (vec_size/4)*4; - while (ptr!=eptr) - { - sum0 += std::fabs(*ptr++); - sum1 += std::fabs(*ptr++); - sum2 += std::fabs(*ptr++); - sum3 += std::fabs(*ptr++); - }; - // add up remaining elements - while (ptr != end()) - sum0 += std::fabs(*ptr++); - - return sum0+sum1+sum2+sum3; + real_type sum = 0; + + for (unsigned int i=0; i::abs(val[i]); + + return sum; } + template -Number Vector::l2_norm () const +typename Vector::real_type +Vector::l2_norm () const { return std::sqrt(norm_sqr()); } + template -Number Vector::lp_norm (const Number p) const +typename Vector::real_type +Vector::lp_norm (const real_type p) const { Assert (vec_size!=0, ExcEmptyObject()); - Number sum0 = 0, - sum1 = 0, - sum2 = 0, - sum3 = 0; - - // use modern processors better by - // allowing pipelined commands to be - // executed in parallel - const_iterator ptr = begin(), - eptr = ptr + (vec_size/4)*4; - while (ptr!=eptr) - { - sum0 += std::pow(std::fabs(*ptr++), p); - sum1 += std::pow(std::fabs(*ptr++), p); - sum2 += std::pow(std::fabs(*ptr++), p); - sum3 += std::pow(std::fabs(*ptr++), p); - }; - // add up remaining elements - while (ptr != end()) - sum0 += std::pow(std::fabs(*ptr++), p); + real_type sum = 0; + + for (unsigned int i=0; i::abs(val[i]), p); - return std::pow(sum0+sum1+sum2+sum3, - static_cast(1./p)); + return std::pow(sum, static_cast(1./p)); } + template -Number Vector::linfty_norm () const +typename Vector::real_type +Vector::linfty_norm () const { Assert (vec_size!=0, ExcEmptyObject()); - Number max0=0., - max1=0., - max2=0., - max3=0.; - for (unsigned int i=0; i<(vec_size/4); ++i) - { - if (max0::abs(val[i]), max); + + return max; } @@ -404,11 +345,8 @@ Vector& Vector::operator -= (const Vector& v) Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); - iterator i_ptr = begin(), - i_end = end(); - const_iterator v_ptr = v.begin(); - while (i_ptr!=i_end) - *i_ptr++ -= *v_ptr++; + for (unsigned int i=0; i::add (const Number v) { Assert (vec_size!=0, ExcEmptyObject()); - iterator i_ptr = begin(), - i_end = end(); - while (i_ptr!=i_end) - *i_ptr++ += v; + for (unsigned int i=0; i::add (const Vector& v) Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); - iterator i_ptr = begin(), - i_end = end(); - const_iterator v_ptr = v.begin(); - while (i_ptr!=i_end) - *i_ptr++ += *v_ptr++; + for (unsigned int i=0; i::add (const Number a, const Vector& v, Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); Assert (vec_size == w.vec_size, ExcDimensionMismatch(vec_size, w.vec_size)); - iterator i_ptr = begin(), - i_end = end(); - const_iterator v_ptr = v.begin(), - w_ptr = w.begin(); - while (i_ptr!=i_end) - *i_ptr++ += a * *v_ptr++ + b * *w_ptr++; + + for (unsigned int i=0; i -void Vector::sadd (const Number x, const Vector& v) +void Vector::sadd (const Number x, + const Vector& v) { Assert (numbers::is_finite(x), ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)")); Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); - iterator i_ptr = begin(), - i_end = end(); - const_iterator v_ptr = v.begin(); - for (; i_ptr!=i_end; ++i_ptr) - *i_ptr = x * *i_ptr + *v_ptr++; + + for (unsigned int i=0; i::sadd (const Number x, const Number a, Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); Assert (vec_size == w.vec_size, ExcDimensionMismatch(vec_size, w.vec_size)); - iterator i_ptr = begin(), - i_end = end(); - const_iterator v_ptr = v.begin(), - w_ptr = w.begin(); - for (; i_ptr!=i_end; ++i_ptr) - *i_ptr = x * *i_ptr + a * *v_ptr++ + b * *w_ptr++; + + for (unsigned int i=0; i::sadd (const Number x, const Number a, Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); Assert (vec_size == w.vec_size, ExcDimensionMismatch(vec_size, w.vec_size)); Assert (vec_size == y.vec_size, ExcDimensionMismatch(vec_size, y.vec_size)); - iterator i_ptr = begin(), - i_end = end(); - const_iterator v_ptr = v.begin(), - w_ptr = w.begin(), - y_ptr = y.begin(); - - for (; i_ptr!=i_end; ++i_ptr) - *i_ptr = (x * *i_ptr) + (a * *v_ptr++) + (b * *w_ptr++) + (c * *y_ptr++); + + for (unsigned int i=0; i::scale (const Vector &s) Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == s.vec_size, ExcDimensionMismatch(vec_size, s.vec_size)); - iterator ptr = begin(); - const const_iterator eptr = end(); - typename Vector::const_iterator sptr = s.begin(); - while (ptr!=eptr) - *ptr++ *= *sptr++; + for (unsigned int i=0; i template -void Vector::equ (const Number a, const Vector& u) +void Vector::equ (const Number a, + const Vector& u) { Assert (numbers::is_finite(a), ExcMessage("The given value is not finite but either infinite or Not A Number (NaN)")); Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == u.vec_size, ExcDimensionMismatch(vec_size, u.vec_size)); - iterator i_ptr = begin(), - i_end = end(); - typename Vector::const_iterator u_ptr = u.begin(); - while (i_ptr!=i_end) - *i_ptr++ = a * *u_ptr++; + + // set the result vector to a*u. we have to + // convert the elements of u to the type of + // the result vector. this is necessary + // because + // operator*(complex,complex) + // is not defined by default + for (unsigned int i=0; i::equ (const Number a, const Vector& u, Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == u.vec_size, ExcDimensionMismatch(vec_size, u.vec_size)); Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); - iterator i_ptr = begin(), - i_end = end(); - const_iterator u_ptr = u.begin(), - v_ptr = v.begin(); - while (i_ptr!=i_end) - *i_ptr++ = a * *u_ptr++ + b * *v_ptr++; + + for (unsigned int i=0; i::equ (const Number a, const Vector& u, Assert (vec_size == u.vec_size, ExcDimensionMismatch(vec_size, u.vec_size)); Assert (vec_size == v.vec_size, ExcDimensionMismatch(vec_size, v.vec_size)); Assert (vec_size == w.vec_size, ExcDimensionMismatch(vec_size, w.vec_size)); - iterator i_ptr = begin(), - i_end = end(); - const_iterator u_ptr = u.begin(), - v_ptr = v.begin(), - w_ptr = w.begin(); - while (i_ptr!=i_end) - *i_ptr++ = a * *u_ptr++ + b * *v_ptr++ + c * *w_ptr++; + + for (unsigned int i=0; i -void Vector::ratio (const Vector &a, const Vector &b) +void Vector::ratio (const Vector &a, + const Vector &b) { Assert (vec_size!=0, ExcEmptyObject()); - Assert (a.vec_size == b.vec_size, ExcDimensionMismatch (a.vec_size, b.vec_size)); + Assert (a.vec_size == b.vec_size, + ExcDimensionMismatch (a.vec_size, b.vec_size)); // no need to reinit with zeros, since // we overwrite them anyway reinit (a.size(), true); - iterator i_ptr = begin(), - i_end = end(); - const_iterator a_ptr = a.begin(), - b_ptr = b.begin(); - while (i_ptr!=i_end) - *i_ptr++ = *a_ptr++ / *b_ptr++; + + for (unsigned int i=0; i::operator == (const Vector& v) const Assert (vec_size!=0, ExcEmptyObject()); Assert (vec_size == v.size(), ExcDimensionMismatch(vec_size, v.size())); + // compare the two vector. we have to + // convert the elements of v to the type of + // the result vector. this is necessary + // because + // operator==(complex,complex) + // is not defined by default for (unsigned int i=0; i::operator == (const Vector& v) const template -void Vector::print (const char* format) const +void Vector::print (const char *format) const { Assert (vec_size!=0, ExcEmptyObject()); - if (!format) format = " %5.2f"; - for (unsigned int j=0;j::print (std::ostream &out, if (across) for (unsigned int i=0; i(val[i]) << ' '; + out << val[i] << ' '; else for (unsigned int i=0; i(val[i]) << std::endl; + out << val[i] << std::endl; out << std::endl; AssertThrow (out, ExcIO()); diff --git a/deal.II/lac/source/vector.cc b/deal.II/lac/source/vector.cc index 53a5636bcc..b25a361fe1 100644 --- a/deal.II/lac/source/vector.cc +++ b/deal.II/lac/source/vector.cc @@ -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 @@ -53,4 +53,43 @@ template void Vector::equ(const float, const Vector&); template void Vector::scale(const Vector&); template void Vector::scale(const Vector&); + + +// complex data types +template class Vector >; + +#ifndef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG +template Vector >::Vector (const Vector > &); +#endif + +template Vector >& Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator= >(const Vector >&); +template bool Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator== >(const Vector >&) const; +template bool Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator== >(const Vector >&) const; +template std::complex Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator* >(const Vector >&) const; +template std::complex Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator* >(const Vector >&) const; +template void Vector >::reinit >(const Vector >&, const bool); +template void Vector >::reinit >(const Vector >&, const bool); +template void Vector >::equ >(const std::complex, const Vector >&); +template void Vector >::equ >(const std::complex, const Vector >&); +template void Vector >::scale >(const Vector >&); +template void Vector >::scale >(const Vector >&); + +template class Vector >; + +#ifndef DEAL_II_EXPLICIT_CONSTRUCTOR_BUG +template Vector >::Vector (const Vector > &); +#endif + +template Vector >& Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator= >(const Vector >&); +template bool Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator== >(const Vector >&) const; +template bool Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator== >(const Vector >&) const; +template std::complex Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator* >(const Vector >&) const; +template std::complex Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator* >(const Vector >&) const; +template void Vector >::reinit >(const Vector >&, const bool); +template void Vector >::reinit >(const Vector >&, const bool); +template void Vector >::equ >(const std::complex, const Vector >&); +template void Vector >::equ >(const std::complex, const Vector >&); +template void Vector >::scale >(const Vector >&); +template void Vector >::scale >(const Vector >&); + DEAL_II_NAMESPACE_CLOSE diff --git a/deal.II/lac/source/vector.long_double.cc b/deal.II/lac/source/vector.long_double.cc index 300c9cc110..33577c3844 100644 --- a/deal.II/lac/source/vector.long_double.cc +++ b/deal.II/lac/source/vector.long_double.cc @@ -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 @@ -16,7 +16,7 @@ DEAL_II_NAMESPACE_OPEN -// explicit instantiations +// explicit instantiations for long double template class Vector; #if !defined(DEAL_II_EXPLICIT_CONSTRUCTOR_BUG) && !defined(DEAL_II_LONG_DOUBLE_LOOP_BUG) @@ -49,4 +49,38 @@ template float Vector::DEAL_II_MEMBER_OP_TEMPLATE_INST operator *::reinit(const Vector&, const bool); template void Vector::equ(const float, const Vector&); + +// explicit instantiations for std::complex +template class Vector >; + +#if !defined(DEAL_II_EXPLICIT_CONSTRUCTOR_BUG) && !defined(DEAL_II_LONG_DOUBLE_LOOP_BUG) +template Vector >::Vector (const Vector > &); +template Vector >::Vector (const Vector > &); + +template Vector >::Vector (const Vector > &); +template Vector >::Vector (const Vector > &); +#endif + +template Vector >& Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator= >(const Vector >&); +template Vector >& Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator= >(const Vector >&); +template std::complex Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator * > (const Vector > &) const; +template std::complex Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator * > (const Vector > &) const; +template std::complex Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator * > (const Vector > &) const; +template void Vector >::reinit >(const Vector >&, const bool); +template void Vector >::reinit >(const Vector >&, const bool); +template void Vector >::reinit >(const Vector >&, const bool); +template void Vector >::equ >(const std::complex, const Vector >&); +template void Vector >::equ >(const std::complex, const Vector >&); +template void Vector >::equ >(const std::complex, const Vector >&); + +template Vector >& Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator= >(const Vector >&); +template std::complex Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator * > (const Vector > &) const; +template void Vector >::reinit >(const Vector >&, const bool); +template void Vector >::equ >(const std::complex, const Vector >&); + +template Vector >& Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator= >(const Vector >&); +template std::complex Vector >::DEAL_II_MEMBER_OP_TEMPLATE_INST operator * > (const Vector > &) const; +template void Vector >::reinit >(const Vector >&, const bool); +template void Vector >::equ >(const std::complex, const Vector >&); + DEAL_II_NAMESPACE_CLOSE diff --git a/tests/bits/Makefile b/tests/bits/Makefile index ea9420c0f2..8bee45bc68 100644 --- a/tests/bits/Makefile +++ b/tests/bits/Makefile @@ -64,6 +64,7 @@ tests_x = grid_generator_?? \ solver_* \ deal_solver_* \ vector_* \ + complex-vector_* \ subdomain_ids_* \ dof_constraints_* \ apply_boundary_values_* \ diff --git a/tests/bits/complex-vector_11.cc b/tests/bits/complex-vector_11.cc new file mode 100644 index 0000000000..1012df683d --- /dev/null +++ b/tests/bits/complex-vector_11.cc @@ -0,0 +1,74 @@ +//---------------------------- vector_11.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_11.cc --------------------------- + + +// check Vector >::size() + +#include "../tests.h" +#include +#include +#include + + +void test (Vector > &v) +{ + // set only certain elements of the vector + for (unsigned int i=0; i (i+1., i+2.); + + v.compress (); + + Assert (v.size() == 100, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_11/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_12.cc b/tests/bits/complex-vector_12.cc new file mode 100644 index 0000000000..91a50b67b3 --- /dev/null +++ b/tests/bits/complex-vector_12.cc @@ -0,0 +1,87 @@ +//---------------------------- vector_12.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_12.cc --------------------------- + + +// check Vector >::operator() in set-mode + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set only certain elements of the + // vector. have a bit pattern of where we + // actually wrote elements to + std::vector pattern (v.size(), false); + for (unsigned int i=0; i (i+1., i+2.); + pattern[i] = true; + } + + v.compress (); + + // check that they are ok, and this time + // all of them + for (unsigned int i=0; i (i+1., i+2.))) + || + ((pattern[i] == false) && (v(i) == std::complex (0)))), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_12/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_13.cc b/tests/bits/complex-vector_13.cc new file mode 100644 index 0000000000..74bb60e9eb --- /dev/null +++ b/tests/bits/complex-vector_13.cc @@ -0,0 +1,87 @@ +//---------------------------- vector_13.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_13.cc --------------------------- + + +// check Vector >::operator() in add-mode + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set only certain elements of the + // vector. have a bit pattern of where we + // actually wrote elements to + std::vector pattern (v.size(), false); + for (unsigned int i=0; i (i+1., i+2.); + pattern[i] = true; + } + + v.compress (); + + // check that they are ok, and this time + // all of them + for (unsigned int i=0; i (i+1., i+2.))) + || + ((pattern[i] == false) && (v(i) == std::complex (0)))), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_13/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_14.cc b/tests/bits/complex-vector_14.cc new file mode 100644 index 0000000000..6c7eb4cb61 --- /dev/null +++ b/tests/bits/complex-vector_14.cc @@ -0,0 +1,93 @@ +//---------------------------- vector_14.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_14.cc --------------------------- + + +// check Vector >::operator() in set/add-mode alternatingly + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set only certain elements of the + // vector. have a bit pattern of where we + // actually wrote elements to + std::vector pattern (v.size(), false); + bool flag = false; + for (unsigned int i=0; i (i+1., i+2.); + else + v(i) = std::complex (i+1., i+2.); + flag = !flag; + + pattern[i] = true; + } + + v.compress (); + + // check that they are ok, and this time + // all of them + for (unsigned int i=0; i (i+1., i+2.))) + || + ((pattern[i] == false) && (v(i) == std::complex(0))), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_14/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_15.cc b/tests/bits/complex-vector_15.cc new file mode 100644 index 0000000000..5de8f96638 --- /dev/null +++ b/tests/bits/complex-vector_15.cc @@ -0,0 +1,90 @@ +//---------------------------- vector_15.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_15.cc --------------------------- + + +// check Vector >::operator() in set/add-mode alternatingly, but +// writing to the same elements + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set only certain elements of the + // vector. have a bit pattern of where we + // actually wrote elements to + std::vector pattern (v.size(), false); + for (unsigned int i=0; i (i+1., i+2.); + pattern[i] = true; + } + for (unsigned int i=0; i (i+1., i+2.); + + v.compress (); + + // check that they are ok, and this time + // all of them + for (unsigned int i=0; i (i+1., i+2.))) + || + ((pattern[i] == false) && (v(i) == std::complex(0))), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_15/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_16.cc b/tests/bits/complex-vector_16.cc new file mode 100644 index 0000000000..b1e1b594f1 --- /dev/null +++ b/tests/bits/complex-vector_16.cc @@ -0,0 +1,92 @@ +//---------------------------- vector_16.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_16.cc --------------------------- + + +// check Vector >::operator() in set/add-mode alternatingly, but +// writing and overwriting the same elements + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set only certain elements of the + // vector. have a bit pattern of where we + // actually wrote elements to + std::vector pattern (v.size(), false); + for (unsigned int i=0; i (i+1., i+2.); + pattern[i] = true; + } + for (unsigned int i=0; i (i+1., i+2.); + for (unsigned int i=0; i (i+1., i+2.); + + v.compress (); + + // check that they are ok, and this time + // all of them + for (unsigned int i=0; i (i+1., i+2.))) + || + ((pattern[i] == false) && (v(i) == std::complex (0))), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_16/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_17.cc b/tests/bits/complex-vector_17.cc new file mode 100644 index 0000000000..4d96b21aff --- /dev/null +++ b/tests/bits/complex-vector_17.cc @@ -0,0 +1,79 @@ +//---------------------------- vector_17.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_17.cc --------------------------- + + +// check Vector >::l1_norm() + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set some elements of the vector + double norm = 0; + for (unsigned int i=0; i (i+1., i+2.); + norm += std::abs(std::complex (i+1., i+2.)); + } + v.compress (); + + // then check the norm + Assert (v.l1_norm() == norm, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_17/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_18.cc b/tests/bits/complex-vector_18.cc new file mode 100644 index 0000000000..30e3295526 --- /dev/null +++ b/tests/bits/complex-vector_18.cc @@ -0,0 +1,80 @@ +//---------------------------- vector_18.cc --------------------------- +// vector_18.cc,v 1.4 2004/02/26 17:25:45 wolf Exp +// Version: +// +// Copyright (C) 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. +// +//---------------------------- vector_18.cc --------------------------- + + +// check Vector >::l2_norm() + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set some elements of the vector + double norm = 0; + for (unsigned int i=0; i (i+1., i+2.); + norm += std::abs(std::complex (i+1., i+2.))* + std::abs(std::complex (i+1., i+2.)); + } + v.compress (); + + // then check the norm + Assert (std::fabs((v.l2_norm() - std::sqrt(norm))/std::sqrt(norm)) < 1e-14, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_18/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_19.cc b/tests/bits/complex-vector_19.cc new file mode 100644 index 0000000000..a054e8e547 --- /dev/null +++ b/tests/bits/complex-vector_19.cc @@ -0,0 +1,80 @@ +//---------------------------- vector_19.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_19.cc --------------------------- + + +// check Vector >::linfty_norm() + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set some elements of the vector + double norm = 0; + for (unsigned int i=0; i (i+1., i+2.); + norm = std::max(norm, + std::abs(std::complex (i+1., i+2.))); + } + v.compress (); + + // then check the norm + Assert (v.linfty_norm() == norm, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_19/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_20.cc b/tests/bits/complex-vector_20.cc new file mode 100644 index 0000000000..821921e729 --- /dev/null +++ b/tests/bits/complex-vector_20.cc @@ -0,0 +1,88 @@ +//---------------------------- vector_20.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_20.cc --------------------------- + + +// check Vector >::operator *= + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set only certain elements of the + // vector. have a bit pattern of where we + // actually wrote elements to + std::vector pattern (v.size(), false); + for (unsigned int i=0; i (i+1., i+2.); + pattern[i] = true; + } + v.compress (); + + // multiply v with 5/4 + v *= 5./4.; + + // check that the entries are ok + for (unsigned int i=0; i (i+1., i+2.)*5./4.)) + || + ((pattern[i] == false) && (v(i) == std::complex(0))), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_20/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_21.cc b/tests/bits/complex-vector_21.cc new file mode 100644 index 0000000000..129dc06d80 --- /dev/null +++ b/tests/bits/complex-vector_21.cc @@ -0,0 +1,88 @@ +//---------------------------- vector_21.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_21.cc --------------------------- + + +// check Vector >::operator /= + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set only certain elements of the + // vector. have a bit pattern of where we + // actually wrote elements to + std::vector pattern (v.size(), false); + for (unsigned int i=0; i (i+1., i+2.); + pattern[i] = true; + } + v.compress (); + + // multiply v with 3/4 + v /= 4./3.; + + // check that the entries are ok + for (unsigned int i=0; i (i+1., i+2.)*3./4.)) + || + ((pattern[i] == false) && (v(i) == std::complex(0))), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_21/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_21_negative.cc b/tests/bits/complex-vector_21_negative.cc new file mode 100644 index 0000000000..efa3e938ec --- /dev/null +++ b/tests/bits/complex-vector_21_negative.cc @@ -0,0 +1,90 @@ +//---------------------------- vector_21_negative.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_21_negative.cc --------------------------- + + +// check Vector >::operator /=. the original check was that the factor +// by which we divide must be positive. this is of course nonsensical, it +// should have been that the factor is != 0... + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set only certain elements of the + // vector. have a bit pattern of where we + // actually wrote elements to + std::vector pattern (v.size(), false); + for (unsigned int i=0; i (i+1., i+2.); + pattern[i] = true; + } + v.compress (); + + // multiply v with 3/4 + v /= -4./3.; + + // check that the entries are ok + for (unsigned int i=0; i (i+1., i+2.)*3./4.) == std::complex(0))) + || + ((pattern[i] == false) && (v(i) == std::complex(0))), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_21_negative/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_22.cc b/tests/bits/complex-vector_22.cc new file mode 100644 index 0000000000..67e3b2809c --- /dev/null +++ b/tests/bits/complex-vector_22.cc @@ -0,0 +1,83 @@ +//---------------------------- vector_22.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_22.cc --------------------------- + + +// check Vector >::operator*(Vector) on two vectors that are +// orthogonal + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + // set only certain elements of each + // vector, but disjoint sets of elements + for (unsigned int i=0; i (i+1., i+2.); + else + w(i) = std::complex (i+1., i+2.); + v.compress (); + w.compress (); + + // make sure the scalar product is zero + Assert (v*w == std::complex(0), ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_22/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_23.cc b/tests/bits/complex-vector_23.cc new file mode 100644 index 0000000000..e3b300dc82 --- /dev/null +++ b/tests/bits/complex-vector_23.cc @@ -0,0 +1,97 @@ +//---------------------------- vector_23.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_23.cc --------------------------- + + +// check Vector >::operator*(Vector) on two vectors that are +// not orthogonal + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + // set only certain elements of each + // vector, and record the expected scalar + // product + std::complex product = 0; + for (unsigned int i=0; i (i+1., i+2.); + product += 1.*i*std::complex (i+1., i+2.); + } + } + + v.compress (); + w.compress (); + + + // make sure the scalar product is correct + deallog << v*w << ' ' << w*v << ' ' + << product << ' ' << std::conj(product) << std::endl; + + Assert (v*w == product, ExcInternalError()); + + // also make sure that v*w=conj(w*v) + Assert (w*v == std::conj(product), ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_23/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_24.cc b/tests/bits/complex-vector_24.cc new file mode 100644 index 0000000000..fb1217c108 --- /dev/null +++ b/tests/bits/complex-vector_24.cc @@ -0,0 +1,82 @@ +//---------------------------- vector_24.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_24.cc --------------------------- + + +// this test used to check for Vector::clear(). However, this +// function has since been removed, so we test for v=0 instead, although that +// may be covered by one of the other tests + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set some entries of the vector + for (unsigned int i=0; i (i+1., i+2.); + v.compress (); + + // then clear it again and make sure the + // vector is really empty + const unsigned int sz = v.size(); + v = 0; + Assert (v.size() == sz, ExcInternalError()); + Assert (v.l2_norm() == 0, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_24/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_25.cc b/tests/bits/complex-vector_25.cc new file mode 100644 index 0000000000..d8f3b267b6 --- /dev/null +++ b/tests/bits/complex-vector_25.cc @@ -0,0 +1,78 @@ +//---------------------------- vector_25.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_25.cc --------------------------- + +// check Vector::operator = (Scalar) with setting to zero + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set some entries of the vector + for (unsigned int i=0; i (i+1., i+2.); + v.compress (); + + // then clear it again and make sure the + // vector is really empty + const unsigned int sz = v.size(); + v = 0; + Assert (v.size() == sz, ExcInternalError()); + Assert (v.l2_norm() == 0, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + +int main () +{ + std::ofstream logfile("complex-vector_25/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_26.cc b/tests/bits/complex-vector_26.cc new file mode 100644 index 0000000000..8d756fd1c5 --- /dev/null +++ b/tests/bits/complex-vector_26.cc @@ -0,0 +1,77 @@ +//---------------------------- vector_26.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_26.cc --------------------------- + +// check Vector::operator = (scalar) with setting to a +// nonzero value + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set some entries of the vector + for (unsigned int i=0; i (i+1., i+2.); + v.compress (); + + const unsigned int sz = v.size(); + v = 2; + Assert (v.size() == sz, ExcInternalError()); + Assert (v.l2_norm() == std::sqrt(4.*sz), ExcInternalError()); + + deallog << "OK" << std::endl; +} + + +int main () +{ + std::ofstream logfile("complex-vector_26/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_27.cc b/tests/bits/complex-vector_27.cc new file mode 100644 index 0000000000..e7ce00568f --- /dev/null +++ b/tests/bits/complex-vector_27.cc @@ -0,0 +1,84 @@ +//---------------------------- vector_27.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_27.cc --------------------------- + + +// check Vector >::operator = (Vector) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set some entries of the vector + for (unsigned int i=0; i (i+1., i+2.); + v.compress (); + + // then copy it + Vector > w (v.size()); + w = v; + + // make sure they're equal + deallog << std::abs(v*w) << ' ' << v.l2_norm() * w.l2_norm() + << ' ' << std::abs(v*w) - v.l2_norm() * w.l2_norm() << std::endl; + Assert (std::abs(std::abs(v*w) - v.l2_norm() * w.l2_norm()) < + 1e-14*(std::abs(v*w)), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_27/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_28.cc b/tests/bits/complex-vector_28.cc new file mode 100644 index 0000000000..df900adfbb --- /dev/null +++ b/tests/bits/complex-vector_28.cc @@ -0,0 +1,86 @@ +//---------------------------- vector_28.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_28.cc --------------------------- + + +// check Vector >::operator = (Vector), except that we don't +// resize the vector to be copied to beforehand + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set some entries of the vector + for (unsigned int i=0; i (i+1., i+2.); + v.compress (); + + // then copy it to a vector of different + // size + Vector > w (1); + w = v; + + // make sure they're equal + deallog << std::abs(v*w) << ' ' << v.l2_norm() * w.l2_norm() + << ' ' << std::abs(v*w) - v.l2_norm() * w.l2_norm() << std::endl; + Assert (std::abs(std::abs(v*w) - v.l2_norm() * w.l2_norm()) < + 1e-14*std::abs(v*w), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_28/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_29.cc b/tests/bits/complex-vector_29.cc new file mode 100644 index 0000000000..370e797823 --- /dev/null +++ b/tests/bits/complex-vector_29.cc @@ -0,0 +1,71 @@ +//---------------------------- vector_29.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2004, 2005 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. +// +//---------------------------- vector_29.cc --------------------------- + + +// check Vector >::reinit(fast) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + v.reinit (13, true); + + Assert (v.size() == 13, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_29/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_30.cc b/tests/bits/complex-vector_30.cc new file mode 100644 index 0000000000..7ef019f2e0 --- /dev/null +++ b/tests/bits/complex-vector_30.cc @@ -0,0 +1,79 @@ +//---------------------------- vector_30.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_30.cc --------------------------- + + +// check Vector >::reinit(!fast) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set some entries of the vector + for (unsigned int i=0; i (i+1., i+2.); + v.compress (); + + // then resize with setting to zero + v.reinit (13, false); + + Assert (v.size() == 13, ExcInternalError()); + Assert (v.l2_norm() == 0, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_30/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_31.cc b/tests/bits/complex-vector_31.cc new file mode 100644 index 0000000000..da7b436b26 --- /dev/null +++ b/tests/bits/complex-vector_31.cc @@ -0,0 +1,81 @@ +//---------------------------- vector_31.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_31.cc --------------------------- + + +// check Vector >::l2_norm() + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set some elements of the vector + std::complex norm = 0; + for (unsigned int i=0; i (i+1., i+2.); + norm += std::conj(std::complex (i+1., i+2.)) * + std::complex (i+1., i+2.); + } + v.compress (); + + // then check the norm + Assert (std::abs(v.norm_sqr() - norm) < 1e-14*std::abs(norm), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_31/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_32.cc b/tests/bits/complex-vector_32.cc new file mode 100644 index 0000000000..0933157447 --- /dev/null +++ b/tests/bits/complex-vector_32.cc @@ -0,0 +1,81 @@ +//---------------------------- vector_32.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_32.cc --------------------------- + + +// check Vector >::mean_value() + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set some elements of the vector + std::complex sum = 0; + for (unsigned int i=0; i (i+1., i+2.); + sum += std::complex (i+1., i+2.); + } + v.compress (); + + // then check the norm + Assert (std::abs(v.mean_value() - sum/(1.*v.size())) < + 1e-14*std::abs(sum)/v.size(), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_32/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_33.cc b/tests/bits/complex-vector_33.cc new file mode 100644 index 0000000000..99011f6e8a --- /dev/null +++ b/tests/bits/complex-vector_33.cc @@ -0,0 +1,82 @@ +//---------------------------- vector_33.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_33.cc --------------------------- + + +// check Vector >::lp_norm(3) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set some elements of the vector + std::complex sum = 0; + for (unsigned int i=0; i (i+1., i+2.); + sum += std::pow (std::abs(std::complex (i+1., i+2.)), + 3); + } + v.compress (); + + // then check the norm + Assert (std::abs(v.lp_norm(3) - std::pow(sum, 1./3.)) < + 1e-14*std::abs(std::pow(sum, 1./3.)), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_33/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_34.cc b/tests/bits/complex-vector_34.cc new file mode 100644 index 0000000000..7958e02f91 --- /dev/null +++ b/tests/bits/complex-vector_34.cc @@ -0,0 +1,80 @@ +//---------------------------- vector_34.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_34.cc --------------------------- + + +// check Vector >::all_zero + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set some elements of the vector + for (unsigned int i=0; i (i+1., i+2.); + } + v.compress (); + + // set them to zero again + v = 0; + + // then check all_zero + Assert (v.all_zero() == true, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_34/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_35.cc b/tests/bits/complex-vector_35.cc new file mode 100644 index 0000000000..c2dd0989c6 --- /dev/null +++ b/tests/bits/complex-vector_35.cc @@ -0,0 +1,101 @@ +//---------------------------- vector_35.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_35.cc --------------------------- + + +// check Vector >::operator+=(Vector) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + // set only certain elements of each + // vector + for (unsigned int i=0; i (i+1., i+2.); + } + + v.compress (); + w.compress (); + + v += w; + + // make sure we get the expected result + for (unsigned int i=0; i (i+1., i+2.), + ExcInternalError()); + Assert (v(i) == std::complex (i+1., i+2.)+1.*i, + ExcInternalError()); + } + else + { + Assert (w(i) == 0., ExcInternalError()); + Assert (v(i) == 1.*i, ExcInternalError()); + } + } + + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_35/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_36.cc b/tests/bits/complex-vector_36.cc new file mode 100644 index 0000000000..6ad65cf0e0 --- /dev/null +++ b/tests/bits/complex-vector_36.cc @@ -0,0 +1,101 @@ +//---------------------------- vector_36.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_36.cc --------------------------- + + +// check Vector >::operator-=(Vector) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + // set only certain elements of each + // vector + for (unsigned int i=0; i (i+1., i+2.); + } + + v.compress (); + w.compress (); + + v -= w; + + // make sure we get the expected result + for (unsigned int i=0; i (i+1., i+2.), + ExcInternalError()); + Assert (v(i) == std::complex (-1., -(i+2.)), + ExcInternalError()); + } + else + { + Assert (w(i) == 0., ExcInternalError()); + Assert (v(i) == 1.*i, ExcInternalError()); + } + } + + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_36/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_37.cc b/tests/bits/complex-vector_37.cc new file mode 100644 index 0000000000..208c7d5349 --- /dev/null +++ b/tests/bits/complex-vector_37.cc @@ -0,0 +1,79 @@ +//---------------------------- vector_37.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_37.cc --------------------------- + + +// check Vector >::add (scalar) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + for (unsigned int i=0; i (i+1., i+2.); + + v.compress (); + + v.add (1.); + + // make sure we get the expected result + for (unsigned int i=0; i (i+2., i+2.), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_37/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_38.cc b/tests/bits/complex-vector_38.cc new file mode 100644 index 0000000000..30697cabd9 --- /dev/null +++ b/tests/bits/complex-vector_38.cc @@ -0,0 +1,89 @@ +//---------------------------- vector_38.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_38.cc --------------------------- + + +// check Vector >::add(Vector) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + for (unsigned int i=0; i (i+1., i+2.); + } + + v.compress (); + w.compress (); + + v.add (w); + + // make sure we get the expected result + for (unsigned int i=0; i (i+1., i+2.), + ExcInternalError()); + Assert (v(i) == 1.*i+std::complex (i+1., i+2.), + ExcInternalError()); + } + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_38/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_39.cc b/tests/bits/complex-vector_39.cc new file mode 100644 index 0000000000..a9b3b6f356 --- /dev/null +++ b/tests/bits/complex-vector_39.cc @@ -0,0 +1,89 @@ +//---------------------------- vector_39.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_39.cc --------------------------- + + +// check Vector >::add(scalar, Vector) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + for (unsigned int i=0; i (i+1., i+2.); + } + + v.compress (); + w.compress (); + + v.add (2, w); + + // make sure we get the expected result + for (unsigned int i=0; i (i+1., i+2.), + ExcInternalError()); + Assert (v(i) == 1.*i+2.*std::complex (i+1., i+2.), + ExcInternalError()); + } + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_39/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_40.cc b/tests/bits/complex-vector_40.cc new file mode 100644 index 0000000000..6fb0b3d68e --- /dev/null +++ b/tests/bits/complex-vector_40.cc @@ -0,0 +1,93 @@ +//---------------------------- vector_40.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_40.cc --------------------------- + + +// check Vector >::add(s,V,s,V) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w, + Vector > &x) +{ + for (unsigned int i=0; i (i+1., i+2.); + x(i) = i+2.; + } + + v.compress (); + w.compress (); + x.compress (); + + v.add (2, w, 3, x); + + // make sure we get the expected result + for (unsigned int i=0; i (i+1., i+2.), ExcInternalError()); + Assert (x(i) == i+2., ExcInternalError()); + Assert (v(i) == 1.*i+2.*std::complex (i+1., i+2.)+3*(i+2.), + ExcInternalError()); + } + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_40/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + Vector > x (100); + test (v,w,x); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_41.cc b/tests/bits/complex-vector_41.cc new file mode 100644 index 0000000000..15af5698ea --- /dev/null +++ b/tests/bits/complex-vector_41.cc @@ -0,0 +1,89 @@ +//---------------------------- vector_41.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_41.cc --------------------------- + + +// check Vector >::sadd(s, Vector) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + for (unsigned int i=0; i (i+1., i+2.); + } + + v.compress (); + w.compress (); + + v.sadd (2, w); + + // make sure we get the expected result + for (unsigned int i=0; i (i+1., i+2.), + ExcInternalError()); + Assert (v(i) == 2.*i+std::complex (i+1., i+2.), + ExcInternalError()); + } + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_41/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_42.cc b/tests/bits/complex-vector_42.cc new file mode 100644 index 0000000000..62c669596a --- /dev/null +++ b/tests/bits/complex-vector_42.cc @@ -0,0 +1,89 @@ +//---------------------------- vector_42.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_42.cc --------------------------- + + +// check Vector >::sadd(scalar, scalar, Vector) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + for (unsigned int i=0; i (i+1., i+2.); + } + + v.compress (); + w.compress (); + + v.sadd (3, 2, w); + + // make sure we get the expected result + for (unsigned int i=0; i (i+1., i+2.), + ExcInternalError()); + Assert (v(i) == 3.*i+2.*std::complex (i+1., i+2.), + ExcInternalError()); + } + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_42/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_43.cc b/tests/bits/complex-vector_43.cc new file mode 100644 index 0000000000..1a281d59ff --- /dev/null +++ b/tests/bits/complex-vector_43.cc @@ -0,0 +1,93 @@ +//---------------------------- vector_43.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_43.cc --------------------------- + + +// check Vector >::sadd(s,s,V,s,V) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w, + Vector > &x) +{ + for (unsigned int i=0; i (i+1., i+2.); + x(i) = i+2.; + } + + v.compress (); + w.compress (); + x.compress (); + + v.sadd (1.5, 2, w, 3, x); + + // make sure we get the expected result + for (unsigned int i=0; i (i+1., i+2.), ExcInternalError()); + Assert (x(i) == i+2., ExcInternalError()); + Assert (v(i) == 1.5*i+2.*std::complex (i+1., i+2.)+3*(i+2.), + ExcInternalError()); + } + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_43/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + Vector > x (100); + test (v,w,x); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_44.cc b/tests/bits/complex-vector_44.cc new file mode 100644 index 0000000000..048d7ab531 --- /dev/null +++ b/tests/bits/complex-vector_44.cc @@ -0,0 +1,102 @@ +//---------------------------- vector_44.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_44.cc --------------------------- + + +// check Vector >::sadd(s,s,V,s,V,s,V) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w, + Vector > &x, + Vector > &y) +{ + for (unsigned int i=0; i (i+1., i+2.); + x(i) = i+2.; + y(i) = std::complex (i+3., i+4.); + } + + v.compress (); + w.compress (); + x.compress (); + y.compress (); + + v.sadd (1.5, 2, w, 3, x, 4, y); + + // make sure we get the expected result + for (unsigned int i=0; i (i+1., i+2.), + ExcInternalError()); + Assert (x(i) == i+2., ExcInternalError()); + Assert (y(i) == std::complex (i+3., i+4.), + ExcInternalError()); + Assert (v(i) == + 1.5*i+2.*std::complex (i+1., i+2.)+ + 3.*(i+2.)+4.*std::complex (i+3., i+4.), + ExcInternalError()); + } + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_44/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + Vector > x (100); + Vector > y (100); + test (v,w,x,y); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_45.cc b/tests/bits/complex-vector_45.cc new file mode 100644 index 0000000000..c16e6c2b40 --- /dev/null +++ b/tests/bits/complex-vector_45.cc @@ -0,0 +1,87 @@ +//---------------------------- vector_45.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_45.cc --------------------------- + + +// check Vector >::scale + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + for (unsigned int i=0; i (i+1., i+2.); + } + + v.compress (); + w.compress (); + + v.scale (w); + + // make sure we get the expected result + for (unsigned int i=0; i (i+1., i+2.), ExcInternalError()); + Assert (v(i) == 1.*i*std::complex (i+1., i+2.), ExcInternalError()); + } + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_45/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_46.cc b/tests/bits/complex-vector_46.cc new file mode 100644 index 0000000000..0ff5839fac --- /dev/null +++ b/tests/bits/complex-vector_46.cc @@ -0,0 +1,89 @@ +//---------------------------- vector_46.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_46.cc --------------------------- + + +// check Vector >::equ (s,V) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + for (unsigned int i=0; i (i+1., i+2.); + } + + v.compress (); + w.compress (); + + v.equ (2, w); + + // make sure we get the expected result + for (unsigned int i=0; i (i+1., i+2.), + ExcInternalError()); + Assert (v(i) == 2.*std::complex (i+1., i+2.), + ExcInternalError()); + } + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_46/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_47.cc b/tests/bits/complex-vector_47.cc new file mode 100644 index 0000000000..4542939155 --- /dev/null +++ b/tests/bits/complex-vector_47.cc @@ -0,0 +1,94 @@ +//---------------------------- vector_47.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_47.cc --------------------------- + + +// check Vector >::equ (s,V,s,V) + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w, + Vector > &x) +{ + for (unsigned int i=0; i (i+1., i+2.); + x(i) = i+2.; + } + + v.compress (); + w.compress (); + x.compress (); + + v.equ (2, w, 3, x); + + // make sure we get the expected result + for (unsigned int i=0; i (i+1., i+2.), + ExcInternalError()); + Assert (x(i) == i+2., ExcInternalError()); + Assert (v(i) == 2.*std::complex (i+1., i+2.)+3.*(i+2.), + ExcInternalError()); + } + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_47/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + Vector > x (100); + test (v,w,x); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_48.cc b/tests/bits/complex-vector_48.cc new file mode 100644 index 0000000000..ab53cd0a85 --- /dev/null +++ b/tests/bits/complex-vector_48.cc @@ -0,0 +1,97 @@ +//---------------------------- vector_48.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_48.cc --------------------------- + + +// check Vector >::ratio + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w, + Vector > &x) +{ + for (unsigned int i=0; i (i+1., i+2.); + w(i) = std::complex (i+2., i+3.); + x(i) = std::complex (i+3., i+4.); + } + + v.compress (); + w.compress (); + x.compress (); + + v.ratio (w, x); + + // make sure we get the expected result + for (unsigned int i=0; i (i+2., i+3.), + ExcInternalError()); + Assert (x(i) == std::complex (i+3., i+4.), + ExcInternalError()); + Assert (std::abs(v(i) - + std::complex (i+2., i+3.) / + std::complex (i+3., i+4.)) < 1e-14*std::abs(v(i)), + ExcInternalError()); + } + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_48/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + Vector > x (100); + test (v,w,x); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_49.cc b/tests/bits/complex-vector_49.cc new file mode 100644 index 0000000000..f4d82c0fcb --- /dev/null +++ b/tests/bits/complex-vector_49.cc @@ -0,0 +1,84 @@ +//---------------------------- vector_49.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_49.cc --------------------------- + + +// check copy constructor Vector >::Vector(Vector) for same template +// argument + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set some entries of the vector + for (unsigned int i=0; i (i+1., i+2.); + v.compress (); + + // then copy it + Vector > w (v); + + // make sure they're equal + deallog << std::abs(v*w) << ' ' << v.l2_norm() * w.l2_norm() + << ' ' << std::abs(v*w) - v.l2_norm() * w.l2_norm() << std::endl; + Assert (std::abs(std::abs(v*w) - v.l2_norm() * w.l2_norm()) + < 1e-14*std::abs(v*w), + ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_49/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_57.cc b/tests/bits/complex-vector_57.cc new file mode 100644 index 0000000000..59250f44cd --- /dev/null +++ b/tests/bits/complex-vector_57.cc @@ -0,0 +1,87 @@ +//---------------------------- vector_57.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2004, 2005 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. +// +//---------------------------- vector_57.cc --------------------------- + + +// check Vector::is_non_zero + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v) +{ + // set only certain elements of the + // vector. they are all positive + std::vector pattern (v.size(), false); + for (unsigned int i=0; i > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_equality_1.cc b/tests/bits/complex-vector_equality_1.cc new file mode 100644 index 0000000000..be0e5b9f13 --- /dev/null +++ b/tests/bits/complex-vector_equality_1.cc @@ -0,0 +1,81 @@ +//---------------------------- vector_equality_1.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_equality_1.cc --------------------------- + + +// check Vector >::operator==(Vector >) for vectors that are not +// equal + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + // set only certain elements of each + // vector + for (unsigned int i=0; i (i+0., i+1.); + if (i%3 == 0) + w(i) = std::complex (i+1., i+2.); + } + + Assert (!(v==w), ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_equality_1/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_equality_2.cc b/tests/bits/complex-vector_equality_2.cc new file mode 100644 index 0000000000..771e297ddd --- /dev/null +++ b/tests/bits/complex-vector_equality_2.cc @@ -0,0 +1,83 @@ +//---------------------------- vector_equality_2.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_equality_2.cc --------------------------- + + +// check Vector >::operator==(Vector >) for vectors that are +// equal + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + // set only certain elements of each + // vector + for (unsigned int i=0; i (i, i+1.); + if (i%3 == 0) + w(i) = std::complex (i+1., i+2.); + } + // but then copy elements and make sure the + // vectors are actually equal + v = w; + Assert (v==w, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_equality_2/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_equality_3.cc b/tests/bits/complex-vector_equality_3.cc new file mode 100644 index 0000000000..eeb122b9b1 --- /dev/null +++ b/tests/bits/complex-vector_equality_3.cc @@ -0,0 +1,81 @@ +//---------------------------- vector_equality_3.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_equality_3.cc --------------------------- + + +// check Vector >::operator!=(Vector >) for vectors that are not +// equal + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + // set only certain elements of each + // vector + for (unsigned int i=0; i (i, i+1.); + if (i%3 == 0) + w(i) = std::complex (i+1., i+2.); + } + + Assert (v.operator != (w), ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_equality_3/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_equality_4.cc b/tests/bits/complex-vector_equality_4.cc new file mode 100644 index 0000000000..6400a5c2aa --- /dev/null +++ b/tests/bits/complex-vector_equality_4.cc @@ -0,0 +1,83 @@ +//---------------------------- vector_equality_4.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_equality_4.cc --------------------------- + + +// check Vector >::operator!=(Vector >) for vectors that are +// equal + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + // set only certain elements of each + // vector + for (unsigned int i=0; i (i, i+1.); + if (i%3 == 0) + w(i) = std::complex (i+1., i+2.); + } + // but then copy elements and make sure the + // vectors are actually equal + v = w; + Assert (! (v.operator != (w)), ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_equality_4/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_equality_5.cc b/tests/bits/complex-vector_equality_5.cc new file mode 100644 index 0000000000..9bf0426e25 --- /dev/null +++ b/tests/bits/complex-vector_equality_5.cc @@ -0,0 +1,82 @@ +//---------------------------- vector_equality_1.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_equality_1.cc --------------------------- + + +// check Vector >::operator==(Vector >) for vectors that are not +// equal and different template arguments + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + // set only certain elements of each + // vector + for (unsigned int i=0; i (i, i+1.); + if (i%3 == 0) + w(i) = std::complex (i+1., i+2.); + } + + Assert (!(v==w), ExcInternalError()); + Assert (!(w==v), ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_equality_5/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_equality_6.cc b/tests/bits/complex-vector_equality_6.cc new file mode 100644 index 0000000000..a03a862e2a --- /dev/null +++ b/tests/bits/complex-vector_equality_6.cc @@ -0,0 +1,84 @@ +//---------------------------- vector_equality_2.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_equality_2.cc --------------------------- + + +// check Vector >::operator==(Vector >) for vectors that are +// equal and different template arguments + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + // set only certain elements of each + // vector + for (unsigned int i=0; i (i, i+1.); + if (i%3 == 0) + w(i) = std::complex (i+1., i+2.); + } + // but then copy elements and make sure the + // vectors are actually equal + v = w; + Assert (v==w, ExcInternalError()); + Assert (w==v, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_equality_6/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_equality_7.cc b/tests/bits/complex-vector_equality_7.cc new file mode 100644 index 0000000000..2135993a80 --- /dev/null +++ b/tests/bits/complex-vector_equality_7.cc @@ -0,0 +1,82 @@ +//---------------------------- vector_equality_3.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_equality_3.cc --------------------------- + + +// check Vector >::operator!=(Vector >) for vectors that are not +// equal and different template arguments + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + // set only certain elements of each + // vector + for (unsigned int i=0; i (i, i+1.); + if (i%3 == 0) + w(i) = std::complex (i+1., i+2.); + } + + Assert (v!=w, ExcInternalError()); + Assert (w!=v, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_equality_7/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_equality_8.cc b/tests/bits/complex-vector_equality_8.cc new file mode 100644 index 0000000000..ee80c1faf6 --- /dev/null +++ b/tests/bits/complex-vector_equality_8.cc @@ -0,0 +1,84 @@ +//---------------------------- vector_equality_4.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_equality_4.cc --------------------------- + + +// check Vector >::operator!=(Vector >) for vectors that are +// equal and different template arguments + +#include "../tests.h" +#include +#include +#include +#include + + +void test (Vector > &v, + Vector > &w) +{ + // set only certain elements of each + // vector + for (unsigned int i=0; i (i, i+1.); + if (i%3 == 0) + w(i) = std::complex (i+1., i+2.); + } + // but then copy elements and make sure the + // vectors are actually equal + v = w; + Assert (! (v!=w), ExcInternalError()); + Assert (! (w!=v), ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_equality_8/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + Vector > w (100); + test (v,w); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex-vector_vector_01.cc b/tests/bits/complex-vector_vector_01.cc new file mode 100644 index 0000000000..ebf758a0c8 --- /dev/null +++ b/tests/bits/complex-vector_vector_01.cc @@ -0,0 +1,75 @@ +//---------------------------- vector_vector_01.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 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. +// +//---------------------------- vector_vector_01.cc --------------------------- + + +// check existence Vector >::Vector(Vector >). this conversion +// constructor was disabled previously altogether because of a compiler defect +// that did not honor the 'explicit' keyword on template constructors. this is +// now autoconf'ed. + +#include "../tests.h" +#include +#include +#include + + +void test (Vector > &v) +{ + for (unsigned int i=0; i (i+1., i+2.); + Vector > w(v); + + Assert (w==v, ExcInternalError()); + + deallog << "OK" << std::endl; +} + + + +int main () +{ + std::ofstream logfile("complex-vector_vector_01/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + try + { + Vector > v (100); + test (v); + } + catch (std::exception &exc) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Exception on processing: " << std::endl + << exc.what() << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + + return 1; + } + catch (...) + { + std::cerr << std::endl << std::endl + << "----------------------------------------------------" + << std::endl; + std::cerr << "Unknown exception!" << std::endl + << "Aborting!" << std::endl + << "----------------------------------------------------" + << std::endl; + return 1; + }; +} diff --git a/tests/bits/complex_vector_11/cmp/generic b/tests/bits/complex_vector_11/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_11/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_12/cmp/generic b/tests/bits/complex_vector_12/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_12/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_13/cmp/generic b/tests/bits/complex_vector_13/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_13/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_14/cmp/generic b/tests/bits/complex_vector_14/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_14/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_15/cmp/generic b/tests/bits/complex_vector_15/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_15/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_16/cmp/generic b/tests/bits/complex_vector_16/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_16/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_17/cmp/generic b/tests/bits/complex_vector_17/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_17/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_18/cmp/generic b/tests/bits/complex_vector_18/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_18/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_19/cmp/generic b/tests/bits/complex_vector_19/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_19/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_20/cmp/generic b/tests/bits/complex_vector_20/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_20/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_21/cmp/generic b/tests/bits/complex_vector_21/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_21/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_21_negative/cmp/generic b/tests/bits/complex_vector_21_negative/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_21_negative/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_22/cmp/generic b/tests/bits/complex_vector_22/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_22/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_23/cmp/generic b/tests/bits/complex_vector_23/cmp/generic new file mode 100644 index 0000000000..92bca168fb --- /dev/null +++ b/tests/bits/complex_vector_23/cmp/generic @@ -0,0 +1,3 @@ + +DEAL::(114444.,116127.) (114444.,-116127.) (114444.,116127.) (114444.,-116127.) +DEAL::OK diff --git a/tests/bits/complex_vector_24/cmp/generic b/tests/bits/complex_vector_24/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_24/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_25/cmp/generic b/tests/bits/complex_vector_25/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_25/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_26/cmp/generic b/tests/bits/complex_vector_26/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_26/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_27/cmp/generic b/tests/bits/complex_vector_27/cmp/generic new file mode 100644 index 0000000000..3128bc4959 --- /dev/null +++ b/tests/bits/complex_vector_27/cmp/generic @@ -0,0 +1,3 @@ + +DEAL::235790. 235790. 0 +DEAL::OK diff --git a/tests/bits/complex_vector_28/cmp/generic b/tests/bits/complex_vector_28/cmp/generic new file mode 100644 index 0000000000..3128bc4959 --- /dev/null +++ b/tests/bits/complex_vector_28/cmp/generic @@ -0,0 +1,3 @@ + +DEAL::235790. 235790. 0 +DEAL::OK diff --git a/tests/bits/complex_vector_29/cmp/generic b/tests/bits/complex_vector_29/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_29/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_30/cmp/generic b/tests/bits/complex_vector_30/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_30/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_31/cmp/generic b/tests/bits/complex_vector_31/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_31/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_32/cmp/generic b/tests/bits/complex_vector_32/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_32/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_33/cmp/generic b/tests/bits/complex_vector_33/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_33/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_34/cmp/generic b/tests/bits/complex_vector_34/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_34/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_35/cmp/generic b/tests/bits/complex_vector_35/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_35/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_36/cmp/generic b/tests/bits/complex_vector_36/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_36/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_37/cmp/generic b/tests/bits/complex_vector_37/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_37/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_38/cmp/generic b/tests/bits/complex_vector_38/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_38/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_39/cmp/generic b/tests/bits/complex_vector_39/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_39/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_40/cmp/generic b/tests/bits/complex_vector_40/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_40/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_41/cmp/generic b/tests/bits/complex_vector_41/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_41/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_42/cmp/generic b/tests/bits/complex_vector_42/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_42/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_43/cmp/generic b/tests/bits/complex_vector_43/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_43/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_44/cmp/generic b/tests/bits/complex_vector_44/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_44/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_45/cmp/generic b/tests/bits/complex_vector_45/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_45/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_46/cmp/generic b/tests/bits/complex_vector_46/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_46/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_47/cmp/generic b/tests/bits/complex_vector_47/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_47/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_48/cmp/generic b/tests/bits/complex_vector_48/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_48/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_49/cmp/generic b/tests/bits/complex_vector_49/cmp/generic new file mode 100644 index 0000000000..3128bc4959 --- /dev/null +++ b/tests/bits/complex_vector_49/cmp/generic @@ -0,0 +1,3 @@ + +DEAL::235790. 235790. 0 +DEAL::OK diff --git a/tests/bits/complex_vector_57/cmp/generic b/tests/bits/complex_vector_57/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_57/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_equality_1/cmp/generic b/tests/bits/complex_vector_equality_1/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_equality_1/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_equality_2/cmp/generic b/tests/bits/complex_vector_equality_2/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_equality_2/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_equality_3/cmp/generic b/tests/bits/complex_vector_equality_3/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_equality_3/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_equality_4/cmp/generic b/tests/bits/complex_vector_equality_4/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_equality_4/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_equality_5/cmp/generic b/tests/bits/complex_vector_equality_5/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_equality_5/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_equality_6/cmp/generic b/tests/bits/complex_vector_equality_6/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_equality_6/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_equality_7/cmp/generic b/tests/bits/complex_vector_equality_7/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_equality_7/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_equality_8/cmp/generic b/tests/bits/complex_vector_equality_8/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_equality_8/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK diff --git a/tests/bits/complex_vector_vector_01/cmp/generic b/tests/bits/complex_vector_vector_01/cmp/generic new file mode 100644 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/bits/complex_vector_vector_01/cmp/generic @@ -0,0 +1,2 @@ + +DEAL::OK