From: Jean-Paul Pelteret Date: Wed, 23 Aug 2017 21:52:45 +0000 (+0200) Subject: Add new constructors to specializations of NumberType. X-Git-Tag: v9.0.0-rc1~1162^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=797bc9c3b10be436cb1b27fd50bd60ccb186a9aa;p=dealii.git Add new constructors to specializations of NumberType. These simply return the input value by refererence if it is of the same type as the output value. --- diff --git a/include/deal.II/base/numbers.h b/include/deal.II/base/numbers.h index 46bddf1e6a..33fcdc6acf 100644 --- a/include/deal.II/base/numbers.h +++ b/include/deal.II/base/numbers.h @@ -397,7 +397,7 @@ namespace internal template struct NumberType { - static DEAL_II_CUDA_HOST_DEV T value (const T &t) + static DEAL_II_CUDA_HOST_DEV const T &value (const T &t) { return t; } @@ -406,10 +406,24 @@ namespace internal template struct NumberType > { + static const std::complex &value (const std::complex &t) + { + return t; + } + static std::complex value (const T &t) { return std::complex(t); } + + // Facilitate cast from complex to complex + template + static std::complex value (const std::complex &t) + { + return std::complex( + NumberType::value(t.real()), + NumberType::value(t.imag())); + } }; } diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index a52f0720b5..357ea704d0 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -601,6 +601,11 @@ namespace internal template struct NumberType > { + static const Tensor &value (const Tensor &t) + { + return t; + } + static Tensor value (const T &t) { Tensor tmp; @@ -612,6 +617,11 @@ namespace internal template struct NumberType > > { + static const Tensor > &value (const Tensor > &t) + { + return t; + } + static Tensor > value (const T &t) { Tensor > tmp; diff --git a/include/deal.II/base/vectorization.h b/include/deal.II/base/vectorization.h index d6c2b238e1..8e5e1bda7d 100644 --- a/include/deal.II/base/vectorization.h +++ b/include/deal.II/base/vectorization.h @@ -74,6 +74,11 @@ namespace internal template struct NumberType > { + static const VectorizedArray &value (const VectorizedArray &t) + { + return t; + } + static VectorizedArray value (const T &t) { VectorizedArray tmp;