From 3ef1e7edb7b9ce9ccef59751481b3b762a666615 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 1 Sep 2015 18:29:00 -0500 Subject: [PATCH] Tensor<0,dim>: Also provide operators for scalar multiplication --- include/deal.II/base/tensor_base.h | 96 ++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 18 deletions(-) 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. * -- 2.39.5