From: guido Date: Mon, 3 May 1999 15:53:51 +0000 (+0000) Subject: Type conversion between vectors X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08bfcb478cf27563d57f02214a20637ac2912cb7;p=dealii-svn.git Type conversion between vectors git-svn-id: https://svn.dealii.org/trunk@1252 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/include/lac/vector.h b/deal.II/lac/include/lac/vector.h index ee5d026eca..5e82d24093 100644 --- a/deal.II/lac/include/lac/vector.h +++ b/deal.II/lac/include/lac/vector.h @@ -137,6 +137,12 @@ class Vector { * U = V . Copy all components */ Vector& operator= (const Vector& V); + + /** + * U = V for different types. + */ + template + Vector& operator= (const Vector& V); /** * U = U * V . Scalar Produkt diff --git a/deal.II/lac/include/lac/vector.templates.h b/deal.II/lac/include/lac/vector.templates.h index f579a75c57..0f573a2ab4 100644 --- a/deal.II/lac/include/lac/vector.templates.h +++ b/deal.II/lac/include/lac/vector.templates.h @@ -526,7 +526,8 @@ Vector& Vector::operator = (const Number s) template -Vector& Vector::operator = (const Vector& v) +Vector& +Vector::operator = (const Vector& v) { if (v.dim != dim) reinit (v.dim, true); @@ -538,6 +539,21 @@ Vector& Vector::operator = (const Vector& v) +template +template +Vector& +Vector::operator = (const Vector& v) +{ + if (v.size() != dim) + reinit (v.size(), true); + if (dim!=0) + copy (v.begin(), v.end(), begin()); + + return *this; +} + + + template void Vector::print (FILE* f, const char* format) const { diff --git a/deal.II/lac/source/vector.cc b/deal.II/lac/source/vector.cc index 7f7a262fd6..ce8f4baeb5 100644 --- a/deal.II/lac/source/vector.cc +++ b/deal.II/lac/source/vector.cc @@ -4,7 +4,10 @@ // explicit instantiations template class Vector; +template Vector& Vector::operator=(const Vector&); + template class Vector; +template Vector& Vector::operator=(const Vector&); // see the .h file for why these functions are disabled. // template Vector::Vector (const Vector& v);