From: Denis Davydov Date: Tue, 3 Feb 2015 13:10:59 +0000 (+0100) Subject: Introduced non-default copy constructor and operator= for Tensor class X-Git-Tag: v8.3.0-rc1~502^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=089b5fb37417edf40db19e4b04a69a5847f9003f;p=dealii.git Introduced non-default copy constructor and operator= for Tensor class --- diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index 7d8b9f11c4..1425289e15 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -102,6 +102,13 @@ public: */ Tensor (const array_type &initializer); + /** + * Copy constructor taking a tesnor of another base data type + */ + template + explicit + Tensor (const Tensor &); + /** * Conversion operator from tensor of tensors. */ @@ -137,6 +144,9 @@ public: */ Tensor &operator = (const Tensor &); + template + Tensor &operator = (const Tensor &); + /** * This operator assigns a scalar to a tensor. To avoid confusion with what * exactly it means to assign a scalar value to a tensor, zero is the only @@ -403,6 +413,26 @@ Tensor::operator = (const Tensor &t) +template +template +inline +Tensor & +Tensor::operator = (const Tensor &t) +{ + for (unsigned int i=0; i +template +Tensor::Tensor (const Tensor &t) +{ + *this = t; +} + + + template inline Tensor & diff --git a/include/deal.II/base/tensor_base.h b/include/deal.II/base/tensor_base.h index 1f7b39ed36..bf2d7c68ae 100644 --- a/include/deal.II/base/tensor_base.h +++ b/include/deal.II/base/tensor_base.h @@ -135,6 +135,9 @@ public: */ Tensor<0,dim,Number> &operator = (const Tensor<0,dim,Number> &); + template + Tensor<0,dim,Number> &operator = (const Tensor<0,dim,OtherNumber> &); + /** * Assignment operator. */ @@ -369,6 +372,9 @@ public: */ Tensor<1,dim,Number> &operator = (const Tensor<1,dim,Number> &); + template + Tensor<1,dim,Number> &operator = (const Tensor<1,dim,OtherNumber> &); + /** * This operator assigns a scalar to a tensor. To avoid confusion with what * exactly it means to assign a scalar value to a tensor, zero is the only @@ -629,6 +635,14 @@ Tensor<0,dim,Number> &Tensor<0,dim,Number>::operator = (const Tensor<0,dim,Numbe return *this; } +template +template +inline +Tensor<0,dim,Number> &Tensor<0,dim,Number>::operator = (const Tensor<0,dim,OtherNumber> &p) +{ + value = p.value; + return *this; +} template @@ -901,6 +915,20 @@ Tensor<1,dim,Number>::operator = (const Tensor<1,dim,Number> &p) +template +template +inline +Tensor<1,dim,Number> & +Tensor<1,dim,Number>::operator = (const Tensor<1,dim,OtherNumber> &p) +{ + for (unsigned int i=0; i inline Tensor<1,dim,Number> &Tensor<1,dim,Number>::operator = (const Number d)