From 2da2f3a26236dc65534a94b297978035a21a6879 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Tue, 3 Feb 2015 17:26:50 -0600 Subject: [PATCH] Address Martin K's comments in review of this patch. --- include/deal.II/base/tensor.h | 27 +++++++++++++++++----- include/deal.II/base/tensor_base.h | 37 ++++++++++++++++-------------- 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index 1425289e15..06b628d375 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -1,6 +1,6 @@ // --------------------------------------------------------------------- // -// Copyright (C) 1998 - 2014 by the deal.II authors +// Copyright (C) 1998 - 2015 by the deal.II authors // // This file is part of the deal.II library. // @@ -103,16 +103,18 @@ public: Tensor (const array_type &initializer); /** - * Copy constructor taking a tesnor of another base data type + * Copy constructor from tensors with different underlying scalar + * type. This obviously requires that the @p OtherNumber type is + * convertible to @p Number. */ template explicit - Tensor (const Tensor &); + Tensor (const Tensor &initializer); /** * Conversion operator from tensor of tensors. */ - Tensor (const Tensor<1,dim,Tensor > &tensor_in); + Tensor (const Tensor<1,dim,Tensor > &initializer); /** * Conversion operator to tensor of tensors. @@ -142,10 +144,15 @@ public: /** * Assignment operator. */ - Tensor &operator = (const Tensor &); + Tensor &operator = (const Tensor &rhs); + /** + * Assignment operator from tensors with different underlying scalar + * type. This obviously requires that the @p OtherNumber type is + * convertible to @p Number. + */ template - Tensor &operator = (const Tensor &); + Tensor &operator = (const Tensor &rhs); /** * This operator assigns a scalar to a tensor. To avoid confusion with what @@ -373,6 +380,8 @@ Tensor::operator[] (const unsigned int i) const return subtensor[i]; } + + template inline Number @@ -387,6 +396,8 @@ Tensor::operator[] (const TableIndices &indices) const return (subtensor[inner_ind])[indices1]; } + + template inline Number & @@ -401,6 +412,8 @@ Tensor::operator[] (const TableIndices &indices) return (subtensor[inner_ind])[indices1]; } + + template inline Tensor & @@ -424,6 +437,8 @@ Tensor::operator = (const Tensor &t) return *this; } + + template template Tensor::Tensor (const Tensor &t) diff --git a/include/deal.II/base/tensor_base.h b/include/deal.II/base/tensor_base.h index c4b5f46cab..eaed5b2f81 100644 --- a/include/deal.II/base/tensor_base.h +++ b/include/deal.II/base/tensor_base.h @@ -113,7 +113,7 @@ public: /** * Copy constructor. */ - Tensor (const Tensor<0,dim,Number> &); + Tensor (const Tensor<0,dim,Number> &initializer); /** * Copy constructor from tensors with different underlying scalar @@ -121,7 +121,8 @@ public: * convertible to @p Number. */ template - Tensor (const Tensor<0,dim,OtherNumber> &); + explicit + Tensor (const Tensor<0,dim,OtherNumber> &initializer); /** * Conversion to Number. Since rank-0 tensors are scalars, this is a natural @@ -141,7 +142,7 @@ public: /** * Assignment operator. */ - Tensor<0,dim,Number> &operator = (const Tensor<0,dim,Number> &); + Tensor<0,dim,Number> &operator = (const Tensor<0,dim,Number> &rhs); /** * Assignment operator from tensors with different underlying scalar @@ -149,7 +150,7 @@ public: * convertible to @p Number. */ template - Tensor<0,dim,Number> &operator = (const Tensor<0,dim,OtherNumber> &); + Tensor<0,dim,Number> &operator = (const Tensor<0,dim,OtherNumber> &rhs); /** * Assignment operator. @@ -159,22 +160,22 @@ public: /** * Test for equality of two tensors. */ - bool operator == (const Tensor<0,dim,Number> &) const; + bool operator == (const Tensor<0,dim,Number> &rhs) const; /** * Test for inequality of two tensors. */ - bool operator != (const Tensor<0,dim,Number> &) const; + bool operator != (const Tensor<0,dim,Number> &rhs) const; /** * Add another vector, i.e. move this point by the given offset. */ - Tensor<0,dim,Number> &operator += (const Tensor<0,dim,Number> &); + Tensor<0,dim,Number> &operator += (const Tensor<0,dim,Number> &rhs); /** * Subtract another vector. */ - Tensor<0,dim,Number> &operator -= (const Tensor<0,dim,Number> &); + Tensor<0,dim,Number> &operator -= (const Tensor<0,dim,Number> &rhs); /** * Scale the vector by factor, i.e. multiply all coordinates by @@ -342,7 +343,8 @@ public: * Constructor. Initialize all entries to zero if initialize==true; * this is the default behaviour. */ - explicit Tensor (const bool initialize = true); + explicit + Tensor (const bool initialize = true); /** * Copy constructor, where the data is copied from a C-style array. @@ -352,7 +354,7 @@ public: /** * Copy constructor. */ - Tensor (const Tensor<1,dim,Number> &); + Tensor (const Tensor<1,dim,Number> &initializer); /** * Copy constructor from tensors with different underlying scalar @@ -360,7 +362,8 @@ public: * convertible to @p Number. */ template - Tensor (const Tensor<1,dim,OtherNumber> &); + explicit + Tensor (const Tensor<1,dim,OtherNumber> &initializer); /** * Read access to the indexth coordinate. @@ -391,7 +394,7 @@ public: /** * Assignment operator. */ - Tensor<1,dim,Number> &operator = (const Tensor<1,dim,Number> &); + Tensor<1,dim,Number> &operator = (const Tensor<1,dim,Number> &rhs); /** * Assignment operator from tensors with different underlying scalar @@ -399,7 +402,7 @@ public: * convertible to @p Number. */ template - Tensor<1,dim,Number> &operator = (const Tensor<1,dim,OtherNumber> &); + Tensor<1,dim,Number> &operator = (const Tensor<1,dim,OtherNumber> &rhs); /** * This operator assigns a scalar to a tensor. To avoid confusion with what @@ -412,22 +415,22 @@ public: /** * Test for equality of two tensors. */ - bool operator == (const Tensor<1,dim,Number> &) const; + bool operator == (const Tensor<1,dim,Number> &rhs) const; /** * Test for inequality of two tensors. */ - bool operator != (const Tensor<1,dim,Number> &) const; + bool operator != (const Tensor<1,dim,Number> &rhs) const; /** * Add another vector, i.e. move this point by the given offset. */ - Tensor<1,dim,Number> &operator += (const Tensor<1,dim,Number> &); + Tensor<1,dim,Number> &operator += (const Tensor<1,dim,Number> &rhs); /** * Subtract another vector. */ - Tensor<1,dim,Number> &operator -= (const Tensor<1,dim,Number> &); + Tensor<1,dim,Number> &operator -= (const Tensor<1,dim,Number> &rhs); /** * Scale the vector by factor, i.e. multiply all coordinates by -- 2.39.5