Loading...
Searching...
No Matches
dotproduct.hh
Go to the documentation of this file.
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#ifndef DUNE_DOTPRODUCT_HH
#define DUNE_DOTPRODUCT_HH
#include "ftraits.hh"
#include "typetraits.hh"
namespace Dune {
template<class T, class = void>
struct IsVector : std::false_type {};
template<class T>
struct IsVector<T, std::void_t<typename T::field_type> >
: std::true_type {};
template<class A, class B>
auto
dot(const A & a, const B & b) -> typename std::enable_if<IsNumber<A>::value && !IsVector<A>::value && !std::is_same<typename FieldTraits<A>::field_type,typename FieldTraits<A>::real_type> ::value, decltype(conj(a)*b)>::type
{
return conj(a)*b;
}
// fundamental type with A being a real type
template<class A, class B>
auto
dot(const A & a, const B & b) -> typename std::enable_if<IsNumber<A>::value && !IsVector<A>::value && std::is_same<typename FieldTraits<A>::field_type,typename FieldTraits<A>::real_type>::value, decltype(a*b)>::type
{
return a*b;
}
template<typename A, typename B>
auto
dot(const A & a, const B & b) -> typename std::enable_if<IsVector<A>::value, decltype(a.dot(b))>::type
{
return a.dot(b);
}
template<class A, class B>
auto
dotT(const A & a, const B & b) -> decltype(a*b)
{
return a*b;
}
} // end namespace DUNE
#endif // DUNE_DOTPRODUCT_HH
typetraits.hh
Traits for type conversions and type information.
ftraits.hh
Type traits to determine the type of reals (when working with complex numbers).
Dune::dotT
auto dotT(const A &a, const B &b) -> decltype(a *b)
Computes an indefinite vector dot product for fundamental data types according to Petsc's VectTDot fu...
Definition dotproduct.hh:81
Dune::dot
auto dot(const A &a, const B &b) -> typename std::enable_if< IsNumber< A >::value &&!IsVector< A >::value &&!std::is_same< typename FieldTraits< A >::field_type, typename FieldTraits< A >::real_type > ::value, decltype(conj(a) *b)>::type
computes the dot product for fundamental data types according to Petsc's VectDot function: dot(a,...
Definition dotproduct.hh:40
Dune::void_t
typename Impl::voider< Types... >::type void_t
Is void for all valid input types. The workhorse for C++11 SFINAE-techniques.
Definition typetraits.hh:40
std
STL namespace.
Dune
Dune namespace
Definition alignedallocator.hh:13
Dune::IsVector
Definition dotproduct.hh:27
Dune::FieldTraits::real_type
T real_type
export the type representing the real type of the field
Definition ftraits.hh:30
Dune::type