From: Matthias Maier Date: Tue, 1 Sep 2015 23:29:00 +0000 (-0500) Subject: Tensor<0,dim>: Also provide operators for scalar multiplication X-Git-Tag: v8.4.0-rc2~466^2~33 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ef1e7edb7b9ce9ccef59751481b3b762a666615;p=dealii.git Tensor<0,dim>: Also provide operators for scalar multiplication --- diff --git a/include/deal.II/base/tensor_base.h b/include/deal.II/base/tensor_base.h index 3971045115..d8c29c411f 100644 --- a/include/deal.II/base/tensor_base.h +++ b/include/deal.II/base/tensor_base.h @@ -886,6 +886,84 @@ operator- (const Tensor<0,dim,Number> &p, const Tensor<0,dim,OtherNumber> &q) +#ifndef DEAL_II_WITH_CXX11 + +template +struct ProductType > +{ + typedef Tensor::type> type; +}; + +template +struct ProductType,U> +{ + typedef Tensor::type> type; +}; + +#endif + + + +/** + * TODO + * + * @relates Tensor + * @relates EnableIfScalar + */ +template ::type> +inline +Tensor<0,dim,typename ProductType::type> +operator * (const Number factor, + const Tensor<0,dim,OtherNumber> &t) +{ + return factor * static_cast(t); +} + + + +/** + * TODO + * + * @relates Tensor + * @relates EnableIfScalar + */ +template ::type> +inline +Tensor<0,dim,typename ProductType::type> +operator * (const Tensor<0,dim,Number> &t, + const OtherNumber factor) +{ + return static_cast(t) * factor; +} + + + +/** + * TODO + * + * @relates Tensor + * @relates EnableIfScalar + */ +template ::type> +inline +Tensor<0,dim,typename ProductType::type> +operator / (const Tensor<0,dim,Number> &t, + const OtherNumber factor) +{ + return static_cast(t) / factor; +} + + + /*---------------------- Inline functions: Tensor<1,dim> ---------------------*/ @@ -1348,24 +1426,6 @@ std::ostream &operator << (std::ostream &out, const Tensor<1,1,double> &p) -#ifndef DEAL_II_WITH_CXX11 - -template -struct ProductType > -{ - typedef Tensor::type> type; -}; - -template -struct ProductType,U> -{ - typedef Tensor::type> type; -}; - -#endif - - - /** * Multiplication of a tensor of rank with a scalar number from the right. *