From d3e1efe1596768ea2312ea9e03906bac7aaf2bc8 Mon Sep 17 00:00:00 2001 From: Christian Engwer <christi@dune-project.org> Date: Thu, 15 Oct 2009 11:44:43 +0000 Subject: [PATCH] add method to compute the conjugate complex value of k [[Imported from SVN: r5658]] --- dune/common/misc.hh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/dune/common/misc.hh b/dune/common/misc.hh index 4a3edc7b4..5a6cab65c 100644 --- a/dune/common/misc.hh +++ b/dune/common/misc.hh @@ -9,15 +9,15 @@ #include <iostream> #include <sstream> +#include <complex> #include "exceptions.hh" -#include "deprecated.hh" namespace Dune { /** \brief Map an integer value to a type - This comes in handy if one tries to emulate member function specialization. - The idea how to do it is presented in "Modern C++ Design" by Alexandrescu. + This comes in handy if one tries to emulate member function specialization. + The idea how to do it is presented in "Modern C++ Design" by Alexandrescu. */ template <int N> struct Int2Type { @@ -29,6 +29,23 @@ namespace Dune { @{ */ + //! compute conjugate complex of x + // conjugate complex does nothing for non-complex types + template<class K> + inline K conjugateComplex (const K& x) + { + return x; + } + +#ifndef DOXYGEN + // specialization for complex + template<class K> + inline std::complex<K> conjugateComplex (const std::complex<K>& c) + { + return std::complex<K>(c.real(),-c.imag()); + } +#endif + //! Return the sign of the value template <class T> int sign(const T& val) -- GitLab