From: guido Date: Wed, 25 Sep 2002 22:23:43 +0000 (+0000) Subject: scale functions with template argument and for BlockVector X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=539b08a9a93c17173ddf1853900f4e1eb3e84e4c;p=dealii-svn.git scale functions with template argument and for BlockVector git-svn-id: https://svn.dealii.org/trunk@6519 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/block_vector.h b/deal.II/lac/include/lac/block_vector.h index e05aac8036..49224ee2e1 100644 --- a/deal.II/lac/include/lac/block_vector.h +++ b/deal.II/lac/include/lac/block_vector.h @@ -1106,6 +1106,14 @@ class BlockVector */ BlockVector & operator *= (const Number factor); + /** + * Multiply each element of this + * vector by the corresponding + * element of @p{v}. + */ + template + void scale (const BlockVector& v); + /** * U=a*V. Assignment. */ diff --git a/deal.II/lac/include/lac/block_vector.templates.h b/deal.II/lac/include/lac/block_vector.templates.h index 930c93e33b..48399e0419 100644 --- a/deal.II/lac/include/lac/block_vector.templates.h +++ b/deal.II/lac/include/lac/block_vector.templates.h @@ -445,6 +445,21 @@ void BlockVector::scale (const Number factor) } + +template +template +void BlockVector::scale (const BlockVector& v) +{ + Assert (num_blocks == v.num_blocks, + ExcDimensionMismatch(num_blocks, v.num_blocks)); + for (unsigned int i=0;i void BlockVector::equ (const Number a, const BlockVector& v, diff --git a/deal.II/lac/include/lac/vector.h b/deal.II/lac/include/lac/vector.h index f963a96aae..98a813906f 100644 --- a/deal.II/lac/include/lac/vector.h +++ b/deal.II/lac/include/lac/vector.h @@ -421,7 +421,8 @@ class Vector * immediate re-assignment) by a * diagonal scaling matrix. */ - void scale (const Vector &scaling_factors); + template + void scale (const Vector &scaling_factors); /** * U=a*V. Assignment. diff --git a/deal.II/lac/include/lac/vector.templates.h b/deal.II/lac/include/lac/vector.templates.h index 685fc90e0c..39a15fa6b0 100644 --- a/deal.II/lac/include/lac/vector.templates.h +++ b/deal.II/lac/include/lac/vector.templates.h @@ -454,14 +454,15 @@ void Vector::scale (const Number factor) template -void Vector::scale (const Vector &s) +template +void Vector::scale (const Vector &s) { Assert (dim!=0, ExcEmptyVector()); Assert (dim == s.dim, ExcDimensionMismatch(dim, s.dim)); iterator ptr = begin(); - const_iterator sptr = s.begin(); const const_iterator eptr = end(); + typename Vector::const_iterator sptr = s.begin(); while (ptr!=eptr) *ptr++ *= *sptr++; } diff --git a/deal.II/lac/source/block_vector.cc b/deal.II/lac/source/block_vector.cc index 9af154837c..dff8748811 100644 --- a/deal.II/lac/source/block_vector.cc +++ b/deal.II/lac/source/block_vector.cc @@ -25,6 +25,8 @@ template void BlockVector::equ(const double, const BlockVector&); template void BlockVector::equ(const double, const BlockVector&); +template void BlockVector::scale(const BlockVector&); +template void BlockVector::scale(const BlockVector&); template class BlockVector; template BlockVector& BlockVector::DEAL_II_MEMBER_OP_TEMPLATE_INST operator=( @@ -37,6 +39,8 @@ template void BlockVector::equ(const float, const BlockVector&); template void BlockVector::equ(const float, const BlockVector&); +template void BlockVector::scale(const BlockVector&); +template void BlockVector::scale(const BlockVector&); namespace BlockVectorIterators { diff --git a/deal.II/lac/source/vector.cc b/deal.II/lac/source/vector.cc index 0dfa53a884..2b945e8748 100644 --- a/deal.II/lac/source/vector.cc +++ b/deal.II/lac/source/vector.cc @@ -23,6 +23,8 @@ template void Vector::reinit(const Vector&, const bool); template void Vector::reinit(const Vector&, const bool); template void Vector::equ(const double, const Vector&); template void Vector::equ(const double, const Vector&); +template void Vector::scale(const Vector&); +template void Vector::scale(const Vector&); template class Vector; template Vector& Vector::DEAL_II_MEMBER_OP_TEMPLATE_INST operator=(const Vector&); @@ -32,6 +34,8 @@ template void Vector::reinit(const Vector&, const bool); template void Vector::reinit(const Vector&, const bool); template void Vector::equ(const float, const Vector&); template void Vector::equ(const float, const Vector&); +template void Vector::scale(const Vector&); +template void Vector::scale(const Vector&); // see the .h file for why these functions are disabled. // template Vector::Vector (const Vector& v);